v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
liftoff-compiler.cc File Reference
Include dependency graph for liftoff-compiler.cc:

Go to the source code of this file.

Namespaces

namespace  v8
 
namespace  v8::internal
 
namespace  v8::internal::wasm
 

Macros

#define __   asm_.
 
#define FREEZE_STATE(witness_name)
 
#define TRACE(...)
 
#define WASM_TRUSTED_INSTANCE_DATA_FIELD_OFFSET(name)
 
#define WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE(name)
 
#define LOAD_INSTANCE_FIELD(dst, name, load_size, pinned)
 
#define LOAD_TAGGED_PTR_INSTANCE_FIELD(dst, name, pinned)
 
#define LOAD_PROTECTED_PTR_INSTANCE_FIELD(dst, name, pinned)
 
#define CODE_COMMENT(str)
 
#define SCOPED_CODE_COMMENT(str)
 
#define LIST_FEATURE(name, ...)
 
#define FUZZER_HEAVY_INSTRUCTION
 
#define CASE_I32_UNOP(opcode, fn)
 
#define CASE_I64_UNOP(opcode, fn)
 
#define CASE_FLOAT_UNOP(opcode, kind, fn)
 
#define CASE_FLOAT_UNOP_WITH_CFALLBACK(opcode, kind, fn)
 
#define CASE_TYPE_CONVERSION(opcode, dst_kind, src_kind, ext_ref, can_trap)
 
#define RUNTIME_STUB_FOR_TRAP(trap_reason)
 
#define CASE_SIMD_EXTRACT_LANE_OP(opcode, kind, fn)
 
#define CASE_SIMD_REPLACE_LANE_OP(opcode, kind, fn)
 
#define ATOMIC_STORE_LIST(V)
 
#define ATOMIC_LOAD_LIST(V)
 
#define ATOMIC_BINOP_INSTRUCTION_LIST(V)
 
#define ATOMIC_COMPARE_EXCHANGE_LIST(V)
 
#define ATOMIC_STORE_OP(name, type)
 
#define ATOMIC_LOAD_OP(name, type)
 
#define ATOMIC_BINOP_OP(op, name, type)
 
#define ATOMIC_COMPARE_EXCHANGE_OP(name, type)
 

Functions

WasmCompilationResult v8::internal::wasm::ExecuteLiftoffCompilation (CompilationEnv *env, const FunctionBody &func_body, const LiftoffOptions &compiler_options)
 
std::unique_ptr< DebugSideTablev8::internal::wasm::GenerateLiftoffDebugSideTable (const WasmCode *code)
 

Variables

constexpr auto v8::internal::wasm::kRegister = VarState::kRegister
 
constexpr auto v8::internal::wasm::kIntConst = VarState::kIntConst
 
constexpr auto v8::internal::wasm::kStack = VarState::kStack
 

Macro Definition Documentation

◆ __

#define __   asm_.

Definition at line 50 of file liftoff-compiler.cc.

◆ ATOMIC_BINOP_INSTRUCTION_LIST

#define ATOMIC_BINOP_INSTRUCTION_LIST ( V)

Definition at line 6003 of file liftoff-compiler.cc.

◆ ATOMIC_BINOP_OP

#define ATOMIC_BINOP_OP ( op,
name,
type )
Value:
case wasm::kExpr##name: \
AtomicBinop(decoder, StoreType::type, imm, &LiftoffAssembler::Atomic##op); \
break;
const char * name
Definition builtins.cc:39

◆ ATOMIC_COMPARE_EXCHANGE_LIST

#define ATOMIC_COMPARE_EXCHANGE_LIST ( V)
Value:
V(I32AtomicCompareExchange, kI32Store) \
V(I64AtomicCompareExchange, kI64Store) \
V(I32AtomicCompareExchange8U, kI32Store8) \
V(I32AtomicCompareExchange16U, kI32Store16) \
V(I64AtomicCompareExchange8U, kI64Store8) \
V(I64AtomicCompareExchange16U, kI64Store16) \
V(I64AtomicCompareExchange32U, kI64Store32)
#define V(Name)

Definition at line 6047 of file liftoff-compiler.cc.

◆ ATOMIC_COMPARE_EXCHANGE_OP

#define ATOMIC_COMPARE_EXCHANGE_OP ( name,
type )
Value:
case wasm::kExpr##name: \
AtomicCompareExchange(decoder, StoreType::type, imm); \
break;

◆ ATOMIC_LOAD_LIST

#define ATOMIC_LOAD_LIST ( V)
Value:
V(I32AtomicLoad, kI32Load) \
V(I64AtomicLoad, kI64Load) \
V(I32AtomicLoad8U, kI32Load8U) \
V(I32AtomicLoad16U, kI32Load16U) \
V(I64AtomicLoad8U, kI64Load8U) \
V(I64AtomicLoad16U, kI64Load16U) \
V(I64AtomicLoad32U, kI64Load32U)

Definition at line 5994 of file liftoff-compiler.cc.

◆ ATOMIC_LOAD_OP

#define ATOMIC_LOAD_OP ( name,
type )
Value:
case wasm::kExpr##name: \
AtomicLoadMem(decoder, LoadType::type, imm); \
break;

◆ ATOMIC_STORE_LIST

#define ATOMIC_STORE_LIST ( V)
Value:
V(I32AtomicStore, kI32Store) \
V(I64AtomicStore, kI64Store) \
V(I32AtomicStore8U, kI32Store8) \
V(I32AtomicStore16U, kI32Store16) \
V(I64AtomicStore8U, kI64Store8) \
V(I64AtomicStore16U, kI64Store16) \
V(I64AtomicStore32U, kI64Store32)

Definition at line 5985 of file liftoff-compiler.cc.

◆ ATOMIC_STORE_OP

#define ATOMIC_STORE_OP ( name,
type )
Value:
case wasm::kExpr##name: \
AtomicStoreMem(decoder, StoreType::type, imm); \
break;

◆ CASE_FLOAT_UNOP

#define CASE_FLOAT_UNOP ( opcode,
kind,
fn )
Value:
case kExpr##opcode: \
return EmitUnOp<k##kind, k##kind>(&LiftoffAssembler::emit_##fn);
EmitFn fn

◆ CASE_FLOAT_UNOP_WITH_CFALLBACK

#define CASE_FLOAT_UNOP_WITH_CFALLBACK ( opcode,
kind,
fn )
Value:
case kExpr##opcode: \
return EmitFloatUnOpWithCFallback<k##kind>(&LiftoffAssembler::emit_##fn, \
&ExternalReference::wasm_##fn);

◆ CASE_I32_UNOP

#define CASE_I32_UNOP ( opcode,
fn )
Value:
case kExpr##opcode: \
return EmitUnOp<kI32, kI32>(&LiftoffAssembler::emit_##fn);

◆ CASE_I64_UNOP

#define CASE_I64_UNOP ( opcode,
fn )
Value:
case kExpr##opcode: \
return EmitUnOp<kI64, kI64>(&LiftoffAssembler::emit_##fn);

◆ CASE_SIMD_EXTRACT_LANE_OP

#define CASE_SIMD_EXTRACT_LANE_OP ( opcode,
kind,
fn )
Value:
case wasm::kExpr##opcode: \
EmitSimdExtractLaneOp<kS128, k##kind>( \
[this](LiftoffRegister dst, LiftoffRegister lhs, \
uint8_t imm_lane_idx) { \
__ emit_##fn(dst, lhs, imm_lane_idx); \
}, \
imm); \
break;
#define __

◆ CASE_SIMD_REPLACE_LANE_OP

#define CASE_SIMD_REPLACE_LANE_OP ( opcode,
kind,
fn )
Value:
case wasm::kExpr##opcode: \
EmitSimdReplaceLaneOp<k##kind>( \
[this](LiftoffRegister dst, LiftoffRegister src1, \
LiftoffRegister src2, uint8_t imm_lane_idx) { \
__ emit_##fn(dst, src1, src2, imm_lane_idx); \
}, \
imm); \
break;

◆ CASE_TYPE_CONVERSION

#define CASE_TYPE_CONVERSION ( opcode,
dst_kind,
src_kind,
ext_ref,
can_trap )
Value:
case kExpr##opcode: \
return EmitTypeConversion<k##dst_kind, k##src_kind, can_trap>( \
decoder, kExpr##opcode, ext_ref);

◆ CODE_COMMENT

#define CODE_COMMENT ( str)
Value:
((void)0)

Definition at line 110 of file liftoff-compiler.cc.

◆ FREEZE_STATE

#define FREEZE_STATE ( witness_name)
Value:
FreezeCacheState witness_name(asm_)
LiftoffAssembler asm_

Definition at line 59 of file liftoff-compiler.cc.

◆ FUZZER_HEAVY_INSTRUCTION

#define FUZZER_HEAVY_INSTRUCTION
Value:
do { \
if (V8_UNLIKELY(max_steps_ != nullptr)) { \
CheckMaxSteps(decoder, kHeavyInstructionSteps); \
} \
} while (false)
int32_t *const max_steps_
#define V8_UNLIKELY(condition)
Definition v8config.h:660

Definition at line 1248 of file liftoff-compiler.cc.

◆ LIST_FEATURE

#define LIST_FEATURE ( name,
... )
Value:
WasmEnabledFeature::name,

◆ LOAD_INSTANCE_FIELD

#define LOAD_INSTANCE_FIELD ( dst,
name,
load_size,
pinned )
Value:
__ LoadFromInstance( \
dst, LoadInstanceIntoRegister(pinned, dst), \
assert_field_size<WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE(name), \
load_size>::size);
#define WASM_TRUSTED_INSTANCE_DATA_FIELD_OFFSET(name)
#define WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE(name)

Definition at line 79 of file liftoff-compiler.cc.

◆ LOAD_PROTECTED_PTR_INSTANCE_FIELD

