| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 case CodeStub::RegExpExec: { | 736 case CodeStub::RegExpExec: { |
| 737 RegExpExecStub stub; | 737 RegExpExecStub stub; |
| 738 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 738 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 739 break; | 739 break; |
| 740 } | 740 } |
| 741 case CodeStub::SubString: { | 741 case CodeStub::SubString: { |
| 742 SubStringStub stub; | 742 SubStringStub stub; |
| 743 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 743 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 744 break; | 744 break; |
| 745 } | 745 } |
| 746 case CodeStub::StringCharAt: { | |
| 747 StringCharAtStub stub; | |
| 748 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | |
| 749 break; | |
| 750 } | |
| 751 case CodeStub::NumberToString: { | 746 case CodeStub::NumberToString: { |
| 752 NumberToStringStub stub; | 747 NumberToStringStub stub; |
| 753 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 748 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 754 break; | 749 break; |
| 755 } | 750 } |
| 756 case CodeStub::StringAdd: { | 751 case CodeStub::StringAdd: { |
| 757 StringAddStub stub(NO_STRING_ADD_FLAGS); | 752 StringAddStub stub(NO_STRING_ADD_FLAGS); |
| 758 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 753 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 759 break; | 754 break; |
| 760 } | 755 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 774 } | 769 } |
| 775 } | 770 } |
| 776 | 771 |
| 777 | 772 |
| 778 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 773 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 779 // Nothing to do. | 774 // Nothing to do. |
| 780 } | 775 } |
| 781 | 776 |
| 782 | 777 |
| 783 void LCodeGen::DoModI(LModI* instr) { | 778 void LCodeGen::DoModI(LModI* instr) { |
| 784 LOperand* right = instr->InputAt(1); | 779 if (instr->hydrogen()->HasPowerOf2Divisor()) { |
| 785 ASSERT(ToRegister(instr->result()).is(edx)); | 780 Register dividend = ToRegister(instr->InputAt(0)); |
| 786 ASSERT(ToRegister(instr->InputAt(0)).is(eax)); | |
| 787 ASSERT(!ToRegister(instr->InputAt(1)).is(eax)); | |
| 788 ASSERT(!ToRegister(instr->InputAt(1)).is(edx)); | |
| 789 | 781 |
| 790 Register right_reg = ToRegister(right); | 782 int32_t divisor = |
| 783 HConstant::cast(instr->hydrogen()->right())->Integer32Value(); |
| 791 | 784 |
| 792 // Check for x % 0. | 785 if (divisor < 0) divisor = -divisor; |
| 793 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { | |
| 794 __ test(right_reg, ToOperand(right)); | |
| 795 DeoptimizeIf(zero, instr->environment()); | |
| 796 } | |
| 797 | 786 |
| 798 // Sign extend to edx. | 787 NearLabel positive_dividend, done; |
| 799 __ cdq(); | 788 __ test(dividend, Operand(dividend)); |
| 800 | 789 __ j(not_sign, &positive_dividend); |
| 801 // Check for (0 % -x) that will produce negative zero. | 790 __ neg(dividend); |
| 802 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 791 __ and_(dividend, divisor - 1); |
| 803 NearLabel positive_left; | 792 __ neg(dividend); |
| 804 NearLabel done; | 793 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 805 __ test(eax, Operand(eax)); | 794 __ j(not_zero, &done); |
| 806 __ j(not_sign, &positive_left); | 795 DeoptimizeIf(no_condition, instr->environment()); |
| 807 __ idiv(right_reg); | 796 } |
| 808 | 797 __ bind(&positive_dividend); |
| 809 // Test the remainder for 0, because then the result would be -0. | 798 __ and_(dividend, divisor - 1); |
| 810 __ test(edx, Operand(edx)); | |
| 811 __ j(not_zero, &done); | |
| 812 | |
| 813 DeoptimizeIf(no_condition, instr->environment()); | |
| 814 __ bind(&positive_left); | |
| 815 __ idiv(right_reg); | |
| 816 __ bind(&done); | 799 __ bind(&done); |
| 817 } else { | 800 } else { |
| 818 __ idiv(right_reg); | 801 LOperand* right = instr->InputAt(1); |
| 802 ASSERT(ToRegister(instr->InputAt(0)).is(eax)); |
| 803 ASSERT(ToRegister(instr->result()).is(edx)); |
| 804 |
| 805 Register right_reg = ToRegister(right); |
| 806 ASSERT(!right_reg.is(eax)); |
| 807 ASSERT(!right_reg.is(edx)); |
| 808 |
| 809 // Check for x % 0. |
| 810 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
| 811 __ test(right_reg, ToOperand(right)); |
| 812 DeoptimizeIf(zero, instr->environment()); |
| 813 } |
| 814 |
| 815 // Sign extend to edx. |
| 816 __ cdq(); |
| 817 |
| 818 // Check for (0 % -x) that will produce negative zero. |
| 819 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 820 NearLabel positive_left; |
| 821 NearLabel done; |
| 822 __ test(eax, Operand(eax)); |
| 823 __ j(not_sign, &positive_left); |
| 824 __ idiv(right_reg); |
| 825 |
| 826 // Test the remainder for 0, because then the result would be -0. |
| 827 __ test(edx, Operand(edx)); |
| 828 __ j(not_zero, &done); |
| 829 |
| 830 DeoptimizeIf(no_condition, instr->environment()); |
| 831 __ bind(&positive_left); |
| 832 __ idiv(right_reg); |
| 833 __ bind(&done); |
| 834 } else { |
| 835 __ idiv(right_reg); |
| 836 } |
| 819 } | 837 } |
| 820 } | 838 } |
| 821 | 839 |
| 822 | 840 |
| 823 void LCodeGen::DoDivI(LDivI* instr) { | 841 void LCodeGen::DoDivI(LDivI* instr) { |
| 824 LOperand* right = instr->InputAt(1); | 842 LOperand* right = instr->InputAt(1); |
| 825 ASSERT(ToRegister(instr->result()).is(eax)); | 843 ASSERT(ToRegister(instr->result()).is(eax)); |
| 826 ASSERT(ToRegister(instr->InputAt(0)).is(eax)); | 844 ASSERT(ToRegister(instr->InputAt(0)).is(eax)); |
| 827 ASSERT(!ToRegister(instr->InputAt(1)).is(eax)); | 845 ASSERT(!ToRegister(instr->InputAt(1)).is(eax)); |
| 828 ASSERT(!ToRegister(instr->InputAt(1)).is(edx)); | 846 ASSERT(!ToRegister(instr->InputAt(1)).is(edx)); |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex); | 3024 instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex); |
| 3007 if (FLAG_debug_code) { | 3025 if (FLAG_debug_code) { |
| 3008 __ AbortIfNotSmi(eax); | 3026 __ AbortIfNotSmi(eax); |
| 3009 } | 3027 } |
| 3010 __ SmiUntag(eax); | 3028 __ SmiUntag(eax); |
| 3011 __ StoreToSafepointRegisterSlot(result, eax); | 3029 __ StoreToSafepointRegisterSlot(result, eax); |
| 3012 __ PopSafepointRegisters(); | 3030 __ PopSafepointRegisters(); |
| 3013 } | 3031 } |
| 3014 | 3032 |
| 3015 | 3033 |
| 3034 void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) { |
| 3035 class DeferredStringCharFromCode: public LDeferredCode { |
| 3036 public: |
| 3037 DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr) |
| 3038 : LDeferredCode(codegen), instr_(instr) { } |
| 3039 virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); } |
| 3040 private: |
| 3041 LStringCharFromCode* instr_; |
| 3042 }; |
| 3043 |
| 3044 DeferredStringCharFromCode* deferred = |
| 3045 new DeferredStringCharFromCode(this, instr); |
| 3046 |
| 3047 ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); |
| 3048 Register char_code = ToRegister(instr->char_code()); |
| 3049 Register result = ToRegister(instr->result()); |
| 3050 ASSERT(!char_code.is(result)); |
| 3051 |
| 3052 __ cmp(char_code, String::kMaxAsciiCharCode); |
| 3053 __ j(above, deferred->entry()); |
| 3054 __ Set(result, Immediate(FACTORY->single_character_string_cache())); |
| 3055 __ mov(result, FieldOperand(result, |
| 3056 char_code, times_pointer_size, |
| 3057 FixedArray::kHeaderSize)); |
| 3058 __ cmp(result, FACTORY->undefined_value()); |
| 3059 __ j(equal, deferred->entry()); |
| 3060 __ bind(deferred->exit()); |
| 3061 } |
| 3062 |
| 3063 |
| 3064 void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) { |
| 3065 Register char_code = ToRegister(instr->char_code()); |
| 3066 Register result = ToRegister(instr->result()); |
| 3067 |
| 3068 // TODO(3095996): Get rid of this. For now, we need to make the |
| 3069 // result register contain a valid pointer because it is already |
| 3070 // contained in the register pointer map. |
| 3071 __ Set(result, Immediate(0)); |
| 3072 |
| 3073 __ PushSafepointRegisters(); |
| 3074 __ SmiTag(char_code); |
| 3075 __ push(char_code); |
| 3076 __ CallRuntimeSaveDoubles(Runtime::kCharFromCode); |
| 3077 RecordSafepointWithRegisters( |
| 3078 instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex); |
| 3079 __ StoreToSafepointRegisterSlot(result, eax); |
| 3080 __ PopSafepointRegisters(); |
| 3081 } |
| 3082 |
| 3083 |
| 3016 void LCodeGen::DoStringLength(LStringLength* instr) { | 3084 void LCodeGen::DoStringLength(LStringLength* instr) { |
| 3017 Register string = ToRegister(instr->string()); | 3085 Register string = ToRegister(instr->string()); |
| 3018 Register result = ToRegister(instr->result()); | 3086 Register result = ToRegister(instr->result()); |
| 3019 __ mov(result, FieldOperand(string, String::kLengthOffset)); | 3087 __ mov(result, FieldOperand(string, String::kLengthOffset)); |
| 3020 } | 3088 } |
| 3021 | 3089 |
| 3022 | 3090 |
| 3023 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { | 3091 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { |
| 3024 LOperand* input = instr->InputAt(0); | 3092 LOperand* input = instr->InputAt(0); |
| 3025 ASSERT(input->IsRegister() || input->IsStackSlot()); | 3093 ASSERT(input->IsRegister() || input->IsStackSlot()); |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3876 ASSERT(osr_pc_offset_ == -1); | 3944 ASSERT(osr_pc_offset_ == -1); |
| 3877 osr_pc_offset_ = masm()->pc_offset(); | 3945 osr_pc_offset_ = masm()->pc_offset(); |
| 3878 } | 3946 } |
| 3879 | 3947 |
| 3880 | 3948 |
| 3881 #undef __ | 3949 #undef __ |
| 3882 | 3950 |
| 3883 } } // namespace v8::internal | 3951 } } // namespace v8::internal |
| 3884 | 3952 |
| 3885 #endif // V8_TARGET_ARCH_IA32 | 3953 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |