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

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

Issue 6286144: Do not compile the unreachable body of functions with illegal redeclarations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 9 years, 10 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/scopes.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // The stub will rewrite receiver and parameter count if the previous 199 // The stub will rewrite receiver and parameter count if the previous
200 // stack frame was an arguments adapter frame. 200 // stack frame was an arguments adapter frame.
201 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT); 201 ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT);
202 __ CallStub(&stub); 202 __ CallStub(&stub);
203 __ mov(ecx, eax); // Duplicate result. 203 __ mov(ecx, eax); // Duplicate result.
204 Move(arguments->AsSlot(), eax, ebx, edx); 204 Move(arguments->AsSlot(), eax, ebx, edx);
205 Slot* dot_arguments_slot = scope()->arguments_shadow()->AsSlot(); 205 Slot* dot_arguments_slot = scope()->arguments_shadow()->AsSlot();
206 Move(dot_arguments_slot, ecx, ebx, edx); 206 Move(dot_arguments_slot, ecx, ebx, edx);
207 } 207 }
208 208
209 { Comment cmnt(masm_, "[ Declarations");
210 // For named function expressions, declare the function name as a
211 // constant.
212 if (scope()->is_function_scope() && scope()->function() != NULL) {
213 EmitDeclaration(scope()->function(), Variable::CONST, NULL);
214 }
215 // Visit all the explicit declarations unless there is an illegal
216 // redeclaration.
217 if (scope()->HasIllegalRedeclaration()) {
218 scope()->VisitIllegalRedeclaration(this);
219 } else {
220 VisitDeclarations(scope()->declarations());
221 }
222 }
223
224 if (FLAG_trace) { 209 if (FLAG_trace) {
225 __ CallRuntime(Runtime::kTraceEnter, 0); 210 __ CallRuntime(Runtime::kTraceEnter, 0);
226 } 211 }
227 212
228 { Comment cmnt(masm_, "[ Stack check"); 213 // Visit the declarations and body unless there is an illegal
229 PrepareForBailout(info->function(), NO_REGISTERS); 214 // redeclaration.
230 NearLabel ok; 215 if (scope()->HasIllegalRedeclaration()) {
231 ExternalReference stack_limit = 216 Comment cmnt(masm_, "[ Declarations");
232 ExternalReference::address_of_stack_limit(); 217 scope()->VisitIllegalRedeclaration(this);
233 __ cmp(esp, Operand::StaticVariable(stack_limit)); 218
234 __ j(above_equal, &ok, taken); 219 } else {
235 StackCheckStub stub; 220 { Comment cmnt(masm_, "[ Declarations");
236 __ CallStub(&stub); 221 // For named function expressions, declare the function name as a
237 __ bind(&ok); 222 // constant.
223 if (scope()->is_function_scope() && scope()->function() != NULL) {
224 EmitDeclaration(scope()->function(), Variable::CONST, NULL);
225 }
226 VisitDeclarations(scope()->declarations());
227 }
228
229 { Comment cmnt(masm_, "[ Stack check");
230 PrepareForBailout(info->function(), NO_REGISTERS);
231 NearLabel ok;
232 ExternalReference stack_limit =
233 ExternalReference::address_of_stack_limit();
234 __ cmp(esp, Operand::StaticVariable(stack_limit));
235 __ j(above_equal, &ok, taken);
236 StackCheckStub stub;
237 __ CallStub(&stub);
238 __ bind(&ok);
239 }
240
241 { Comment cmnt(masm_, "[ Body");
242 ASSERT(loop_depth() == 0);
243 VisitStatements(function()->body());
244 ASSERT(loop_depth() == 0);
245 }
238 } 246 }
239 247
240 { Comment cmnt(masm_, "[ Body"); 248 // Always emit a 'return undefined' in case control fell off the end of
241 ASSERT(loop_depth() == 0); 249 // the body.
242 VisitStatements(function()->body());
243 ASSERT(loop_depth() == 0);
244 }
245
246 { Comment cmnt(masm_, "[ return <undefined>;"); 250 { Comment cmnt(masm_, "[ return <undefined>;");
247 // Emit a 'return undefined' in case control fell off the end of the body.
248 __ mov(eax, Factory::undefined_value()); 251 __ mov(eax, Factory::undefined_value());
249 EmitReturnSequence(); 252 EmitReturnSequence();
250 } 253 }
251 } 254 }
252 255
253 256
254 void FullCodeGenerator::ClearAccumulator() { 257 void FullCodeGenerator::ClearAccumulator() {
255 __ Set(eax, Immediate(Smi::FromInt(0))); 258 __ Set(eax, Immediate(Smi::FromInt(0)));
256 } 259 }
257 260
(...skipping 4132 matching lines...) Expand 10 before | Expand all | Expand 10 after
4390 // And return. 4393 // And return.
4391 __ ret(0); 4394 __ ret(0);
4392 } 4395 }
4393 4396
4394 4397
4395 #undef __ 4398 #undef __
4396 4399
4397 } } // namespace v8::internal 4400 } } // namespace v8::internal
4398 4401
4399 #endif // V8_TARGET_ARCH_IA32 4402 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698