// Copyright (c) 1994-2006 Sun Microsystems Inc. // All Rights Reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // - Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // - Redistribution in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // - Neither the name of Sun Microsystems or the names of contributors may // be used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The original source code covered by the above license above has been // modified significantly by Google Inc. // Copyright 2012 the V8 project authors. All rights reserved. #ifndef V8_CODEGEN_ASSEMBLER_H_ #define V8_CODEGEN_ASSEMBLER_H_ #include <algorithm> #include <forward_list> #include <map> #include <memory> #include <ostream> #include <type_traits> #include <unordered_map> #include "src/base/macros.h" #include "src/base/memory.h" #include "src/codegen/code-comments.h" #include "src/codegen/cpu-features.h" #include "src/codegen/external-reference.h" #include "src/codegen/label.h" #include "src/codegen/reglist.h" #include "src/codegen/reloc-info.h" #include "src/common/globals.h" #include "src/deoptimizer/deoptimize-reason.h" #include "src/flags/flags.h" #include "src/handles/handles.h" #include "src/objects/objects.h" #include "src/sandbox/indirect-pointer-tag.h" #include "src/utils/ostreams.h" namespace v8 { // Forward declarations. class ApiFunction; namespace internal { Memory; ReadUnalignedValue; WriteUnalignedValue; // Forward declarations. class EmbeddedData; class OffHeapInstructionStream; class Isolate; class SCTableReference; class SourcePosition; class StatsCounter; class Label; // ----------------------------------------------------------------------------- // Optimization for far-jmp like instructions that can be replaced by shorter. struct JumpOptimizationInfo { … }; class HeapNumberRequest { … }; // ----------------------------------------------------------------------------- // Platform independent assembler base class. enum class CodeObjectRequired { … }; enum class BuiltinCallJumpMode { … }; struct V8_EXPORT_PRIVATE AssemblerOptions { … }; class AssemblerBuffer { … }; // Describes a HeapObject slot containing a pointer to another HeapObject. Such // a slot can either contain a direct/tagged pointer, or an indirect pointer // (i.e. an index into a pointer table, which then contains the actual pointer // to the object) together with a specific IndirectPointerTag. class SlotDescriptor { … }; // Allocate an AssemblerBuffer which uses an existing buffer. This buffer cannot // grow, so it must be large enough for all code emitted by the Assembler. V8_EXPORT_PRIVATE std::unique_ptr<AssemblerBuffer> ExternalAssemblerBuffer(void* buffer, int size); // Allocate a new growable AssemblerBuffer with a given initial size. V8_EXPORT_PRIVATE std::unique_ptr<AssemblerBuffer> NewAssemblerBuffer(int size); class V8_EXPORT_PRIVATE AssemblerBase : public Malloced { … }; // Enable a specified feature within a scope. class V8_EXPORT_PRIVATE V8_NODISCARD CpuFeatureScope { … }; #ifdef V8_CODE_COMMENTS #if V8_SUPPORTS_SOURCE_LOCATION // We'll get the function name from the source location, no need to pass it in. #define ASM_CODE_COMMENT(asm) … #else #define ASM_CODE_COMMENT … #endif #define ASM_CODE_COMMENT_STRING(asm, comment) … #else #define ASM_CODE_COMMENT … #define ASM_CODE_COMMENT_STRING … #endif // Use this macro to mark functions that are only defined if // V8_ENABLE_DEBUG_CODE is set, and are a no-op otherwise. // Use like: // void AssertMyCondition() NOOP_UNLESS_DEBUG_CODE; #ifdef V8_ENABLE_DEBUG_CODE #define NOOP_UNLESS_DEBUG_CODE #else #define NOOP_UNLESS_DEBUG_CODE … #endif } // namespace internal } // namespace v8 #endif // V8_CODEGEN_ASSEMBLER_H_