Chromium Code Reviews| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 UNREACHABLE(); | 482 UNREACHABLE(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 | 485 |
| 486 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { | 486 void FastCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 487 UNREACHABLE(); | 487 UNREACHABLE(); |
| 488 } | 488 } |
| 489 | 489 |
| 490 | 490 |
| 491 void FastCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { | 491 void FastCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
| 492 UNREACHABLE(); | 492 // The try-finally construct can enter the finally block in three ways: |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
Consider some judicious code generator comments, t
| |
| 493 // 1. By exiting the try-block normally, | |
| 494 // 2. by exiting the try-block with a function-local control flow transfer | |
| 495 // (break/continue/return), or | |
| 496 // 3. by exiting the try-block with a thrown exception. | |
| 497 // | |
| 498 // Normal exit and local control flow removes the try-handler before calling | |
| 499 // the fially block through finally_entry label. | |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
"fially" ==> "finally"
Lasse Reichstein
2009/12/16 08:43:30
Fixed
| |
| 500 // Throwing an exception follows the try-handler chain, which consumes | |
| 501 // the try handler, and then enters the finally block through the | |
| 502 // finally_entry label. | |
| 503 // The finally block must assume a return address on top of the stack | |
| 504 // and a value in the result register (rax/eax/r0), both of which must | |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
Probably should note that the value may be the ret
Lasse Reichstein
2009/12/16 08:43:30
Done
| |
| 505 // be preserved. The return address isn't GC-safe, so it should be | |
| 506 // cooked before GC. | |
| 507 Label finally_entry; | |
| 508 Label try_handler_setup; | |
| 509 | |
| 510 // Jump to try-handler setup and try-block code. Use call to put try-handler | |
| 511 // address on stack. | |
| 512 __ Call(&try_handler_setup); | |
| 513 | |
| 514 // This code is only executed during stack-handler traversal when an | |
| 515 // exception is thrown. | |
| 516 // Call the finally block and then rethrow the exception. | |
| 517 __ Call(&finally_entry); | |
| 518 ThrowException(); | |
| 519 | |
| 520 { | |
| 521 // Finally block implementation. | |
| 522 __ bind(&finally_entry); | |
| 523 Finally finally_block(this); | |
| 524 EnterFinallyBlock(); | |
| 525 Visit(stmt->finally_block()); | |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
Isn't it OK to VisitStatements the body of this bl
Lasse Reichstein
2009/12/16 08:43:30
It should be ok (you can't label the blocks, so th
| |
| 526 ReturnFromFinallyBlock(); // Performs a return to the calling code. | |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
Can we call this ExitFinallyBlock, to parallel Ent
Lasse Reichstein
2009/12/16 08:43:30
Fixed.
(The point was that it actually did a retur
| |
| 527 } | |
| 528 | |
| 529 __ bind(&try_handler_setup); | |
| 530 { | |
| 531 // Setup try handler (stack pointer registers). | |
| 532 __ PushTryHandler(IN_JAVASCRIPT, TRY_FINALLY_HANDLER); | |
|
Kevin Millikin (Chromium)
2009/12/10 13:51:12
It seems nicer to properly nest the Push/Pop of th
Lasse Reichstein
2009/12/16 08:43:30
Done
| |
| 533 TryFinally try_block(this, &finally_entry); | |
| 534 VisitStatements(stmt->try_block()->statements()); | |
| 535 __ PopTryHandler(); | |
| 536 } | |
| 537 // Execute the finally block on the way out. | |
| 538 __ Call(&finally_entry); | |
| 493 } | 539 } |
| 494 | 540 |
| 495 | 541 |
| 496 void FastCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { | 542 void FastCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { |
| 497 #ifdef ENABLE_DEBUGGER_SUPPORT | 543 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 498 Comment cmnt(masm_, "[ DebuggerStatement"); | 544 Comment cmnt(masm_, "[ DebuggerStatement"); |
| 499 SetStatementPosition(stmt); | 545 SetStatementPosition(stmt); |
| 500 __ CallRuntime(Runtime::kDebugBreak, 0); | 546 __ CallRuntime(Runtime::kDebugBreak, 0); |
| 501 // Ignore the return value. | 547 // Ignore the return value. |
| 502 #endif | 548 #endif |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 } | 666 } |
| 621 | 667 |
| 622 | 668 |
| 623 int FastCodeGenerator::TryCatch::Exit(int stack_depth) { | 669 int FastCodeGenerator::TryCatch::Exit(int stack_depth) { |
| 624 __ Drop(stack_depth); | 670 __ Drop(stack_depth); |
| 625 __ PopTryHandler(); | 671 __ PopTryHandler(); |
| 626 return 0; | 672 return 0; |
| 627 } | 673 } |
| 628 | 674 |
| 629 | 675 |
| 676 int FastCodeGenerator::TryFinally::Exit(int stack_depth) { | |
| 677 __ Drop(stack_depth); | |
| 678 __ PopTryHandler(); | |
| 679 __ Call(finally_entry_); | |
| 680 return 0; | |
| 681 } | |
| 682 | |
| 683 | |
| 684 int FastCodeGenerator::TryCatch::Exit(int stack_depth) { | |
| 685 __ Drop(stack_depth); | |
| 686 __ PopTryHandler(); | |
| 687 return 0; | |
| 688 } | |
| 689 | |
| 690 | |
| 630 #undef __ | 691 #undef __ |
| 631 | 692 |
| 632 | 693 |
| 633 } } // namespace v8::internal | 694 } } // namespace v8::internal |
| OLD | NEW |