Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: src/arm/full-codegen-arm.cc

Issue 3116042: Prepare for optionally inlining smi cases in the code generated... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/full-codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 continue; 658 continue;
659 } 659 }
660 660
661 Comment cmnt(masm_, "[ Case comparison"); 661 Comment cmnt(masm_, "[ Case comparison");
662 __ bind(&next_test); 662 __ bind(&next_test);
663 next_test.Unuse(); 663 next_test.Unuse();
664 664
665 // Compile the label expression. 665 // Compile the label expression.
666 VisitForValue(clause->label(), kAccumulator); 666 VisitForValue(clause->label(), kAccumulator);
667 667
668 // Perform the comparison as if via '==='. The comparison stub expects 668 // Perform the comparison as if via '==='.
669 // the smi vs. smi case to be handled before it is called.
670 Label slow_case;
671 __ ldr(r1, MemOperand(sp, 0)); // Switch value. 669 __ ldr(r1, MemOperand(sp, 0)); // Switch value.
672 __ orr(r2, r1, r0); 670 if (ShouldInlineSmiCase(Token::EQ_STRICT)) {
673 __ tst(r2, Operand(kSmiTagMask)); 671 Label slow_case;
674 __ b(ne, &slow_case); 672 __ orr(r2, r1, r0);
675 __ cmp(r1, r0); 673 __ tst(r2, Operand(kSmiTagMask));
676 __ b(ne, &next_test); 674 __ b(ne, &slow_case);
677 __ Drop(1); // Switch value is no longer needed. 675 __ cmp(r1, r0);
678 __ b(clause->body_target()->entry_label()); 676 __ b(ne, &next_test);
677 __ Drop(1); // Switch value is no longer needed.
678 __ b(clause->body_target()->entry_label());
679 __ bind(&slow_case);
680 }
679 681
680 __ bind(&slow_case);
681 CompareStub stub(eq, true, kBothCouldBeNaN, true, r1, r0); 682 CompareStub stub(eq, true, kBothCouldBeNaN, true, r1, r0);
682 __ CallStub(&stub); 683 __ CallStub(&stub);
683 __ cmp(r0, Operand(0)); 684 __ cmp(r0, Operand(0));
684 __ b(ne, &next_test); 685 __ b(ne, &next_test);
685 __ Drop(1); // Switch value is no longer needed. 686 __ Drop(1); // Switch value is no longer needed.
686 __ b(clause->body_target()->entry_label()); 687 __ b(clause->body_target()->entry_label());
687 } 688 }
688 689
689 // Discard the test value and jump to the default if present, otherwise to 690 // Discard the test value and jump to the default if present, otherwise to
690 // the end of the statement. 691 // the end of the statement.
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 // GenericUnaryOpStub expects the argument to be in the 2666 // GenericUnaryOpStub expects the argument to be in the
2666 // accumulator register r0. 2667 // accumulator register r0.
2667 VisitForValue(expr->expression(), kAccumulator); 2668 VisitForValue(expr->expression(), kAccumulator);
2668 __ CallStub(&stub); 2669 __ CallStub(&stub);
2669 Apply(context_, r0); 2670 Apply(context_, r0);
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 r0.
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 r0.
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 __ BranchOnSmi(result_register(), &smi); 2681 Label call_stub;
2685 // Non-smi: call stub leaving result in accumulator register. 2682 __ BranchOnNotSmi(r0, &call_stub);
2683 __ mvn(r0, Operand(r0));
2684 // Bit-clear inverted smi-tag.
2685 __ bic(r0, r0, Operand(kSmiTagMask));
2686 __ b(&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);
2686 __ CallStub(&stub); 2693 __ CallStub(&stub);
2687 __ b(&done);
2688 // Perform operation directly on Smis.
2689 __ bind(&smi);
2690 __ mvn(result_register(), Operand(result_register()));
2691 // Bit-clear inverted smi-tag.
2692 __ bic(result_register(), result_register(), Operand(kSmiTagMask));
2693 __ bind(&done); 2694 __ bind(&done);
2694 Apply(context_, result_register()); 2695 Apply(context_, r0);
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 case Token::GTE: 3049 case Token::GTE:
3049 cc = ge; 3050 cc = ge;
3050 __ pop(r1); 3051 __ pop(r1);
3051 break; 3052 break;
3052 case Token::IN: 3053 case Token::IN:
3053 case Token::INSTANCEOF: 3054 case Token::INSTANCEOF:
3054 default: 3055 default:
3055 UNREACHABLE(); 3056 UNREACHABLE();
3056 } 3057 }
3057 3058
3058 // The comparison stub expects the smi vs. smi case to be handled 3059 if (ShouldInlineSmiCase(op)) {
3059 // before it is called. 3060 Label slow_case;
3060 Label slow_case; 3061 __ orr(r2, r0, Operand(r1));
3061 __ orr(r2, r0, Operand(r1)); 3062 __ BranchOnNotSmi(r2, &slow_case);
3062 __ BranchOnNotSmi(r2, &slow_case); 3063 __ cmp(r1, r0);
3063 __ cmp(r1, r0); 3064 Split(cc, if_true, if_false, NULL);
3064 __ b(cc, if_true); 3065 __ bind(&slow_case);
3065 __ jmp(if_false); 3066 }
3066 3067
3067 __ bind(&slow_case);
3068 CompareStub stub(cc, strict, kBothCouldBeNaN, true, r1, r0); 3068 CompareStub stub(cc, strict, kBothCouldBeNaN, true, r1, r0);
3069 __ CallStub(&stub); 3069 __ CallStub(&stub);
3070 __ cmp(r0, Operand(0)); 3070 __ cmp(r0, Operand(0));
3071 Split(cc, if_true, if_false, fall_through); 3071 Split(cc, if_true, if_false, fall_through);
3072 } 3072 }
3073 } 3073 }
3074 3074
3075 // Convert the result of the comparison into one expected for this 3075 // Convert the result of the comparison into one expected for this
3076 // expression's context. 3076 // expression's context.
3077 Apply(context_, if_true, if_false); 3077 Apply(context_, if_true, if_false);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3159 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 3159 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
3160 __ add(pc, r1, Operand(masm_->CodeObject())); 3160 __ add(pc, r1, Operand(masm_->CodeObject()));
3161 } 3161 }
3162 3162
3163 3163
3164 #undef __ 3164 #undef __
3165 3165
3166 } } // namespace v8::internal 3166 } } // namespace v8::internal
3167 3167
3168 #endif // V8_TARGET_ARCH_ARM 3168 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698