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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 644 } |
645 | 645 |
646 | 646 |
647 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 647 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
648 HEnvironment* hydrogen_env = current_block_->last_environment(); | 648 HEnvironment* hydrogen_env = current_block_->last_environment(); |
649 instr->set_environment(CreateEnvironment(hydrogen_env)); | 649 instr->set_environment(CreateEnvironment(hydrogen_env)); |
650 return instr; | 650 return instr; |
651 } | 651 } |
652 | 652 |
653 | 653 |
654 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( | |
655 LInstruction* instr, int ast_id) { | |
656 ASSERT(instructions_pending_deoptimization_environment_ == NULL); | |
657 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | |
658 instructions_pending_deoptimization_environment_ = instr; | |
659 pending_deoptimization_ast_id_ = ast_id; | |
660 return instr; | |
661 } | |
662 | |
663 | |
664 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { | |
665 instructions_pending_deoptimization_environment_ = NULL; | |
666 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | |
667 } | |
668 | |
669 | |
670 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 654 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
671 HInstruction* hinstr, | 655 HInstruction* hinstr, |
672 CanDeoptimize can_deoptimize) { | 656 CanDeoptimize can_deoptimize) { |
673 allocator_->MarkAsCall(); | 657 allocator_->MarkAsCall(); |
674 instr = AssignPointerMap(instr); | 658 instr = AssignPointerMap(instr); |
675 | 659 |
676 if (hinstr->HasSideEffects()) { | 660 if (hinstr->HasSideEffects()) { |
677 ASSERT(hinstr->next()->IsSimulate()); | 661 ASSERT(hinstr->next()->IsSimulate()); |
678 HSimulate* sim = HSimulate::cast(hinstr->next()); | 662 HSimulate* sim = HSimulate::cast(hinstr->next()); |
679 instr = SetInstructionPendingDeoptimizationEnvironment( | 663 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
680 instr, sim->ast_id()); | 664 pending_deoptimization_ast_id_ = sim->ast_id(); |
681 } | 665 } |
682 | 666 |
683 // If instruction does not have side-effects lazy deoptimization | 667 // If instruction does not have side-effects lazy deoptimization |
684 // after the call will try to deoptimize to the point before the call. | 668 // after the call will try to deoptimize to the point before the call. |
685 // Thus we still need to attach environment to this call even if | 669 // Thus we still need to attach environment to this call even if |
686 // call sequence can not deoptimize eagerly. | 670 // call sequence can not deoptimize eagerly. |
687 bool needs_environment = | 671 bool needs_environment = |
688 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); | 672 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); |
689 if (needs_environment && !instr->HasEnvironment()) { | 673 if (needs_environment && !instr->HasEnvironment()) { |
690 instr = AssignEnvironment(instr); | 674 instr = AssignEnvironment(instr); |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 if (instr->HasAssignedIndexAt(i)) { | 1546 if (instr->HasAssignedIndexAt(i)) { |
1563 env->Bind(instr->GetAssignedIndexAt(i), value); | 1547 env->Bind(instr->GetAssignedIndexAt(i), value); |
1564 } else { | 1548 } else { |
1565 env->Push(value); | 1549 env->Push(value); |
1566 } | 1550 } |
1567 } | 1551 } |
1568 ASSERT(env->length() == instr->environment_length()); | 1552 ASSERT(env->length() == instr->environment_length()); |
1569 | 1553 |
1570 // If there is an instruction pending deoptimization environment create a | 1554 // If there is an instruction pending deoptimization environment create a |
1571 // lazy bailout instruction to capture the environment. | 1555 // lazy bailout instruction to capture the environment. |
1572 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | 1556 if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) { |
| 1557 ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); |
1573 LLazyBailout* lazy_bailout = new LLazyBailout; | 1558 LLazyBailout* lazy_bailout = new LLazyBailout; |
1574 LInstruction* result = AssignEnvironment(lazy_bailout); | 1559 LInstruction* result = AssignEnvironment(lazy_bailout); |
1575 instructions_pending_deoptimization_environment_-> | 1560 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
1576 set_deoptimization_environment(result->environment()); | |
1577 ClearInstructionPendingDeoptimizationEnvironment(); | |
1578 return result; | 1561 return result; |
1579 } | 1562 } |
1580 | 1563 |
1581 return NULL; | 1564 return NULL; |
1582 } | 1565 } |
1583 | 1566 |
1584 | 1567 |
1585 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 1568 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
1586 return MarkAsCall(new LStackCheck, instr); | 1569 return MarkAsCall(new LStackCheck, instr); |
1587 } | 1570 } |
1588 | 1571 |
1589 | 1572 |
1590 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 1573 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
1591 Abort("Unimplemented: %s", "DoEnterInlined"); | 1574 Abort("Unimplemented: %s", "DoEnterInlined"); |
1592 return NULL; | 1575 return NULL; |
1593 } | 1576 } |
1594 | 1577 |
1595 | 1578 |
1596 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1579 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
1597 Abort("Unimplemented: %s", "DoLeaveInlined"); | 1580 Abort("Unimplemented: %s", "DoLeaveInlined"); |
1598 return NULL; | 1581 return NULL; |
1599 } | 1582 } |
1600 | 1583 |
1601 } } // namespace v8::internal | 1584 } } // namespace v8::internal |
1602 | 1585 |
1603 #endif // V8_TARGET_ARCH_X64 | 1586 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |