| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // Note: A lot of the helper functions below will vanish when we use virtual | 147 // Note: A lot of the helper functions below will vanish when we use virtual |
| 148 // function instead of switch more often. | 148 // function instead of switch more often. |
| 149 void Generate(MacroAssembler* masm); | 149 void Generate(MacroAssembler* masm); |
| 150 | 150 |
| 151 void GenerateTypeTransition(MacroAssembler* masm); | 151 void GenerateTypeTransition(MacroAssembler* masm); |
| 152 | 152 |
| 153 void GenerateSmiStub(MacroAssembler* masm); | 153 void GenerateSmiStub(MacroAssembler* masm); |
| 154 void GenerateSmiStubSub(MacroAssembler* masm); | 154 void GenerateSmiStubSub(MacroAssembler* masm); |
| 155 void GenerateSmiStubBitNot(MacroAssembler* masm); | 155 void GenerateSmiStubBitNot(MacroAssembler* masm); |
| 156 void GenerateSmiCodeSub(MacroAssembler* masm, NearLabel* non_smi, | 156 void GenerateSmiCodeSub(MacroAssembler* masm, |
| 157 Label* slow); | 157 Label* non_smi, |
| 158 void GenerateSmiCodeBitNot(MacroAssembler* masm, NearLabel* non_smi); | 158 Label* slow, |
| 159 Label::Distance non_smi_near = Label::kFar, |
| 160 Label::Distance slow_near = Label::kFar); |
| 161 void GenerateSmiCodeBitNot(MacroAssembler* masm, |
| 162 Label* non_smi, |
| 163 Label::Distance non_smi_near); |
| 159 | 164 |
| 160 void GenerateHeapNumberStub(MacroAssembler* masm); | 165 void GenerateHeapNumberStub(MacroAssembler* masm); |
| 161 void GenerateHeapNumberStubSub(MacroAssembler* masm); | 166 void GenerateHeapNumberStubSub(MacroAssembler* masm); |
| 162 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); | 167 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); |
| 163 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); | 168 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); |
| 164 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); | 169 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); |
| 165 | 170 |
| 166 void GenerateGenericStub(MacroAssembler* masm); | 171 void GenerateGenericStub(MacroAssembler* masm); |
| 167 void GenerateGenericStubSub(MacroAssembler* masm); | 172 void GenerateGenericStubSub(MacroAssembler* masm); |
| 168 void GenerateGenericStubBitNot(MacroAssembler* masm); | 173 void GenerateGenericStubBitNot(MacroAssembler* masm); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 private: | 384 private: |
| 380 Major MajorKey() { return SubString; } | 385 Major MajorKey() { return SubString; } |
| 381 int MinorKey() { return 0; } | 386 int MinorKey() { return 0; } |
| 382 | 387 |
| 383 void Generate(MacroAssembler* masm); | 388 void Generate(MacroAssembler* masm); |
| 384 }; | 389 }; |
| 385 | 390 |
| 386 | 391 |
| 387 class StringCompareStub: public CodeStub { | 392 class StringCompareStub: public CodeStub { |
| 388 public: | 393 public: |
| 389 explicit StringCompareStub() {} | 394 StringCompareStub() {} |
| 390 | 395 |
| 391 // Compare two flat ascii strings and returns result in rax after popping two | 396 // Compares two flat ASCII strings and returns result in rax. |
| 392 // arguments from the stack. | |
| 393 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 397 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
| 394 Register left, | 398 Register left, |
| 395 Register right, | 399 Register right, |
| 396 Register scratch1, | 400 Register scratch1, |
| 397 Register scratch2, | 401 Register scratch2, |
| 398 Register scratch3, | 402 Register scratch3, |
| 399 Register scratch4); | 403 Register scratch4); |
| 400 | 404 |
| 405 // Compares two flat ASCII strings for equality and returns result |
| 406 // in rax. |
| 407 static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, |
| 408 Register left, |
| 409 Register right, |
| 410 Register scratch1, |
| 411 Register scratch2); |
| 412 |
| 401 private: | 413 private: |
| 402 Major MajorKey() { return StringCompare; } | 414 virtual Major MajorKey() { return StringCompare; } |
| 403 int MinorKey() { return 0; } | 415 virtual int MinorKey() { return 0; } |
| 416 virtual void Generate(MacroAssembler* masm); |
| 404 | 417 |
| 405 void Generate(MacroAssembler* masm); | 418 static void GenerateAsciiCharsCompareLoop( |
| 419 MacroAssembler* masm, |
| 420 Register left, |
| 421 Register right, |
| 422 Register length, |
| 423 Register scratch, |
| 424 Label* chars_not_equal, |
| 425 Label::Distance near_jump = Label::kFar); |
| 406 }; | 426 }; |
| 407 | 427 |
| 408 | 428 |
| 409 class NumberToStringStub: public CodeStub { | 429 class NumberToStringStub: public CodeStub { |
| 410 public: | 430 public: |
| 411 NumberToStringStub() { } | 431 NumberToStringStub() { } |
| 412 | 432 |
| 413 // Generate code to do a lookup in the number string cache. If the number in | 433 // Generate code to do a lookup in the number string cache. If the number in |
| 414 // the register object is found in the cache the generated code falls through | 434 // the register object is found in the cache the generated code falls through |
| 415 // with the result in the result register. The object and the result register | 435 // with the result in the result register. The object and the result register |
| (...skipping 20 matching lines...) Expand all Loading... |
| 436 const char* GetName() { return "NumberToStringStub"; } | 456 const char* GetName() { return "NumberToStringStub"; } |
| 437 | 457 |
| 438 #ifdef DEBUG | 458 #ifdef DEBUG |
| 439 void Print() { | 459 void Print() { |
| 440 PrintF("NumberToStringStub\n"); | 460 PrintF("NumberToStringStub\n"); |
| 441 } | 461 } |
| 442 #endif | 462 #endif |
| 443 }; | 463 }; |
| 444 | 464 |
| 445 | 465 |
| 466 class StringDictionaryLookupStub: public CodeStub { |
| 467 public: |
| 468 enum LookupMode { POSITIVE_LOOKUP, NEGATIVE_LOOKUP }; |
| 469 |
| 470 StringDictionaryLookupStub(Register dictionary, |
| 471 Register result, |
| 472 Register index, |
| 473 LookupMode mode) |
| 474 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { } |
| 475 |
| 476 void Generate(MacroAssembler* masm); |
| 477 |
| 478 MUST_USE_RESULT static MaybeObject* GenerateNegativeLookup( |
| 479 MacroAssembler* masm, |
| 480 Label* miss, |
| 481 Label* done, |
| 482 Register properties, |
| 483 String* name, |
| 484 Register r0); |
| 485 |
| 486 static void GeneratePositiveLookup(MacroAssembler* masm, |
| 487 Label* miss, |
| 488 Label* done, |
| 489 Register elements, |
| 490 Register name, |
| 491 Register r0, |
| 492 Register r1); |
| 493 |
| 494 private: |
| 495 static const int kInlinedProbes = 4; |
| 496 static const int kTotalProbes = 20; |
| 497 |
| 498 static const int kCapacityOffset = |
| 499 StringDictionary::kHeaderSize + |
| 500 StringDictionary::kCapacityIndex * kPointerSize; |
| 501 |
| 502 static const int kElementsStartOffset = |
| 503 StringDictionary::kHeaderSize + |
| 504 StringDictionary::kElementsStartIndex * kPointerSize; |
| 505 |
| 506 |
| 507 #ifdef DEBUG |
| 508 void Print() { |
| 509 PrintF("StringDictionaryLookupStub\n"); |
| 510 } |
| 511 #endif |
| 512 |
| 513 Major MajorKey() { return StringDictionaryNegativeLookup; } |
| 514 |
| 515 int MinorKey() { |
| 516 return DictionaryBits::encode(dictionary_.code()) | |
| 517 ResultBits::encode(result_.code()) | |
| 518 IndexBits::encode(index_.code()) | |
| 519 LookupModeBits::encode(mode_); |
| 520 } |
| 521 |
| 522 class DictionaryBits: public BitField<int, 0, 4> {}; |
| 523 class ResultBits: public BitField<int, 4, 4> {}; |
| 524 class IndexBits: public BitField<int, 8, 4> {}; |
| 525 class LookupModeBits: public BitField<LookupMode, 12, 1> {}; |
| 526 |
| 527 Register dictionary_; |
| 528 Register result_; |
| 529 Register index_; |
| 530 LookupMode mode_; |
| 531 }; |
| 532 |
| 533 |
| 446 class RecordWriteStub: public CodeStub { | 534 class RecordWriteStub: public CodeStub { |
| 447 public: | 535 public: |
| 448 RecordWriteStub(Register object, | 536 RecordWriteStub(Register object, |
| 449 Register value, | 537 Register value, |
| 450 Register address, | 538 Register address, |
| 451 EmitRememberedSet emit_remembered_set, | 539 EmitRememberedSet emit_remembered_set, |
| 452 SaveFPRegsMode fp_mode) | 540 SaveFPRegsMode fp_mode) |
| 453 : object_(object), | 541 : object_(object), |
| 454 value_(value), | 542 value_(value), |
| 455 address_(address), | 543 address_(address), |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 EmitRememberedSet emit_remembered_set_; | 733 EmitRememberedSet emit_remembered_set_; |
| 646 SaveFPRegsMode save_fp_regs_mode_; | 734 SaveFPRegsMode save_fp_regs_mode_; |
| 647 Label slow_; | 735 Label slow_; |
| 648 RegisterAllocation regs_; | 736 RegisterAllocation regs_; |
| 649 }; | 737 }; |
| 650 | 738 |
| 651 | 739 |
| 652 } } // namespace v8::internal | 740 } } // namespace v8::internal |
| 653 | 741 |
| 654 #endif // V8_X64_CODE_STUBS_X64_H_ | 742 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |