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

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

Issue 536029: Fix a problem with const initialization in the top-level 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
« no previous file with comments | « src/compiler.cc ('k') | src/ia32/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 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 282
283 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { 283 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) {
284 Comment cmnt(masm_, "[ EmptyStatement"); 284 Comment cmnt(masm_, "[ EmptyStatement");
285 SetStatementPosition(stmt); 285 SetStatementPosition(stmt);
286 } 286 }
287 287
288 288
289 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { 289 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) {
290 Comment cmnt(masm_, "[ IfStatement"); 290 Comment cmnt(masm_, "[ IfStatement");
291 SetStatementPosition(stmt);
291 // Expressions cannot recursively enter statements, there are no labels in 292 // Expressions cannot recursively enter statements, there are no labels in
292 // the state. 293 // the state.
293 ASSERT_EQ(NULL, true_label_); 294 ASSERT_EQ(NULL, true_label_);
294 ASSERT_EQ(NULL, false_label_); 295 ASSERT_EQ(NULL, false_label_);
295 Label then_part, else_part, done; 296 Label then_part, else_part, done;
296 297
297 // Do not worry about optimizing for empty then or else bodies. 298 // Do not worry about optimizing for empty then or else bodies.
298 true_label_ = &then_part; 299 true_label_ = &then_part;
299 false_label_ = &else_part; 300 false_label_ = &else_part;
300 ASSERT(stmt->condition()->context() == Expression::kTest); 301 ASSERT(stmt->condition()->context() == Expression::kTest);
301 Visit(stmt->condition()); 302 Visit(stmt->condition());
302 true_label_ = NULL; 303 true_label_ = NULL;
303 false_label_ = NULL; 304 false_label_ = NULL;
304 305
305 __ bind(&then_part); 306 __ bind(&then_part);
306 Visit(stmt->then_statement()); 307 Visit(stmt->then_statement());
307 __ jmp(&done); 308 __ jmp(&done);
308 309
309 __ bind(&else_part); 310 __ bind(&else_part);
310 Visit(stmt->else_statement()); 311 Visit(stmt->else_statement());
311 312
312 __ bind(&done); 313 __ bind(&done);
313 } 314 }
314 315
315 316
316 void FastCodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { 317 void FastCodeGenerator::VisitContinueStatement(ContinueStatement* stmt) {
317 Comment cmnt(masm_, "[ ContinueStatement"); 318 Comment cmnt(masm_, "[ ContinueStatement");
319 SetStatementPosition(stmt);
318 NestedStatement* current = nesting_stack_; 320 NestedStatement* current = nesting_stack_;
319 int stack_depth = 0; 321 int stack_depth = 0;
320 while (!current->IsContinueTarget(stmt->target())) { 322 while (!current->IsContinueTarget(stmt->target())) {
321 stack_depth = current->Exit(stack_depth); 323 stack_depth = current->Exit(stack_depth);
322 current = current->outer(); 324 current = current->outer();
323 } 325 }
324 __ Drop(stack_depth); 326 __ Drop(stack_depth);
325 327
326 Iteration* loop = current->AsIteration(); 328 Iteration* loop = current->AsIteration();
327 __ jmp(loop->continue_target()); 329 __ jmp(loop->continue_target());
328 } 330 }
329 331
330 332
331 void FastCodeGenerator::VisitBreakStatement(BreakStatement* stmt) { 333 void FastCodeGenerator::VisitBreakStatement(BreakStatement* stmt) {
332 Comment cmnt(masm_, "[ BreakStatement"); 334 Comment cmnt(masm_, "[ BreakStatement");
335 SetStatementPosition(stmt);
333 NestedStatement* current = nesting_stack_; 336 NestedStatement* current = nesting_stack_;
334 int stack_depth = 0; 337 int stack_depth = 0;
335 while (!current->IsBreakTarget(stmt->target())) { 338 while (!current->IsBreakTarget(stmt->target())) {
336 stack_depth = current->Exit(stack_depth); 339 stack_depth = current->Exit(stack_depth);
337 current = current->outer(); 340 current = current->outer();
338 } 341 }
339 __ Drop(stack_depth); 342 __ Drop(stack_depth);
340 343
341 Breakable* target = current->AsBreakable(); 344 Breakable* target = current->AsBreakable();
342 __ jmp(target->break_target()); 345 __ jmp(target->break_target());
343 } 346 }
344 347
345 348
346 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { 349 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
347 Comment cmnt(masm_, "[ ReturnStatement"); 350 Comment cmnt(masm_, "[ ReturnStatement");
351 SetStatementPosition(stmt);
348 Expression* expr = stmt->expression(); 352 Expression* expr = stmt->expression();
349 // Complete the statement based on the type of the subexpression. 353 // Complete the statement based on the type of the subexpression.
350 if (expr->AsLiteral() != NULL) { 354 if (expr->AsLiteral() != NULL) {
351 __ Move(result_register(), expr->AsLiteral()->handle()); 355 __ Move(result_register(), expr->AsLiteral()->handle());
352 } else { 356 } else {
353 ASSERT_EQ(Expression::kValue, expr->context()); 357 ASSERT_EQ(Expression::kValue, expr->context());
354 Visit(expr); 358 Visit(expr);
355 __ pop(result_register()); 359 __ pop(result_register());
356 } 360 }
357 361
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 403 }
400 404
401 405
402 void FastCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { 406 void FastCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
403 UNREACHABLE(); 407 UNREACHABLE();
404 } 408 }
405 409
406 410
407 void FastCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { 411 void FastCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) {
408 Comment cmnt(masm_, "[ DoWhileStatement"); 412 Comment cmnt(masm_, "[ DoWhileStatement");
413 SetStatementPosition(stmt);
409 Label body, stack_limit_hit, stack_check_success; 414 Label body, stack_limit_hit, stack_check_success;
410 415
411 Iteration loop_statement(this, stmt); 416 Iteration loop_statement(this, stmt);
412 increment_loop_depth(); 417 increment_loop_depth();
413 418
414 __ bind(&body); 419 __ bind(&body);
415 Visit(stmt->body()); 420 Visit(stmt->body());
416 421
417 // Check stack before looping. 422 // Check stack before looping.
418 __ StackLimitCheck(&stack_limit_hit); 423 __ StackLimitCheck(&stack_limit_hit);
(...skipping 17 matching lines...) Expand all
436 __ jmp(&stack_check_success); 441 __ jmp(&stack_check_success);
437 442
438 __ bind(loop_statement.break_target()); 443 __ bind(loop_statement.break_target());
439 444
440 decrement_loop_depth(); 445 decrement_loop_depth();
441 } 446 }
442 447
443 448
444 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { 449 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) {
445 Comment cmnt(masm_, "[ WhileStatement"); 450 Comment cmnt(masm_, "[ WhileStatement");
451 SetStatementPosition(stmt);
446 Label body, stack_limit_hit, stack_check_success; 452 Label body, stack_limit_hit, stack_check_success;
447 453
448 Iteration loop_statement(this, stmt); 454 Iteration loop_statement(this, stmt);
449 increment_loop_depth(); 455 increment_loop_depth();
450 456
451 // Emit the test at the bottom of the loop. 457 // Emit the test at the bottom of the loop.
452 __ jmp(loop_statement.continue_target()); 458 __ jmp(loop_statement.continue_target());
453 459
454 __ bind(&body); 460 __ bind(&body);
455 Visit(stmt->body()); 461 Visit(stmt->body());
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 __ Drop(stack_depth); 788 __ Drop(stack_depth);
783 __ PopTryHandler(); 789 __ PopTryHandler();
784 return 0; 790 return 0;
785 } 791 }
786 792
787 793
788 #undef __ 794 #undef __
789 795
790 796
791 } } // namespace v8::internal 797 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698