| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { | 435 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { |
| 436 __ push(reg); | 436 __ push(reg); |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 void FullCodeGenerator::TestContext::Plug(Register reg) const { | 440 void FullCodeGenerator::TestContext::Plug(Register reg) const { |
| 441 // For simplicity we always test the accumulator register. | 441 // For simplicity we always test the accumulator register. |
| 442 __ Move(result_register(), reg); | 442 __ Move(result_register(), reg); |
| 443 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 443 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 444 codegen()->DoTest(this); | 444 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 445 } | 445 } |
| 446 | 446 |
| 447 | 447 |
| 448 void FullCodeGenerator::EffectContext::PlugTOS() const { | 448 void FullCodeGenerator::EffectContext::PlugTOS() const { |
| 449 __ Drop(1); | 449 __ Drop(1); |
| 450 } | 450 } |
| 451 | 451 |
| 452 | 452 |
| 453 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { | 453 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { |
| 454 __ pop(result_register()); | 454 __ pop(result_register()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 | 457 |
| 458 void FullCodeGenerator::StackValueContext::PlugTOS() const { | 458 void FullCodeGenerator::StackValueContext::PlugTOS() const { |
| 459 } | 459 } |
| 460 | 460 |
| 461 | 461 |
| 462 void FullCodeGenerator::TestContext::PlugTOS() const { | 462 void FullCodeGenerator::TestContext::PlugTOS() const { |
| 463 // For simplicity we always test the accumulator register. | 463 // For simplicity we always test the accumulator register. |
| 464 __ pop(result_register()); | 464 __ pop(result_register()); |
| 465 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 465 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 466 codegen()->DoTest(this); | 466 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 467 } | 467 } |
| 468 | 468 |
| 469 | 469 |
| 470 void FullCodeGenerator::EffectContext::PrepareTest( | 470 void FullCodeGenerator::EffectContext::PrepareTest( |
| 471 Label* materialize_true, | 471 Label* materialize_true, |
| 472 Label* materialize_false, | 472 Label* materialize_false, |
| 473 Label** if_true, | 473 Label** if_true, |
| 474 Label** if_false, | 474 Label** if_false, |
| 475 Label** fall_through) const { | 475 Label** fall_through) const { |
| 476 // In an effect context, the true and the false case branch to the | 476 // In an effect context, the true and the false case branch to the |
| (...skipping 29 matching lines...) Expand all Loading... |
| 506 Label* materialize_false, | 506 Label* materialize_false, |
| 507 Label** if_true, | 507 Label** if_true, |
| 508 Label** if_false, | 508 Label** if_false, |
| 509 Label** fall_through) const { | 509 Label** fall_through) const { |
| 510 *if_true = true_label_; | 510 *if_true = true_label_; |
| 511 *if_false = false_label_; | 511 *if_false = false_label_; |
| 512 *fall_through = fall_through_; | 512 *fall_through = fall_through_; |
| 513 } | 513 } |
| 514 | 514 |
| 515 | 515 |
| 516 void FullCodeGenerator::DoTest(const TestContext* context) { | |
| 517 DoTest(context->condition(), | |
| 518 context->true_label(), | |
| 519 context->false_label(), | |
| 520 context->fall_through()); | |
| 521 } | |
| 522 | |
| 523 | |
| 524 void FullCodeGenerator::VisitDeclarations( | 516 void FullCodeGenerator::VisitDeclarations( |
| 525 ZoneList<Declaration*>* declarations) { | 517 ZoneList<Declaration*>* declarations) { |
| 526 int length = declarations->length(); | 518 int length = declarations->length(); |
| 527 int globals = 0; | 519 int globals = 0; |
| 528 for (int i = 0; i < length; i++) { | 520 for (int i = 0; i < length; i++) { |
| 529 Declaration* decl = declarations->at(i); | 521 Declaration* decl = declarations->at(i); |
| 530 Variable* var = decl->proxy()->var(); | 522 Variable* var = decl->proxy()->var(); |
| 531 Slot* slot = var->AsSlot(); | 523 Slot* slot = var->AsSlot(); |
| 532 | 524 |
| 533 // If it was not possible to allocate the variable at compile | 525 // If it was not possible to allocate the variable at compile |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 ForwardBailoutToChild(expr); | 727 ForwardBailoutToChild(expr); |
| 736 | 728 |
| 737 } else if (context()->IsAccumulatorValue()) { | 729 } else if (context()->IsAccumulatorValue()) { |
| 738 VisitForAccumulatorValue(left); | 730 VisitForAccumulatorValue(left); |
| 739 // We want the value in the accumulator for the test, and on the stack in | 731 // We want the value in the accumulator for the test, and on the stack in |
| 740 // case we need it. | 732 // case we need it. |
| 741 __ push(result_register()); | 733 __ push(result_register()); |
| 742 Label discard, restore; | 734 Label discard, restore; |
| 743 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 735 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 744 if (is_logical_and) { | 736 if (is_logical_and) { |
| 745 DoTest(left, &discard, &restore, &restore); | 737 DoTest(&discard, &restore, &restore); |
| 746 } else { | 738 } else { |
| 747 DoTest(left, &restore, &discard, &restore); | 739 DoTest(&restore, &discard, &restore); |
| 748 } | 740 } |
| 749 __ bind(&restore); | 741 __ bind(&restore); |
| 750 __ pop(result_register()); | 742 __ pop(result_register()); |
| 751 __ jmp(&done); | 743 __ jmp(&done); |
| 752 __ bind(&discard); | 744 __ bind(&discard); |
| 753 __ Drop(1); | 745 __ Drop(1); |
| 754 PrepareForBailoutForId(right_id, NO_REGISTERS); | 746 PrepareForBailoutForId(right_id, NO_REGISTERS); |
| 755 | 747 |
| 756 } else if (context()->IsStackValue()) { | 748 } else if (context()->IsStackValue()) { |
| 757 VisitForAccumulatorValue(left); | 749 VisitForAccumulatorValue(left); |
| 758 // We want the value in the accumulator for the test, and on the stack in | 750 // We want the value in the accumulator for the test, and on the stack in |
| 759 // case we need it. | 751 // case we need it. |
| 760 __ push(result_register()); | 752 __ push(result_register()); |
| 761 Label discard; | 753 Label discard; |
| 762 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 754 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 763 if (is_logical_and) { | 755 if (is_logical_and) { |
| 764 DoTest(left, &discard, &done, &discard); | 756 DoTest(&discard, &done, &discard); |
| 765 } else { | 757 } else { |
| 766 DoTest(left, &done, &discard, &discard); | 758 DoTest(&done, &discard, &discard); |
| 767 } | 759 } |
| 768 __ bind(&discard); | 760 __ bind(&discard); |
| 769 __ Drop(1); | 761 __ Drop(1); |
| 770 PrepareForBailoutForId(right_id, NO_REGISTERS); | 762 PrepareForBailoutForId(right_id, NO_REGISTERS); |
| 771 | 763 |
| 772 } else { | 764 } else { |
| 773 ASSERT(context()->IsEffect()); | 765 ASSERT(context()->IsEffect()); |
| 774 Label eval_right; | 766 Label eval_right; |
| 775 if (is_logical_and) { | 767 if (is_logical_and) { |
| 776 VisitForControl(left, &eval_right, &done, &eval_right); | 768 VisitForControl(left, &eval_right, &done, &eval_right); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 // that scope again afterwards. | 1092 // that scope again afterwards. |
| 1101 | 1093 |
| 1102 Label try_handler_setup, catch_entry, done; | 1094 Label try_handler_setup, catch_entry, done; |
| 1103 __ Call(&try_handler_setup); | 1095 __ Call(&try_handler_setup); |
| 1104 // Try handler code, exception in result register. | 1096 // Try handler code, exception in result register. |
| 1105 | 1097 |
| 1106 // Extend the context before executing the catch block. | 1098 // Extend the context before executing the catch block. |
| 1107 { Comment cmnt(masm_, "[ Extend catch context"); | 1099 { Comment cmnt(masm_, "[ Extend catch context"); |
| 1108 __ Push(stmt->name()); | 1100 __ Push(stmt->name()); |
| 1109 __ push(result_register()); | 1101 __ push(result_register()); |
| 1110 __ CallRuntime(Runtime::kPushCatchContext, 2); | 1102 __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2); |
| 1103 __ push(result_register()); |
| 1104 __ CallRuntime(Runtime::kPushCatchContext, 1); |
| 1111 StoreToFrameField(StandardFrameConstants::kContextOffset, | 1105 StoreToFrameField(StandardFrameConstants::kContextOffset, |
| 1112 context_register()); | 1106 context_register()); |
| 1113 } | 1107 } |
| 1114 | 1108 |
| 1115 Visit(stmt->catch_block()); | 1109 Visit(stmt->catch_block()); |
| 1116 __ jmp(&done); | 1110 __ jmp(&done); |
| 1117 | 1111 |
| 1118 // Try block code. Sets up the exception handler chain. | 1112 // Try block code. Sets up the exception handler chain. |
| 1119 __ bind(&try_handler_setup); | 1113 __ bind(&try_handler_setup); |
| 1120 { | 1114 { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 __ Drop(stack_depth); | 1281 __ Drop(stack_depth); |
| 1288 __ PopTryHandler(); | 1282 __ PopTryHandler(); |
| 1289 return 0; | 1283 return 0; |
| 1290 } | 1284 } |
| 1291 | 1285 |
| 1292 | 1286 |
| 1293 #undef __ | 1287 #undef __ |
| 1294 | 1288 |
| 1295 | 1289 |
| 1296 } } // namespace v8::internal | 1290 } } // namespace v8::internal |
| OLD | NEW |