| 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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 continue; | 661 continue; |
| 662 } | 662 } |
| 663 | 663 |
| 664 Comment cmnt(masm_, "[ Case comparison"); | 664 Comment cmnt(masm_, "[ Case comparison"); |
| 665 __ bind(&next_test); | 665 __ bind(&next_test); |
| 666 next_test.Unuse(); | 666 next_test.Unuse(); |
| 667 | 667 |
| 668 // Compile the label expression. | 668 // Compile the label expression. |
| 669 VisitForValue(clause->label(), kAccumulator); | 669 VisitForValue(clause->label(), kAccumulator); |
| 670 | 670 |
| 671 // Perform the comparison as if via '==='. The comparison stub expects | 671 // Perform the comparison as if via '==='. |
| 672 // the smi vs. smi case to be handled before it is called. | |
| 673 Label slow_case; | |
| 674 __ mov(edx, Operand(esp, 0)); // Switch value. | 672 __ mov(edx, Operand(esp, 0)); // Switch value. |
| 675 __ mov(ecx, edx); | 673 if (ShouldInlineSmiCase(Token::EQ_STRICT)) { |
| 676 __ or_(ecx, Operand(eax)); | 674 Label slow_case; |
| 677 __ test(ecx, Immediate(kSmiTagMask)); | 675 __ mov(ecx, edx); |
| 678 __ j(not_zero, &slow_case, not_taken); | 676 __ or_(ecx, Operand(eax)); |
| 679 __ cmp(edx, Operand(eax)); | 677 __ test(ecx, Immediate(kSmiTagMask)); |
| 680 __ j(not_equal, &next_test); | 678 __ j(not_zero, &slow_case, not_taken); |
| 681 __ Drop(1); // Switch value is no longer needed. | 679 __ cmp(edx, Operand(eax)); |
| 682 __ jmp(clause->body_target()->entry_label()); | 680 __ j(not_equal, &next_test); |
| 681 __ Drop(1); // Switch value is no longer needed. |
| 682 __ jmp(clause->body_target()->entry_label()); |
| 683 __ bind(&slow_case); |
| 684 } |
| 683 | 685 |
| 684 __ bind(&slow_case); | |
| 685 CompareStub stub(equal, true); | 686 CompareStub stub(equal, true); |
| 686 __ CallStub(&stub); | 687 __ CallStub(&stub); |
| 687 __ test(eax, Operand(eax)); | 688 __ test(eax, Operand(eax)); |
| 688 __ j(not_equal, &next_test); | 689 __ j(not_equal, &next_test); |
| 689 __ Drop(1); // Switch value is no longer needed. | 690 __ Drop(1); // Switch value is no longer needed. |
| 690 __ jmp(clause->body_target()->entry_label()); | 691 __ jmp(clause->body_target()->entry_label()); |
| 691 } | 692 } |
| 692 | 693 |
| 693 // Discard the test value and jump to the default if present, otherwise to | 694 // Discard the test value and jump to the default if present, otherwise to |
| 694 // the end of the statement. | 695 // the end of the statement. |
| (...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2665 // GenericUnaryOpStub expects the argument to be in the | 2666 // GenericUnaryOpStub expects the argument to be in the |
| 2666 // accumulator register eax. | 2667 // accumulator register eax. |
| 2667 VisitForValue(expr->expression(), kAccumulator); | 2668 VisitForValue(expr->expression(), kAccumulator); |
| 2668 __ CallStub(&stub); | 2669 __ CallStub(&stub); |
| 2669 Apply(context_, eax); | 2670 Apply(context_, eax); |
| 2670 break; | 2671 break; |
| 2671 } | 2672 } |
| 2672 | 2673 |
| 2673 case Token::BIT_NOT: { | 2674 case Token::BIT_NOT: { |
| 2674 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); | 2675 Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); |
| 2675 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | 2676 // The generic unary operation stub expects the argument to be |
| 2676 UnaryOverwriteMode overwrite = | 2677 // in the accumulator register eax. |
| 2677 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | |
| 2678 GenericUnaryOpStub stub(Token::BIT_NOT, overwrite); | |
| 2679 // GenericUnaryOpStub expects the argument to be in the | |
| 2680 // accumulator register eax. | |
| 2681 VisitForValue(expr->expression(), kAccumulator); | 2678 VisitForValue(expr->expression(), kAccumulator); |
| 2682 // Avoid calling the stub for Smis. | 2679 Label done; |
| 2683 Label smi, done; | 2680 if (ShouldInlineSmiCase(expr->op())) { |
| 2684 __ test(result_register(), Immediate(kSmiTagMask)); | 2681 Label call_stub; |
| 2685 __ j(zero, &smi); | 2682 __ test(eax, Immediate(kSmiTagMask)); |
| 2686 // Non-smi: call stub leaving result in accumulator register. | 2683 __ j(not_zero, &call_stub); |
| 2684 __ lea(eax, Operand(eax, kSmiTagMask)); |
| 2685 __ not_(eax); |
| 2686 __ jmp(&done); |
| 2687 __ bind(&call_stub); |
| 2688 } |
| 2689 bool overwrite = expr->expression()->ResultOverwriteAllowed(); |
| 2690 UnaryOverwriteMode mode = |
| 2691 overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
| 2692 GenericUnaryOpStub stub(Token::BIT_NOT, mode); |
| 2687 __ CallStub(&stub); | 2693 __ CallStub(&stub); |
| 2688 __ jmp(&done); | |
| 2689 // Perform operation directly on Smis. | |
| 2690 __ bind(&smi); | |
| 2691 __ not_(result_register()); | |
| 2692 __ and_(result_register(), ~kSmiTagMask); // Remove inverted smi-tag. | |
| 2693 __ bind(&done); | 2694 __ bind(&done); |
| 2694 Apply(context_, result_register()); | 2695 Apply(context_, eax); |
| 2695 break; | 2696 break; |
| 2696 } | 2697 } |
| 2697 | 2698 |
| 2698 default: | 2699 default: |
| 2699 UNREACHABLE(); | 2700 UNREACHABLE(); |
| 2700 } | 2701 } |
| 2701 } | 2702 } |
| 2702 | 2703 |
| 2703 | 2704 |
| 2704 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 2705 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3059 case Token::GTE: | 3060 case Token::GTE: |
| 3060 cc = greater_equal; | 3061 cc = greater_equal; |
| 3061 __ pop(edx); | 3062 __ pop(edx); |
| 3062 break; | 3063 break; |
| 3063 case Token::IN: | 3064 case Token::IN: |
| 3064 case Token::INSTANCEOF: | 3065 case Token::INSTANCEOF: |
| 3065 default: | 3066 default: |
| 3066 UNREACHABLE(); | 3067 UNREACHABLE(); |
| 3067 } | 3068 } |
| 3068 | 3069 |
| 3069 // The comparison stub expects the smi vs. smi case to be | 3070 if (ShouldInlineSmiCase(op)) { |
| 3070 // handled before it is called. | 3071 Label slow_case; |
| 3071 Label slow_case; | 3072 __ mov(ecx, Operand(edx)); |
| 3072 __ mov(ecx, Operand(edx)); | 3073 __ or_(ecx, Operand(eax)); |
| 3073 __ or_(ecx, Operand(eax)); | 3074 __ test(ecx, Immediate(kSmiTagMask)); |
| 3074 __ test(ecx, Immediate(kSmiTagMask)); | 3075 __ j(not_zero, &slow_case, not_taken); |
| 3075 __ j(not_zero, &slow_case, not_taken); | 3076 __ cmp(edx, Operand(eax)); |
| 3076 __ cmp(edx, Operand(eax)); | 3077 Split(cc, if_true, if_false, NULL); |
| 3077 __ j(cc, if_true); | 3078 __ bind(&slow_case); |
| 3078 __ jmp(if_false); | 3079 } |
| 3079 | 3080 |
| 3080 __ bind(&slow_case); | |
| 3081 CompareStub stub(cc, strict); | 3081 CompareStub stub(cc, strict); |
| 3082 __ CallStub(&stub); | 3082 __ CallStub(&stub); |
| 3083 __ test(eax, Operand(eax)); | 3083 __ test(eax, Operand(eax)); |
| 3084 Split(cc, if_true, if_false, fall_through); | 3084 Split(cc, if_true, if_false, fall_through); |
| 3085 } | 3085 } |
| 3086 } | 3086 } |
| 3087 | 3087 |
| 3088 // Convert the result of the comparison into one expected for this | 3088 // Convert the result of the comparison into one expected for this |
| 3089 // expression's context. | 3089 // expression's context. |
| 3090 Apply(context_, if_true, if_false); | 3090 Apply(context_, if_true, if_false); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3171 // And return. | 3171 // And return. |
| 3172 __ ret(0); | 3172 __ ret(0); |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 | 3175 |
| 3176 #undef __ | 3176 #undef __ |
| 3177 | 3177 |
| 3178 } } // namespace v8::internal | 3178 } } // namespace v8::internal |
| 3179 | 3179 |
| 3180 #endif // V8_TARGET_ARCH_IA32 | 3180 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |