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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 // Store the function for the given builtin in the target register. | 368 // Store the function for the given builtin in the target register. |
369 void GetBuiltinFunction(Register target, Builtins::JavaScript id); | 369 void GetBuiltinFunction(Register target, Builtins::JavaScript id); |
370 | 370 |
371 // Store the code object for the given builtin in the target register. | 371 // Store the code object for the given builtin in the target register. |
372 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 372 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
373 | 373 |
374 | 374 |
375 // --------------------------------------------------------------------------- | 375 // --------------------------------------------------------------------------- |
376 // Smi tagging, untagging and operations on tagged smis. | 376 // Smi tagging, untagging and operations on tagged smis. |
377 | 377 |
378 class SmiFunctionInvoker { | |
danno
2013/08/07 18:41:26
I think approach works, but I think you can get aw
haitao.feng
2013/08/12 09:54:24
Thanks for the recommendation. I used a slightly d
| |
379 public: | |
380 explicit SmiFunctionInvoker(Label* label) : label_(label) { } | |
381 virtual ~SmiFunctionInvoker() { } | |
382 virtual void Bailout() { } | |
383 virtual Label* on_not_smi_result() { return label_; } | |
384 virtual bool reserve_source_operands() { return true; } | |
385 virtual bool check_minus_zero() { return true; } | |
386 private: | |
387 Label* label_; | |
388 }; | |
389 | |
378 void InitializeSmiConstantRegister() { | 390 void InitializeSmiConstantRegister() { |
379 movq(kSmiConstantRegister, | 391 movq(kSmiConstantRegister, |
380 reinterpret_cast<uint64_t>(Smi::FromInt(kSmiConstantRegisterValue)), | 392 reinterpret_cast<uint64_t>(Smi::FromInt(kSmiConstantRegisterValue)), |
381 RelocInfo::NONE64); | 393 RelocInfo::NONE64); |
382 } | 394 } |
383 | 395 |
384 // Conversions between tagged smi values and non-tagged integer values. | 396 // Conversions between tagged smi values and non-tagged integer values. |
385 | 397 |
386 // Tag an integer value. The result must be known to be a valid smi value. | 398 // Tag an integer value. The result must be known to be a valid smi value. |
387 // Only uses the low 32 bits of the src register. Sets the N and Z flags | 399 // Only uses the low 32 bits of the src register. Sets the N and Z flags |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 // and to one if it isn't. | 489 // and to one if it isn't. |
478 void CheckSmiToIndicator(Register dst, Register src); | 490 void CheckSmiToIndicator(Register dst, Register src); |
479 void CheckSmiToIndicator(Register dst, const Operand& src); | 491 void CheckSmiToIndicator(Register dst, const Operand& src); |
480 | 492 |
481 // Test-and-jump functions. Typically combines a check function | 493 // Test-and-jump functions. Typically combines a check function |
482 // above with a conditional jump. | 494 // above with a conditional jump. |
483 | 495 |
484 // Jump if the value cannot be represented by a smi. | 496 // Jump if the value cannot be represented by a smi. |
485 void JumpIfNotValidSmiValue(Register src, Label* on_invalid, | 497 void JumpIfNotValidSmiValue(Register src, Label* on_invalid, |
486 Label::Distance near_jump = Label::kFar); | 498 Label::Distance near_jump = Label::kFar); |
499 // Jump if the value can be represented by a smi. | |
500 void JumpIfValidSmiValue(Register src, Label* on_valid, | |
501 Label::Distance near_jump = Label::kFar); | |
487 | 502 |
488 // Jump if the unsigned integer value cannot be represented by a smi. | 503 // Jump if the unsigned integer value cannot be represented by a smi. |
489 void JumpIfUIntNotValidSmiValue(Register src, Label* on_invalid, | 504 void JumpIfUIntNotValidSmiValue(Register src, Label* on_invalid, |
490 Label::Distance near_jump = Label::kFar); | 505 Label::Distance near_jump = Label::kFar); |
506 // Jump if the unsigned integer value can be represented by a smi. | |
507 void JumpIfUIntValidSmiValue(Register src, Label* on_valid, | |
508 Label::Distance near_jump = Label::kFar); | |
509 | |
491 | 510 |
492 // Jump to label if the value is a tagged smi. | 511 // Jump to label if the value is a tagged smi. |
493 void JumpIfSmi(Register src, | 512 void JumpIfSmi(Register src, |
494 Label* on_smi, | 513 Label* on_smi, |
495 Label::Distance near_jump = Label::kFar); | 514 Label::Distance near_jump = Label::kFar); |
496 | 515 |
497 // Jump to label if the value is not a tagged smi. | 516 // Jump to label if the value is not a tagged smi. |
498 void JumpIfNotSmi(Register src, | 517 void JumpIfNotSmi(Register src, |
499 Label* on_not_smi, | 518 Label* on_not_smi, |
500 Label::Distance near_jump = Label::kFar); | 519 Label::Distance near_jump = Label::kFar); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 void SmiNot(Register dst, Register src); | 662 void SmiNot(Register dst, Register src); |
644 void SmiAnd(Register dst, Register src1, Register src2); | 663 void SmiAnd(Register dst, Register src1, Register src2); |
645 void SmiOr(Register dst, Register src1, Register src2); | 664 void SmiOr(Register dst, Register src1, Register src2); |
646 void SmiXor(Register dst, Register src1, Register src2); | 665 void SmiXor(Register dst, Register src1, Register src2); |
647 void SmiAndConstant(Register dst, Register src1, Smi* constant); | 666 void SmiAndConstant(Register dst, Register src1, Smi* constant); |
648 void SmiOrConstant(Register dst, Register src1, Smi* constant); | 667 void SmiOrConstant(Register dst, Register src1, Smi* constant); |
649 void SmiXorConstant(Register dst, Register src1, Smi* constant); | 668 void SmiXorConstant(Register dst, Register src1, Smi* constant); |
650 | 669 |
651 void SmiShiftLeftConstant(Register dst, | 670 void SmiShiftLeftConstant(Register dst, |
652 Register src, | 671 Register src, |
653 int shift_value); | 672 int shift_value, |
673 SmiFunctionInvoker& env); | |
654 void SmiShiftLogicalRightConstant(Register dst, | 674 void SmiShiftLogicalRightConstant(Register dst, |
655 Register src, | 675 Register src, |
656 int shift_value, | 676 int shift_value, |
657 Label* on_not_smi_result, | 677 Label* on_not_smi_result, |
658 Label::Distance near_jump = Label::kFar); | 678 Label::Distance near_jump = Label::kFar); |
659 void SmiShiftArithmeticRightConstant(Register dst, | 679 void SmiShiftArithmeticRightConstant(Register dst, |
660 Register src, | 680 Register src, |
661 int shift_value); | 681 int shift_value); |
662 | 682 |
663 // Shifts a smi value to the left, and returns the result if that is a smi. | 683 // Shifts a smi value to the left, and returns the result if that is a smi. |
664 // Uses and clobbers rcx, so dst may not be rcx. | 684 // Uses and clobbers rcx, so dst may not be rcx. |
665 void SmiShiftLeft(Register dst, | 685 void SmiShiftLeft(Register dst, |
666 Register src1, | 686 Register src1, |
667 Register src2); | 687 Register src2, |
688 Label* on_not_smi_result); | |
668 // Shifts a smi value to the right, shifting in zero bits at the top, and | 689 // Shifts a smi value to the right, shifting in zero bits at the top, and |
669 // returns the unsigned intepretation of the result if that is a smi. | 690 // returns the unsigned intepretation of the result if that is a smi. |
670 // Uses and clobbers rcx, so dst may not be rcx. | 691 // Uses and clobbers rcx, so dst may not be rcx. |
671 void SmiShiftLogicalRight(Register dst, | 692 void SmiShiftLogicalRight(Register dst, |
672 Register src1, | 693 Register src1, |
673 Register src2, | 694 Register src2, |
674 Label* on_not_smi_result, | 695 Label* on_not_smi_result, |
675 Label::Distance near_jump = Label::kFar); | 696 Label::Distance near_jump = Label::kFar); |
676 // Shifts a smi value to the right, sign extending the top, and | 697 // Shifts a smi value to the right, sign extending the top, and |
677 // returns the signed intepretation of the result. That will always | 698 // returns the signed intepretation of the result. That will always |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 } | 736 } |
716 | 737 |
717 void Move(const Operand& dst, Smi* source) { | 738 void Move(const Operand& dst, Smi* source) { |
718 Register constant = GetSmiConstant(source); | 739 Register constant = GetSmiConstant(source); |
719 movq(dst, constant); | 740 movq(dst, constant); |
720 } | 741 } |
721 | 742 |
722 void Push(Smi* smi); | 743 void Push(Smi* smi); |
723 void Test(const Operand& dst, Smi* source); | 744 void Test(const Operand& dst, Smi* source); |
724 | 745 |
746 void PushInt64AsTwoSmis(Register src, Register scratch = kScratchRegister); | |
747 void PopInt64AsTwoSmis(Register dst, Register scratch = kScratchRegister); | |
748 static bool IsUnsafeSmiOperator(Token::Value op); | |
725 | 749 |
726 // --------------------------------------------------------------------------- | 750 // --------------------------------------------------------------------------- |
727 // String macros. | 751 // String macros. |
728 | 752 |
729 // If object is a string, its map is loaded into object_map. | 753 // If object is a string, its map is loaded into object_map. |
730 void JumpIfNotString(Register object, | 754 void JumpIfNotString(Register object, |
731 Register object_map, | 755 Register object_map, |
732 Label* not_string, | 756 Label* not_string, |
733 Label::Distance near_jump = Label::kFar); | 757 Label::Distance near_jump = Label::kFar); |
734 | 758 |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1541 masm->popfq(); \ | 1565 masm->popfq(); \ |
1542 } \ | 1566 } \ |
1543 masm-> | 1567 masm-> |
1544 #else | 1568 #else |
1545 #define ACCESS_MASM(masm) masm-> | 1569 #define ACCESS_MASM(masm) masm-> |
1546 #endif | 1570 #endif |
1547 | 1571 |
1548 } } // namespace v8::internal | 1572 } } // namespace v8::internal |
1549 | 1573 |
1550 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1574 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |