Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef jit_x64_Architecture_x64_h |
michael@0 | 8 | #define jit_x64_Architecture_x64_h |
michael@0 | 9 | |
michael@0 | 10 | #include "assembler/assembler/MacroAssembler.h" |
michael@0 | 11 | |
michael@0 | 12 | namespace js { |
michael@0 | 13 | namespace jit { |
michael@0 | 14 | |
michael@0 | 15 | // In bytes: slots needed for potential memory->memory move spills. |
michael@0 | 16 | // +8 for cycles |
michael@0 | 17 | // +8 for gpr spills |
michael@0 | 18 | // +8 for double spills |
michael@0 | 19 | static const uint32_t ION_FRAME_SLACK_SIZE = 24; |
michael@0 | 20 | |
michael@0 | 21 | #ifdef _WIN64 |
michael@0 | 22 | static const uint32_t ShadowStackSpace = 32; |
michael@0 | 23 | #else |
michael@0 | 24 | static const uint32_t ShadowStackSpace = 0; |
michael@0 | 25 | #endif |
michael@0 | 26 | |
michael@0 | 27 | class Registers { |
michael@0 | 28 | public: |
michael@0 | 29 | typedef JSC::X86Registers::RegisterID Code; |
michael@0 | 30 | |
michael@0 | 31 | static const char *GetName(Code code) { |
michael@0 | 32 | static const char * const Names[] = { "rax", "rcx", "rdx", "rbx", |
michael@0 | 33 | "rsp", "rbp", "rsi", "rdi", |
michael@0 | 34 | "r8", "r9", "r10", "r11", |
michael@0 | 35 | "r12", "r13", "r14", "r15" }; |
michael@0 | 36 | return Names[code]; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | static Code FromName(const char *name) { |
michael@0 | 40 | for (size_t i = 0; i < Total; i++) { |
michael@0 | 41 | if (strcmp(GetName(Code(i)), name) == 0) |
michael@0 | 42 | return Code(i); |
michael@0 | 43 | } |
michael@0 | 44 | return Invalid; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | static const Code StackPointer = JSC::X86Registers::esp; |
michael@0 | 48 | static const Code Invalid = JSC::X86Registers::invalid_reg; |
michael@0 | 49 | |
michael@0 | 50 | static const uint32_t Total = 16; |
michael@0 | 51 | static const uint32_t Allocatable = 14; |
michael@0 | 52 | |
michael@0 | 53 | static const uint32_t AllMask = (1 << Total) - 1; |
michael@0 | 54 | |
michael@0 | 55 | static const uint32_t ArgRegMask = |
michael@0 | 56 | # if !defined(_WIN64) |
michael@0 | 57 | (1 << JSC::X86Registers::edi) | |
michael@0 | 58 | (1 << JSC::X86Registers::esi) | |
michael@0 | 59 | # endif |
michael@0 | 60 | (1 << JSC::X86Registers::edx) | |
michael@0 | 61 | (1 << JSC::X86Registers::ecx) | |
michael@0 | 62 | (1 << JSC::X86Registers::r8) | |
michael@0 | 63 | (1 << JSC::X86Registers::r9); |
michael@0 | 64 | |
michael@0 | 65 | static const uint32_t VolatileMask = |
michael@0 | 66 | (1 << JSC::X86Registers::eax) | |
michael@0 | 67 | (1 << JSC::X86Registers::ecx) | |
michael@0 | 68 | (1 << JSC::X86Registers::edx) | |
michael@0 | 69 | # if !defined(_WIN64) |
michael@0 | 70 | (1 << JSC::X86Registers::esi) | |
michael@0 | 71 | (1 << JSC::X86Registers::edi) | |
michael@0 | 72 | # endif |
michael@0 | 73 | (1 << JSC::X86Registers::r8) | |
michael@0 | 74 | (1 << JSC::X86Registers::r9) | |
michael@0 | 75 | (1 << JSC::X86Registers::r10) | |
michael@0 | 76 | (1 << JSC::X86Registers::r11); |
michael@0 | 77 | |
michael@0 | 78 | static const uint32_t NonVolatileMask = |
michael@0 | 79 | (1 << JSC::X86Registers::ebx) | |
michael@0 | 80 | #if defined(_WIN64) |
michael@0 | 81 | (1 << JSC::X86Registers::esi) | |
michael@0 | 82 | (1 << JSC::X86Registers::edi) | |
michael@0 | 83 | #endif |
michael@0 | 84 | (1 << JSC::X86Registers::ebp) | |
michael@0 | 85 | (1 << JSC::X86Registers::r12) | |
michael@0 | 86 | (1 << JSC::X86Registers::r13) | |
michael@0 | 87 | (1 << JSC::X86Registers::r14) | |
michael@0 | 88 | (1 << JSC::X86Registers::r15); |
michael@0 | 89 | |
michael@0 | 90 | static const uint32_t WrapperMask = VolatileMask; |
michael@0 | 91 | |
michael@0 | 92 | static const uint32_t SingleByteRegs = VolatileMask | NonVolatileMask; |
michael@0 | 93 | |
michael@0 | 94 | static const uint32_t NonAllocatableMask = |
michael@0 | 95 | (1 << JSC::X86Registers::esp) | |
michael@0 | 96 | (1 << JSC::X86Registers::r11); // This is ScratchReg. |
michael@0 | 97 | |
michael@0 | 98 | // Registers that can be allocated without being saved, generally. |
michael@0 | 99 | static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask; |
michael@0 | 100 | |
michael@0 | 101 | static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; |
michael@0 | 102 | |
michael@0 | 103 | // Registers returned from a JS -> JS call. |
michael@0 | 104 | static const uint32_t JSCallMask = |
michael@0 | 105 | (1 << JSC::X86Registers::ecx); |
michael@0 | 106 | |
michael@0 | 107 | // Registers returned from a JS -> C call. |
michael@0 | 108 | static const uint32_t CallMask = |
michael@0 | 109 | (1 << JSC::X86Registers::eax); |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | // Smallest integer type that can hold a register bitmask. |
michael@0 | 113 | typedef uint16_t PackedRegisterMask; |
michael@0 | 114 | |
michael@0 | 115 | class FloatRegisters { |
michael@0 | 116 | public: |
michael@0 | 117 | typedef JSC::X86Registers::XMMRegisterID Code; |
michael@0 | 118 | |
michael@0 | 119 | static const char *GetName(Code code) { |
michael@0 | 120 | static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3", |
michael@0 | 121 | "xmm4", "xmm5", "xmm6", "xmm7", |
michael@0 | 122 | "xmm8", "xmm9", "xmm10", "xmm11", |
michael@0 | 123 | "xmm12", "xmm13", "xmm14", "xmm15" }; |
michael@0 | 124 | return Names[code]; |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | static Code FromName(const char *name) { |
michael@0 | 128 | for (size_t i = 0; i < Total; i++) { |
michael@0 | 129 | if (strcmp(GetName(Code(i)), name) == 0) |
michael@0 | 130 | return Code(i); |
michael@0 | 131 | } |
michael@0 | 132 | return Invalid; |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | static const Code Invalid = JSC::X86Registers::invalid_xmm; |
michael@0 | 136 | |
michael@0 | 137 | static const uint32_t Total = 16; |
michael@0 | 138 | static const uint32_t Allocatable = 15; |
michael@0 | 139 | |
michael@0 | 140 | static const uint32_t AllMask = (1 << Total) - 1; |
michael@0 | 141 | |
michael@0 | 142 | static const uint32_t VolatileMask = |
michael@0 | 143 | #if defined(_WIN64) |
michael@0 | 144 | (1 << JSC::X86Registers::xmm0) | |
michael@0 | 145 | (1 << JSC::X86Registers::xmm1) | |
michael@0 | 146 | (1 << JSC::X86Registers::xmm2) | |
michael@0 | 147 | (1 << JSC::X86Registers::xmm3) | |
michael@0 | 148 | (1 << JSC::X86Registers::xmm4) | |
michael@0 | 149 | (1 << JSC::X86Registers::xmm5); |
michael@0 | 150 | #else |
michael@0 | 151 | AllMask; |
michael@0 | 152 | #endif |
michael@0 | 153 | |
michael@0 | 154 | static const uint32_t NonVolatileMask = AllMask & ~VolatileMask; |
michael@0 | 155 | |
michael@0 | 156 | static const uint32_t WrapperMask = VolatileMask; |
michael@0 | 157 | |
michael@0 | 158 | static const uint32_t NonAllocatableMask = |
michael@0 | 159 | (1 << JSC::X86Registers::xmm15); // This is ScratchFloatReg. |
michael@0 | 160 | |
michael@0 | 161 | static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; |
michael@0 | 162 | }; |
michael@0 | 163 | |
michael@0 | 164 | } // namespace jit |
michael@0 | 165 | } // namespace js |
michael@0 | 166 | |
michael@0 | 167 | #endif /* jit_x64_Architecture_x64_h */ |