Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 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 the v8 (Javasrcript Engine) Datasource. |
| 15 | |
| 16 | These tables are WIP, the schema is not stable and you should not rely on them |
| 17 | for any serious business just yet"" |
| 18 | """ |
| 19 | |
| 20 | from python.generators.trace_processor_table.public import Alias |
| 21 | from python.generators.trace_processor_table.public import Column as C |
| 22 | from python.generators.trace_processor_table.public import ColumnDoc |
| 23 | from python.generators.trace_processor_table.public import ColumnFlag |
| 24 | from python.generators.trace_processor_table.public import CppInt32 |
| 25 | from python.generators.trace_processor_table.public import CppInt64 |
| 26 | from python.generators.trace_processor_table.public import CppOptional |
| 27 | from python.generators.trace_processor_table.public import CppString |
| 28 | from python.generators.trace_processor_table.public import CppTableId |
| 29 | from python.generators.trace_processor_table.public import CppUint32 |
| 30 | from python.generators.trace_processor_table.public import CppUint32 as CppBool |
| 31 | from python.generators.trace_processor_table.public import Table |
| 32 | from python.generators.trace_processor_table.public import TableDoc |
| 33 | from .profiler_tables import STACK_PROFILE_FRAME_TABLE |
| 34 | |
| 35 | V8_ISOLATE = Table( |
| 36 | python_module=__file__, |
| 37 | class_name='V8IsolateTable', |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 38 | sql_name='__intrinsic_v8_isolate', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 39 | columns=[ |
| 40 | C('upid', CppUint32()), |
| 41 | C('internal_isolate_id', CppInt32()), |
| 42 | C('embedded_blob_code_start_address', CppInt64()), |
| 43 | C('embedded_blob_code_size', CppInt64()), |
| 44 | C('code_range_base_address', CppOptional(CppInt64())), |
| 45 | C('code_range_size', CppOptional(CppInt64())), |
| 46 | C('shared_code_range', CppOptional(CppBool())), |
| 47 | C('embedded_blob_code_copy_start_address', CppOptional(CppInt64())), |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 48 | ], |
| 49 | tabledoc=TableDoc( |
| 50 | doc='Represents one Isolate instance', |
| 51 | group='v8', |
| 52 | columns={ |
| 53 | 'upid': |
| 54 | 'Process the isolate was created in.', |
| 55 | 'internal_isolate_id': |
| 56 | 'Internal id used by the v8 engine. Unique in a process.', |
| 57 | 'embedded_blob_code_start_address': |
| 58 | 'Absolute start address of the embedded code blob.', |
| 59 | 'embedded_blob_code_size': |
| 60 | 'Size in bytes of the embedded code blob.', |
| 61 | 'code_range_base_address': |
| 62 | 'If this Isolate defines a CodeRange its base address is stored' |
| 63 | ' here', |
| 64 | 'code_range_size': |
| 65 | 'If this Isolate defines a CodeRange its size is stored here', |
| 66 | 'shared_code_range': |
| 67 | 'Whether the code range for this Isolate is shared with others' |
| 68 | ' in the same process. There is at max one such shared code' |
| 69 | ' range per process.', |
| 70 | 'embedded_blob_code_copy_start_address': |
| 71 | 'Used when short builtin calls are enabled, where embedded' |
| 72 | ' builtins are copied into the CodeRange so calls can be' |
| 73 | ' nearer.', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 74 | }, |
| 75 | ), |
| 76 | ) |
| 77 | |
| 78 | V8_JS_SCRIPT = Table( |
| 79 | python_module=__file__, |
| 80 | class_name='V8JsScriptTable', |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 81 | sql_name='__intrinsic_v8_js_script', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 82 | columns=[ |
| 83 | C('v8_isolate_id', CppTableId(V8_ISOLATE)), |
| 84 | C('internal_script_id', CppInt32()), |
| 85 | C('script_type', CppString()), |
| 86 | C('name', CppString()), |
| 87 | C('source', CppOptional(CppString())), |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 88 | ], |
| 89 | tabledoc=TableDoc( |
| 90 | doc='Represents one Javascript script', |
| 91 | group='v8', |
| 92 | columns={ |
| 93 | 'v8_isolate_id': 'V8 Isolate', |
| 94 | 'internal_script_id': 'Script id used by the V8 engine', |
| 95 | 'script_type': '', |
| 96 | 'name': '', |
| 97 | 'source': 'Actual contents of the script.', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 98 | }, |
| 99 | ), |
| 100 | ) |
| 101 | |
| 102 | V8_WASM_SCRIPT = Table( |
| 103 | python_module=__file__, |
| 104 | class_name='V8WasmScriptTable', |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 105 | sql_name='__intrinsic_v8_wasm_script', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 106 | columns=[ |
| 107 | C('v8_isolate_id', CppTableId(V8_ISOLATE)), |
| 108 | C('internal_script_id', CppInt32()), |
| 109 | C('url', CppString()), |
| 110 | C('source', CppOptional(CppString())), |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 111 | ], |
| 112 | tabledoc=TableDoc( |
| 113 | doc='Represents one WASM script', |
| 114 | group='v8', |
| 115 | columns={ |
| 116 | 'v8_isolate_id': 'V8 Isolate', |
| 117 | 'internal_script_id': 'Script id used by the V8 engine', |
| 118 | 'url': 'URL of the source', |
| 119 | 'source': 'Actual contents of the script.', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 120 | }, |
| 121 | ), |
| 122 | ) |
| 123 | |
| 124 | V8_JS_FUNCTION = Table( |
| 125 | python_module=__file__, |
| 126 | class_name='V8JsFunctionTable', |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 127 | sql_name='__intrinsic_v8_js_function', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 128 | columns=[ |
| 129 | C('name', CppString()), |
| 130 | C('v8_js_script_id', CppTableId(V8_JS_SCRIPT)), |
| 131 | C('is_toplevel', CppBool()), |
| 132 | C('kind', CppString()), |
| 133 | C('line', CppOptional(CppUint32())), |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 134 | C('col', CppOptional(CppUint32())), |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 135 | ], |
| 136 | tabledoc=TableDoc( |
| 137 | doc='Represents a v8 Javascript function', |
| 138 | group='v8', |
| 139 | columns={ |
| 140 | 'name': |
| 141 | '', |
| 142 | 'v8_js_script_id': |
| 143 | ColumnDoc( |
| 144 | doc='Script where the function is defined.', |
| 145 | joinable='v8_js_script.id', |
| 146 | ), |
| 147 | 'is_toplevel': |
| 148 | 'Whether this function represents the top level script', |
| 149 | 'kind': |
| 150 | 'Function kind (e.g. regular function or constructor)', |
| 151 | 'line': |
| 152 | 'Line in script where function is defined. Starts at 1', |
Carlos Caballero | 0542994 | 2024-03-13 19:28:50 +0000 | [diff] [blame] | 153 | 'col': |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 154 | 'Column in script where function is defined. Starts at 1', |
Carlos Caballero | ccbb725 | 2024-01-19 00:41:33 +0000 | [diff] [blame] | 155 | }, |
| 156 | ), |
| 157 | ) |
| 158 | |
| 159 | # Keep this list sorted. |
| 160 | ALL_TABLES = [ |
| 161 | V8_ISOLATE, |
| 162 | V8_JS_SCRIPT, |
| 163 | V8_WASM_SCRIPT, |
| 164 | V8_JS_FUNCTION, |
| 165 | ] |