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

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

Issue 2888: Fix http://code.google.com/p/v8/issues/detail?id=69 :... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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/codegen-ia32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 Label next, fall_through, default_case; 2754 Label next, fall_through, default_case;
2755 ZoneList<CaseClause*>* cases = node->cases(); 2755 ZoneList<CaseClause*>* cases = node->cases();
2756 int length = cases->length(); 2756 int length = cases->length();
2757 2757
2758 for (int i = 0; i < length; i++) { 2758 for (int i = 0; i < length; i++) {
2759 CaseClause* clause = cases->at(i); 2759 CaseClause* clause = cases->at(i);
2760 2760
2761 Comment cmnt(masm_, "[ case clause"); 2761 Comment cmnt(masm_, "[ case clause");
2762 2762
2763 if (clause->is_default()) { 2763 if (clause->is_default()) {
2764 // Continue matching cases. The program will execute the default case's
2765 // statements if it does not match any of the cases.
2766 __ b(&next);
2767
2764 // Bind the default case label, so we can branch to it when we 2768 // Bind the default case label, so we can branch to it when we
2765 // have compared against all other cases. 2769 // have compared against all other cases.
2766 ASSERT(default_case.is_unused()); // at most one default clause 2770 ASSERT(default_case.is_unused()); // at most one default clause
2767 2771 __ bind(&default_case);
2768 // If the default case is the first (but not only) case, we have
2769 // to jump past it for now. Once we're done with the remaining
2770 // clauses, we'll branch back here. If it isn't the first case,
2771 // we jump past it by avoiding to chain it into the next chain.
2772 if (length > 1) {
2773 if (i == 0) __ b(&next);
2774 __ bind(&default_case);
2775 }
2776
2777 } else { 2772 } else {
2778 __ bind(&next); 2773 __ bind(&next);
2779 next.Unuse(); 2774 next.Unuse();
2780 __ ldr(r0, MemOperand(sp, 0)); 2775 __ ldr(r0, MemOperand(sp, 0));
2781 __ push(r0); // duplicate TOS 2776 __ push(r0); // duplicate TOS
2782 Load(clause->label()); 2777 Load(clause->label());
2783 Comparison(eq, true); 2778 Comparison(eq, true);
2784 Branch(false, &next); 2779 Branch(false, &next);
2785 // Entering the case statement -> remove the switch value from the stack
2786 __ pop(r0);
2787 } 2780 }
2788 2781
2782 // Entering the case statement for the first time. Remove the switch value
2783 // from the stack.
2784 __ pop(r0);
2785
2789 // Generate code for the body. 2786 // Generate code for the body.
2787 // This is also the target for the fall through from the previous case's
2788 // statements which has to skip over the matching code and the popping of
2789 // the switch value.
2790 __ bind(&fall_through); 2790 __ bind(&fall_through);
2791 fall_through.Unuse(); 2791 fall_through.Unuse();
2792 VisitStatements(clause->statements()); 2792 VisitStatements(clause->statements());
2793 __ b(&fall_through); 2793 __ b(&fall_through);
2794 } 2794 }
2795 2795
2796 __ bind(&next); 2796 __ bind(&next);
2797 // Reached the end of the case statements -> remove the switch value 2797 // Reached the end of the case statements without matching any of the cases.
2798 // from the stack. 2798 if (default_case.is_bound()) {
2799 __ pop(r0); // __ Pop(no_reg) 2799 // A default case exists -> execute its statements.
2800 if (default_case.is_bound()) __ b(&default_case); 2800 __ b(&default_case);
2801 2801 } else {
2802 // Remove the switch value from the stack.
2803 __ pop(r0);
2804 }
2805
2802 __ bind(&fall_through); 2806 __ bind(&fall_through);
2803 __ bind(node->break_target()); 2807 __ bind(node->break_target());
2804 } 2808 }
2805 2809
2806 2810
2807 void ArmCodeGenerator::VisitLoopStatement(LoopStatement* node) { 2811 void ArmCodeGenerator::VisitLoopStatement(LoopStatement* node) {
2808 Comment cmnt(masm_, "[ LoopStatement"); 2812 Comment cmnt(masm_, "[ LoopStatement");
2809 if (FLAG_debug_info) RecordStatementPosition(node); 2813 if (FLAG_debug_info) RecordStatementPosition(node);
2810 node->set_break_stack_height(break_stack_height_); 2814 node->set_break_stack_height(break_stack_height_);
2811 2815
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
4578 bool is_eval) { 4582 bool is_eval) {
4579 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval); 4583 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval);
4580 if (!code.is_null()) { 4584 if (!code.is_null()) {
4581 Counters::total_compiled_code_size.Increment(code->instruction_size()); 4585 Counters::total_compiled_code_size.Increment(code->instruction_size());
4582 } 4586 }
4583 return code; 4587 return code;
4584 } 4588 }
4585 4589
4586 4590
4587 } } // namespace v8::internal 4591 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698