1# Copyright (C) 2024 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Contains tables related to Jitted code. 15 16These tables are WIP, the schema is not stable and you should not rely on them 17for any serious business just yet"" 18""" 19 20from python.generators.trace_processor_table.public import Alias 21from python.generators.trace_processor_table.public import Column as C 22from python.generators.trace_processor_table.public import CppInt64 23from python.generators.trace_processor_table.public import CppOptional 24from python.generators.trace_processor_table.public import CppString 25from python.generators.trace_processor_table.public import CppUint32 26from python.generators.trace_processor_table.public import CppTableId 27from python.generators.trace_processor_table.public import ColumnFlag 28from python.generators.trace_processor_table.public import Table 29from python.generators.trace_processor_table.public import TableDoc 30from python.generators.trace_processor_table.public import WrappingSqlView 31from .profiler_tables import STACK_PROFILE_FRAME_TABLE 32 33JIT_CODE_TABLE = Table( 34 python_module=__file__, 35 class_name='JitCodeTable', 36 sql_name='__intrinsic_jit_code', 37 columns=[ 38 C('create_ts', CppInt64(), ColumnFlag.SORTED), 39 C('estimated_delete_ts', CppOptional(CppInt64())), 40 C('utid', CppUint32()), 41 C('start_address', CppInt64()), 42 C('size', CppInt64()), 43 C('function_name', CppString()), 44 C('native_code_base64', CppOptional(CppString())), 45 C('jit_code_id', Alias('id')), 46 ], 47 tabledoc=TableDoc( 48 doc=""" 49 Represents a jitted code snippet 50 """, 51 group='jit', 52 columns={ 53 'create_ts': """Time this code was created / allocated""", 54 'estimated_delete_ts': 55 ("""Time this code was destroyed / deallocated. This is an upper 56 bound, as we can only detect deletions indirectly when new code 57 is allocated overlapping existing one. 58 """), 59 'utid': 'Thread that generated the code', 60 'start_address': 'Start address for the generated code', 61 'size': 'Size in bytes of the generated code', 62 'function_name': 'Function name', 63 'native_code_base64': 'Jitted code base64 encoded', 64 'jit_code_id': 'Alias for id. Makes joins easier', 65 }, 66 ), 67) 68 69JIT_FRAME_TABLE = Table( 70 python_module=__file__, 71 class_name='JitFrameTable', 72 sql_name='__intrinsic_jit_frame', 73 columns=[ 74 C('jit_code_id', CppTableId(JIT_CODE_TABLE)), 75 C('frame_id', CppTableId(STACK_PROFILE_FRAME_TABLE)), 76 ], 77 tabledoc=TableDoc( 78 doc=""" 79 Represents a jitted frame 80 """, 81 group='jit', 82 columns={ 83 'jit_code_id': 'Jitted code snipped the frame is in', 84 'frame_id': 'Jitted frame', 85 }, 86 ), 87) 88 89# Keep this list sorted. 90ALL_TABLES = [JIT_CODE_TABLE, JIT_FRAME_TABLE] 91