OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 void FullCodeGenerator::EffectContext::Plug(Register reg) const { | 505 void FullCodeGenerator::EffectContext::Plug(Register reg) const { |
506 } | 506 } |
507 | 507 |
508 | 508 |
509 void FullCodeGenerator::AccumulatorValueContext::Plug(Register reg) const { | 509 void FullCodeGenerator::AccumulatorValueContext::Plug(Register reg) const { |
510 __ Move(result_register(), reg); | 510 __ Move(result_register(), reg); |
511 } | 511 } |
512 | 512 |
513 | 513 |
514 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { | 514 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { |
515 __ Push(reg); | 515 __ push(reg); |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 void FullCodeGenerator::TestContext::Plug(Register reg) const { | 519 void FullCodeGenerator::TestContext::Plug(Register reg) const { |
520 // For simplicity we always test the accumulator register. | 520 // For simplicity we always test the accumulator register. |
521 __ Move(result_register(), reg); | 521 __ Move(result_register(), reg); |
522 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | 522 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
523 codegen()->DoTest(this); | 523 codegen()->DoTest(this); |
524 } | 524 } |
525 | 525 |
526 | 526 |
527 void FullCodeGenerator::EffectContext::PlugTOS() const { | 527 void FullCodeGenerator::EffectContext::PlugTOS() const { |
528 __ Drop(1); | 528 __ Drop(1); |
529 } | 529 } |
530 | 530 |
531 | 531 |
532 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { | 532 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { |
533 __ Pop(result_register()); | 533 __ pop(result_register()); |
534 } | 534 } |
535 | 535 |
536 | 536 |
537 void FullCodeGenerator::StackValueContext::PlugTOS() const { | 537 void FullCodeGenerator::StackValueContext::PlugTOS() const { |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 void FullCodeGenerator::TestContext::PlugTOS() const { | 541 void FullCodeGenerator::TestContext::PlugTOS() const { |
542 // For simplicity we always test the accumulator register. | 542 // For simplicity we always test the accumulator register. |
543 __ Pop(result_register()); | 543 __ pop(result_register()); |
544 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); | 544 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
545 codegen()->DoTest(this); | 545 codegen()->DoTest(this); |
546 } | 546 } |
547 | 547 |
548 | 548 |
549 void FullCodeGenerator::EffectContext::PrepareTest( | 549 void FullCodeGenerator::EffectContext::PrepareTest( |
550 Label* materialize_true, | 550 Label* materialize_true, |
551 Label* materialize_false, | 551 Label* materialize_false, |
552 Label** if_true, | 552 Label** if_true, |
553 Label** if_false, | 553 Label** if_false, |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 } else { | 999 } else { |
1000 VisitForControl(left, test->true_label(), &eval_right, &eval_right); | 1000 VisitForControl(left, test->true_label(), &eval_right, &eval_right); |
1001 } | 1001 } |
1002 PrepareForBailoutForId(right_id, NO_REGISTERS); | 1002 PrepareForBailoutForId(right_id, NO_REGISTERS); |
1003 __ bind(&eval_right); | 1003 __ bind(&eval_right); |
1004 | 1004 |
1005 } else if (context()->IsAccumulatorValue()) { | 1005 } else if (context()->IsAccumulatorValue()) { |
1006 VisitForAccumulatorValue(left); | 1006 VisitForAccumulatorValue(left); |
1007 // We want the value in the accumulator for the test, and on the stack in | 1007 // We want the value in the accumulator for the test, and on the stack in |
1008 // case we need it. | 1008 // case we need it. |
1009 __ Push(result_register()); | 1009 __ push(result_register()); |
1010 Label discard, restore; | 1010 Label discard, restore; |
1011 if (is_logical_and) { | 1011 if (is_logical_and) { |
1012 DoTest(left, &discard, &restore, &restore); | 1012 DoTest(left, &discard, &restore, &restore); |
1013 } else { | 1013 } else { |
1014 DoTest(left, &restore, &discard, &restore); | 1014 DoTest(left, &restore, &discard, &restore); |
1015 } | 1015 } |
1016 __ bind(&restore); | 1016 __ bind(&restore); |
1017 __ Pop(result_register()); | 1017 __ pop(result_register()); |
1018 __ jmp(&done); | 1018 __ jmp(&done); |
1019 __ bind(&discard); | 1019 __ bind(&discard); |
1020 __ Drop(1); | 1020 __ Drop(1); |
1021 PrepareForBailoutForId(right_id, NO_REGISTERS); | 1021 PrepareForBailoutForId(right_id, NO_REGISTERS); |
1022 | 1022 |
1023 } else if (context()->IsStackValue()) { | 1023 } else if (context()->IsStackValue()) { |
1024 VisitForAccumulatorValue(left); | 1024 VisitForAccumulatorValue(left); |
1025 // We want the value in the accumulator for the test, and on the stack in | 1025 // We want the value in the accumulator for the test, and on the stack in |
1026 // case we need it. | 1026 // case we need it. |
1027 __ Push(result_register()); | 1027 __ push(result_register()); |
1028 Label discard; | 1028 Label discard; |
1029 if (is_logical_and) { | 1029 if (is_logical_and) { |
1030 DoTest(left, &discard, &done, &discard); | 1030 DoTest(left, &discard, &done, &discard); |
1031 } else { | 1031 } else { |
1032 DoTest(left, &done, &discard, &discard); | 1032 DoTest(left, &done, &discard, &discard); |
1033 } | 1033 } |
1034 __ bind(&discard); | 1034 __ bind(&discard); |
1035 __ Drop(1); | 1035 __ Drop(1); |
1036 PrepareForBailoutForId(right_id, NO_REGISTERS); | 1036 PrepareForBailoutForId(right_id, NO_REGISTERS); |
1037 | 1037 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 // result register. | 1409 // result register. |
1410 | 1410 |
1411 Label try_entry, handler_entry, exit; | 1411 Label try_entry, handler_entry, exit; |
1412 __ jmp(&try_entry); | 1412 __ jmp(&try_entry); |
1413 __ bind(&handler_entry); | 1413 __ bind(&handler_entry); |
1414 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); | 1414 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); |
1415 // Exception handler code, the exception is in the result register. | 1415 // Exception handler code, the exception is in the result register. |
1416 // Extend the context before executing the catch block. | 1416 // Extend the context before executing the catch block. |
1417 { Comment cmnt(masm_, "[ Extend catch context"); | 1417 { Comment cmnt(masm_, "[ Extend catch context"); |
1418 __ Push(stmt->variable()->name()); | 1418 __ Push(stmt->variable()->name()); |
1419 __ Push(result_register()); | 1419 __ push(result_register()); |
1420 PushFunctionArgumentForContextAllocation(); | 1420 PushFunctionArgumentForContextAllocation(); |
1421 __ CallRuntime(Runtime::kPushCatchContext, 3); | 1421 __ CallRuntime(Runtime::kPushCatchContext, 3); |
1422 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1422 StoreToFrameField(StandardFrameConstants::kContextOffset, |
1423 context_register()); | 1423 context_register()); |
1424 } | 1424 } |
1425 | 1425 |
1426 Scope* saved_scope = scope(); | 1426 Scope* saved_scope = scope(); |
1427 scope_ = stmt->scope(); | 1427 scope_ = stmt->scope(); |
1428 ASSERT(scope_->declarations()->is_empty()); | 1428 ASSERT(scope_->declarations()->is_empty()); |
1429 { WithOrCatch catch_body(this); | 1429 { WithOrCatch catch_body(this); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 | 1474 |
1475 // Jump to try-handler setup and try-block code. | 1475 // Jump to try-handler setup and try-block code. |
1476 __ jmp(&try_entry); | 1476 __ jmp(&try_entry); |
1477 __ bind(&handler_entry); | 1477 __ bind(&handler_entry); |
1478 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); | 1478 handler_table()->set(stmt->index(), Smi::FromInt(handler_entry.pos())); |
1479 // Exception handler code. This code is only executed when an exception | 1479 // Exception handler code. This code is only executed when an exception |
1480 // is thrown. The exception is in the result register, and must be | 1480 // is thrown. The exception is in the result register, and must be |
1481 // preserved by the finally block. Call the finally block and then | 1481 // preserved by the finally block. Call the finally block and then |
1482 // rethrow the exception if it returns. | 1482 // rethrow the exception if it returns. |
1483 __ Call(&finally_entry); | 1483 __ Call(&finally_entry); |
1484 __ Push(result_register()); | 1484 __ push(result_register()); |
1485 __ CallRuntime(Runtime::kReThrow, 1); | 1485 __ CallRuntime(Runtime::kReThrow, 1); |
1486 | 1486 |
1487 // Finally block implementation. | 1487 // Finally block implementation. |
1488 __ bind(&finally_entry); | 1488 __ bind(&finally_entry); |
1489 EnterFinallyBlock(); | 1489 EnterFinallyBlock(); |
1490 { Finally finally_body(this); | 1490 { Finally finally_body(this); |
1491 Visit(stmt->finally_block()); | 1491 Visit(stmt->finally_block()); |
1492 } | 1492 } |
1493 ExitFinallyBlock(); // Return to the calling code. | 1493 ExitFinallyBlock(); // Return to the calling code. |
1494 | 1494 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 } | 1616 } |
1617 | 1617 |
1618 return false; | 1618 return false; |
1619 } | 1619 } |
1620 | 1620 |
1621 | 1621 |
1622 #undef __ | 1622 #undef __ |
1623 | 1623 |
1624 | 1624 |
1625 } } // namespace v8::internal | 1625 } } // namespace v8::internal |
OLD | NEW |