// Copyright 2021 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. #ifndef V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_SHARED_IA32_X64_H_ #define V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_SHARED_IA32_X64_H_ #include <optional> #include "src/base/macros.h" #include "src/codegen/cpu-features.h" #include "src/codegen/external-reference.h" #include "src/codegen/macro-assembler-base.h" #if V8_TARGET_ARCH_IA32 #include "src/codegen/ia32/register-ia32.h" #elif V8_TARGET_ARCH_X64 #include "src/codegen/x64/register-x64.h" #else #error Unsupported target architecture. #endif namespace v8 { namespace internal { class Assembler; // For WebAssembly we care about the full floating point register. If we are not // running Wasm, we can get away with saving half of those registers. #if V8_ENABLE_WEBASSEMBLY constexpr int kStackSavedSavedFPSize = …; #else constexpr int kStackSavedSavedFPSize = kDoubleSize; #endif // V8_ENABLE_WEBASSEMBLY // Base class for SharedMacroAssembler. This class contains macro-assembler // functions that can be shared across ia32 and x64 without any template // machinery, i.e. does not require the CRTP pattern that // SharedMacroAssembler exposes. This allows us to keep the bulk of // definition inside a separate source file, rather than putting everything // inside this header. class V8_EXPORT_PRIVATE SharedMacroAssemblerBase : public MacroAssemblerBase { … }; // Common base class template shared by ia32 and x64 MacroAssembler. This uses // the Curiously Recurring Template Pattern (CRTP), where Impl is the actual // class (subclass of SharedMacroAssembler instantiated with the actual // class). This allows static polymorphism, where member functions can be move // into SharedMacroAssemblerBase, and we can also call into member functions // defined in ia32 or x64 specific MacroAssembler from within this template // class, via Impl. // // Note: all member functions must be defined in this header file so that the // compiler can generate code for the function definitions. See // https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl for rationale. // If a function does not need polymorphism, move it into // SharedMacroAssemblerBase, and define it outside of this header. template <typename Impl> class V8_EXPORT_PRIVATE SharedMacroAssembler : public SharedMacroAssemblerBase { … }; } // namespace internal } // namespace v8 #endif // V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_SHARED_IA32_X64_H_