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

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

Issue 341081: Begin using the top-level code generator for code that is inside... (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
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 break; 68 break;
69 default: 69 default:
70 UNREACHABLE(); 70 UNREACHABLE();
71 } 71 }
72 return offset; 72 return offset;
73 } 73 }
74 74
75 75
76 void FastCodeGenerator::VisitDeclarations( 76 void FastCodeGenerator::VisitDeclarations(
77 ZoneList<Declaration*>* declarations) { 77 ZoneList<Declaration*>* declarations) {
78 Comment cmnt(masm_, "[ Declarations");
78 int length = declarations->length(); 79 int length = declarations->length();
79 int globals = 0; 80 int globals = 0;
80 for (int i = 0; i < length; i++) { 81 for (int i = 0; i < length; i++) {
81 Declaration* node = declarations->at(i); 82 Declaration* node = declarations->at(i);
82 Variable* var = node->proxy()->var(); 83 Variable* var = node->proxy()->var();
83 Slot* slot = var->slot(); 84 Slot* slot = var->slot();
84 85
85 // If it was not possible to allocate the variable at compile 86 // If it was not possible to allocate the variable at compile
86 // time, we need to "declare" it at runtime to make sure it 87 // time, we need to "declare" it at runtime to make sure it
87 // actually exists in the local context. 88 // actually exists in the local context.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 283 }
283 284
284 285
285 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { 286 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) {
286 Comment cmnt(masm_, "[ EmptyStatement"); 287 Comment cmnt(masm_, "[ EmptyStatement");
287 SetStatementPosition(stmt); 288 SetStatementPosition(stmt);
288 } 289 }
289 290
290 291
291 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { 292 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) {
293 Comment cmnt(masm_, "[ IfStatement");
292 // Expressions cannot recursively enter statements, there are no labels in 294 // Expressions cannot recursively enter statements, there are no labels in
293 // the state. 295 // the state.
294 ASSERT_EQ(NULL, true_label_); 296 ASSERT_EQ(NULL, true_label_);
295 ASSERT_EQ(NULL, false_label_); 297 ASSERT_EQ(NULL, false_label_);
296 Label then_part, else_part, done; 298 Label then_part, else_part, done;
297 299
298 // Do not worry about optimizing for empty then or else bodies. 300 // Do not worry about optimizing for empty then or else bodies.
299 true_label_ = &then_part; 301 true_label_ = &then_part;
300 false_label_ = &else_part; 302 false_label_ = &else_part;
301 ASSERT(stmt->condition()->context() == Expression::kTest); 303 ASSERT(stmt->condition()->context() == Expression::kTest);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 UNREACHABLE(); 345 UNREACHABLE();
344 } 346 }
345 347
346 348
347 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { 349 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) {
348 UNREACHABLE(); 350 UNREACHABLE();
349 } 351 }
350 352
351 353
352 void FastCodeGenerator::VisitForStatement(ForStatement* stmt) { 354 void FastCodeGenerator::VisitForStatement(ForStatement* stmt) {
355 Comment cmnt(masm_, "[ ForStatement");
353 Label test, body, exit; 356 Label test, body, exit;
354 if (stmt->init() != NULL) Visit(stmt->init()); 357 if (stmt->init() != NULL) Visit(stmt->init());
355 358
359 increment_loop_depth();
Søren Thygesen Gjesse 2009/11/03 13:57:47 How placing the increment_loop_depth()/decrement_l
Kevin Millikin (Chromium) 2009/11/03 14:16:09 I thought about that, but it seemed too complicate
356 // Emit the test at the bottom of the loop (even if empty). 360 // Emit the test at the bottom of the loop (even if empty).
357 __ jmp(&test); 361 __ jmp(&test);
358 __ bind(&body); 362 __ bind(&body);
359 Visit(stmt->body()); 363 Visit(stmt->body());
360 if (stmt->next() != NULL) Visit(stmt->next()); 364 if (stmt->next() != NULL) Visit(stmt->next());
361 365
362 __ bind(&test); 366 __ bind(&test);
363 if (stmt->cond() == NULL) { 367 if (stmt->cond() == NULL) {
364 // For an empty test jump to the top of the loop. 368 // For an empty test jump to the top of the loop.
365 __ jmp(&body); 369 __ jmp(&body);
366 } else { 370 } else {
367 // We are not in an expression context because we have been compiling 371 // We are not in an expression context because we have been compiling
368 // statements. Set up a test expression context for the condition. 372 // statements. Set up a test expression context for the condition.
369 ASSERT_EQ(NULL, true_label_); 373 ASSERT_EQ(NULL, true_label_);
370 ASSERT_EQ(NULL, false_label_); 374 ASSERT_EQ(NULL, false_label_);
371 true_label_ = &body; 375 true_label_ = &body;
372 false_label_ = &exit; 376 false_label_ = &exit;
373 ASSERT(stmt->cond()->context() == Expression::kTest); 377 ASSERT(stmt->cond()->context() == Expression::kTest);
374 Visit(stmt->cond()); 378 Visit(stmt->cond());
375 true_label_ = NULL; 379 true_label_ = NULL;
376 false_label_ = NULL; 380 false_label_ = NULL;
377 } 381 }
378 382
379 __ bind(&exit); 383 __ bind(&exit);
384 decrement_loop_depth();
380 } 385 }
381 386
382 387
383 void FastCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 388 void FastCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
384 UNREACHABLE(); 389 UNREACHABLE();
385 } 390 }
386 391
387 392
388 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { 393 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
389 UNREACHABLE(); 394 UNREACHABLE();
(...skipping 10 matching lines...) Expand all
400 } 405 }
401 406
402 407
403 void FastCodeGenerator::VisitFunctionBoilerplateLiteral( 408 void FastCodeGenerator::VisitFunctionBoilerplateLiteral(
404 FunctionBoilerplateLiteral* expr) { 409 FunctionBoilerplateLiteral* expr) {
405 UNREACHABLE(); 410 UNREACHABLE();
406 } 411 }
407 412
408 413
409 void FastCodeGenerator::VisitConditional(Conditional* expr) { 414 void FastCodeGenerator::VisitConditional(Conditional* expr) {
415 Comment cmnt(masm_, "[ Conditional");
410 ASSERT_EQ(Expression::kTest, expr->condition()->context()); 416 ASSERT_EQ(Expression::kTest, expr->condition()->context());
411 ASSERT_EQ(expr->context(), expr->then_expression()->context()); 417 ASSERT_EQ(expr->context(), expr->then_expression()->context());
412 ASSERT_EQ(expr->context(), expr->else_expression()->context()); 418 ASSERT_EQ(expr->context(), expr->else_expression()->context());
413 419
414 420
415 Label true_case, false_case, done; 421 Label true_case, false_case, done;
416 Label* saved_true = true_label_; 422 Label* saved_true = true_label_;
417 Label* saved_false = false_label_; 423 Label* saved_false = false_label_;
418 424
419 true_label_ = &true_case; 425 true_label_ = &true_case;
(...skipping 20 matching lines...) Expand all
440 } 446 }
441 447
442 448
443 void FastCodeGenerator::VisitSlot(Slot* expr) { 449 void FastCodeGenerator::VisitSlot(Slot* expr) {
444 // Slots do not appear directly in the AST. 450 // Slots do not appear directly in the AST.
445 UNREACHABLE(); 451 UNREACHABLE();
446 } 452 }
447 453
448 454
449 void FastCodeGenerator::VisitLiteral(Literal* expr) { 455 void FastCodeGenerator::VisitLiteral(Literal* expr) {
456 Comment cmnt(masm_, "[ Literal");
450 Move(expr->context(), expr); 457 Move(expr->context(), expr);
451 } 458 }
452 459
453 460
454 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 461 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
455 Comment cmnt(masm_, "[ Assignment"); 462 Comment cmnt(masm_, "[ Assignment");
456 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); 463 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
457 464
458 // Record source code position of the (possible) IC call. 465 // Record source code position of the (possible) IC call.
459 SetSourcePosition(expr->position()); 466 SetSourcePosition(expr->position());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 510
504 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 511 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
505 UNREACHABLE(); 512 UNREACHABLE();
506 } 513 }
507 514
508 515
509 #undef __ 516 #undef __
510 517
511 518
512 } } // namespace v8::internal 519 } } // namespace v8::internal
OLDNEW
« src/ast.h ('K') | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698