|
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/. */ |
|
6 |
|
7 #ifndef jit_x86_Architecture_x86_h |
|
8 #define jit_x86_Architecture_x86_h |
|
9 |
|
10 #include "assembler/assembler/MacroAssembler.h" |
|
11 |
|
12 namespace js { |
|
13 namespace jit { |
|
14 |
|
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; |
|
20 |
|
21 // Only Win64 requires shadow stack space. |
|
22 static const uint32_t ShadowStackSpace = 0; |
|
23 |
|
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; |
|
28 |
|
29 //// |
|
30 // These offsets are related to bailouts. |
|
31 //// |
|
32 |
|
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; |
|
35 |
|
36 class Registers { |
|
37 public: |
|
38 typedef JSC::X86Registers::RegisterID Code; |
|
39 |
|
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 } |
|
45 |
|
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 } |
|
53 |
|
54 static const Code StackPointer = JSC::X86Registers::esp; |
|
55 static const Code Invalid = JSC::X86Registers::invalid_reg; |
|
56 |
|
57 static const uint32_t Total = 8; |
|
58 static const uint32_t Allocatable = 7; |
|
59 |
|
60 static const uint32_t AllMask = (1 << Total) - 1; |
|
61 |
|
62 static const uint32_t ArgRegMask = 0; |
|
63 |
|
64 static const uint32_t VolatileMask = |
|
65 (1 << JSC::X86Registers::eax) | |
|
66 (1 << JSC::X86Registers::ecx) | |
|
67 (1 << JSC::X86Registers::edx); |
|
68 |
|
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); |
|
74 |
|
75 static const uint32_t WrapperMask = |
|
76 VolatileMask | |
|
77 (1 << JSC::X86Registers::ebx); |
|
78 |
|
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); |
|
84 |
|
85 static const uint32_t NonAllocatableMask = |
|
86 (1 << JSC::X86Registers::esp); |
|
87 |
|
88 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; |
|
89 |
|
90 // Registers that can be allocated without being saved, generally. |
|
91 static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask; |
|
92 |
|
93 // Registers returned from a JS -> JS call. |
|
94 static const uint32_t JSCallMask = |
|
95 (1 << JSC::X86Registers::ecx) | |
|
96 (1 << JSC::X86Registers::edx); |
|
97 |
|
98 // Registers returned from a JS -> C call. |
|
99 static const uint32_t CallMask = |
|
100 (1 << JSC::X86Registers::eax); |
|
101 }; |
|
102 |
|
103 // Smallest integer type that can hold a register bitmask. |
|
104 typedef uint8_t PackedRegisterMask; |
|
105 |
|
106 class FloatRegisters { |
|
107 public: |
|
108 typedef JSC::X86Registers::XMMRegisterID Code; |
|
109 |
|
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 } |
|
115 |
|
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 } |
|
123 |
|
124 static const Code Invalid = JSC::X86Registers::invalid_xmm; |
|
125 |
|
126 static const uint32_t Total = 8; |
|
127 static const uint32_t Allocatable = 7; |
|
128 |
|
129 static const uint32_t AllMask = (1 << Total) - 1; |
|
130 |
|
131 static const uint32_t VolatileMask = AllMask; |
|
132 static const uint32_t NonVolatileMask = 0; |
|
133 |
|
134 static const uint32_t WrapperMask = VolatileMask; |
|
135 |
|
136 static const uint32_t NonAllocatableMask = |
|
137 (1 << JSC::X86Registers::xmm7); |
|
138 |
|
139 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; |
|
140 }; |
|
141 |
|
142 } // namespace jit |
|
143 } // namespace js |
|
144 |
|
145 #endif /* jit_x86_Architecture_x86_h */ |