summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/shared-function-info.tq
blob: fab396a2cc0e1c741971fe2a3c2caf7bdf553130 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@generateCppClass
extern class PreparseData extends HeapObject {
  // TODO(v8:8983): Add declaration for variable-sized region.
  data_length: int32;
  children_length: int32;
}

extern class InterpreterData extends Struct {
  bytecode_array: BytecodeArray;
  interpreter_trampoline: Code;
}

type FunctionKind extends uint8 constexpr 'FunctionKind';
type FunctionSyntaxKind extends uint8 constexpr 'FunctionSyntaxKind';
type BailoutReason extends uint8 constexpr 'BailoutReason';

bitfield struct SharedFunctionInfoFlags extends uint32 {
  // Have FunctionKind first to make it cheaper to access.
  function_kind: FunctionKind: 5 bit;
  is_native: bool: 1 bit;
  is_strict: bool: 1 bit;
  function_syntax_kind: FunctionSyntaxKind: 3 bit;
  is_class_constructor: bool: 1 bit;
  has_duplicate_parameters: bool: 1 bit;
  allow_lazy_compilation: bool: 1 bit;
  needs_home_object: bool: 1 bit;
  is_asm_wasm_broken: bool: 1 bit;
  function_map_index: uint32: 5 bit;
  disabled_optimization_reason: BailoutReason: 4 bit;
  requires_instance_members_initializer: bool: 1 bit;
  construct_as_builtin: bool: 1 bit;
  name_should_print_as_anonymous: bool: 1 bit;
  has_reported_binary_coverage: bool: 1 bit;
  is_top_level: bool: 1 bit;
  is_oneshot_iife_or_properties_are_final: bool: 1 bit;
  private_name_lookup_skips_outer_class: bool: 1 bit;
}

bitfield struct SharedFunctionInfoFlags2 extends uint8 {
  class_scope_has_private_brand: bool: 1 bit;
  has_static_private_methods_or_accessors: bool: 1 bit;
  has_optimized_at_least_once: bool: 1 bit;
  may_have_cached_code: bool: 1 bit;
}

@export
@customCppClass
@customMap  // Just to place the map at the beginning of the roots array.
class SharedFunctionInfo extends HeapObject {
  weak function_data: Object;
  name_or_scope_info: String|NoSharedNameSentinel|ScopeInfo;
  outer_scope_info_or_feedback_metadata: HeapObject;
  script_or_debug_info: Script|DebugInfo|Undefined;
  // [length]: The function length - usually the number of declared parameters.
  // Use up to 2^16-2 parameters (16 bits of values, where one is reserved for
  // kDontAdaptArgumentsSentinel). The value is only reliable when the function
  // has been compiled.
  length: int16;
  formal_parameter_count: uint16;
  function_token_offset: uint16;
  // [expected_nof_properties]: Expected number of properties for the
  // function. The value is only reliable when the function has been compiled.
  expected_nof_properties: uint8;
  flags2: SharedFunctionInfoFlags2;
  flags: SharedFunctionInfoFlags;
  // [function_literal_id] - uniquely identifies the FunctionLiteral this
  // SharedFunctionInfo represents within its script, or -1 if this
  // SharedFunctionInfo object doesn't correspond to a parsed FunctionLiteral.
  function_literal_id: int32;
  // [unique_id] - For --trace-maps purposes, an identifier that's persistent
  // even if the GC moves this SharedFunctionInfo.
  @if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
}

@abstract
@export
@customCppClass
class UncompiledData extends HeapObject {
  inferred_name: String;
  start_position: int32;
  end_position: int32;
}

@export
@customCppClass
class UncompiledDataWithoutPreparseData extends UncompiledData {
}

@export
@customCppClass
class UncompiledDataWithPreparseData extends UncompiledData {
  preparse_data: PreparseData;
}

@export
class OnHeapBasicBlockProfilerData extends HeapObject {
  block_ids: ByteArray;  // Stored as 4-byte ints
  counts: ByteArray;     // Stored as 8-byte floats
  name: String;
  schedule: String;
  code: String;
  hash: Smi;
}