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

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

Issue 300003: Recognize in the fast-mode code generator when a subexpression is a... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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/compiler.cc » ('j') | src/ia32/fast-codegen-ia32.cc » ('J')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { 107 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
108 Comment cmnt(masm_, "[ ExpressionStatement"); 108 Comment cmnt(masm_, "[ ExpressionStatement");
109 SetStatementPosition(stmt); 109 SetStatementPosition(stmt);
110 Visit(stmt->expression()); 110 Visit(stmt->expression());
111 } 111 }
112 112
113 113
114 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { 114 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
115 Comment cmnt(masm_, "[ ReturnStatement"); 115 Comment cmnt(masm_, "[ ReturnStatement");
116 SetStatementPosition(stmt); 116 SetStatementPosition(stmt);
117 Visit(stmt->expression()); 117 Expression* expr = stmt->expression();
118 __ pop(r0); 118 Visit(expr);
119
120 // Complete the statement based on the location of the subexpression.
121 Location source = expr->location();
122 ASSERT(!source.is_nowhere());
123 if (source.is_temporary()) {
124 __ pop(r0);
125 } else {
126 ASSERT(source.is_constant());
127 ASSERT(expr->AsLiteral() != NULL);
128 __ mov(r0, Operand(expr->AsLiteral()->handle()));
129 }
119 __ RecordJSReturn(); 130 __ RecordJSReturn();
120 __ mov(sp, fp); 131 __ mov(sp, fp);
121 __ ldm(ia_w, sp, fp.bit() | lr.bit()); 132 __ ldm(ia_w, sp, fp.bit() | lr.bit());
122 int num_parameters = function_->scope()->num_parameters(); 133 int num_parameters = function_->scope()->num_parameters();
123 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); 134 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize));
124 __ Jump(lr); 135 __ Jump(lr);
125 } 136 }
126 137
127 138
128 void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 139 void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
129 Comment cmnt(masm_, "[ VariableProxy"); 140 Comment cmnt(masm_, "[ VariableProxy");
130 Expression* rewrite = expr->var()->rewrite(); 141 Expression* rewrite = expr->var()->rewrite();
131 ASSERT(rewrite != NULL); 142 ASSERT(rewrite != NULL);
132 143
133 Slot* slot = rewrite->AsSlot(); 144 Slot* slot = rewrite->AsSlot();
134 ASSERT(slot != NULL); 145 ASSERT(slot != NULL);
135 { Comment cmnt(masm_, "[ Slot"); 146 { Comment cmnt(masm_, "[ Slot");
136 if (expr->location().is_temporary()) { 147 if (expr->location().is_temporary()) {
137 __ ldr(ip, MemOperand(fp, SlotOffset(slot))); 148 __ ldr(ip, MemOperand(fp, SlotOffset(slot)));
138 __ push(ip); 149 __ push(ip);
139 } else { 150 } else {
140 ASSERT(expr->location().is_nowhere()); 151 ASSERT(expr->location().is_nowhere());
141 } 152 }
142 } 153 }
143 } 154 }
144 155
145 156
146 void FastCodeGenerator::VisitLiteral(Literal* expr) {
147 Comment cmnt(masm_, "[ Literal");
148 if (expr->location().is_temporary()) {
149 __ mov(ip, Operand(expr->handle()));
150 __ push(ip);
151 } else {
152 ASSERT(expr->location().is_nowhere());
153 }
154 }
155
156
157 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 157 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
158 Comment cmnt(masm_, "[ Assignment"); 158 Comment cmnt(masm_, "[ Assignment");
159 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); 159 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
160 Expression* rhs = expr->value();
161 Visit(rhs);
160 162
161 Visit(expr->value()); 163 // Left-hand side is always a (parameter or local) slot.
162
163 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); 164 Variable* var = expr->target()->AsVariableProxy()->AsVariable();
164 ASSERT(var != NULL && var->slot() != NULL); 165 ASSERT(var != NULL && var->slot() != NULL);
165 166
166 if (expr->location().is_temporary()) { 167 // Complete the assignment based on the location of the right-hand-side
167 __ ldr(ip, MemOperand(sp)); 168 // value and the desired location of the assignment value.
169 Location destination = expr->location();
170 Location source = rhs->location();
171 ASSERT(!destination.is_constant());
172 ASSERT(!source.is_nowhere());
173
174 if (source.is_temporary()) {
175 if (destination.is_temporary()) {
176 // Case 'temp1 <- (var = temp0)'. Preserve right-hand-side temporary
177 // on the stack.
178 __ ldr(ip, MemOperand(sp));
179 } else {
180 ASSERT(destination.is_nowhere());
181 // Case 'var = temp'. Discard right-hand-side temporary.
182 __ pop(ip);
183 }
184 __ str(ip, MemOperand(fp, SlotOffset(var->slot())));
168 } else { 185 } else {
169 ASSERT(expr->location().is_nowhere()); 186 ASSERT(source.is_constant());
170 __ pop(ip); 187 ASSERT(rhs->AsLiteral() != NULL);
188 // Two cases: 'temp <- (var = constant)', or 'var = constant' with a
189 // discarded result. Always perform the assignment.
190 __ mov(ip, Operand(rhs->AsLiteral()->handle()));
191 __ str(ip, MemOperand(fp, SlotOffset(var->slot())));
192 if (destination.is_temporary()) {
193 // Case 'temp <- (var = constant)'. Save result.
194 __ push(ip);
195 }
171 } 196 }
172 __ str(ip, MemOperand(fp, SlotOffset(var->slot())));
173 } 197 }
174 198
175 199
176 } } // namespace v8::internal 200 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/ia32/fast-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698