// 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-compiler.h" #include "src/assembler-inl.h" #include "src/base/optional.h" // TODO(clemensh): Remove dependences on compiler stuff. #include "src/compiler/linkage.h" #include "src/compiler/wasm-compiler.h" #include "src/counters.h" #include "src/macro-assembler-inl.h" #include "src/tracing/trace-event.h" #include "src/wasm/baseline/liftoff-assembler.h" #include "src/wasm/function-body-decoder-impl.h" #include "src/wasm/function-compiler.h" #include "src/wasm/memory-tracing.h" #include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-linkage.h" #include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-opcodes.h" namespace v8 { namespace internal { namespace wasm { 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()); #ifdef DEBUG #define DEBUG_CODE_COMMENT(str) \ do { \ __ RecordComment(str); \ } while (false) #else #define DEBUG_CODE_COMMENT(str) ((void)0) #endif 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: MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(MovableLabel); MovableLabel() : label_(new Label()) {} Label* get() { return label_.get(); } private: std::unique_ptr