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

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

Issue 354024: Emitting the common return sequence in the top-level compiler in one function... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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/fast-codegen.h » ('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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ASSERT(loop_depth() == 0); 95 ASSERT(loop_depth() == 0);
96 VisitStatements(fun->body()); 96 VisitStatements(fun->body());
97 ASSERT(loop_depth() == 0); 97 ASSERT(loop_depth() == 0);
98 } 98 }
99 99
100 { Comment cmnt(masm_, "[ return <undefined>;"); 100 { Comment cmnt(masm_, "[ return <undefined>;");
101 // Emit a 'return undefined' in case control fell off the end of the 101 // Emit a 'return undefined' in case control fell off the end of the
102 // body. 102 // body.
103 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); 103 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
104 } 104 }
105 { Comment cmnt(masm_, "Return sequence"); 105 EmitReturnSequence(function_->end_position());
106 if (return_label_.is_bound()) {
107 __ b(&return_label_);
108 } else {
109 __ bind(&return_label_);
110 SetReturnPosition(fun);
111 if (FLAG_trace) {
112 // Push the return value on the stack as the parameter.
113 // Runtime::TraceExit returns its parameter in r0.
114 __ push(r0);
115 __ CallRuntime(Runtime::kTraceExit, 1);
116 }
117 __ RecordJSReturn();
118 __ mov(sp, fp);
119 __ ldm(ia_w, sp, fp.bit() | lr.bit());
120 int num_parameters = function_->scope()->num_parameters();
121 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize));
122 __ Jump(lr);
123 }
124 }
125 } 106 }
126 107
127 108
109 void FastCodeGenerator::EmitReturnSequence(int position) {
110 Comment cmnt(masm_, "[ Return sequence");
111 if (return_label_.is_bound()) {
112 __ b(&return_label_);
113 } else {
114 __ bind(&return_label_);
115 if (FLAG_trace) {
116 // Push the return value on the stack as the parameter.
117 // Runtime::TraceExit returns its parameter in r0.
118 __ push(r0);
119 __ CallRuntime(Runtime::kTraceExit, 1);
120 }
121 #ifdef DEBUG
122 // Add a label for checking the size of the code used for returning.
123 Label check_exit_codesize;
124 masm_->bind(&check_exit_codesize);
125 #endif
126 CodeGenerator::RecordPositions(masm_, position);
127 __ RecordJSReturn();
128 __ mov(sp, fp);
129 __ ldm(ia_w, sp, fp.bit() | lr.bit());
130 int num_parameters = function_->scope()->num_parameters();
131 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize));
132 __ Jump(lr);
133 }
134 #ifdef DEBUG
135 // Check that the size of the code used for returning matches what is
136 // expected by the debugger. The add instruction above is an addressing
137 // mode 1 instruction where there are restrictions on which immediate values
138 // can be encoded in the instruction and which immediate values requires
139 // use of an additional instruction for moving the immediate to a temporary
140 // register.
141 int expected_return_sequence_length = CodeGenerator::kJSReturnSequenceLength;
142 if (!masm_->ImmediateFitsAddrMode1Instruction((num_parameters + 1) *
143 kPointerSize)) {
144 // Additional mov instruction generated.
145 expected_return_sequence_length++;
146 }
147 ASSERT_EQ(expected_return_sequence_length,
148 masm_->InstructionsGeneratedSince(&check_exit_codesize));
149 #endif
150 }
151
152
128 void FastCodeGenerator::Move(Expression::Context context, Register source) { 153 void FastCodeGenerator::Move(Expression::Context context, Register source) {
129 switch (context) { 154 switch (context) {
130 case Expression::kUninitialized: 155 case Expression::kUninitialized:
131 UNREACHABLE(); 156 UNREACHABLE();
132 case Expression::kEffect: 157 case Expression::kEffect:
133 break; 158 break;
134 case Expression::kValue: 159 case Expression::kValue:
135 __ push(source); 160 __ push(source);
136 break; 161 break;
137 case Expression::kTest: 162 case Expression::kTest:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 __ mov(r1, Operand(pairs)); 277 __ mov(r1, Operand(pairs));
253 __ mov(r0, Operand(Smi::FromInt(is_eval_ ? 1 : 0))); 278 __ mov(r0, Operand(Smi::FromInt(is_eval_ ? 1 : 0)));
254 __ stm(db_w, sp, cp.bit() | r1.bit() | r0.bit()); 279 __ stm(db_w, sp, cp.bit() | r1.bit() | r0.bit());
255 __ CallRuntime(Runtime::kDeclareGlobals, 3); 280 __ CallRuntime(Runtime::kDeclareGlobals, 3);
256 // Return value is ignored. 281 // Return value is ignored.
257 } 282 }
258 283
259 284
260 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { 285 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
261 Comment cmnt(masm_, "[ ReturnStatement"); 286 Comment cmnt(masm_, "[ ReturnStatement");
262 SetStatementPosition(stmt);
263 Expression* expr = stmt->expression(); 287 Expression* expr = stmt->expression();
264 // Complete the statement based on the type of the subexpression. 288 // Complete the statement based on the type of the subexpression.
265 if (expr->AsLiteral() != NULL) { 289 if (expr->AsLiteral() != NULL) {
266 __ mov(r0, Operand(expr->AsLiteral()->handle())); 290 __ mov(r0, Operand(expr->AsLiteral()->handle()));
267 } else { 291 } else {
268 ASSERT_EQ(Expression::kValue, expr->context()); 292 ASSERT_EQ(Expression::kValue, expr->context());
269 Visit(expr); 293 Visit(expr);
270 __ pop(r0); 294 __ pop(r0);
271 } 295 }
272 if (return_label_.is_bound()) { 296 EmitReturnSequence(stmt->statement_pos());
273 __ b(&return_label_);
274 } else {
275 __ bind(&return_label_);
276 if (FLAG_trace) {
277 __ push(r0);
278 __ CallRuntime(Runtime::kTraceExit, 1);
279 }
280 __ RecordJSReturn();
281 __ mov(sp, fp);
282 __ ldm(ia_w, sp, fp.bit() | lr.bit());
283 int num_parameters = function_->scope()->num_parameters();
284 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize));
285 __ Jump(lr);
286 }
287 } 297 }
288 298
289 299
290 void FastCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 300 void FastCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
291 Comment cmnt(masm_, "[ FunctionLiteral"); 301 Comment cmnt(masm_, "[ FunctionLiteral");
292 302
293 // Build the function boilerplate and instantiate it. 303 // Build the function boilerplate and instantiate it.
294 Handle<JSFunction> boilerplate = BuildBoilerplate(expr); 304 Handle<JSFunction> boilerplate = BuildBoilerplate(expr);
295 if (HasStackOverflow()) return; 305 if (HasStackOverflow()) return;
296 306
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 true_label_ = saved_true; 1287 true_label_ = saved_true;
1278 false_label_ = saved_false; 1288 false_label_ = saved_false;
1279 // Convert current context to test context: End post-test code. 1289 // Convert current context to test context: End post-test code.
1280 } 1290 }
1281 1291
1282 1292
1283 #undef __ 1293 #undef __
1284 1294
1285 1295
1286 } } // namespace v8::internal 1296 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/fast-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698