• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5extern class PreparseData extends HeapObject {
6  // TODO(v8:8983): Add declaration for variable-sized region.
7  data_length: int32;
8  children_length: int32;
9}
10
11extern class InterpreterData extends Struct {
12  bytecode_array: BytecodeArray;
13  @if(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: CodeDataContainer;
14  @ifnot(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: Code;
15}
16
17type FunctionKind extends uint8 constexpr 'FunctionKind';
18type FunctionSyntaxKind extends uint8 constexpr 'FunctionSyntaxKind';
19type BailoutReason extends uint8 constexpr 'BailoutReason';
20type OSRCodeCacheStateOfSFI extends uint8 constexpr 'OSRCodeCacheStateOfSFI';
21
22bitfield struct SharedFunctionInfoFlags extends uint32 {
23  // Have FunctionKind first to make it cheaper to access.
24  function_kind: FunctionKind: 5 bit;
25  is_native: bool: 1 bit;
26  is_strict: bool: 1 bit;
27  function_syntax_kind: FunctionSyntaxKind: 3 bit;
28  is_class_constructor: bool: 1 bit;
29  has_duplicate_parameters: bool: 1 bit;
30  allow_lazy_compilation: bool: 1 bit;
31  is_asm_wasm_broken: bool: 1 bit;
32  function_map_index: uint32: 5 bit;
33  disabled_optimization_reason: BailoutReason: 4 bit;
34  requires_instance_members_initializer: bool: 1 bit;
35  construct_as_builtin: bool: 1 bit;
36  name_should_print_as_anonymous: bool: 1 bit;
37  has_reported_binary_coverage: bool: 1 bit;
38  is_top_level: bool: 1 bit;
39  properties_are_final: bool: 1 bit;
40  private_name_lookup_skips_outer_class: bool: 1 bit;
41  osr_code_cache_state: OSRCodeCacheStateOfSFI: 2 bit;
42}
43
44bitfield struct SharedFunctionInfoFlags2 extends uint8 {
45  class_scope_has_private_brand: bool: 1 bit;
46  has_static_private_methods_or_accessors: bool: 1 bit;
47  maglev_compilation_failed: bool: 1 bit;
48}
49
50@generateBodyDescriptor
51extern class SharedFunctionInfo extends HeapObject {
52  // function_data field is treated as a custom weak pointer. We visit this
53  // field as a weak pointer if there is aged bytecode. If there is no bytecode
54  // or if the bytecode is young then we treat it as a strong pointer. This is
55  // done to support flushing of bytecode.
56  @customWeakMarking function_data: Object;
57  name_or_scope_info: String|NoSharedNameSentinel|ScopeInfo;
58  outer_scope_info_or_feedback_metadata: HeapObject;
59  script_or_debug_info: Script|DebugInfo|Undefined;
60  // [length]: The function length - usually the number of declared parameters
61  // (always without the receiver).
62  // Use up to 2^16-2 parameters (16 bits of values, where one is reserved for
63  // kDontAdaptArgumentsSentinel). The value is only reliable when the function
64  // has been compiled.
65  length: int16;
66  // [formal_parameter_count]: The number of declared parameters (or the special
67  // value kDontAdaptArgumentsSentinel to indicate that arguments are passed
68  // unaltered).
69  // In contrast to [length], formal_parameter_count includes the receiver.
70  formal_parameter_count: uint16;
71  function_token_offset: uint16;
72  // [expected_nof_properties]: Expected number of properties for the
73  // function. The value is only reliable when the function has been compiled.
74  expected_nof_properties: uint8;
75  flags2: SharedFunctionInfoFlags2;
76  flags: SharedFunctionInfoFlags;
77  // [function_literal_id] - uniquely identifies the FunctionLiteral this
78  // SharedFunctionInfo represents within its script, or -1 if this
79  // SharedFunctionInfo object doesn't correspond to a parsed FunctionLiteral.
80  function_literal_id: int32;
81  // [unique_id] - For --log-maps purposes, an identifier that's persistent
82  // even if the GC moves this SharedFunctionInfo.
83  @if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
84}
85
86const kDontAdaptArgumentsSentinel: constexpr int32
87    generates 'kDontAdaptArgumentsSentinel';
88
89@export
90macro LoadSharedFunctionInfoFormalParameterCountWithoutReceiver(
91    sfi: SharedFunctionInfo): uint16 {
92  let formalParameterCount = sfi.formal_parameter_count;
93  if (Convert<int32>(formalParameterCount) != kDontAdaptArgumentsSentinel) {
94    formalParameterCount =
95        Convert<uint16>(formalParameterCount - kJSArgcReceiverSlots);
96  }
97  return formalParameterCount;
98}
99
100@export
101macro LoadSharedFunctionInfoFormalParameterCountWithReceiver(
102    sfi: SharedFunctionInfo): uint16 {
103  return sfi.formal_parameter_count;
104}
105
106@export
107macro IsSharedFunctionInfoDontAdaptArguments(sfi: SharedFunctionInfo): bool {
108  const formalParameterCount = sfi.formal_parameter_count;
109  return Convert<int32>(formalParameterCount) == kDontAdaptArgumentsSentinel;
110}
111
112@abstract
113extern class UncompiledData extends HeapObject {
114  inferred_name: String;
115  start_position: int32;
116  end_position: int32;
117}
118
119@generateBodyDescriptor
120@generateUniqueMap
121@generateFactoryFunction
122extern class UncompiledDataWithoutPreparseData extends UncompiledData {
123}
124
125@generateBodyDescriptor
126@generateUniqueMap
127@generateFactoryFunction
128extern class UncompiledDataWithPreparseData extends UncompiledData {
129  preparse_data: PreparseData;
130}
131
132@generateBodyDescriptor
133@generateUniqueMap
134@generateFactoryFunction
135extern class UncompiledDataWithoutPreparseDataWithJob extends
136    UncompiledDataWithoutPreparseData {
137  // TODO(v8:10391): Define the field as ExternalPointer or move jobs into cage.
138  job: RawPtr;
139}
140
141@generateBodyDescriptor
142@generateUniqueMap
143@generateFactoryFunction
144extern class UncompiledDataWithPreparseDataAndJob extends
145    UncompiledDataWithPreparseData {
146  // TODO(v8:10391): Define the field as ExternalPointer or move jobs into cage.
147  job: RawPtr;
148}
149
150@export
151class OnHeapBasicBlockProfilerData extends HeapObject {
152  block_ids: ByteArray;  // Stored as 4-byte ints
153  counts: ByteArray;     // Stored as 4-byte unsigned ints
154  name: String;
155  schedule: String;
156  code: String;
157  hash: Smi;
158}
159