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 .profiler_tables import STACK_PROFILE_FRAME_TABLE 31 32JIT_CODE_TABLE = Table( 33 python_module=__file__, 34 class_name='JitCodeTable', 35 sql_name='__intrinsic_jit_code', 36 columns=[ 37 C('create_ts', CppInt64(), ColumnFlag.SORTED), 38 C('estimated_delete_ts', CppOptional(CppInt64())), 39 C('utid', CppUint32()), 40 C('start_address', CppInt64()), 41 C('size', CppInt64()), 42 C('function_name', CppString()), 43 C('native_code_base64', CppOptional(CppString())), 44 C('jit_code_id', Alias('id')), 45 ], 46 tabledoc=TableDoc( 47 doc=""" 48 Represents a jitted code snippet 49 """, 50 group='jit', 51 columns={ 52 'create_ts': """Time this code was created / allocated""", 53 'estimated_delete_ts': 54 ("""Time this code was destroyed / deallocated. This is an upper 55 bound, as we can only detect deletions indirectly when new code 56 is allocated overlapping existing one. 57 """), 58 'utid': 'Thread that generated the code', 59 'start_address': 'Start address for the generated code', 60 'size': 'Size in bytes of the generated code', 61 'function_name': 'Function name', 62 'native_code_base64': 'Jitted code base64 encoded', 63 'jit_code_id': 'Alias for id. Makes joins easier', 64 }, 65 ), 66) 67 68JIT_FRAME_TABLE = Table( 69 python_module=__file__, 70 class_name='JitFrameTable', 71 sql_name='__intrinsic_jit_frame', 72 columns=[ 73 C('jit_code_id', CppTableId(JIT_CODE_TABLE)), 74 C('frame_id', CppTableId(STACK_PROFILE_FRAME_TABLE)), 75 ], 76 tabledoc=TableDoc( 77 doc=""" 78 Represents a jitted frame 79 """, 80 group='jit', 81 columns={ 82 'jit_code_id': 'Jitted code snipped the frame is in', 83 'frame_id': 'Jitted frame', 84 }, 85 ), 86) 87 88# Keep this list sorted. 89ALL_TABLES = [JIT_CODE_TABLE, JIT_FRAME_TABLE] 90