michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_x86_Architecture_x86_h michael@0: #define jit_x86_Architecture_x86_h michael@0: michael@0: #include "assembler/assembler/MacroAssembler.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: // In bytes: slots needed for potential memory->memory move spills. michael@0: // +8 for cycles michael@0: // +4 for gpr spills michael@0: // +8 for double spills michael@0: static const uint32_t ION_FRAME_SLACK_SIZE = 20; michael@0: michael@0: // Only Win64 requires shadow stack space. michael@0: static const uint32_t ShadowStackSpace = 0; michael@0: michael@0: // These offsets are specific to nunboxing, and capture offsets into the michael@0: // components of a js::Value. michael@0: static const int32_t NUNBOX32_TYPE_OFFSET = 4; michael@0: static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0; michael@0: michael@0: //// michael@0: // These offsets are related to bailouts. michael@0: //// michael@0: michael@0: // Size of each bailout table entry. On x86 this is a 5-byte relative call. michael@0: static const uint32_t BAILOUT_TABLE_ENTRY_SIZE = 5; michael@0: michael@0: class Registers { michael@0: public: michael@0: typedef JSC::X86Registers::RegisterID Code; michael@0: michael@0: static const char *GetName(Code code) { michael@0: static const char * const Names[] = { "eax", "ecx", "edx", "ebx", michael@0: "esp", "ebp", "esi", "edi" }; michael@0: return Names[code]; michael@0: } michael@0: michael@0: static Code FromName(const char *name) { michael@0: for (size_t i = 0; i < Total; i++) { michael@0: if (strcmp(GetName(Code(i)), name) == 0) michael@0: return Code(i); michael@0: } michael@0: return Invalid; michael@0: } michael@0: michael@0: static const Code StackPointer = JSC::X86Registers::esp; michael@0: static const Code Invalid = JSC::X86Registers::invalid_reg; michael@0: michael@0: static const uint32_t Total = 8; michael@0: static const uint32_t Allocatable = 7; michael@0: michael@0: static const uint32_t AllMask = (1 << Total) - 1; michael@0: michael@0: static const uint32_t ArgRegMask = 0; michael@0: michael@0: static const uint32_t VolatileMask = michael@0: (1 << JSC::X86Registers::eax) | michael@0: (1 << JSC::X86Registers::ecx) | michael@0: (1 << JSC::X86Registers::edx); michael@0: michael@0: static const uint32_t NonVolatileMask = michael@0: (1 << JSC::X86Registers::ebx) | michael@0: (1 << JSC::X86Registers::esi) | michael@0: (1 << JSC::X86Registers::edi) | michael@0: (1 << JSC::X86Registers::ebp); michael@0: michael@0: static const uint32_t WrapperMask = michael@0: VolatileMask | michael@0: (1 << JSC::X86Registers::ebx); michael@0: michael@0: static const uint32_t SingleByteRegs = michael@0: (1 << JSC::X86Registers::eax) | michael@0: (1 << JSC::X86Registers::ecx) | michael@0: (1 << JSC::X86Registers::edx) | michael@0: (1 << JSC::X86Registers::ebx); michael@0: michael@0: static const uint32_t NonAllocatableMask = michael@0: (1 << JSC::X86Registers::esp); michael@0: michael@0: static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; michael@0: michael@0: // Registers that can be allocated without being saved, generally. michael@0: static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask; michael@0: michael@0: // Registers returned from a JS -> JS call. michael@0: static const uint32_t JSCallMask = michael@0: (1 << JSC::X86Registers::ecx) | michael@0: (1 << JSC::X86Registers::edx); michael@0: michael@0: // Registers returned from a JS -> C call. michael@0: static const uint32_t CallMask = michael@0: (1 << JSC::X86Registers::eax); michael@0: }; michael@0: michael@0: // Smallest integer type that can hold a register bitmask. michael@0: typedef uint8_t PackedRegisterMask; michael@0: michael@0: class FloatRegisters { michael@0: public: michael@0: typedef JSC::X86Registers::XMMRegisterID Code; michael@0: michael@0: static const char *GetName(Code code) { michael@0: static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3", michael@0: "xmm4", "xmm5", "xmm6", "xmm7" }; michael@0: return Names[code]; michael@0: } michael@0: michael@0: static Code FromName(const char *name) { michael@0: for (size_t i = 0; i < Total; i++) { michael@0: if (strcmp(GetName(Code(i)), name) == 0) michael@0: return Code(i); michael@0: } michael@0: return Invalid; michael@0: } michael@0: michael@0: static const Code Invalid = JSC::X86Registers::invalid_xmm; michael@0: michael@0: static const uint32_t Total = 8; michael@0: static const uint32_t Allocatable = 7; michael@0: michael@0: static const uint32_t AllMask = (1 << Total) - 1; michael@0: michael@0: static const uint32_t VolatileMask = AllMask; michael@0: static const uint32_t NonVolatileMask = 0; michael@0: michael@0: static const uint32_t WrapperMask = VolatileMask; michael@0: michael@0: static const uint32_t NonAllocatableMask = michael@0: (1 << JSC::X86Registers::xmm7); michael@0: michael@0: static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; michael@0: }; michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_x86_Architecture_x86_h */