| OLD | NEW |
| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { | 291 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { |
| 292 // Expressions cannot recursively enter statements, there are no labels in | 292 // Expressions cannot recursively enter statements, there are no labels in |
| 293 // the state. | 293 // the state. |
| 294 ASSERT_EQ(NULL, true_label_); | 294 ASSERT_EQ(NULL, true_label_); |
| 295 ASSERT_EQ(NULL, false_label_); | 295 ASSERT_EQ(NULL, false_label_); |
| 296 Label then_part, else_part, done; | 296 Label then_part, else_part, done; |
| 297 | 297 |
| 298 // Do not worry about optimizing for empty then or else bodies. | 298 // Do not worry about optimizing for empty then or else bodies. |
| 299 true_label_ = &then_part; | 299 true_label_ = &then_part; |
| 300 false_label_ = &else_part; | 300 false_label_ = &else_part; |
| 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()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 UNREACHABLE(); | 343 UNREACHABLE(); |
| 343 } | 344 } |
| 344 | 345 |
| 345 | 346 |
| 346 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { | 347 void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { |
| 347 UNREACHABLE(); | 348 UNREACHABLE(); |
| 348 } | 349 } |
| 349 | 350 |
| 350 | 351 |
| 351 void FastCodeGenerator::VisitForStatement(ForStatement* stmt) { | 352 void FastCodeGenerator::VisitForStatement(ForStatement* stmt) { |
| 352 UNREACHABLE(); | 353 Label test, body, exit; |
| 354 if (stmt->init() != NULL) Visit(stmt->init()); |
| 355 |
| 356 // Emit the test at the bottom of the loop (even if empty). |
| 357 __ jmp(&test); |
| 358 __ bind(&body); |
| 359 Visit(stmt->body()); |
| 360 if (stmt->next() != NULL) Visit(stmt->next()); |
| 361 |
| 362 __ bind(&test); |
| 363 if (stmt->cond() == NULL) { |
| 364 // For an empty test jump to the top of the loop. |
| 365 __ jmp(&body); |
| 366 } else { |
| 367 // We are not in an expression context because we have been compiling |
| 368 // statements. Set up a test expression context for the condition. |
| 369 ASSERT_EQ(NULL, true_label_); |
| 370 ASSERT_EQ(NULL, false_label_); |
| 371 true_label_ = &body; |
| 372 false_label_ = &exit; |
| 373 ASSERT(stmt->cond()->context() == Expression::kTest); |
| 374 Visit(stmt->cond()); |
| 375 true_label_ = NULL; |
| 376 false_label_ = NULL; |
| 377 } |
| 378 |
| 379 __ bind(&exit); |
| 353 } | 380 } |
| 354 | 381 |
| 355 | 382 |
| 356 void FastCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 383 void FastCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 357 UNREACHABLE(); | 384 UNREACHABLE(); |
| 358 } | 385 } |
| 359 | 386 |
| 360 | 387 |
| 361 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 388 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 362 UNREACHABLE(); | 389 UNREACHABLE(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 508 |
| 482 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 509 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 483 UNREACHABLE(); | 510 UNREACHABLE(); |
| 484 } | 511 } |
| 485 | 512 |
| 486 | 513 |
| 487 #undef __ | 514 #undef __ |
| 488 | 515 |
| 489 | 516 |
| 490 } } // namespace v8::internal | 517 } } // namespace v8::internal |
| OLD | NEW |