OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
2 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 6 // found in the LICENSE file. |
4 | 7 |
5 #ifndef V8_ARM_CODE_STUBS_ARM_H_ | 8 #ifndef V8_PPC_CODE_STUBS_PPC_H_ |
6 #define V8_ARM_CODE_STUBS_ARM_H_ | 9 #define V8_PPC_CODE_STUBS_PPC_H_ |
7 | 10 |
8 #include "src/ic-inl.h" | 11 #include "src/ic-inl.h" |
9 | 12 |
10 namespace v8 { | 13 namespace v8 { |
11 namespace internal { | 14 namespace internal { |
12 | 15 |
13 | 16 |
14 void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); | 17 void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); |
15 | 18 |
16 | 19 |
(...skipping 25 matching lines...) Expand all Loading... |
42 Register dest, | 45 Register dest, |
43 Register src, | 46 Register src, |
44 Register count, | 47 Register count, |
45 Register scratch, | 48 Register scratch, |
46 String::Encoding encoding); | 49 String::Encoding encoding); |
47 | 50 |
48 | 51 |
49 // Generate string hash. | 52 // Generate string hash. |
50 static void GenerateHashInit(MacroAssembler* masm, | 53 static void GenerateHashInit(MacroAssembler* masm, |
51 Register hash, | 54 Register hash, |
52 Register character); | 55 Register character, |
| 56 Register scratch); |
53 | 57 |
54 static void GenerateHashAddCharacter(MacroAssembler* masm, | 58 static void GenerateHashAddCharacter(MacroAssembler* masm, |
55 Register hash, | 59 Register hash, |
56 Register character); | 60 Register character, |
| 61 Register scratch); |
57 | 62 |
58 static void GenerateHashGetHash(MacroAssembler* masm, | 63 static void GenerateHashGetHash(MacroAssembler* masm, |
59 Register hash); | 64 Register hash, |
| 65 Register scratch); |
60 | 66 |
61 private: | 67 private: |
62 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); | 68 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); |
63 }; | 69 }; |
64 | 70 |
65 | 71 |
66 class SubStringStub: public PlatformCodeStub { | 72 class SubStringStub: public PlatformCodeStub { |
67 public: | 73 public: |
68 explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} | 74 explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} |
69 | 75 |
70 private: | 76 private: |
71 Major MajorKey() const { return SubString; } | 77 Major MajorKey() const { return SubString; } |
72 int MinorKey() const { return 0; } | 78 int MinorKey() const { return 0; } |
73 | 79 |
74 void Generate(MacroAssembler* masm); | 80 void Generate(MacroAssembler* masm); |
75 }; | 81 }; |
76 | 82 |
77 | 83 |
78 | 84 |
79 class StringCompareStub: public PlatformCodeStub { | 85 class StringCompareStub: public PlatformCodeStub { |
80 public: | 86 public: |
81 explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { } | 87 explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { } |
82 | 88 |
83 // Compares two flat ASCII strings and returns result in r0. | 89 // Compares two flat ASCII strings and returns result in r0. |
84 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 90 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
85 Register left, | 91 Register left, |
86 Register right, | 92 Register right, |
87 Register scratch1, | 93 Register scratch1, |
88 Register scratch2, | 94 Register scratch2, |
89 Register scratch3, | 95 Register scratch3); |
90 Register scratch4); | |
91 | 96 |
92 // Compares two flat ASCII strings for equality and returns result | 97 // Compares two flat ASCII strings for equality and returns result |
93 // in r0. | 98 // in r0. |
94 static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, | 99 static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, |
95 Register left, | 100 Register left, |
96 Register right, | 101 Register right, |
97 Register scratch1, | 102 Register scratch1, |
98 Register scratch2, | 103 Register scratch2); |
99 Register scratch3); | |
100 | 104 |
101 private: | 105 private: |
102 virtual Major MajorKey() const { return StringCompare; } | 106 virtual Major MajorKey() const { return StringCompare; } |
103 virtual int MinorKey() const { return 0; } | 107 virtual int MinorKey() const { return 0; } |
104 virtual void Generate(MacroAssembler* masm); | 108 virtual void Generate(MacroAssembler* masm); |
105 | 109 |
106 static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, | 110 static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, |
107 Register left, | 111 Register left, |
108 Register right, | 112 Register right, |
109 Register length, | 113 Register length, |
110 Register scratch1, | 114 Register scratch1, |
111 Register scratch2, | |
112 Label* chars_not_equal); | 115 Label* chars_not_equal); |
113 }; | 116 }; |
114 | 117 |
115 | 118 |
116 // This stub can convert a signed int32 to a heap number (double). It does | |
117 // not work for int32s that are in Smi range! No GC occurs during this stub | |
118 // so you don't have to set up the frame. | |
119 class WriteInt32ToHeapNumberStub : public PlatformCodeStub { | |
120 public: | |
121 WriteInt32ToHeapNumberStub(Isolate* isolate, | |
122 Register the_int, | |
123 Register the_heap_number, | |
124 Register scratch) | |
125 : PlatformCodeStub(isolate), | |
126 the_int_(the_int), | |
127 the_heap_number_(the_heap_number), | |
128 scratch_(scratch) { } | |
129 | |
130 static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); | |
131 | |
132 private: | |
133 Register the_int_; | |
134 Register the_heap_number_; | |
135 Register scratch_; | |
136 | |
137 // Minor key encoding in 16 bits. | |
138 class IntRegisterBits: public BitField<int, 0, 4> {}; | |
139 class HeapNumberRegisterBits: public BitField<int, 4, 4> {}; | |
140 class ScratchRegisterBits: public BitField<int, 8, 4> {}; | |
141 | |
142 Major MajorKey() const { return WriteInt32ToHeapNumber; } | |
143 int MinorKey() const { | |
144 // Encode the parameters in a unique 16 bit value. | |
145 return IntRegisterBits::encode(the_int_.code()) | |
146 | HeapNumberRegisterBits::encode(the_heap_number_.code()) | |
147 | ScratchRegisterBits::encode(scratch_.code()); | |
148 } | |
149 | |
150 void Generate(MacroAssembler* masm); | |
151 }; | |
152 | |
153 | |
154 class RecordWriteStub: public PlatformCodeStub { | 119 class RecordWriteStub: public PlatformCodeStub { |
155 public: | 120 public: |
156 RecordWriteStub(Isolate* isolate, | 121 RecordWriteStub(Isolate* isolate, |
157 Register object, | 122 Register object, |
158 Register value, | 123 Register value, |
159 Register address, | 124 Register address, |
160 RememberedSetAction remembered_set_action, | 125 RememberedSetAction remembered_set_action, |
161 SaveFPRegsMode fp_mode) | 126 SaveFPRegsMode fp_mode) |
162 : PlatformCodeStub(isolate), | 127 : PlatformCodeStub(isolate), |
163 object_(object), | 128 object_(object), |
164 value_(value), | 129 value_(value), |
165 address_(address), | 130 address_(address), |
166 remembered_set_action_(remembered_set_action), | 131 remembered_set_action_(remembered_set_action), |
167 save_fp_regs_mode_(fp_mode), | 132 save_fp_regs_mode_(fp_mode), |
168 regs_(object, // An input reg. | 133 regs_(object, // An input reg. |
169 address, // An input reg. | 134 address, // An input reg. |
170 value) { // One scratch reg. | 135 value) { // One scratch reg. |
171 } | 136 } |
172 | 137 |
173 enum Mode { | 138 enum Mode { |
174 STORE_BUFFER_ONLY, | 139 STORE_BUFFER_ONLY, |
175 INCREMENTAL, | 140 INCREMENTAL, |
176 INCREMENTAL_COMPACTION | 141 INCREMENTAL_COMPACTION |
177 }; | 142 }; |
178 | 143 |
179 virtual bool SometimesSetsUpAFrame() { return false; } | 144 virtual bool SometimesSetsUpAFrame() { return false; } |
180 | 145 |
181 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { | 146 static void PatchBranchIntoNop(MacroAssembler* masm, int pos) { |
182 masm->instr_at_put(pos, (masm->instr_at(pos) & ~B27) | (B24 | B20)); | 147 masm->instr_at_put(pos, (masm->instr_at(pos) & ~kBOfieldMask) | BT); |
183 ASSERT(Assembler::IsTstImmediate(masm->instr_at(pos))); | 148 // roohack ASSERT(Assembler::IsTstImmediate(masm->instr_at(pos))); |
184 } | 149 } |
185 | 150 |
186 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { | 151 static void PatchNopIntoBranch(MacroAssembler* masm, int pos) { |
187 masm->instr_at_put(pos, (masm->instr_at(pos) & ~(B24 | B20)) | B27); | 152 masm->instr_at_put(pos, (masm->instr_at(pos) & ~kBOfieldMask) | BF); |
188 ASSERT(Assembler::IsBranch(masm->instr_at(pos))); | 153 // roohack ASSERT(Assembler::IsBranch(masm->instr_at(pos))); |
189 } | 154 } |
190 | 155 |
191 static Mode GetMode(Code* stub) { | 156 static Mode GetMode(Code* stub) { |
192 Instr first_instruction = Assembler::instr_at(stub->instruction_start()); | 157 Instr first_instruction = Assembler::instr_at(stub->instruction_start() + |
| 158 Assembler::kInstrSize); |
193 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + | 159 Instr second_instruction = Assembler::instr_at(stub->instruction_start() + |
194 Assembler::kInstrSize); | 160 (Assembler::kInstrSize*2)); |
195 | 161 |
196 if (Assembler::IsBranch(first_instruction)) { | 162 if (BF == (first_instruction & kBOfieldMask)) { |
197 return INCREMENTAL; | 163 return INCREMENTAL; |
198 } | 164 } |
199 | 165 |
200 ASSERT(Assembler::IsTstImmediate(first_instruction)); | 166 // roohack ASSERT(Assembler::IsTstImmediate(first_instruction)); |
201 | 167 |
202 if (Assembler::IsBranch(second_instruction)) { | 168 if (BF == (second_instruction & kBOfieldMask)) { |
203 return INCREMENTAL_COMPACTION; | 169 return INCREMENTAL_COMPACTION; |
204 } | 170 } |
205 | 171 |
206 ASSERT(Assembler::IsTstImmediate(second_instruction)); | 172 // roohack ASSERT(Assembler::IsTstImmediate(second_instruction)); |
207 | 173 |
208 return STORE_BUFFER_ONLY; | 174 return STORE_BUFFER_ONLY; |
209 } | 175 } |
210 | 176 |
211 static void Patch(Code* stub, Mode mode) { | 177 static void Patch(Code* stub, Mode mode) { |
212 MacroAssembler masm(NULL, | 178 MacroAssembler masm(NULL, |
213 stub->instruction_start(), | 179 stub->instruction_start(), |
214 stub->instruction_size()); | 180 stub->instruction_size()); |
215 switch (mode) { | 181 switch (mode) { |
216 case STORE_BUFFER_ONLY: | 182 case STORE_BUFFER_ONLY: |
217 ASSERT(GetMode(stub) == INCREMENTAL || | 183 ASSERT(GetMode(stub) == INCREMENTAL || |
218 GetMode(stub) == INCREMENTAL_COMPACTION); | 184 GetMode(stub) == INCREMENTAL_COMPACTION); |
219 PatchBranchIntoNop(&masm, 0); | 185 |
220 PatchBranchIntoNop(&masm, Assembler::kInstrSize); | 186 PatchBranchIntoNop(&masm, Assembler::kInstrSize); |
| 187 PatchBranchIntoNop(&masm, Assembler::kInstrSize*2); |
221 break; | 188 break; |
222 case INCREMENTAL: | 189 case INCREMENTAL: |
223 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 190 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); |
224 PatchNopIntoBranch(&masm, 0); | 191 PatchNopIntoBranch(&masm, Assembler::kInstrSize); |
225 break; | 192 break; |
226 case INCREMENTAL_COMPACTION: | 193 case INCREMENTAL_COMPACTION: |
227 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); | 194 ASSERT(GetMode(stub) == STORE_BUFFER_ONLY); |
228 PatchNopIntoBranch(&masm, Assembler::kInstrSize); | 195 PatchNopIntoBranch(&masm, Assembler::kInstrSize*2); |
229 break; | 196 break; |
230 } | 197 } |
231 ASSERT(GetMode(stub) == mode); | 198 ASSERT(GetMode(stub) == mode); |
232 CpuFeatures::FlushICache(stub->instruction_start(), | 199 CpuFeatures::FlushICache(stub->instruction_start()+Assembler::kInstrSize, |
233 2 * Assembler::kInstrSize); | 200 2 * Assembler::kInstrSize); |
234 } | 201 } |
235 | 202 |
236 private: | 203 private: |
237 // This is a helper class for freeing up 3 scratch registers. The input is | 204 // This is a helper class for freeing up 3 scratch registers. The input is |
238 // two registers that must be preserved and one scratch register provided by | 205 // two registers that must be preserved and one scratch register provided by |
239 // the caller. | 206 // the caller. |
240 class RegisterAllocation { | 207 class RegisterAllocation { |
241 public: | 208 public: |
242 RegisterAllocation(Register object, | 209 RegisterAllocation(Register object, |
243 Register address, | 210 Register address, |
(...skipping 13 matching lines...) Expand all Loading... |
257 } | 224 } |
258 | 225 |
259 void Restore(MacroAssembler* masm) { | 226 void Restore(MacroAssembler* masm) { |
260 masm->pop(scratch1_); | 227 masm->pop(scratch1_); |
261 } | 228 } |
262 | 229 |
263 // If we have to call into C then we need to save and restore all caller- | 230 // If we have to call into C then we need to save and restore all caller- |
264 // saved registers that were not already preserved. The scratch registers | 231 // saved registers that were not already preserved. The scratch registers |
265 // will be restored by other means so we don't bother pushing them here. | 232 // will be restored by other means so we don't bother pushing them here. |
266 void SaveCallerSaveRegisters(MacroAssembler* masm, SaveFPRegsMode mode) { | 233 void SaveCallerSaveRegisters(MacroAssembler* masm, SaveFPRegsMode mode) { |
267 masm->stm(db_w, sp, (kCallerSaved | lr.bit()) & ~scratch1_.bit()); | 234 masm->mflr(r0); |
| 235 masm->push(r0); |
| 236 masm->MultiPush(kJSCallerSaved & ~scratch1_.bit()); |
268 if (mode == kSaveFPRegs) { | 237 if (mode == kSaveFPRegs) { |
269 masm->SaveFPRegs(sp, scratch0_); | 238 // Save all volatile FP registers except d0. |
| 239 masm->SaveFPRegs(sp, 1, DoubleRegister::kNumVolatileRegisters - 1); |
270 } | 240 } |
271 } | 241 } |
272 | 242 |
273 inline void RestoreCallerSaveRegisters(MacroAssembler*masm, | 243 inline void RestoreCallerSaveRegisters(MacroAssembler*masm, |
274 SaveFPRegsMode mode) { | 244 SaveFPRegsMode mode) { |
275 if (mode == kSaveFPRegs) { | 245 if (mode == kSaveFPRegs) { |
276 masm->RestoreFPRegs(sp, scratch0_); | 246 // Restore all volatile FP registers except d0. |
| 247 masm->RestoreFPRegs(sp, 1, DoubleRegister::kNumVolatileRegisters - 1); |
277 } | 248 } |
278 masm->ldm(ia_w, sp, (kCallerSaved | lr.bit()) & ~scratch1_.bit()); | 249 masm->MultiPop(kJSCallerSaved & ~scratch1_.bit()); |
| 250 masm->pop(r0); |
| 251 masm->mtlr(r0); |
279 } | 252 } |
280 | 253 |
281 inline Register object() { return object_; } | 254 inline Register object() { return object_; } |
282 inline Register address() { return address_; } | 255 inline Register address() { return address_; } |
283 inline Register scratch0() { return scratch0_; } | 256 inline Register scratch0() { return scratch0_; } |
284 inline Register scratch1() { return scratch1_; } | 257 inline Register scratch1() { return scratch1_; } |
285 | 258 |
286 private: | 259 private: |
287 Register object_; | 260 Register object_; |
288 Register address_; | 261 Register address_; |
(...skipping 23 matching lines...) Expand all Loading... |
312 ValueBits::encode(value_.code()) | | 285 ValueBits::encode(value_.code()) | |
313 AddressBits::encode(address_.code()) | | 286 AddressBits::encode(address_.code()) | |
314 RememberedSetActionBits::encode(remembered_set_action_) | | 287 RememberedSetActionBits::encode(remembered_set_action_) | |
315 SaveFPRegsModeBits::encode(save_fp_regs_mode_); | 288 SaveFPRegsModeBits::encode(save_fp_regs_mode_); |
316 } | 289 } |
317 | 290 |
318 void Activate(Code* code) { | 291 void Activate(Code* code) { |
319 code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code); | 292 code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code); |
320 } | 293 } |
321 | 294 |
322 class ObjectBits: public BitField<int, 0, 4> {}; | 295 class ObjectBits: public BitField<int, 0, 5> {}; |
323 class ValueBits: public BitField<int, 4, 4> {}; | 296 class ValueBits: public BitField<int, 5, 5> {}; |
324 class AddressBits: public BitField<int, 8, 4> {}; | 297 class AddressBits: public BitField<int, 10, 5> {}; |
325 class RememberedSetActionBits: public BitField<RememberedSetAction, 12, 1> {}; | 298 class RememberedSetActionBits: public BitField<RememberedSetAction, 15, 1> {}; |
326 class SaveFPRegsModeBits: public BitField<SaveFPRegsMode, 13, 1> {}; | 299 class SaveFPRegsModeBits: public BitField<SaveFPRegsMode, 16, 1> {}; |
327 | 300 |
328 Register object_; | 301 Register object_; |
329 Register value_; | 302 Register value_; |
330 Register address_; | 303 Register address_; |
331 RememberedSetAction remembered_set_action_; | 304 RememberedSetAction remembered_set_action_; |
332 SaveFPRegsMode save_fp_regs_mode_; | 305 SaveFPRegsMode save_fp_regs_mode_; |
333 Label slow_; | 306 Label slow_; |
334 RegisterAllocation regs_; | 307 RegisterAllocation regs_; |
335 }; | 308 }; |
336 | 309 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 368 |
396 Major MajorKey() const { return NameDictionaryLookup; } | 369 Major MajorKey() const { return NameDictionaryLookup; } |
397 | 370 |
398 int MinorKey() const { return LookupModeBits::encode(mode_); } | 371 int MinorKey() const { return LookupModeBits::encode(mode_); } |
399 | 372 |
400 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; | 373 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; |
401 | 374 |
402 LookupMode mode_; | 375 LookupMode mode_; |
403 }; | 376 }; |
404 | 377 |
405 | |
406 class PlatformInterfaceDescriptor { | |
407 public: | |
408 explicit PlatformInterfaceDescriptor( | |
409 TargetAddressStorageMode storage_mode) | |
410 : storage_mode_(storage_mode) { } | |
411 | |
412 TargetAddressStorageMode storage_mode() { return storage_mode_; } | |
413 | |
414 private: | |
415 TargetAddressStorageMode storage_mode_; | |
416 }; | |
417 | |
418 | |
419 } } // namespace v8::internal | 378 } } // namespace v8::internal |
420 | 379 |
421 #endif // V8_ARM_CODE_STUBS_ARM_H_ | 380 #endif // V8_PPC_CODE_STUBS_PPC_H_ |
OLD | NEW |