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

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

Issue 546006: Some cleanup of the toplevel code generator:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 offset += JavaScriptFrameConstants::kLocal0Offset; 68 offset += JavaScriptFrameConstants::kLocal0Offset;
69 break; 69 break;
70 case Slot::CONTEXT: 70 case Slot::CONTEXT:
71 case Slot::LOOKUP: 71 case Slot::LOOKUP:
72 UNREACHABLE(); 72 UNREACHABLE();
73 } 73 }
74 return offset; 74 return offset;
75 } 75 }
76 76
77 77
78 void FastCodeGenerator::Apply(Expression::Context context, Register reg) {
79 switch (context) {
80 case Expression::kUninitialized:
81 UNREACHABLE();
82 case Expression::kEffect:
83 break;
84 case Expression::kValue:
85 __ push(reg);
86 break;
87 case Expression::kTest:
88 TestAndBranch(reg, true_label_, false_label_);
89 break;
90 case Expression::kValueTest: {
91 Label discard;
92 __ push(reg);
93 TestAndBranch(reg, true_label_, &discard);
94 __ bind(&discard);
95 __ Drop(1);
96 __ jmp(false_label_);
97 break;
98 }
99 case Expression::kTestValue: {
100 Label discard;
101 __ push(reg);
102 TestAndBranch(reg, &discard, false_label_);
103 __ bind(&discard);
104 __ Drop(1);
105 __ jmp(true_label_);
106 }
107 }
108 }
109
110
78 void FastCodeGenerator::VisitDeclarations( 111 void FastCodeGenerator::VisitDeclarations(
79 ZoneList<Declaration*>* declarations) { 112 ZoneList<Declaration*>* declarations) {
80 int length = declarations->length(); 113 int length = declarations->length();
81 int globals = 0; 114 int globals = 0;
82 for (int i = 0; i < length; i++) { 115 for (int i = 0; i < length; i++) {
83 Declaration* decl = declarations->at(i); 116 Declaration* decl = declarations->at(i);
84 Variable* var = decl->proxy()->var(); 117 Variable* var = decl->proxy()->var();
85 Slot* slot = var->slot(); 118 Slot* slot = var->slot();
86 119
87 // If it was not possible to allocate the variable at compile 120 // If it was not possible to allocate the variable at compile
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 650
618 651
619 void FastCodeGenerator::VisitSlot(Slot* expr) { 652 void FastCodeGenerator::VisitSlot(Slot* expr) {
620 // Slots do not appear directly in the AST. 653 // Slots do not appear directly in the AST.
621 UNREACHABLE(); 654 UNREACHABLE();
622 } 655 }
623 656
624 657
625 void FastCodeGenerator::VisitLiteral(Literal* expr) { 658 void FastCodeGenerator::VisitLiteral(Literal* expr) {
626 Comment cmnt(masm_, "[ Literal"); 659 Comment cmnt(masm_, "[ Literal");
627 Move(expr->context(), expr); 660 Apply(expr->context(), expr);
628 } 661 }
629 662
630 663
631 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 664 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
632 Comment cmnt(masm_, "[ Assignment"); 665 Comment cmnt(masm_, "[ Assignment");
633 666
634 // Record source code position of the (possible) IC call. 667 // Record source code position of the (possible) IC call.
635 SetSourcePosition(expr->position()); 668 SetSourcePosition(expr->position());
636 669
637 // Left-hand side can only be a property, a global or a (parameter or local) 670 // Left-hand side can only be a property, a global or a (parameter or local)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 __ Drop(stack_depth); 782 __ Drop(stack_depth);
750 __ PopTryHandler(); 783 __ PopTryHandler();
751 return 0; 784 return 0;
752 } 785 }
753 786
754 787
755 #undef __ 788 #undef __
756 789
757 790
758 } } // namespace v8::internal 791 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698