OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 Comment cmnt(masm_, "[ Case comparison"); | 678 Comment cmnt(masm_, "[ Case comparison"); |
679 __ bind(&next_test); | 679 __ bind(&next_test); |
680 next_test.Unuse(); | 680 next_test.Unuse(); |
681 | 681 |
682 // Compile the label expression. | 682 // Compile the label expression. |
683 VisitForValue(clause->label(), kAccumulator); | 683 VisitForValue(clause->label(), kAccumulator); |
684 | 684 |
685 // Perform the comparison as if via '==='. | 685 // Perform the comparison as if via '==='. |
686 __ mov(edx, Operand(esp, 0)); // Switch value. | 686 __ mov(edx, Operand(esp, 0)); // Switch value. |
687 if (ShouldInlineSmiCase(Token::EQ_STRICT)) { | 687 bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
| 688 if (inline_smi_code) { |
688 Label slow_case; | 689 Label slow_case; |
689 __ mov(ecx, edx); | 690 __ mov(ecx, edx); |
690 __ or_(ecx, Operand(eax)); | 691 __ or_(ecx, Operand(eax)); |
691 __ test(ecx, Immediate(kSmiTagMask)); | 692 __ test(ecx, Immediate(kSmiTagMask)); |
692 __ j(not_zero, &slow_case, not_taken); | 693 __ j(not_zero, &slow_case, not_taken); |
693 __ cmp(edx, Operand(eax)); | 694 __ cmp(edx, Operand(eax)); |
694 __ j(not_equal, &next_test); | 695 __ j(not_equal, &next_test); |
695 __ Drop(1); // Switch value is no longer needed. | 696 __ Drop(1); // Switch value is no longer needed. |
696 __ jmp(clause->body_target()->entry_label()); | 697 __ jmp(clause->body_target()->entry_label()); |
697 __ bind(&slow_case); | 698 __ bind(&slow_case); |
698 } | 699 } |
699 | 700 |
700 CompareStub stub(equal, true); | 701 CompareFlags flags = inline_smi_code |
| 702 ? NO_SMI_COMPARE_IN_STUB |
| 703 : NO_COMPARE_FLAGS; |
| 704 CompareStub stub(equal, true, flags); |
701 __ CallStub(&stub); | 705 __ CallStub(&stub); |
702 __ test(eax, Operand(eax)); | 706 __ test(eax, Operand(eax)); |
703 __ j(not_equal, &next_test); | 707 __ j(not_equal, &next_test); |
704 __ Drop(1); // Switch value is no longer needed. | 708 __ Drop(1); // Switch value is no longer needed. |
705 __ jmp(clause->body_target()->entry_label()); | 709 __ jmp(clause->body_target()->entry_label()); |
706 } | 710 } |
707 | 711 |
708 // Discard the test value and jump to the default if present, otherwise to | 712 // Discard the test value and jump to the default if present, otherwise to |
709 // the end of the statement. | 713 // the end of the statement. |
710 __ bind(&next_test); | 714 __ bind(&next_test); |
(...skipping 2539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3250 __ bind(&no_conversion); | 3254 __ bind(&no_conversion); |
3251 Apply(context_, result_register()); | 3255 Apply(context_, result_register()); |
3252 break; | 3256 break; |
3253 } | 3257 } |
3254 | 3258 |
3255 case Token::SUB: { | 3259 case Token::SUB: { |
3256 Comment cmt(masm_, "[ UnaryOperation (SUB)"); | 3260 Comment cmt(masm_, "[ UnaryOperation (SUB)"); |
3257 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | 3261 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
3258 UnaryOverwriteMode overwrite = | 3262 UnaryOverwriteMode overwrite = |
3259 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | 3263 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
3260 GenericUnaryOpStub stub(Token::SUB, overwrite); | 3264 GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS); |
3261 // GenericUnaryOpStub expects the argument to be in the | 3265 // GenericUnaryOpStub expects the argument to be in the |
3262 // accumulator register eax. | 3266 // accumulator register eax. |
3263 VisitForValue(expr->expression(), kAccumulator); | 3267 VisitForValue(expr->expression(), kAccumulator); |
3264 __ CallStub(&stub); | 3268 __ CallStub(&stub); |
3265 Apply(context_, eax); | 3269 Apply(context_, eax); |
3266 break; | 3270 break; |
3267 } | 3271 } |
3268 | 3272 |
3269 case Token::BIT_NOT: { | 3273 case Token::BIT_NOT: { |
3270 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); | 3274 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); |
3271 // The generic unary operation stub expects the argument to be | 3275 // The generic unary operation stub expects the argument to be |
3272 // in the accumulator register eax. | 3276 // in the accumulator register eax. |
3273 VisitForValue(expr->expression(), kAccumulator); | 3277 VisitForValue(expr->expression(), kAccumulator); |
3274 Label done; | 3278 Label done; |
3275 if (ShouldInlineSmiCase(expr->op())) { | 3279 bool inline_smi_case = ShouldInlineSmiCase(expr->op()); |
| 3280 if (inline_smi_case) { |
3276 Label call_stub; | 3281 Label call_stub; |
3277 __ test(eax, Immediate(kSmiTagMask)); | 3282 __ test(eax, Immediate(kSmiTagMask)); |
3278 __ j(not_zero, &call_stub); | 3283 __ j(not_zero, &call_stub); |
3279 __ lea(eax, Operand(eax, kSmiTagMask)); | 3284 __ lea(eax, Operand(eax, kSmiTagMask)); |
3280 __ not_(eax); | 3285 __ not_(eax); |
3281 __ jmp(&done); | 3286 __ jmp(&done); |
3282 __ bind(&call_stub); | 3287 __ bind(&call_stub); |
3283 } | 3288 } |
3284 bool overwrite = expr->expression()->ResultOverwriteAllowed(); | 3289 bool overwrite = expr->expression()->ResultOverwriteAllowed(); |
3285 UnaryOverwriteMode mode = | 3290 UnaryOverwriteMode mode = |
3286 overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | 3291 overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
3287 GenericUnaryOpStub stub(Token::BIT_NOT, mode); | 3292 UnaryOpFlags flags = inline_smi_case |
| 3293 ? NO_UNARY_SMI_CODE_IN_STUB |
| 3294 : NO_UNARY_FLAGS; |
| 3295 GenericUnaryOpStub stub(Token::BIT_NOT, mode, flags); |
3288 __ CallStub(&stub); | 3296 __ CallStub(&stub); |
3289 __ bind(&done); | 3297 __ bind(&done); |
3290 Apply(context_, eax); | 3298 Apply(context_, eax); |
3291 break; | 3299 break; |
3292 } | 3300 } |
3293 | 3301 |
3294 default: | 3302 default: |
3295 UNREACHABLE(); | 3303 UNREACHABLE(); |
3296 } | 3304 } |
3297 } | 3305 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3665 case Token::GTE: | 3673 case Token::GTE: |
3666 cc = greater_equal; | 3674 cc = greater_equal; |
3667 __ pop(edx); | 3675 __ pop(edx); |
3668 break; | 3676 break; |
3669 case Token::IN: | 3677 case Token::IN: |
3670 case Token::INSTANCEOF: | 3678 case Token::INSTANCEOF: |
3671 default: | 3679 default: |
3672 UNREACHABLE(); | 3680 UNREACHABLE(); |
3673 } | 3681 } |
3674 | 3682 |
3675 if (ShouldInlineSmiCase(op)) { | 3683 bool inline_smi_code = ShouldInlineSmiCase(op); |
| 3684 if (inline_smi_code) { |
3676 Label slow_case; | 3685 Label slow_case; |
3677 __ mov(ecx, Operand(edx)); | 3686 __ mov(ecx, Operand(edx)); |
3678 __ or_(ecx, Operand(eax)); | 3687 __ or_(ecx, Operand(eax)); |
3679 __ test(ecx, Immediate(kSmiTagMask)); | 3688 __ test(ecx, Immediate(kSmiTagMask)); |
3680 __ j(not_zero, &slow_case, not_taken); | 3689 __ j(not_zero, &slow_case, not_taken); |
3681 __ cmp(edx, Operand(eax)); | 3690 __ cmp(edx, Operand(eax)); |
3682 Split(cc, if_true, if_false, NULL); | 3691 Split(cc, if_true, if_false, NULL); |
3683 __ bind(&slow_case); | 3692 __ bind(&slow_case); |
3684 } | 3693 } |
3685 | 3694 |
3686 CompareStub stub(cc, strict); | 3695 CompareFlags flags = inline_smi_code |
| 3696 ? NO_SMI_COMPARE_IN_STUB |
| 3697 : NO_COMPARE_FLAGS; |
| 3698 CompareStub stub(cc, strict, flags); |
3687 __ CallStub(&stub); | 3699 __ CallStub(&stub); |
3688 __ test(eax, Operand(eax)); | 3700 __ test(eax, Operand(eax)); |
3689 Split(cc, if_true, if_false, fall_through); | 3701 Split(cc, if_true, if_false, fall_through); |
3690 } | 3702 } |
3691 } | 3703 } |
3692 | 3704 |
3693 // Convert the result of the comparison into one expected for this | 3705 // Convert the result of the comparison into one expected for this |
3694 // expression's context. | 3706 // expression's context. |
3695 Apply(context_, if_true, if_false); | 3707 Apply(context_, if_true, if_false); |
3696 } | 3708 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3776 // And return. | 3788 // And return. |
3777 __ ret(0); | 3789 __ ret(0); |
3778 } | 3790 } |
3779 | 3791 |
3780 | 3792 |
3781 #undef __ | 3793 #undef __ |
3782 | 3794 |
3783 } } // namespace v8::internal | 3795 } } // namespace v8::internal |
3784 | 3796 |
3785 #endif // V8_TARGET_ARCH_IA32 | 3797 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |