blob: 76a8cda36c069ad88c4c469eb9440b210a8ad317 [file] [log] [blame]
Carlos Caballeroccbb7252024-01-19 00:41:33 +00001# 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
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 ColumnDoc
23from python.generators.trace_processor_table.public import ColumnFlag
24from python.generators.trace_processor_table.public import CppInt32
25from python.generators.trace_processor_table.public import CppInt64
26from python.generators.trace_processor_table.public import CppOptional
27from python.generators.trace_processor_table.public import CppString
28from python.generators.trace_processor_table.public import CppTableId
29from python.generators.trace_processor_table.public import CppUint32
30from python.generators.trace_processor_table.public import CppUint32 as CppBool
31from python.generators.trace_processor_table.public import Table
32from python.generators.trace_processor_table.public import TableDoc
33from .profiler_tables import STACK_PROFILE_FRAME_TABLE
34
35V8_ISOLATE = Table(
36 python_module=__file__,
37 class_name='V8IsolateTable',
Carlos Caballero05429942024-03-13 19:28:50 +000038 sql_name='__intrinsic_v8_isolate',
Carlos Caballeroccbb7252024-01-19 00:41:33 +000039 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 Caballeroccbb7252024-01-19 00:41:33 +000048 ],
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 Caballeroccbb7252024-01-19 00:41:33 +000074 },
75 ),
76)
77
78V8_JS_SCRIPT = Table(
79 python_module=__file__,
80 class_name='V8JsScriptTable',
Carlos Caballero05429942024-03-13 19:28:50 +000081 sql_name='__intrinsic_v8_js_script',
Carlos Caballeroccbb7252024-01-19 00:41:33 +000082 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 Caballeroccbb7252024-01-19 00:41:33 +000088 ],
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 Caballeroccbb7252024-01-19 00:41:33 +000098 },
99 ),
100)
101
102V8_WASM_SCRIPT = Table(
103 python_module=__file__,
104 class_name='V8WasmScriptTable',
Carlos Caballero05429942024-03-13 19:28:50 +0000105 sql_name='__intrinsic_v8_wasm_script',
Carlos Caballeroccbb7252024-01-19 00:41:33 +0000106 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 Caballeroccbb7252024-01-19 00:41:33 +0000111 ],
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 Caballeroccbb7252024-01-19 00:41:33 +0000120 },
121 ),
122)
123
124V8_JS_FUNCTION = Table(
125 python_module=__file__,
126 class_name='V8JsFunctionTable',
Carlos Caballero05429942024-03-13 19:28:50 +0000127 sql_name='__intrinsic_v8_js_function',
Carlos Caballeroccbb7252024-01-19 00:41:33 +0000128 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 Caballero05429942024-03-13 19:28:50 +0000134 C('col', CppOptional(CppUint32())),
Carlos Caballeroccbb7252024-01-19 00:41:33 +0000135 ],
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 Caballero05429942024-03-13 19:28:50 +0000153 'col':
Carlos Caballeroccbb7252024-01-19 00:41:33 +0000154 'Column in script where function is defined. Starts at 1',
Carlos Caballeroccbb7252024-01-19 00:41:33 +0000155 },
156 ),
157)
158
159# Keep this list sorted.
160ALL_TABLES = [
161 V8_ISOLATE,
162 V8_JS_SCRIPT,
163 V8_WASM_SCRIPT,
164 V8_JS_FUNCTION,
165]