11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciextern class PreparseData extends HeapObject {
61cb0ef41Sopenharmony_ci  // TODO(v8:8983): Add declaration for variable-sized region.
71cb0ef41Sopenharmony_ci  data_length: int32;
81cb0ef41Sopenharmony_ci  children_length: int32;
91cb0ef41Sopenharmony_ci}
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciextern class InterpreterData extends Struct {
121cb0ef41Sopenharmony_ci  bytecode_array: BytecodeArray;
131cb0ef41Sopenharmony_ci  @if(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: CodeDataContainer;
141cb0ef41Sopenharmony_ci  @ifnot(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: Code;
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_citype FunctionKind extends uint8 constexpr 'FunctionKind';
181cb0ef41Sopenharmony_citype FunctionSyntaxKind extends uint8 constexpr 'FunctionSyntaxKind';
191cb0ef41Sopenharmony_citype BailoutReason extends uint8 constexpr 'BailoutReason';
201cb0ef41Sopenharmony_citype OSRCodeCacheStateOfSFI extends uint8 constexpr 'OSRCodeCacheStateOfSFI';
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cibitfield struct SharedFunctionInfoFlags extends uint32 {
231cb0ef41Sopenharmony_ci  // Have FunctionKind first to make it cheaper to access.
241cb0ef41Sopenharmony_ci  function_kind: FunctionKind: 5 bit;
251cb0ef41Sopenharmony_ci  is_native: bool: 1 bit;
261cb0ef41Sopenharmony_ci  is_strict: bool: 1 bit;
271cb0ef41Sopenharmony_ci  function_syntax_kind: FunctionSyntaxKind: 3 bit;
281cb0ef41Sopenharmony_ci  is_class_constructor: bool: 1 bit;
291cb0ef41Sopenharmony_ci  has_duplicate_parameters: bool: 1 bit;
301cb0ef41Sopenharmony_ci  allow_lazy_compilation: bool: 1 bit;
311cb0ef41Sopenharmony_ci  is_asm_wasm_broken: bool: 1 bit;
321cb0ef41Sopenharmony_ci  function_map_index: uint32: 5 bit;
331cb0ef41Sopenharmony_ci  disabled_optimization_reason: BailoutReason: 4 bit;
341cb0ef41Sopenharmony_ci  requires_instance_members_initializer: bool: 1 bit;
351cb0ef41Sopenharmony_ci  construct_as_builtin: bool: 1 bit;
361cb0ef41Sopenharmony_ci  name_should_print_as_anonymous: bool: 1 bit;
371cb0ef41Sopenharmony_ci  has_reported_binary_coverage: bool: 1 bit;
381cb0ef41Sopenharmony_ci  is_top_level: bool: 1 bit;
391cb0ef41Sopenharmony_ci  properties_are_final: bool: 1 bit;
401cb0ef41Sopenharmony_ci  private_name_lookup_skips_outer_class: bool: 1 bit;
411cb0ef41Sopenharmony_ci  osr_code_cache_state: OSRCodeCacheStateOfSFI: 2 bit;
421cb0ef41Sopenharmony_ci}
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_cibitfield struct SharedFunctionInfoFlags2 extends uint8 {
451cb0ef41Sopenharmony_ci  class_scope_has_private_brand: bool: 1 bit;
461cb0ef41Sopenharmony_ci  has_static_private_methods_or_accessors: bool: 1 bit;
471cb0ef41Sopenharmony_ci  maglev_compilation_failed: bool: 1 bit;
481cb0ef41Sopenharmony_ci}
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci@generateBodyDescriptor
511cb0ef41Sopenharmony_ciextern class SharedFunctionInfo extends HeapObject {
521cb0ef41Sopenharmony_ci  // function_data field is treated as a custom weak pointer. We visit this
531cb0ef41Sopenharmony_ci  // field as a weak pointer if there is aged bytecode. If there is no bytecode
541cb0ef41Sopenharmony_ci  // or if the bytecode is young then we treat it as a strong pointer. This is
551cb0ef41Sopenharmony_ci  // done to support flushing of bytecode.
561cb0ef41Sopenharmony_ci  @customWeakMarking function_data: Object;
571cb0ef41Sopenharmony_ci  name_or_scope_info: String|NoSharedNameSentinel|ScopeInfo;
581cb0ef41Sopenharmony_ci  outer_scope_info_or_feedback_metadata: HeapObject;
591cb0ef41Sopenharmony_ci  script_or_debug_info: Script|DebugInfo|Undefined;
601cb0ef41Sopenharmony_ci  // [length]: The function length - usually the number of declared parameters
611cb0ef41Sopenharmony_ci  // (always without the receiver).
621cb0ef41Sopenharmony_ci  // Use up to 2^16-2 parameters (16 bits of values, where one is reserved for
631cb0ef41Sopenharmony_ci  // kDontAdaptArgumentsSentinel). The value is only reliable when the function
641cb0ef41Sopenharmony_ci  // has been compiled.
651cb0ef41Sopenharmony_ci  length: int16;
661cb0ef41Sopenharmony_ci  // [formal_parameter_count]: The number of declared parameters (or the special
671cb0ef41Sopenharmony_ci  // value kDontAdaptArgumentsSentinel to indicate that arguments are passed
681cb0ef41Sopenharmony_ci  // unaltered).
691cb0ef41Sopenharmony_ci  // In contrast to [length], formal_parameter_count includes the receiver.
701cb0ef41Sopenharmony_ci  formal_parameter_count: uint16;
711cb0ef41Sopenharmony_ci  function_token_offset: uint16;
721cb0ef41Sopenharmony_ci  // [expected_nof_properties]: Expected number of properties for the
731cb0ef41Sopenharmony_ci  // function. The value is only reliable when the function has been compiled.
741cb0ef41Sopenharmony_ci  expected_nof_properties: uint8;
751cb0ef41Sopenharmony_ci  flags2: SharedFunctionInfoFlags2;
761cb0ef41Sopenharmony_ci  flags: SharedFunctionInfoFlags;
771cb0ef41Sopenharmony_ci  // [function_literal_id] - uniquely identifies the FunctionLiteral this
781cb0ef41Sopenharmony_ci  // SharedFunctionInfo represents within its script, or -1 if this
791cb0ef41Sopenharmony_ci  // SharedFunctionInfo object doesn't correspond to a parsed FunctionLiteral.
801cb0ef41Sopenharmony_ci  function_literal_id: int32;
811cb0ef41Sopenharmony_ci  // [unique_id] - For --log-maps purposes, an identifier that's persistent
821cb0ef41Sopenharmony_ci  // even if the GC moves this SharedFunctionInfo.
831cb0ef41Sopenharmony_ci  @if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
841cb0ef41Sopenharmony_ci}
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ciconst kDontAdaptArgumentsSentinel: constexpr int32
871cb0ef41Sopenharmony_ci    generates 'kDontAdaptArgumentsSentinel';
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci@export
901cb0ef41Sopenharmony_cimacro LoadSharedFunctionInfoFormalParameterCountWithoutReceiver(
911cb0ef41Sopenharmony_ci    sfi: SharedFunctionInfo): uint16 {
921cb0ef41Sopenharmony_ci  let formalParameterCount = sfi.formal_parameter_count;
931cb0ef41Sopenharmony_ci  if (Convert<int32>(formalParameterCount) != kDontAdaptArgumentsSentinel) {
941cb0ef41Sopenharmony_ci    formalParameterCount =
951cb0ef41Sopenharmony_ci        Convert<uint16>(formalParameterCount - kJSArgcReceiverSlots);
961cb0ef41Sopenharmony_ci  }
971cb0ef41Sopenharmony_ci  return formalParameterCount;
981cb0ef41Sopenharmony_ci}
991cb0ef41Sopenharmony_ci
1001cb0ef41Sopenharmony_ci@export
1011cb0ef41Sopenharmony_cimacro LoadSharedFunctionInfoFormalParameterCountWithReceiver(
1021cb0ef41Sopenharmony_ci    sfi: SharedFunctionInfo): uint16 {
1031cb0ef41Sopenharmony_ci  return sfi.formal_parameter_count;
1041cb0ef41Sopenharmony_ci}
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_ci@export
1071cb0ef41Sopenharmony_cimacro IsSharedFunctionInfoDontAdaptArguments(sfi: SharedFunctionInfo): bool {
1081cb0ef41Sopenharmony_ci  const formalParameterCount = sfi.formal_parameter_count;
1091cb0ef41Sopenharmony_ci  return Convert<int32>(formalParameterCount) == kDontAdaptArgumentsSentinel;
1101cb0ef41Sopenharmony_ci}
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci@abstract
1131cb0ef41Sopenharmony_ciextern class UncompiledData extends HeapObject {
1141cb0ef41Sopenharmony_ci  inferred_name: String;
1151cb0ef41Sopenharmony_ci  start_position: int32;
1161cb0ef41Sopenharmony_ci  end_position: int32;
1171cb0ef41Sopenharmony_ci}
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci@generateBodyDescriptor
1201cb0ef41Sopenharmony_ci@generateUniqueMap
1211cb0ef41Sopenharmony_ci@generateFactoryFunction
1221cb0ef41Sopenharmony_ciextern class UncompiledDataWithoutPreparseData extends UncompiledData {
1231cb0ef41Sopenharmony_ci}
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci@generateBodyDescriptor
1261cb0ef41Sopenharmony_ci@generateUniqueMap
1271cb0ef41Sopenharmony_ci@generateFactoryFunction
1281cb0ef41Sopenharmony_ciextern class UncompiledDataWithPreparseData extends UncompiledData {
1291cb0ef41Sopenharmony_ci  preparse_data: PreparseData;
1301cb0ef41Sopenharmony_ci}
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci@generateBodyDescriptor
1331cb0ef41Sopenharmony_ci@generateUniqueMap
1341cb0ef41Sopenharmony_ci@generateFactoryFunction
1351cb0ef41Sopenharmony_ciextern class UncompiledDataWithoutPreparseDataWithJob extends
1361cb0ef41Sopenharmony_ci    UncompiledDataWithoutPreparseData {
1371cb0ef41Sopenharmony_ci  // TODO(v8:10391): Define the field as ExternalPointer or move jobs into cage.
1381cb0ef41Sopenharmony_ci  job: RawPtr;
1391cb0ef41Sopenharmony_ci}
1401cb0ef41Sopenharmony_ci
1411cb0ef41Sopenharmony_ci@generateBodyDescriptor
1421cb0ef41Sopenharmony_ci@generateUniqueMap
1431cb0ef41Sopenharmony_ci@generateFactoryFunction
1441cb0ef41Sopenharmony_ciextern class UncompiledDataWithPreparseDataAndJob extends
1451cb0ef41Sopenharmony_ci    UncompiledDataWithPreparseData {
1461cb0ef41Sopenharmony_ci  // TODO(v8:10391): Define the field as ExternalPointer or move jobs into cage.
1471cb0ef41Sopenharmony_ci  job: RawPtr;
1481cb0ef41Sopenharmony_ci}
1491cb0ef41Sopenharmony_ci
1501cb0ef41Sopenharmony_ci@export
1511cb0ef41Sopenharmony_ciclass OnHeapBasicBlockProfilerData extends HeapObject {
1521cb0ef41Sopenharmony_ci  block_ids: ByteArray;  // Stored as 4-byte ints
1531cb0ef41Sopenharmony_ci  counts: ByteArray;     // Stored as 4-byte unsigned ints
1541cb0ef41Sopenharmony_ci  name: String;
1551cb0ef41Sopenharmony_ci  schedule: String;
1561cb0ef41Sopenharmony_ci  code: String;
1571cb0ef41Sopenharmony_ci  hash: Smi;
1581cb0ef41Sopenharmony_ci}
159