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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1031 |
1032 | 1032 |
1033 void LCodeGen::DoDivI(LDivI* instr) { | 1033 void LCodeGen::DoDivI(LDivI* instr) { |
1034 class DeferredDivI: public LDeferredCode { | 1034 class DeferredDivI: public LDeferredCode { |
1035 public: | 1035 public: |
1036 DeferredDivI(LCodeGen* codegen, LDivI* instr) | 1036 DeferredDivI(LCodeGen* codegen, LDivI* instr) |
1037 : LDeferredCode(codegen), instr_(instr) { } | 1037 : LDeferredCode(codegen), instr_(instr) { } |
1038 virtual void Generate() { | 1038 virtual void Generate() { |
1039 codegen()->DoDeferredBinaryOpStub(instr_, Token::DIV); | 1039 codegen()->DoDeferredBinaryOpStub(instr_, Token::DIV); |
1040 } | 1040 } |
| 1041 virtual LInstruction* instr() { return instr_; } |
1041 private: | 1042 private: |
1042 LDivI* instr_; | 1043 LDivI* instr_; |
1043 }; | 1044 }; |
1044 | 1045 |
1045 const Register left = ToRegister(instr->InputAt(0)); | 1046 const Register left = ToRegister(instr->InputAt(0)); |
1046 const Register right = ToRegister(instr->InputAt(1)); | 1047 const Register right = ToRegister(instr->InputAt(1)); |
1047 const Register scratch = scratch0(); | 1048 const Register scratch = scratch0(); |
1048 const Register result = ToRegister(instr->result()); | 1049 const Register result = ToRegister(instr->result()); |
1049 | 1050 |
1050 // Check for x / 0. | 1051 // Check for x / 0. |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 | 2034 |
2034 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { | 2035 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
2035 class DeferredInstanceOfKnownGlobal: public LDeferredCode { | 2036 class DeferredInstanceOfKnownGlobal: public LDeferredCode { |
2036 public: | 2037 public: |
2037 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, | 2038 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, |
2038 LInstanceOfKnownGlobal* instr) | 2039 LInstanceOfKnownGlobal* instr) |
2039 : LDeferredCode(codegen), instr_(instr) { } | 2040 : LDeferredCode(codegen), instr_(instr) { } |
2040 virtual void Generate() { | 2041 virtual void Generate() { |
2041 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_); | 2042 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_); |
2042 } | 2043 } |
2043 | 2044 virtual LInstruction* instr() { return instr_; } |
2044 Label* map_check() { return &map_check_; } | 2045 Label* map_check() { return &map_check_; } |
2045 | |
2046 private: | 2046 private: |
2047 LInstanceOfKnownGlobal* instr_; | 2047 LInstanceOfKnownGlobal* instr_; |
2048 Label map_check_; | 2048 Label map_check_; |
2049 }; | 2049 }; |
2050 | 2050 |
2051 DeferredInstanceOfKnownGlobal* deferred; | 2051 DeferredInstanceOfKnownGlobal* deferred; |
2052 deferred = new DeferredInstanceOfKnownGlobal(this, instr); | 2052 deferred = new DeferredInstanceOfKnownGlobal(this, instr); |
2053 | 2053 |
2054 Label done, false_result; | 2054 Label done, false_result; |
2055 Register object = ToRegister(instr->InputAt(0)); | 2055 Register object = ToRegister(instr->InputAt(0)); |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { | 2938 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { |
2939 // Class for deferred case. | 2939 // Class for deferred case. |
2940 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { | 2940 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { |
2941 public: | 2941 public: |
2942 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, | 2942 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, |
2943 LUnaryMathOperation* instr) | 2943 LUnaryMathOperation* instr) |
2944 : LDeferredCode(codegen), instr_(instr) { } | 2944 : LDeferredCode(codegen), instr_(instr) { } |
2945 virtual void Generate() { | 2945 virtual void Generate() { |
2946 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); | 2946 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); |
2947 } | 2947 } |
| 2948 virtual LInstruction* instr() { return instr_; } |
2948 private: | 2949 private: |
2949 LUnaryMathOperation* instr_; | 2950 LUnaryMathOperation* instr_; |
2950 }; | 2951 }; |
2951 | 2952 |
2952 Representation r = instr->hydrogen()->value()->representation(); | 2953 Representation r = instr->hydrogen()->value()->representation(); |
2953 if (r.IsDouble()) { | 2954 if (r.IsDouble()) { |
2954 DwVfpRegister input = ToDoubleRegister(instr->InputAt(0)); | 2955 DwVfpRegister input = ToDoubleRegister(instr->InputAt(0)); |
2955 DwVfpRegister result = ToDoubleRegister(instr->result()); | 2956 DwVfpRegister result = ToDoubleRegister(instr->result()); |
2956 __ vabs(result, input); | 2957 __ vabs(result, input); |
2957 } else if (r.IsInteger32()) { | 2958 } else if (r.IsInteger32()) { |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3487 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 3488 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
3488 } | 3489 } |
3489 | 3490 |
3490 | 3491 |
3491 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { | 3492 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { |
3492 class DeferredStringCharCodeAt: public LDeferredCode { | 3493 class DeferredStringCharCodeAt: public LDeferredCode { |
3493 public: | 3494 public: |
3494 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) | 3495 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) |
3495 : LDeferredCode(codegen), instr_(instr) { } | 3496 : LDeferredCode(codegen), instr_(instr) { } |
3496 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } | 3497 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } |
| 3498 virtual LInstruction* instr() { return instr_; } |
3497 private: | 3499 private: |
3498 LStringCharCodeAt* instr_; | 3500 LStringCharCodeAt* instr_; |
3499 }; | 3501 }; |
3500 | 3502 |
3501 Register string = ToRegister(instr->string()); | 3503 Register string = ToRegister(instr->string()); |
3502 Register index = ToRegister(instr->index()); | 3504 Register index = ToRegister(instr->index()); |
3503 Register result = ToRegister(instr->result()); | 3505 Register result = ToRegister(instr->result()); |
3504 | 3506 |
3505 DeferredStringCharCodeAt* deferred = | 3507 DeferredStringCharCodeAt* deferred = |
3506 new DeferredStringCharCodeAt(this, instr); | 3508 new DeferredStringCharCodeAt(this, instr); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 __ StoreToSafepointRegisterSlot(r0, result); | 3612 __ StoreToSafepointRegisterSlot(r0, result); |
3611 } | 3613 } |
3612 | 3614 |
3613 | 3615 |
3614 void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) { | 3616 void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) { |
3615 class DeferredStringCharFromCode: public LDeferredCode { | 3617 class DeferredStringCharFromCode: public LDeferredCode { |
3616 public: | 3618 public: |
3617 DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr) | 3619 DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr) |
3618 : LDeferredCode(codegen), instr_(instr) { } | 3620 : LDeferredCode(codegen), instr_(instr) { } |
3619 virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); } | 3621 virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); } |
| 3622 virtual LInstruction* instr() { return instr_; } |
3620 private: | 3623 private: |
3621 LStringCharFromCode* instr_; | 3624 LStringCharFromCode* instr_; |
3622 }; | 3625 }; |
3623 | 3626 |
3624 DeferredStringCharFromCode* deferred = | 3627 DeferredStringCharFromCode* deferred = |
3625 new DeferredStringCharFromCode(this, instr); | 3628 new DeferredStringCharFromCode(this, instr); |
3626 | 3629 |
3627 ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); | 3630 ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); |
3628 Register char_code = ToRegister(instr->char_code()); | 3631 Register char_code = ToRegister(instr->char_code()); |
3629 Register result = ToRegister(instr->result()); | 3632 Register result = ToRegister(instr->result()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3681 __ vcvt_f64_s32(ToDoubleRegister(output), single_scratch); | 3684 __ vcvt_f64_s32(ToDoubleRegister(output), single_scratch); |
3682 } | 3685 } |
3683 | 3686 |
3684 | 3687 |
3685 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 3688 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
3686 class DeferredNumberTagI: public LDeferredCode { | 3689 class DeferredNumberTagI: public LDeferredCode { |
3687 public: | 3690 public: |
3688 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) | 3691 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
3689 : LDeferredCode(codegen), instr_(instr) { } | 3692 : LDeferredCode(codegen), instr_(instr) { } |
3690 virtual void Generate() { codegen()->DoDeferredNumberTagI(instr_); } | 3693 virtual void Generate() { codegen()->DoDeferredNumberTagI(instr_); } |
| 3694 virtual LInstruction* instr() { return instr_; } |
3691 private: | 3695 private: |
3692 LNumberTagI* instr_; | 3696 LNumberTagI* instr_; |
3693 }; | 3697 }; |
3694 | 3698 |
3695 LOperand* input = instr->InputAt(0); | 3699 LOperand* input = instr->InputAt(0); |
3696 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3700 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
3697 Register reg = ToRegister(input); | 3701 Register reg = ToRegister(input); |
3698 | 3702 |
3699 DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr); | 3703 DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr); |
3700 __ SmiTag(reg, SetCC); | 3704 __ SmiTag(reg, SetCC); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3746 __ StoreToSafepointRegisterSlot(reg, reg); | 3750 __ StoreToSafepointRegisterSlot(reg, reg); |
3747 } | 3751 } |
3748 | 3752 |
3749 | 3753 |
3750 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { | 3754 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { |
3751 class DeferredNumberTagD: public LDeferredCode { | 3755 class DeferredNumberTagD: public LDeferredCode { |
3752 public: | 3756 public: |
3753 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) | 3757 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) |
3754 : LDeferredCode(codegen), instr_(instr) { } | 3758 : LDeferredCode(codegen), instr_(instr) { } |
3755 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } | 3759 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } |
| 3760 virtual LInstruction* instr() { return instr_; } |
3756 private: | 3761 private: |
3757 LNumberTagD* instr_; | 3762 LNumberTagD* instr_; |
3758 }; | 3763 }; |
3759 | 3764 |
3760 DoubleRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 3765 DoubleRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
3761 Register scratch = scratch0(); | 3766 Register scratch = scratch0(); |
3762 Register reg = ToRegister(instr->result()); | 3767 Register reg = ToRegister(instr->result()); |
3763 Register temp1 = ToRegister(instr->TempAt(0)); | 3768 Register temp1 = ToRegister(instr->TempAt(0)); |
3764 Register temp2 = ToRegister(instr->TempAt(1)); | 3769 Register temp2 = ToRegister(instr->TempAt(1)); |
3765 | 3770 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3854 // Smi to double register conversion | 3859 // Smi to double register conversion |
3855 __ bind(&load_smi); | 3860 __ bind(&load_smi); |
3856 __ SmiUntag(input_reg); // Untag smi before converting to float. | 3861 __ SmiUntag(input_reg); // Untag smi before converting to float. |
3857 __ vmov(flt_scratch, input_reg); | 3862 __ vmov(flt_scratch, input_reg); |
3858 __ vcvt_f64_s32(result_reg, flt_scratch); | 3863 __ vcvt_f64_s32(result_reg, flt_scratch); |
3859 __ SmiTag(input_reg); // Retag smi. | 3864 __ SmiTag(input_reg); // Retag smi. |
3860 __ bind(&done); | 3865 __ bind(&done); |
3861 } | 3866 } |
3862 | 3867 |
3863 | 3868 |
3864 class DeferredTaggedToI: public LDeferredCode { | |
3865 public: | |
3866 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) | |
3867 : LDeferredCode(codegen), instr_(instr) { } | |
3868 virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); } | |
3869 private: | |
3870 LTaggedToI* instr_; | |
3871 }; | |
3872 | |
3873 | |
3874 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 3869 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
3875 Register input_reg = ToRegister(instr->InputAt(0)); | 3870 Register input_reg = ToRegister(instr->InputAt(0)); |
3876 Register scratch1 = scratch0(); | 3871 Register scratch1 = scratch0(); |
3877 Register scratch2 = ToRegister(instr->TempAt(0)); | 3872 Register scratch2 = ToRegister(instr->TempAt(0)); |
3878 DwVfpRegister double_scratch = double_scratch0(); | 3873 DwVfpRegister double_scratch = double_scratch0(); |
3879 SwVfpRegister single_scratch = double_scratch.low(); | 3874 SwVfpRegister single_scratch = double_scratch.low(); |
3880 | 3875 |
3881 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); | 3876 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); |
3882 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); | 3877 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); |
3883 | 3878 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3946 __ vmov(scratch1, double_scratch.high()); | 3941 __ vmov(scratch1, double_scratch.high()); |
3947 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 3942 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
3948 DeoptimizeIf(ne, instr->environment()); | 3943 DeoptimizeIf(ne, instr->environment()); |
3949 } | 3944 } |
3950 } | 3945 } |
3951 __ bind(&done); | 3946 __ bind(&done); |
3952 } | 3947 } |
3953 | 3948 |
3954 | 3949 |
3955 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 3950 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
| 3951 class DeferredTaggedToI: public LDeferredCode { |
| 3952 public: |
| 3953 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) |
| 3954 : LDeferredCode(codegen), instr_(instr) { } |
| 3955 virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); } |
| 3956 virtual LInstruction* instr() { return instr_; } |
| 3957 private: |
| 3958 LTaggedToI* instr_; |
| 3959 }; |
| 3960 |
3956 LOperand* input = instr->InputAt(0); | 3961 LOperand* input = instr->InputAt(0); |
3957 ASSERT(input->IsRegister()); | 3962 ASSERT(input->IsRegister()); |
3958 ASSERT(input->Equals(instr->result())); | 3963 ASSERT(input->Equals(instr->result())); |
3959 | 3964 |
3960 Register input_reg = ToRegister(input); | 3965 Register input_reg = ToRegister(input); |
3961 | 3966 |
3962 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); | 3967 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); |
3963 | 3968 |
3964 // Optimistically untag the input. | 3969 // Optimistically untag the input. |
3965 // If the input is a HeapObject, SmiUntag will set the carry flag. | 3970 // If the input is a HeapObject, SmiUntag will set the carry flag. |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4505 safepoints_.SetPcAfterGap(pc); | 4510 safepoints_.SetPcAfterGap(pc); |
4506 } | 4511 } |
4507 | 4512 |
4508 | 4513 |
4509 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 4514 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
4510 class DeferredStackCheck: public LDeferredCode { | 4515 class DeferredStackCheck: public LDeferredCode { |
4511 public: | 4516 public: |
4512 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) | 4517 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) |
4513 : LDeferredCode(codegen), instr_(instr) { } | 4518 : LDeferredCode(codegen), instr_(instr) { } |
4514 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } | 4519 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
| 4520 virtual LInstruction* instr() { return instr_; } |
4515 private: | 4521 private: |
4516 LStackCheck* instr_; | 4522 LStackCheck* instr_; |
4517 }; | 4523 }; |
4518 | 4524 |
4519 if (instr->hydrogen()->is_function_entry()) { | 4525 if (instr->hydrogen()->is_function_entry()) { |
4520 // Perform stack overflow check. | 4526 // Perform stack overflow check. |
4521 Label done; | 4527 Label done; |
4522 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 4528 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
4523 __ cmp(sp, Operand(ip)); | 4529 __ cmp(sp, Operand(ip)); |
4524 __ b(hs, &done); | 4530 __ b(hs, &done); |
(...skipping 29 matching lines...) Expand all Loading... |
4554 ASSERT(osr_pc_offset_ == -1); | 4560 ASSERT(osr_pc_offset_ == -1); |
4555 osr_pc_offset_ = masm()->pc_offset(); | 4561 osr_pc_offset_ = masm()->pc_offset(); |
4556 } | 4562 } |
4557 | 4563 |
4558 | 4564 |
4559 | 4565 |
4560 | 4566 |
4561 #undef __ | 4567 #undef __ |
4562 | 4568 |
4563 } } // namespace v8::internal | 4569 } } // namespace v8::internal |
OLD | NEW |