#define LOAD_PROTECTED_PTR_INSTANCE_FIELD ( dst,
name,
pinned )
Value:
static_assert( \
WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE(Protected##name) == kTaggedSize, \
"field in WasmTrustedInstanceData does not have the expected size"); \
__ LoadProtectedPointer( \
dst, LoadInstanceIntoRegister(pinned, dst), \

Definition at line 94 of file liftoff-compiler.cc.

◆ LOAD_TAGGED_PTR_INSTANCE_FIELD

#define LOAD_TAGGED_PTR_INSTANCE_FIELD ( dst,
name,
pinned )
Value:
static_assert( \
WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE(name) == kTaggedSize, \
"field in WasmTrustedInstanceData does not have the expected size"); \
__ LoadTaggedPointerFromInstance( \
dst, LoadInstanceIntoRegister(pinned, dst), \

Definition at line 86 of file liftoff-compiler.cc.

◆ RUNTIME_STUB_FOR_TRAP

#define RUNTIME_STUB_FOR_TRAP ( trap_reason)
Value:
case k##trap_reason: \
return Builtin::kThrowWasm##trap_reason;

◆ SCOPED_CODE_COMMENT

#define SCOPED_CODE_COMMENT ( str)
Value:
((void)0)

Definition at line 111 of file liftoff-compiler.cc.

◆ TRACE

#define TRACE ( ...)
Value:
do { \
if (v8_flags.trace_liftoff) PrintF("[liftoff] " __VA_ARGS__); \
} while (false)

Definition at line 61 of file liftoff-compiler.cc.

◆ WASM_TRUSTED_INSTANCE_DATA_FIELD_OFFSET

#define WASM_TRUSTED_INSTANCE_DATA_FIELD_OFFSET ( name)
Value:
ObjectAccess::ToTagged(WasmTrustedInstanceData::k##name##Offset)

Definition at line 66 of file liftoff-compiler.cc.

◆ WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE

#define WASM_TRUSTED_INSTANCE_DATA_FIELD_SIZE ( name)
Value:
FIELD_SIZE(WasmTrustedInstanceData::k##name##Offset)
#define FIELD_SIZE(Name)
Definition utils.h:259

Definition at line 76 of file liftoff-compiler.cc.

Variable Documentation

◆ asm_

LiftoffAssembler asm_
private

Definition at line 9426 of file liftoff-compiler.cc.

◆ bailout_reason_

LiftoffBailoutReason bailout_reason_ = kSuccess
private

Definition at line 9439 of file liftoff-compiler.cc.

◆ builtin

Builtin builtin

Definition at line 530 of file liftoff-compiler.cc.

◆ cached_instance_data

Register cached_instance_data

Definition at line 533 of file liftoff-compiler.cc.

◆ catch_label

Label catch_label

Definition at line 459 of file liftoff-compiler.cc.

◆ catch_reached

bool catch_reached = false

Definition at line 460 of file liftoff-compiler.cc.

◆ catch_state

LiftoffAssembler::CacheState catch_state

Definition at line 458 of file liftoff-compiler.cc.

◆ changed_values_

std::vector<Value> changed_values_
private

Definition at line 237 of file liftoff-compiler.cc.

◆ compiler_

LiftoffCompiler* compiler_
private

Definition at line 839 of file liftoff-compiler.cc.

◆ continuation

MovableLabel continuation

Definition at line 529 of file liftoff-compiler.cc.

◆ dead_breakpoint_

int dead_breakpoint_ = 0
private

Definition at line 9461 of file liftoff-compiler.cc.

◆ debug_sidetable_builder_

DebugSideTableBuilder* const debug_sidetable_builder_
private

Definition at line 9436 of file liftoff-compiler.cc.

◆ debug_sidetable_entry_builder

DebugSideTableBuilder::EntryBuilder* debug_sidetable_entry_builder

Definition at line 537 of file liftoff-compiler.cc.

◆ deopt_info_bytecode_offset_

const uint32_t deopt_info_bytecode_offset_
private

Definition at line 9497 of file liftoff-compiler.cc.

◆ deopt_location_kind_

const LocationKindForDeopt deopt_location_kind_
private

Definition at line 9498 of file liftoff-compiler.cc.

◆ descriptor_

compiler::CallDescriptor* const descriptor_
private

Definition at line 9434 of file liftoff-compiler.cc.

◆ detect_nondeterminism_

const bool detect_nondeterminism_
private

Definition at line 9494 of file liftoff-compiler.cc.

◆ did_function_entry_break_checks_

bool did_function_entry_break_checks_ = false
private

Definition at line 9466 of file liftoff-compiler.cc.

◆ else_state

ElseState* else_state = nullptr

Definition at line 465 of file liftoff-compiler.cc.

◆ encountered_call_instructions_

std::vector<uint32_t> encountered_call_instructions_
private

Definition at line 9488 of file liftoff-compiler.cc.

◆ entries

ZoneVector<Entry> entries

Definition at line 515 of file liftoff-compiler.cc.

◆ entries_

std::vector<EntryBuilder> entries_
private

Definition at line 304 of file liftoff-compiler.cc.

◆ env_

CompilationEnv* const env_
private

Definition at line 9435 of file liftoff-compiler.cc.

◆ first_arg

ArgType first_arg

Definition at line 2031 of file liftoff-compiler.cc.

◆ fn

EmitFn fn

Definition at line 2030 of file liftoff-compiler.cc.

◆ for_debugging_

const ForDebugging for_debugging_
private

Definition at line 9438 of file liftoff-compiler.cc.

◆ frame_description_

std::unique_ptr<LiftoffFrameDescriptionForDeopt> frame_description_
private

Definition at line 9500 of file liftoff-compiler.cc.

◆ free_temps_

LiftoffRegList free_temps_
private

Definition at line 391 of file liftoff-compiler.cc.

◆ freeze_

FreezeCacheState freeze_
private

Definition at line 3380 of file liftoff-compiler.cc.

◆ func_index_

const int func_index_
private

Definition at line 9440 of file liftoff-compiler.cc.

◆ handler

MovableLabel handler

Definition at line 9469 of file liftoff-compiler.cc.

◆ handler_table_offset_

int handler_table_offset_ = Assembler::kNoHandlerTable
private

Definition at line 9474 of file liftoff-compiler.cc.

◆ handlers_

ZoneVector<HandlerInfo> handlers_
private

Definition at line 9473 of file liftoff-compiler.cc.

◆ in_handler

bool in_handler = false

Definition at line 461 of file liftoff-compiler.cc.

◆ inline_storage_

ValueKind inline_storage_[kInlineStorage]
private

Definition at line 504 of file liftoff-compiler.cc.

◆ input_idx_

uint32_t input_idx_ {kFirstInputIdx}
private

Definition at line 842 of file liftoff-compiler.cc.

◆ kFirstInputIdx

uint32_t kFirstInputIdx = 2
staticconstexprprivate

Definition at line 837 of file liftoff-compiler.cc.

◆ kind

ValueKind kind

Definition at line 513 of file liftoff-compiler.cc.

◆ kind_

ValueKind kind_
private

Definition at line 843 of file liftoff-compiler.cc.

◆ kInlineStorage

size_t kInlineStorage = 8
staticconstexprprivate

Definition at line 491 of file liftoff-compiler.cc.

◆ kNoOutstandingOp

WasmOpcode kNoOutstandingOp = kExprUnreachable
staticconstexprprivate

Definition at line 9419 of file liftoff-compiler.cc.

◆ kTierUpCostForCheck

int kTierUpCostForCheck = 20
staticconstexpr

Definition at line 447 of file liftoff-compiler.cc.

◆ kTierUpCostForFunctionEntry

int kTierUpCostForFunctionEntry = 40
staticconstexpr

Definition at line 448 of file liftoff-compiler.cc.

◆ kUnconditionallySupported

base::EnumSet<ValueKind> kUnconditionallySupported
staticconstexprprivate
Initial value:
{
kI32, kI64, kF32, kF64,
kRef, kRefNull, kI8, kI16}

Definition at line 9420 of file liftoff-compiler.cc.

◆ kUsesPoppedArgs

bool kUsesPoppedArgs = false
staticconstexpr

Definition at line 435 of file liftoff-compiler.cc.

◆ label

MovableLabel label

Definition at line 452 of file liftoff-compiler.cc.

◆ label_

Label* label_
private

Definition at line 150 of file liftoff-compiler.cc.

◆ label_state

LiftoffAssembler::CacheState label_state

Definition at line 466 of file liftoff-compiler.cc.

◆ last_ool_values_

std::vector<Value> last_ool_values_
private

Definition at line 309 of file liftoff-compiler.cc.

◆ last_safepoint_offset_

int last_safepoint_offset_ = -1
private

Definition at line 9481 of file liftoff-compiler.cc.

◆ last_values_

std::vector<Value> last_values_
private

Definition at line 303 of file liftoff-compiler.cc.

◆ location_

LinkageLocation location_ {LinkageLocation::ForAnyRegister()}
private

Definition at line 847 of file liftoff-compiler.cc.

◆ max_steps_

int32_t* const max_steps_
private

Definition at line 9492 of file liftoff-compiler.cc.

◆ needs_gp_pair_

bool needs_gp_pair_
private

Definition at line 844 of file liftoff-compiler.cc.

◆ next_breakpoint_end_

const int* next_breakpoint_end_ = nullptr
private

Definition at line 9457 of file liftoff-compiler.cc.

◆ next_breakpoint_ptr_

const int* next_breakpoint_ptr_ = nullptr
private

Definition at line 9456 of file liftoff-compiler.cc.

◆ no_match

Label* no_match

Definition at line 7527 of file liftoff-compiler.cc.

◆ no_match_trap

Builtin no_match_trap

Definition at line 7528 of file liftoff-compiler.cc.

◆ null_check_strategy_

const compiler::NullCheckStrategy null_check_strategy_
private
Initial value:
=
trap_handler::IsTrapHandlerEnabled() && V8_STATIC_ROOTS_BOOL
? compiler::NullCheckStrategy::kTrapHandler
: compiler::NullCheckStrategy::kExplicit
#define V8_STATIC_ROOTS_BOOL
Definition v8config.h:1001

Definition at line 9502 of file liftoff-compiler.cc.

◆ null_succeeds

bool null_succeeds

Definition at line 7530 of file liftoff-compiler.cc.

◆ num_exceptions

int num_exceptions = 0

Definition at line 470 of file liftoff-compiler.cc.

◆ num_exceptions_

int num_exceptions_ = 0
private

Definition at line 9477 of file liftoff-compiler.cc.

◆ num_locals_

int num_locals_ = -1
private

Definition at line 300 of file liftoff-compiler.cc.

◆ num_params_

const uint32_t num_params_
private

Definition at line 840 of file liftoff-compiler.cc.

◆ obj_reg

Register obj_reg = no_reg

Definition at line 7524 of file liftoff-compiler.cc.

◆ obj_type

ValueType obj_type

Definition at line 7525 of file liftoff-compiler.cc.

◆ offset

int offset

Definition at line 511 of file liftoff-compiler.cc.

◆ ool_entries_

std::list<EntryBuilder> ool_entries_
private

Definition at line 310 of file liftoff-compiler.cc.

◆ out_of_line_code_

ZoneVector<OutOfLineCode> out_of_line_code_
private

Definition at line 9441 of file liftoff-compiler.cc.

◆ outstanding_op_

WasmOpcode outstanding_op_ = kNoOutstandingOp
private

Definition at line 9430 of file liftoff-compiler.cc.

◆ param_idx_

uint32_t param_idx_ {0}
private

Definition at line 841 of file liftoff-compiler.cc.

◆ param_regs_

LiftoffRegList param_regs_
private

Definition at line 848 of file liftoff-compiler.cc.

◆ pc_offset

int pc_offset

Definition at line 9470 of file liftoff-compiler.cc.

◆ pc_offset_

int pc_offset_
private

Definition at line 235 of file liftoff-compiler.cc.

◆ pc_offset_stack_frame_construction_

uint32_t pc_offset_stack_frame_construction_ = 0
private

Definition at line 9451 of file liftoff-compiler.cc.

◆ position

WasmCodePosition position

Definition at line 531 of file liftoff-compiler.cc.

◆ protected_instructions_

ZoneVector<trap_handler::ProtectedInstructionData> protected_instructions_
private

Definition at line 9443 of file liftoff-compiler.cc.

◆ rc_

RegClass rc_
private

Definition at line 846 of file liftoff-compiler.cc.

◆ reg

LiftoffRegister reg

Definition at line 512 of file liftoff-compiler.cc.

◆ reg_

LiftoffRegister reg_
private

Definition at line 427 of file liftoff-compiler.cc.

◆ reg_kind_

ValueKind reg_kind_
private

Definition at line 845 of file liftoff-compiler.cc.

◆ regs_to_save

LiftoffRegList regs_to_save

Definition at line 532 of file liftoff-compiler.cc.

◆ safepoint_info

OutOfLineSafepointInfo* safepoint_info

Definition at line 534 of file liftoff-compiler.cc.

◆ safepoint_table_builder_

SafepointTableBuilder safepoint_table_builder_
private

Definition at line 9448 of file liftoff-compiler.cc.

◆ size

int size = actual_size
staticconstexpr

Definition at line 73 of file liftoff-compiler.cc.

◆ slots

ZoneVector<int> slots

Definition at line 521 of file liftoff-compiler.cc.

◆ source_position_table_builder_

SourcePositionTableBuilder source_position_table_builder_
private

Definition at line 9442 of file liftoff-compiler.cc.

◆ spilled_registers

SpilledRegistersForInspection* spilled_registers

Definition at line 536 of file liftoff-compiler.cc.

◆ spills

LiftoffRegList spills

Definition at line 522 of file liftoff-compiler.cc.

◆ stack_height_

int stack_height_
private

Definition at line 236 of file liftoff-compiler.cc.

◆ stack_value_types_for_debugging_

base::OwnedVector<ValueType> stack_value_types_for_debugging_
private

Definition at line 9437 of file liftoff-compiler.cc.

◆ state

LiftoffAssembler::CacheState state

Definition at line 453 of file liftoff-compiler.cc.

◆ supported_types_

base::EnumSet<ValueKind> supported_types_ = kUnconditionallySupported
private

Definition at line 9433 of file liftoff-compiler.cc.

◆ temp_scope_

TempRegisterScope* temp_scope_
private

Definition at line 428 of file liftoff-compiler.cc.

◆ tmp

Register tmp = no_reg

Definition at line 7526 of file liftoff-compiler.cc.

◆ trap

std::optional<OolTrapLabel> trap

Definition at line 7529 of file liftoff-compiler.cc.

◆ try_info

TryInfo* try_info = nullptr

Definition at line 468 of file liftoff-compiler.cc.

◆ zone_

Zone* zone_
private

Definition at line 9447 of file liftoff-compiler.cc.