| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 20 matching lines...) Expand all Loading... |
| 31 #include "macro-assembler.h" | 31 #include "macro-assembler.h" |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 #include "ic-inl.h" | 33 #include "ic-inl.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 | 38 |
| 39 // Compute a transcendental math function natively, or call the | 39 // Compute a transcendental math function natively, or call the |
| 40 // TranscendentalCache runtime function. | 40 // TranscendentalCache runtime function. |
| 41 class TranscendentalCacheStub: public CodeStub { | 41 class TranscendentalCacheStub: public PlatformCodeStub { |
| 42 public: | 42 public: |
| 43 enum ArgumentType { | 43 enum ArgumentType { |
| 44 TAGGED = 0, | 44 TAGGED = 0, |
| 45 UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits | 45 UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TranscendentalCacheStub(TranscendentalCache::Type type, | 48 TranscendentalCacheStub(TranscendentalCache::Type type, |
| 49 ArgumentType argument_type) | 49 ArgumentType argument_type) |
| 50 : type_(type), argument_type_(argument_type) {} | 50 : type_(type), argument_type_(argument_type) {} |
| 51 void Generate(MacroAssembler* masm); | 51 void Generate(MacroAssembler* masm); |
| 52 static void GenerateOperation(MacroAssembler* masm, | 52 static void GenerateOperation(MacroAssembler* masm, |
| 53 TranscendentalCache::Type type); | 53 TranscendentalCache::Type type); |
| 54 private: | 54 private: |
| 55 TranscendentalCache::Type type_; | 55 TranscendentalCache::Type type_; |
| 56 ArgumentType argument_type_; | 56 ArgumentType argument_type_; |
| 57 | 57 |
| 58 Major MajorKey() { return TranscendentalCache; } | 58 Major MajorKey() { return TranscendentalCache; } |
| 59 int MinorKey() { return type_ | argument_type_; } | 59 int MinorKey() { return type_ | argument_type_; } |
| 60 Runtime::FunctionId RuntimeFunction(); | 60 Runtime::FunctionId RuntimeFunction(); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 | 63 |
| 64 class StoreBufferOverflowStub: public CodeStub { | 64 class StoreBufferOverflowStub: public PlatformCodeStub { |
| 65 public: | 65 public: |
| 66 explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp) | 66 explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp) |
| 67 : save_doubles_(save_fp) { } | 67 : save_doubles_(save_fp) { } |
| 68 | 68 |
| 69 void Generate(MacroAssembler* masm); | 69 void Generate(MacroAssembler* masm); |
| 70 | 70 |
| 71 virtual bool IsPregenerated() { return true; } | 71 virtual bool IsPregenerated() { return true; } |
| 72 static void GenerateFixedRegStubsAheadOfTime(); | 72 static void GenerateFixedRegStubsAheadOfTime(); |
| 73 virtual bool SometimesSetsUpAFrame() { return false; } | 73 virtual bool SometimesSetsUpAFrame() { return false; } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 SaveFPRegsMode save_doubles_; | 76 SaveFPRegsMode save_doubles_; |
| 77 | 77 |
| 78 Major MajorKey() { return StoreBufferOverflow; } | 78 Major MajorKey() { return StoreBufferOverflow; } |
| 79 int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; } | 79 int MinorKey() { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; } |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 | 82 |
| 83 class UnaryOpStub: public CodeStub { | 83 class UnaryOpStub: public PlatformCodeStub { |
| 84 public: | 84 public: |
| 85 UnaryOpStub(Token::Value op, | 85 UnaryOpStub(Token::Value op, |
| 86 UnaryOverwriteMode mode, | 86 UnaryOverwriteMode mode, |
| 87 UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) | 87 UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) |
| 88 : op_(op), | 88 : op_(op), |
| 89 mode_(mode), | 89 mode_(mode), |
| 90 operand_type_(operand_type) { | 90 operand_type_(operand_type) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 virtual InlineCacheState GetICState() { | 147 virtual InlineCacheState GetICState() { |
| 148 return UnaryOpIC::ToState(operand_type_); | 148 return UnaryOpIC::ToState(operand_type_); |
| 149 } | 149 } |
| 150 | 150 |
| 151 virtual void FinishCode(Handle<Code> code) { | 151 virtual void FinishCode(Handle<Code> code) { |
| 152 code->set_unary_op_type(operand_type_); | 152 code->set_unary_op_type(operand_type_); |
| 153 } | 153 } |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 | 156 |
| 157 class BinaryOpStub: public CodeStub { | 157 class BinaryOpStub: public PlatformCodeStub { |
| 158 public: | 158 public: |
| 159 BinaryOpStub(Token::Value op, OverwriteMode mode) | 159 BinaryOpStub(Token::Value op, OverwriteMode mode) |
| 160 : op_(op), | 160 : op_(op), |
| 161 mode_(mode), | 161 mode_(mode), |
| 162 operands_type_(BinaryOpIC::UNINITIALIZED), | 162 operands_type_(BinaryOpIC::UNINITIALIZED), |
| 163 result_type_(BinaryOpIC::UNINITIALIZED) { | 163 result_type_(BinaryOpIC::UNINITIALIZED) { |
| 164 use_sse3_ = CpuFeatures::IsSupported(SSE3); | 164 use_sse3_ = CpuFeatures::IsSupported(SSE3); |
| 165 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 165 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 166 } | 166 } |
| 167 | 167 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Omit left string check in stub (left is definitely a string). | 308 // Omit left string check in stub (left is definitely a string). |
| 309 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, | 309 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, |
| 310 // Omit right string check in stub (right is definitely a string). | 310 // Omit right string check in stub (right is definitely a string). |
| 311 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, | 311 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, |
| 312 // Omit both string checks in stub. | 312 // Omit both string checks in stub. |
| 313 NO_STRING_CHECK_IN_STUB = | 313 NO_STRING_CHECK_IN_STUB = |
| 314 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB | 314 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 | 317 |
| 318 class StringAddStub: public CodeStub { | 318 class StringAddStub: public PlatformCodeStub { |
| 319 public: | 319 public: |
| 320 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} | 320 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} |
| 321 | 321 |
| 322 private: | 322 private: |
| 323 Major MajorKey() { return StringAdd; } | 323 Major MajorKey() { return StringAdd; } |
| 324 int MinorKey() { return flags_; } | 324 int MinorKey() { return flags_; } |
| 325 | 325 |
| 326 void Generate(MacroAssembler* masm); | 326 void Generate(MacroAssembler* masm); |
| 327 | 327 |
| 328 void GenerateConvertArgument(MacroAssembler* masm, | 328 void GenerateConvertArgument(MacroAssembler* masm, |
| 329 int stack_offset, | 329 int stack_offset, |
| 330 Register arg, | 330 Register arg, |
| 331 Register scratch1, | 331 Register scratch1, |
| 332 Register scratch2, | 332 Register scratch2, |
| 333 Register scratch3, | 333 Register scratch3, |
| 334 Label* slow); | 334 Label* slow); |
| 335 | 335 |
| 336 const StringAddFlags flags_; | 336 const StringAddFlags flags_; |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 | 339 |
| 340 class SubStringStub: public CodeStub { | 340 class SubStringStub: public PlatformCodeStub { |
| 341 public: | 341 public: |
| 342 SubStringStub() {} | 342 SubStringStub() {} |
| 343 | 343 |
| 344 private: | 344 private: |
| 345 Major MajorKey() { return SubString; } | 345 Major MajorKey() { return SubString; } |
| 346 int MinorKey() { return 0; } | 346 int MinorKey() { return 0; } |
| 347 | 347 |
| 348 void Generate(MacroAssembler* masm); | 348 void Generate(MacroAssembler* masm); |
| 349 }; | 349 }; |
| 350 | 350 |
| 351 | 351 |
| 352 class StringCompareStub: public CodeStub { | 352 class StringCompareStub: public PlatformCodeStub { |
| 353 public: | 353 public: |
| 354 StringCompareStub() { } | 354 StringCompareStub() { } |
| 355 | 355 |
| 356 // Compares two flat ASCII strings and returns result in eax. | 356 // Compares two flat ASCII strings and returns result in eax. |
| 357 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 357 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
| 358 Register left, | 358 Register left, |
| 359 Register right, | 359 Register right, |
| 360 Register scratch1, | 360 Register scratch1, |
| 361 Register scratch2, | 361 Register scratch2, |
| 362 Register scratch3); | 362 Register scratch3); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 378 MacroAssembler* masm, | 378 MacroAssembler* masm, |
| 379 Register left, | 379 Register left, |
| 380 Register right, | 380 Register right, |
| 381 Register length, | 381 Register length, |
| 382 Register scratch, | 382 Register scratch, |
| 383 Label* chars_not_equal, | 383 Label* chars_not_equal, |
| 384 Label::Distance chars_not_equal_near = Label::kFar); | 384 Label::Distance chars_not_equal_near = Label::kFar); |
| 385 }; | 385 }; |
| 386 | 386 |
| 387 | 387 |
| 388 class NumberToStringStub: public CodeStub { | 388 class NumberToStringStub: public PlatformCodeStub { |
| 389 public: | 389 public: |
| 390 NumberToStringStub() { } | 390 NumberToStringStub() { } |
| 391 | 391 |
| 392 // Generate code to do a lookup in the number string cache. If the number in | 392 // Generate code to do a lookup in the number string cache. If the number in |
| 393 // the register object is found in the cache the generated code falls through | 393 // the register object is found in the cache the generated code falls through |
| 394 // with the result in the result register. The object and the result register | 394 // with the result in the result register. The object and the result register |
| 395 // can be the same. If the number is not found in the cache the code jumps to | 395 // can be the same. If the number is not found in the cache the code jumps to |
| 396 // the label not_found with only the content of register object unchanged. | 396 // the label not_found with only the content of register object unchanged. |
| 397 static void GenerateLookupNumberStringCache(MacroAssembler* masm, | 397 static void GenerateLookupNumberStringCache(MacroAssembler* masm, |
| 398 Register object, | 398 Register object, |
| 399 Register result, | 399 Register result, |
| 400 Register scratch1, | 400 Register scratch1, |
| 401 Register scratch2, | 401 Register scratch2, |
| 402 bool object_is_smi, | 402 bool object_is_smi, |
| 403 Label* not_found); | 403 Label* not_found); |
| 404 | 404 |
| 405 private: | 405 private: |
| 406 Major MajorKey() { return NumberToString; } | 406 Major MajorKey() { return NumberToString; } |
| 407 int MinorKey() { return 0; } | 407 int MinorKey() { return 0; } |
| 408 | 408 |
| 409 void Generate(MacroAssembler* masm); | 409 void Generate(MacroAssembler* masm); |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 | 412 |
| 413 class StringDictionaryLookupStub: public CodeStub { | 413 class StringDictionaryLookupStub: public PlatformCodeStub { |
| 414 public: | 414 public: |
| 415 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; | 415 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; |
| 416 | 416 |
| 417 StringDictionaryLookupStub(Register dictionary, | 417 StringDictionaryLookupStub(Register dictionary, |
| 418 Register result, | 418 Register result, |
| 419 Register index, | 419 Register index, |
| 420 LookupMode mode) | 420 LookupMode mode) |
| 421 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { } | 421 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { } |
| 422 | 422 |
| 423 void Generate(MacroAssembler* masm); | 423 void Generate(MacroAssembler* masm); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 class IndexBits: public BitField<int, 6, 3> {}; | 465 class IndexBits: public BitField<int, 6, 3> {}; |
| 466 class LookupModeBits: public BitField<LookupMode, 9, 1> {}; | 466 class LookupModeBits: public BitField<LookupMode, 9, 1> {}; |
| 467 | 467 |
| 468 Register dictionary_; | 468 Register dictionary_; |
| 469 Register result_; | 469 Register result_; |
| 470 Register index_; | 470 Register index_; |
| 471 LookupMode mode_; | 471 LookupMode mode_; |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 | 474 |
| 475 class RecordWriteStub: public CodeStub { | 475 class RecordWriteStub: public PlatformCodeStub { |
| 476 public: | 476 public: |
| 477 RecordWriteStub(Register object, | 477 RecordWriteStub(Register object, |
| 478 Register value, | 478 Register value, |
| 479 Register address, | 479 Register address, |
| 480 RememberedSetAction remembered_set_action, | 480 RememberedSetAction remembered_set_action, |
| 481 SaveFPRegsMode fp_mode) | 481 SaveFPRegsMode fp_mode) |
| 482 : object_(object), | 482 : object_(object), |
| 483 value_(value), | 483 value_(value), |
| 484 address_(address), | 484 address_(address), |
| 485 remembered_set_action_(remembered_set_action), | 485 remembered_set_action_(remembered_set_action), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 Register scratch0_orig_; | 668 Register scratch0_orig_; |
| 669 Register object_; | 669 Register object_; |
| 670 Register address_; | 670 Register address_; |
| 671 Register scratch0_; | 671 Register scratch0_; |
| 672 Register scratch1_; | 672 Register scratch1_; |
| 673 // Third scratch register is always ecx. | 673 // Third scratch register is always ecx. |
| 674 | 674 |
| 675 Register GetRegThatIsNotEcxOr(Register r1, | 675 Register GetRegThatIsNotEcxOr(Register r1, |
| 676 Register r2, | 676 Register r2, |
| 677 Register r3) { | 677 Register r3) { |
| 678 for (int i = 0; i < Register::kNumAllocatableRegisters; i++) { | 678 for (int i = 0; i < Register::NumAllocatableRegisters(); i++) { |
| 679 Register candidate = Register::FromAllocationIndex(i); | 679 Register candidate = Register::FromAllocationIndex(i); |
| 680 if (candidate.is(ecx)) continue; | 680 if (candidate.is(ecx)) continue; |
| 681 if (candidate.is(r1)) continue; | 681 if (candidate.is(r1)) continue; |
| 682 if (candidate.is(r2)) continue; | 682 if (candidate.is(r2)) continue; |
| 683 if (candidate.is(r3)) continue; | 683 if (candidate.is(r3)) continue; |
| 684 return candidate; | 684 return candidate; |
| 685 } | 685 } |
| 686 UNREACHABLE(); | 686 UNREACHABLE(); |
| 687 return no_reg; | 687 return no_reg; |
| 688 } | 688 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 Register address_; | 727 Register address_; |
| 728 RememberedSetAction remembered_set_action_; | 728 RememberedSetAction remembered_set_action_; |
| 729 SaveFPRegsMode save_fp_regs_mode_; | 729 SaveFPRegsMode save_fp_regs_mode_; |
| 730 RegisterAllocation regs_; | 730 RegisterAllocation regs_; |
| 731 }; | 731 }; |
| 732 | 732 |
| 733 | 733 |
| 734 } } // namespace v8::internal | 734 } } // namespace v8::internal |
| 735 | 735 |
| 736 #endif // V8_IA32_CODE_STUBS_IA32_H_ | 736 #endif // V8_IA32_CODE_STUBS_IA32_H_ |
| OLD | NEW |