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.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jit_x86_Architecture_x86_h
8 #define jit_x86_Architecture_x86_h
10 #include "assembler/assembler/MacroAssembler.h"
12 namespace js {
13 namespace jit {
15 // In bytes: slots needed for potential memory->memory move spills.
16 // +8 for cycles
17 // +4 for gpr spills
18 // +8 for double spills
19 static const uint32_t ION_FRAME_SLACK_SIZE = 20;
21 // Only Win64 requires shadow stack space.
22 static const uint32_t ShadowStackSpace = 0;
24 // These offsets are specific to nunboxing, and capture offsets into the
25 // components of a js::Value.
26 static const int32_t NUNBOX32_TYPE_OFFSET = 4;
27 static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0;
29 ////
30 // These offsets are related to bailouts.
31 ////
33 // Size of each bailout table entry. On x86 this is a 5-byte relative call.
34 static const uint32_t BAILOUT_TABLE_ENTRY_SIZE = 5;
36 class Registers {
37 public:
38 typedef JSC::X86Registers::RegisterID Code;
40 static const char *GetName(Code code) {
41 static const char * const Names[] = { "eax", "ecx", "edx", "ebx",
42 "esp", "ebp", "esi", "edi" };
43 return Names[code];
44 }
46 static Code FromName(const char *name) {
47 for (size_t i = 0; i < Total; i++) {
48 if (strcmp(GetName(Code(i)), name) == 0)
49 return Code(i);
50 }
51 return Invalid;
52 }
54 static const Code StackPointer = JSC::X86Registers::esp;
55 static const Code Invalid = JSC::X86Registers::invalid_reg;
57 static const uint32_t Total = 8;
58 static const uint32_t Allocatable = 7;
60 static const uint32_t AllMask = (1 << Total) - 1;
62 static const uint32_t ArgRegMask = 0;
64 static const uint32_t VolatileMask =
65 (1 << JSC::X86Registers::eax) |
66 (1 << JSC::X86Registers::ecx) |
67 (1 << JSC::X86Registers::edx);
69 static const uint32_t NonVolatileMask =
70 (1 << JSC::X86Registers::ebx) |
71 (1 << JSC::X86Registers::esi) |
72 (1 << JSC::X86Registers::edi) |
73 (1 << JSC::X86Registers::ebp);
75 static const uint32_t WrapperMask =
76 VolatileMask |
77 (1 << JSC::X86Registers::ebx);
79 static const uint32_t SingleByteRegs =
80 (1 << JSC::X86Registers::eax) |
81 (1 << JSC::X86Registers::ecx) |
82 (1 << JSC::X86Registers::edx) |
83 (1 << JSC::X86Registers::ebx);
85 static const uint32_t NonAllocatableMask =
86 (1 << JSC::X86Registers::esp);
88 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
90 // Registers that can be allocated without being saved, generally.
91 static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
93 // Registers returned from a JS -> JS call.
94 static const uint32_t JSCallMask =
95 (1 << JSC::X86Registers::ecx) |
96 (1 << JSC::X86Registers::edx);
98 // Registers returned from a JS -> C call.
99 static const uint32_t CallMask =
100 (1 << JSC::X86Registers::eax);
101 };
103 // Smallest integer type that can hold a register bitmask.
104 typedef uint8_t PackedRegisterMask;
106 class FloatRegisters {
107 public:
108 typedef JSC::X86Registers::XMMRegisterID Code;
110 static const char *GetName(Code code) {
111 static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
112 "xmm4", "xmm5", "xmm6", "xmm7" };
113 return Names[code];
114 }
116 static Code FromName(const char *name) {
117 for (size_t i = 0; i < Total; i++) {
118 if (strcmp(GetName(Code(i)), name) == 0)
119 return Code(i);
120 }
121 return Invalid;
122 }
124 static const Code Invalid = JSC::X86Registers::invalid_xmm;
126 static const uint32_t Total = 8;
127 static const uint32_t Allocatable = 7;
129 static const uint32_t AllMask = (1 << Total) - 1;
131 static const uint32_t VolatileMask = AllMask;
132 static const uint32_t NonVolatileMask = 0;
134 static const uint32_t WrapperMask = VolatileMask;
136 static const uint32_t NonAllocatableMask =
137 (1 << JSC::X86Registers::xmm7);
139 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
140 };
142 } // namespace jit
143 } // namespace js
145 #endif /* jit_x86_Architecture_x86_h */