// Copyright 2017 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. #include "src/wasm/baseline/liftoff-assembler.h" #include "src/assembler-inl.h" #include "src/base/optional.h" #include "src/compiler/linkage.h" #include "src/compiler/wasm-compiler.h" #include "src/counters.h" #include "src/macro-assembler-inl.h" #include "src/wasm/function-body-decoder-impl.h" #include "src/wasm/memory-tracing.h" #include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-opcodes.h" namespace v8 { namespace internal { namespace wasm { using WasmCompilationData = compiler::WasmCompilationData; constexpr auto kRegister = LiftoffAssembler::VarState::kRegister; constexpr auto KIntConst = LiftoffAssembler::VarState::KIntConst; constexpr auto kStack = LiftoffAssembler::VarState::kStack; namespace { #define __ asm_-> #define TRACE(...) \ do { \ if (FLAG_trace_liftoff) PrintF("[liftoff] " __VA_ARGS__); \ } while (false) #define WASM_INSTANCE_OBJECT_OFFSET(name) \ (WasmInstanceObject::k##name##Offset - kHeapObjectTag) #define LOAD_INSTANCE_FIELD(dst, name, type) \ __ LoadFromInstance(dst.gp(), WASM_INSTANCE_OBJECT_OFFSET(name), \ LoadType(type).size()); constexpr LoadType::LoadTypeValue kPointerLoadType = kPointerSize == 8 ? LoadType::kI64Load : LoadType::kI32Load; #if V8_TARGET_ARCH_ARM64 // On ARM64, the Assembler keeps track of pointers to Labels to resolve // branches to distant targets. Moving labels would confuse the Assembler, // thus store the label on the heap and keep a unique_ptr. class MovableLabel { public: Label* get() { return label_.get(); } MovableLabel() : MovableLabel(new Label()) {} operator bool() const { return label_ != nullptr; } static MovableLabel None() { return MovableLabel(nullptr); } private: std::unique_ptr