| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Omit left string check in stub (left is definitely a string). | 218 // Omit left string check in stub (left is definitely a string). |
| 219 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, | 219 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, |
| 220 // Omit right string check in stub (right is definitely a string). | 220 // Omit right string check in stub (right is definitely a string). |
| 221 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, | 221 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, |
| 222 // Omit both string checks in stub. | 222 // Omit both string checks in stub. |
| 223 NO_STRING_CHECK_IN_STUB = | 223 NO_STRING_CHECK_IN_STUB = |
| 224 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB | 224 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 | 227 |
| 228 class StringAddStub: public CodeStub { | 228 class StringAddStub: public PlatformCodeStub { |
| 229 public: | 229 public: |
| 230 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} | 230 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} |
| 231 | 231 |
| 232 private: | 232 private: |
| 233 Major MajorKey() { return StringAdd; } | 233 Major MajorKey() { return StringAdd; } |
| 234 int MinorKey() { return flags_; } | 234 int MinorKey() { return flags_; } |
| 235 | 235 |
| 236 void Generate(MacroAssembler* masm); | 236 void Generate(MacroAssembler* masm); |
| 237 | 237 |
| 238 void GenerateConvertArgument(MacroAssembler* masm, | 238 void GenerateConvertArgument(MacroAssembler* masm, |
| 239 int stack_offset, | 239 int stack_offset, |
| 240 Register arg, | 240 Register arg, |
| 241 Register scratch1, | 241 Register scratch1, |
| 242 Register scratch2, | 242 Register scratch2, |
| 243 Register scratch3, | 243 Register scratch3, |
| 244 Label* slow); | 244 Label* slow); |
| 245 | 245 |
| 246 const StringAddFlags flags_; | 246 const StringAddFlags flags_; |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 | 249 |
| 250 class SubStringStub: public CodeStub { | 250 class SubStringStub: public PlatformCodeStub { |
| 251 public: | 251 public: |
| 252 SubStringStub() {} | 252 SubStringStub() {} |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 Major MajorKey() { return SubString; } | 255 Major MajorKey() { return SubString; } |
| 256 int MinorKey() { return 0; } | 256 int MinorKey() { return 0; } |
| 257 | 257 |
| 258 void Generate(MacroAssembler* masm); | 258 void Generate(MacroAssembler* masm); |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 | 261 |
| 262 class StringCompareStub: public CodeStub { | 262 class StringCompareStub: public PlatformCodeStub { |
| 263 public: | 263 public: |
| 264 StringCompareStub() { } | 264 StringCompareStub() { } |
| 265 | 265 |
| 266 // Compares two flat ASCII strings and returns result in eax. | 266 // Compares two flat ASCII strings and returns result in eax. |
| 267 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 267 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
| 268 Register left, | 268 Register left, |
| 269 Register right, | 269 Register right, |
| 270 Register scratch1, | 270 Register scratch1, |
| 271 Register scratch2, | 271 Register scratch2, |
| 272 Register scratch3); | 272 Register scratch3); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 288 MacroAssembler* masm, | 288 MacroAssembler* masm, |
| 289 Register left, | 289 Register left, |
| 290 Register right, | 290 Register right, |
| 291 Register length, | 291 Register length, |
| 292 Register scratch, | 292 Register scratch, |
| 293 Label* chars_not_equal, | 293 Label* chars_not_equal, |
| 294 Label::Distance chars_not_equal_near = Label::kFar); | 294 Label::Distance chars_not_equal_near = Label::kFar); |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 | 297 |
| 298 class NumberToStringStub: public CodeStub { | 298 class NumberToStringStub: public PlatformCodeStub { |
| 299 public: | 299 public: |
| 300 NumberToStringStub() { } | 300 NumberToStringStub() { } |
| 301 | 301 |
| 302 // Generate code to do a lookup in the number string cache. If the number in | 302 // Generate code to do a lookup in the number string cache. If the number in |
| 303 // the register object is found in the cache the generated code falls through | 303 // the register object is found in the cache the generated code falls through |
| 304 // with the result in the result register. The object and the result register | 304 // with the result in the result register. The object and the result register |
| 305 // can be the same. If the number is not found in the cache the code jumps to | 305 // can be the same. If the number is not found in the cache the code jumps to |
| 306 // the label not_found with only the content of register object unchanged. | 306 // the label not_found with only the content of register object unchanged. |
| 307 static void GenerateLookupNumberStringCache(MacroAssembler* masm, | 307 static void GenerateLookupNumberStringCache(MacroAssembler* masm, |
| 308 Register object, | 308 Register object, |
| 309 Register result, | 309 Register result, |
| 310 Register scratch1, | 310 Register scratch1, |
| 311 Register scratch2, | 311 Register scratch2, |
| 312 bool object_is_smi, | 312 bool object_is_smi, |
| 313 Label* not_found); | 313 Label* not_found); |
| 314 | 314 |
| 315 private: | 315 private: |
| 316 Major MajorKey() { return NumberToString; } | 316 Major MajorKey() { return NumberToString; } |
| 317 int MinorKey() { return 0; } | 317 int MinorKey() { return 0; } |
| 318 | 318 |
| 319 void Generate(MacroAssembler* masm); | 319 void Generate(MacroAssembler* masm); |
| 320 }; | 320 }; |
| 321 | 321 |
| 322 | 322 |
| 323 class StringDictionaryLookupStub: public CodeStub { | 323 class StringDictionaryLookupStub: public PlatformCodeStub { |
| 324 public: | 324 public: |
| 325 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; | 325 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; |
| 326 | 326 |
| 327 StringDictionaryLookupStub(Register dictionary, | 327 StringDictionaryLookupStub(Register dictionary, |
| 328 Register result, | 328 Register result, |
| 329 Register index, | 329 Register index, |
| 330 LookupMode mode) | 330 LookupMode mode) |
| 331 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { } | 331 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { } |
| 332 | 332 |
| 333 void Generate(MacroAssembler* masm); | 333 void Generate(MacroAssembler* masm); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 class IndexBits: public BitField<int, 6, 3> {}; | 375 class IndexBits: public BitField<int, 6, 3> {}; |
| 376 class LookupModeBits: public BitField<LookupMode, 9, 1> {}; | 376 class LookupModeBits: public BitField<LookupMode, 9, 1> {}; |
| 377 | 377 |
| 378 Register dictionary_; | 378 Register dictionary_; |
| 379 Register result_; | 379 Register result_; |
| 380 Register index_; | 380 Register index_; |
| 381 LookupMode mode_; | 381 LookupMode mode_; |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 | 384 |
| 385 class RecordWriteStub: public CodeStub { | 385 class RecordWriteStub: public PlatformCodeStub { |
| 386 public: | 386 public: |
| 387 RecordWriteStub(Register object, | 387 RecordWriteStub(Register object, |
| 388 Register value, | 388 Register value, |
| 389 Register address, | 389 Register address, |
| 390 RememberedSetAction remembered_set_action, | 390 RememberedSetAction remembered_set_action, |
| 391 SaveFPRegsMode fp_mode) | 391 SaveFPRegsMode fp_mode) |
| 392 : object_(object), | 392 : object_(object), |
| 393 value_(value), | 393 value_(value), |
| 394 address_(address), | 394 address_(address), |
| 395 remembered_set_action_(remembered_set_action), | 395 remembered_set_action_(remembered_set_action), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 Register scratch0_orig_; | 578 Register scratch0_orig_; |
| 579 Register object_; | 579 Register object_; |
| 580 Register address_; | 580 Register address_; |
| 581 Register scratch0_; | 581 Register scratch0_; |
| 582 Register scratch1_; | 582 Register scratch1_; |
| 583 // Third scratch register is always ecx. | 583 // Third scratch register is always ecx. |
| 584 | 584 |
| 585 Register GetRegThatIsNotEcxOr(Register r1, | 585 Register GetRegThatIsNotEcxOr(Register r1, |
| 586 Register r2, | 586 Register r2, |
| 587 Register r3) { | 587 Register r3) { |
| 588 for (int i = 0; i < Register::kNumAllocatableRegisters; i++) { | 588 for (int i = 0; i < Register::NumAllocatableRegisters(); i++) { |
| 589 Register candidate = Register::FromAllocationIndex(i); | 589 Register candidate = Register::FromAllocationIndex(i); |
| 590 if (candidate.is(ecx)) continue; | 590 if (candidate.is(ecx)) continue; |
| 591 if (candidate.is(r1)) continue; | 591 if (candidate.is(r1)) continue; |
| 592 if (candidate.is(r2)) continue; | 592 if (candidate.is(r2)) continue; |
| 593 if (candidate.is(r3)) continue; | 593 if (candidate.is(r3)) continue; |
| 594 return candidate; | 594 return candidate; |
| 595 } | 595 } |
| 596 UNREACHABLE(); | 596 UNREACHABLE(); |
| 597 return no_reg; | 597 return no_reg; |
| 598 } | 598 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 Register address_; | 637 Register address_; |
| 638 RememberedSetAction remembered_set_action_; | 638 RememberedSetAction remembered_set_action_; |
| 639 SaveFPRegsMode save_fp_regs_mode_; | 639 SaveFPRegsMode save_fp_regs_mode_; |
| 640 RegisterAllocation regs_; | 640 RegisterAllocation regs_; |
| 641 }; | 641 }; |
| 642 | 642 |
| 643 | 643 |
| 644 } } // namespace v8::internal | 644 } } // namespace v8::internal |
| 645 | 645 |
| 646 #endif // V8_IA32_CODE_STUBS_IA32_H_ | 646 #endif // V8_IA32_CODE_STUBS_IA32_H_ |
| OLD | NEW |