OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 18 matching lines...) Expand all Loading... |
29 #define V8_ARM_CODE_STUBS_ARM_H_ | 29 #define V8_ARM_CODE_STUBS_ARM_H_ |
30 | 30 |
31 #include "ic-inl.h" | 31 #include "ic-inl.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 | 36 |
37 // Compute a transcendental math function natively, or call the | 37 // Compute a transcendental math function natively, or call the |
38 // TranscendentalCache runtime function. | 38 // TranscendentalCache runtime function. |
39 class TranscendentalCacheStub: public CodeStub { | 39 class TranscendentalCacheStub: public PlatformCodeStub { |
40 public: | 40 public: |
41 enum ArgumentType { | 41 enum ArgumentType { |
42 TAGGED = 0 << TranscendentalCache::kTranscendentalTypeBits, | 42 TAGGED = 0 << TranscendentalCache::kTranscendentalTypeBits, |
43 UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits | 43 UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits |
44 }; | 44 }; |
45 | 45 |
46 TranscendentalCacheStub(TranscendentalCache::Type type, | 46 TranscendentalCacheStub(TranscendentalCache::Type type, |
47 ArgumentType argument_type) | 47 ArgumentType argument_type) |
48 : type_(type), argument_type_(argument_type) { } | 48 : type_(type), argument_type_(argument_type) { } |
49 void Generate(MacroAssembler* masm); | 49 void Generate(MacroAssembler* masm); |
50 private: | 50 private: |
51 TranscendentalCache::Type type_; | 51 TranscendentalCache::Type type_; |
52 ArgumentType argument_type_; | 52 ArgumentType argument_type_; |
53 void GenerateCallCFunction(MacroAssembler* masm, Register scratch); | 53 void GenerateCallCFunction(MacroAssembler* masm, Register scratch); |
54 | 54 |
55 Major MajorKey() { return TranscendentalCache; } | 55 Major MajorKey() { return TranscendentalCache; } |
56 int MinorKey() { return type_ | argument_type_; } | 56 int MinorKey() { return type_ | argument_type_; } |
57 Runtime::FunctionId RuntimeFunction(); | 57 Runtime::FunctionId RuntimeFunction(); |
58 }; | 58 }; |
59 | 59 |
60 | 60 |
61 class StoreBufferOverflowStub: public CodeStub { | 61 class StoreBufferOverflowStub: public PlatformCodeStub { |
62 public: | 62 public: |
63 explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp) | 63 explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp) |
64 : save_doubles_(save_fp) { } | 64 : save_doubles_(save_fp) { } |
65 | 65 |
66 void Generate(MacroAssembler* masm); | 66 void Generate(MacroAssembler* masm); |
67 | 67 |
68 virtual bool IsPregenerated(); | 68 virtual bool IsPregenerated(); |
69 static void GenerateFixedRegStubsAheadOfTime(); | 69 static void GenerateFixedRegStubsAheadOfTime(); |
70 virtual bool SometimesSetsUpAFrame() { return false; } | 70 virtual bool SometimesSetsUpAFrame() { return false; } |
71 | 71 |
72 private: | 72 private: |
73 SaveFPRegsMode save_doubles_; | 73 SaveFPRegsMode save_doubles_; |
74 | 74 |
75 Major MajorKey() { return StoreBufferOverflow; } | 75 Major MajorKey() { return StoreBufferOverflow; } |
76 int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; } | 76 int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; } |
77 }; | 77 }; |
78 | 78 |
79 | 79 |
80 class UnaryOpStub: public CodeStub { | 80 class UnaryOpStub: public PlatformCodeStub { |
81 public: | 81 public: |
82 UnaryOpStub(Token::Value op, | 82 UnaryOpStub(Token::Value op, |
83 UnaryOverwriteMode mode, | 83 UnaryOverwriteMode mode, |
84 UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) | 84 UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) |
85 : op_(op), | 85 : op_(op), |
86 mode_(mode), | 86 mode_(mode), |
87 operand_type_(operand_type) { | 87 operand_type_(operand_type) { |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // Omit left string check in stub (left is definitely a string). | 212 // Omit left string check in stub (left is definitely a string). |
213 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, | 213 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, |
214 // Omit right string check in stub (right is definitely a string). | 214 // Omit right string check in stub (right is definitely a string). |
215 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, | 215 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, |
216 // Omit both string checks in stub. | 216 // Omit both string checks in stub. |
217 NO_STRING_CHECK_IN_STUB = | 217 NO_STRING_CHECK_IN_STUB = |
218 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB | 218 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB |
219 }; | 219 }; |
220 | 220 |
221 | 221 |
222 class StringAddStub: public CodeStub { | 222 class StringAddStub: public PlatformCodeStub { |
223 public: | 223 public: |
224 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} | 224 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} |
225 | 225 |
226 private: | 226 private: |
227 Major MajorKey() { return StringAdd; } | 227 Major MajorKey() { return StringAdd; } |
228 int MinorKey() { return flags_; } | 228 int MinorKey() { return flags_; } |
229 | 229 |
230 void Generate(MacroAssembler* masm); | 230 void Generate(MacroAssembler* masm); |
231 | 231 |
232 void GenerateConvertArgument(MacroAssembler* masm, | 232 void GenerateConvertArgument(MacroAssembler* masm, |
233 int stack_offset, | 233 int stack_offset, |
234 Register arg, | 234 Register arg, |
235 Register scratch1, | 235 Register scratch1, |
236 Register scratch2, | 236 Register scratch2, |
237 Register scratch3, | 237 Register scratch3, |
238 Register scratch4, | 238 Register scratch4, |
239 Label* slow); | 239 Label* slow); |
240 | 240 |
241 const StringAddFlags flags_; | 241 const StringAddFlags flags_; |
242 }; | 242 }; |
243 | 243 |
244 | 244 |
245 class SubStringStub: public CodeStub { | 245 class SubStringStub: public PlatformCodeStub { |
246 public: | 246 public: |
247 SubStringStub() {} | 247 SubStringStub() {} |
248 | 248 |
249 private: | 249 private: |
250 Major MajorKey() { return SubString; } | 250 Major MajorKey() { return SubString; } |
251 int MinorKey() { return 0; } | 251 int MinorKey() { return 0; } |
252 | 252 |
253 void Generate(MacroAssembler* masm); | 253 void Generate(MacroAssembler* masm); |
254 }; | 254 }; |
255 | 255 |
256 | 256 |
257 | 257 |
258 class StringCompareStub: public CodeStub { | 258 class StringCompareStub: public PlatformCodeStub { |
259 public: | 259 public: |
260 StringCompareStub() { } | 260 StringCompareStub() { } |
261 | 261 |
262 // Compares two flat ASCII strings and returns result in r0. | 262 // Compares two flat ASCII strings and returns result in r0. |
263 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 263 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
264 Register left, | 264 Register left, |
265 Register right, | 265 Register right, |
266 Register scratch1, | 266 Register scratch1, |
267 Register scratch2, | 267 Register scratch2, |
268 Register scratch3, | 268 Register scratch3, |
(...skipping 19 matching lines...) Expand all Loading... |
288 Register length, | 288 Register length, |
289 Register scratch1, | 289 Register scratch1, |
290 Register scratch2, | 290 Register scratch2, |
291 Label* chars_not_equal); | 291 Label* chars_not_equal); |
292 }; | 292 }; |
293 | 293 |
294 | 294 |
295 // This stub can convert a signed int32 to a heap number (double). It does | 295 // This stub can convert a signed int32 to a heap number (double). It does |
296 // not work for int32s that are in Smi range! No GC occurs during this stub | 296 // not work for int32s that are in Smi range! No GC occurs during this stub |
297 // so you don't have to set up the frame. | 297 // so you don't have to set up the frame. |
298 class WriteInt32ToHeapNumberStub : public CodeStub { | 298 class WriteInt32ToHeapNumberStub : public PlatformCodeStub { |
299 public: | 299 public: |
300 WriteInt32ToHeapNumberStub(Register the_int, | 300 WriteInt32ToHeapNumberStub(Register the_int, |
301 Register the_heap_number, | 301 Register the_heap_number, |
302 Register scratch) | 302 Register scratch) |
303 : the_int_(the_int), | 303 : the_int_(the_int), |
304 the_heap_number_(the_heap_number), | 304 the_heap_number_(the_heap_number), |
305 scratch_(scratch) { } | 305 scratch_(scratch) { } |
306 | 306 |
307 bool IsPregenerated(); | 307 bool IsPregenerated(); |
308 static void GenerateFixedRegStubsAheadOfTime(); | 308 static void GenerateFixedRegStubsAheadOfTime(); |
(...skipping 13 matching lines...) Expand all Loading... |
322 // Encode the parameters in a unique 16 bit value. | 322 // Encode the parameters in a unique 16 bit value. |
323 return IntRegisterBits::encode(the_int_.code()) | 323 return IntRegisterBits::encode(the_int_.code()) |
324 | HeapNumberRegisterBits::encode(the_heap_number_.code()) | 324 | HeapNumberRegisterBits::encode(the_heap_number_.code()) |
325 | ScratchRegisterBits::encode(scratch_.code()); | 325 | ScratchRegisterBits::encode(scratch_.code()); |
326 } | 326 } |
327 | 327 |
328 void Generate(MacroAssembler* masm); | 328 void Generate(MacroAssembler* masm); |
329 }; | 329 }; |
330 | 330 |
331 | 331 |
332 class NumberToStringStub: public CodeStub { | 332 class NumberToStringStub: public PlatformCodeStub { |
333 public: | 333 public: |
334 NumberToStringStub() { } | 334 NumberToStringStub() { } |
335 | 335 |
336 // Generate code to do a lookup in the number string cache. If the number in | 336 // Generate code to do a lookup in the number string cache. If the number in |
337 // the register object is found in the cache the generated code falls through | 337 // the register object is found in the cache the generated code falls through |
338 // with the result in the result register. The object and the result register | 338 // with the result in the result register. The object and the result register |
339 // can be the same. If the number is not found in the cache the code jumps to | 339 // can be the same. If the number is not found in the cache the code jumps to |
340 // the label not_found with only the content of register object unchanged. | 340 // the label not_found with only the content of register object unchanged. |
341 static void GenerateLookupNumberStringCache(MacroAssembler* masm, | 341 static void GenerateLookupNumberStringCache(MacroAssembler* masm, |
342 Register object, | 342 Register object, |
343 Register result, | 343 Register result, |
344 Register scratch1, | 344 Register scratch1, |
345 Register scratch2, | 345 Register scratch2, |
346 Register scratch3, | 346 Register scratch3, |
347 bool object_is_smi, | 347 bool object_is_smi, |
348 Label* not_found); | 348 Label* not_found); |
349 | 349 |
350 private: | 350 private: |
351 Major MajorKey() { return NumberToString; } | 351 Major MajorKey() { return NumberToString; } |
352 int MinorKey() { return 0; } | 352 int MinorKey() { return 0; } |
353 | 353 |
354 void Generate(MacroAssembler* masm); | 354 void Generate(MacroAssembler* masm); |
355 }; | 355 }; |
356 | 356 |
357 | 357 |
358 class RecordWriteStub: public CodeStub { | 358 class RecordWriteStub: public PlatformCodeStub { |
359 public: | 359 public: |
360 RecordWriteStub(Register object, | 360 RecordWriteStub(Register object, |
361 Register value, | 361 Register value, |
362 Register address, | 362 Register address, |
363 RememberedSetAction remembered_set_action, | 363 RememberedSetAction remembered_set_action, |
364 SaveFPRegsMode fp_mode) | 364 SaveFPRegsMode fp_mode) |
365 : object_(object), | 365 : object_(object), |
366 value_(value), | 366 value_(value), |
367 address_(address), | 367 address_(address), |
368 remembered_set_action_(remembered_set_action), | 368 remembered_set_action_(remembered_set_action), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 private: | 505 private: |
506 Register object_; | 506 Register object_; |
507 Register address_; | 507 Register address_; |
508 Register scratch0_; | 508 Register scratch0_; |
509 Register scratch1_; | 509 Register scratch1_; |
510 | 510 |
511 Register GetRegThatIsNotOneOf(Register r1, | 511 Register GetRegThatIsNotOneOf(Register r1, |
512 Register r2, | 512 Register r2, |
513 Register r3) { | 513 Register r3) { |
514 for (int i = 0; i < Register::kNumAllocatableRegisters; i++) { | 514 for (int i = 0; i < Register::NumAllocatableRegisters(); i++) { |
515 Register candidate = Register::FromAllocationIndex(i); | 515 Register candidate = Register::FromAllocationIndex(i); |
516 if (candidate.is(r1)) continue; | 516 if (candidate.is(r1)) continue; |
517 if (candidate.is(r2)) continue; | 517 if (candidate.is(r2)) continue; |
518 if (candidate.is(r3)) continue; | 518 if (candidate.is(r3)) continue; |
519 return candidate; | 519 return candidate; |
520 } | 520 } |
521 UNREACHABLE(); | 521 UNREACHABLE(); |
522 return no_reg; | 522 return no_reg; |
523 } | 523 } |
524 friend class RecordWriteStub; | 524 friend class RecordWriteStub; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 RememberedSetAction remembered_set_action_; | 563 RememberedSetAction remembered_set_action_; |
564 SaveFPRegsMode save_fp_regs_mode_; | 564 SaveFPRegsMode save_fp_regs_mode_; |
565 Label slow_; | 565 Label slow_; |
566 RegisterAllocation regs_; | 566 RegisterAllocation regs_; |
567 }; | 567 }; |
568 | 568 |
569 | 569 |
570 // Enter C code from generated RegExp code in a way that allows | 570 // Enter C code from generated RegExp code in a way that allows |
571 // the C code to fix the return address in case of a GC. | 571 // the C code to fix the return address in case of a GC. |
572 // Currently only needed on ARM. | 572 // Currently only needed on ARM. |
573 class RegExpCEntryStub: public CodeStub { | 573 class RegExpCEntryStub: public PlatformCodeStub { |
574 public: | 574 public: |
575 RegExpCEntryStub() {} | 575 RegExpCEntryStub() {} |
576 virtual ~RegExpCEntryStub() {} | 576 virtual ~RegExpCEntryStub() {} |
577 void Generate(MacroAssembler* masm); | 577 void Generate(MacroAssembler* masm); |
578 | 578 |
579 private: | 579 private: |
580 Major MajorKey() { return RegExpCEntry; } | 580 Major MajorKey() { return RegExpCEntry; } |
581 int MinorKey() { return 0; } | 581 int MinorKey() { return 0; } |
582 | 582 |
583 bool NeedsImmovableCode() { return true; } | 583 bool NeedsImmovableCode() { return true; } |
584 }; | 584 }; |
585 | 585 |
586 | 586 |
587 // Trampoline stub to call into native code. To call safely into native code | 587 // Trampoline stub to call into native code. To call safely into native code |
588 // in the presence of compacting GC (which can move code objects) we need to | 588 // in the presence of compacting GC (which can move code objects) we need to |
589 // keep the code which called into native pinned in the memory. Currently the | 589 // keep the code which called into native pinned in the memory. Currently the |
590 // simplest approach is to generate such stub early enough so it can never be | 590 // simplest approach is to generate such stub early enough so it can never be |
591 // moved by GC | 591 // moved by GC |
592 class DirectCEntryStub: public CodeStub { | 592 class DirectCEntryStub: public PlatformCodeStub { |
593 public: | 593 public: |
594 DirectCEntryStub() {} | 594 DirectCEntryStub() {} |
595 void Generate(MacroAssembler* masm); | 595 void Generate(MacroAssembler* masm); |
596 void GenerateCall(MacroAssembler* masm, ExternalReference function); | 596 void GenerateCall(MacroAssembler* masm, ExternalReference function); |
597 void GenerateCall(MacroAssembler* masm, Register target); | 597 void GenerateCall(MacroAssembler* masm, Register target); |
598 | 598 |
599 private: | 599 private: |
600 Major MajorKey() { return DirectCEntry; } | 600 Major MajorKey() { return DirectCEntry; } |
601 int MinorKey() { return 0; } | 601 int MinorKey() { return 0; } |
602 | 602 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 DwVfpRegister dst, | 732 DwVfpRegister dst, |
733 Register dst1, | 733 Register dst1, |
734 Register dst2, | 734 Register dst2, |
735 Register heap_number_map, | 735 Register heap_number_map, |
736 Register scratch1, | 736 Register scratch1, |
737 Register scratch2, | 737 Register scratch2, |
738 Label* not_number); | 738 Label* not_number); |
739 }; | 739 }; |
740 | 740 |
741 | 741 |
742 class StringDictionaryLookupStub: public CodeStub { | 742 class StringDictionaryLookupStub: public PlatformCodeStub { |
743 public: | 743 public: |
744 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; | 744 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; |
745 | 745 |
746 explicit StringDictionaryLookupStub(LookupMode mode) : mode_(mode) { } | 746 explicit StringDictionaryLookupStub(LookupMode mode) : mode_(mode) { } |
747 | 747 |
748 void Generate(MacroAssembler* masm); | 748 void Generate(MacroAssembler* masm); |
749 | 749 |
750 static void GenerateNegativeLookup(MacroAssembler* masm, | 750 static void GenerateNegativeLookup(MacroAssembler* masm, |
751 Label* miss, | 751 Label* miss, |
752 Label* done, | 752 Label* done, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; | 786 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; |
787 | 787 |
788 LookupMode mode_; | 788 LookupMode mode_; |
789 }; | 789 }; |
790 | 790 |
791 | 791 |
792 } } // namespace v8::internal | 792 } } // namespace v8::internal |
793 | 793 |
794 #endif // V8_ARM_CODE_STUBS_ARM_H_ | 794 #endif // V8_ARM_CODE_STUBS_ARM_H_ |
OLD | NEW |