| 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 648 |
| 649 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 649 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 650 HEnvironment* hydrogen_env = current_block_->last_environment(); | 650 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 651 instr->set_environment(CreateEnvironment(hydrogen_env)); | 651 instr->set_environment(CreateEnvironment(hydrogen_env)); |
| 652 return instr; | 652 return instr; |
| 653 } | 653 } |
| 654 | 654 |
| 655 | 655 |
| 656 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( | 656 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( |
| 657 LInstruction* instr, int ast_id) { | 657 LInstruction* instr, int ast_id) { |
| 658 ASSERT(instructions_pending_deoptimization_environment_ == NULL); | 658 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
| 659 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | 659 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
| 660 instructions_pending_deoptimization_environment_ = instr; | 660 instruction_pending_deoptimization_environment_ = instr; |
| 661 pending_deoptimization_ast_id_ = ast_id; | 661 pending_deoptimization_ast_id_ = ast_id; |
| 662 return instr; | 662 return instr; |
| 663 } | 663 } |
| 664 | 664 |
| 665 | 665 |
| 666 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { | 666 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { |
| 667 instructions_pending_deoptimization_environment_ = NULL; | 667 instruction_pending_deoptimization_environment_ = NULL; |
| 668 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | 668 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
| 669 } | 669 } |
| 670 | 670 |
| 671 | 671 |
| 672 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 672 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 673 HInstruction* hinstr, | 673 HInstruction* hinstr, |
| 674 CanDeoptimize can_deoptimize) { | 674 CanDeoptimize can_deoptimize) { |
| 675 allocator_->MarkAsCall(); | 675 allocator_->MarkAsCall(); |
| 676 instr = AssignPointerMap(instr); | 676 instr = AssignPointerMap(instr); |
| 677 | 677 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 | 1021 |
| 1022 LOperand* temp = TempRegister(); | 1022 LOperand* temp = TempRegister(); |
| 1023 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp); | 1023 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), temp); |
| 1024 } else if (v->IsCompareJSObjectEq()) { | 1024 } else if (v->IsCompareJSObjectEq()) { |
| 1025 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); | 1025 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); |
| 1026 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), | 1026 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), |
| 1027 UseRegisterAtStart(compare->right())); | 1027 UseRegisterAtStart(compare->right())); |
| 1028 } else if (v->IsInstanceOf()) { | 1028 } else if (v->IsInstanceOf()) { |
| 1029 HInstanceOf* instance_of = HInstanceOf::cast(v); | 1029 HInstanceOf* instance_of = HInstanceOf::cast(v); |
| 1030 LInstruction* result = | 1030 LInstruction* result = |
| 1031 new LInstanceOfAndBranch(Use(instance_of->left()), | 1031 new LInstanceOfAndBranch(UseFixed(instance_of->left(), r0), |
| 1032 Use(instance_of->right())); | 1032 UseFixed(instance_of->right(), r1)); |
| 1033 return MarkAsCall(result, instr); | 1033 return MarkAsCall(result, instr); |
| 1034 } else if (v->IsTypeofIs()) { | 1034 } else if (v->IsTypeofIs()) { |
| 1035 HTypeofIs* typeof_is = HTypeofIs::cast(v); | 1035 HTypeofIs* typeof_is = HTypeofIs::cast(v); |
| 1036 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); | 1036 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value())); |
| 1037 } else { | 1037 } else { |
| 1038 if (v->IsConstant()) { | 1038 if (v->IsConstant()) { |
| 1039 if (HConstant::cast(v)->handle()->IsTrue()) { | 1039 if (HConstant::cast(v)->handle()->IsTrue()) { |
| 1040 return new LGoto(instr->FirstSuccessor()->block_id()); | 1040 return new LGoto(instr->FirstSuccessor()->block_id()); |
| 1041 } else if (HConstant::cast(v)->handle()->IsFalse()) { | 1041 } else if (HConstant::cast(v)->handle()->IsFalse()) { |
| 1042 return new LGoto(instr->SecondSuccessor()->block_id()); | 1042 return new LGoto(instr->SecondSuccessor()->block_id()); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 return AssignEnvironment(DefineSameAsFirst(result)); | 1456 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 | 1459 |
| 1460 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1460 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
| 1461 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), | 1461 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), |
| 1462 UseRegister(instr->length()))); | 1462 UseRegister(instr->length()))); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 | 1465 |
| 1466 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { |
| 1467 // The control instruction marking the end of a block that completed |
| 1468 // abruptly (e.g., threw an exception). There is nothing specific to do. |
| 1469 return NULL; |
| 1470 } |
| 1471 |
| 1472 |
| 1466 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) { | 1473 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) { |
| 1467 LOperand* value = UseFixed(instr->value(), r0); | 1474 LOperand* value = UseFixed(instr->value(), r0); |
| 1468 return MarkAsCall(new LThrow(value), instr); | 1475 return MarkAsCall(new LThrow(value), instr); |
| 1469 } | 1476 } |
| 1470 | 1477 |
| 1471 | 1478 |
| 1472 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1479 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
| 1473 Representation from = instr->from(); | 1480 Representation from = instr->from(); |
| 1474 Representation to = instr->to(); | 1481 Representation to = instr->to(); |
| 1475 if (from.IsTagged()) { | 1482 if (from.IsTagged()) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 | 1602 |
| 1596 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) { | 1603 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) { |
| 1597 LLoadGlobal* result = new LLoadGlobal(); | 1604 LLoadGlobal* result = new LLoadGlobal(); |
| 1598 return instr->check_hole_value() | 1605 return instr->check_hole_value() |
| 1599 ? AssignEnvironment(DefineAsRegister(result)) | 1606 ? AssignEnvironment(DefineAsRegister(result)) |
| 1600 : DefineAsRegister(result); | 1607 : DefineAsRegister(result); |
| 1601 } | 1608 } |
| 1602 | 1609 |
| 1603 | 1610 |
| 1604 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) { | 1611 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) { |
| 1605 return new LStoreGlobal(UseRegisterAtStart(instr->value())); | 1612 if (instr->check_hole_value()) { |
| 1613 LOperand* temp = TempRegister(); |
| 1614 LOperand* value = UseRegister(instr->value()); |
| 1615 return AssignEnvironment(new LStoreGlobal(value, temp)); |
| 1616 } else { |
| 1617 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1618 return new LStoreGlobal(value, NULL); |
| 1619 } |
| 1606 } | 1620 } |
| 1607 | 1621 |
| 1608 | 1622 |
| 1609 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { | 1623 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { |
| 1610 return DefineAsRegister(new LLoadContextSlot); | 1624 return DefineAsRegister(new LLoadContextSlot); |
| 1611 } | 1625 } |
| 1612 | 1626 |
| 1613 | 1627 |
| 1614 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { | 1628 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { |
| 1615 return DefineAsRegister( | 1629 return DefineAsRegister( |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 } | 1837 } |
| 1824 } | 1838 } |
| 1825 | 1839 |
| 1826 ASSERT(env->length() == instr->environment_length()); | 1840 ASSERT(env->length() == instr->environment_length()); |
| 1827 | 1841 |
| 1828 // If there is an instruction pending deoptimization environment create a | 1842 // If there is an instruction pending deoptimization environment create a |
| 1829 // lazy bailout instruction to capture the environment. | 1843 // lazy bailout instruction to capture the environment. |
| 1830 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | 1844 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
| 1831 LInstruction* result = new LLazyBailout; | 1845 LInstruction* result = new LLazyBailout; |
| 1832 result = AssignEnvironment(result); | 1846 result = AssignEnvironment(result); |
| 1833 instructions_pending_deoptimization_environment_-> | 1847 instruction_pending_deoptimization_environment_-> |
| 1834 set_deoptimization_environment(result->environment()); | 1848 set_deoptimization_environment(result->environment()); |
| 1835 ClearInstructionPendingDeoptimizationEnvironment(); | 1849 ClearInstructionPendingDeoptimizationEnvironment(); |
| 1836 return result; | 1850 return result; |
| 1837 } | 1851 } |
| 1838 | 1852 |
| 1839 return NULL; | 1853 return NULL; |
| 1840 } | 1854 } |
| 1841 | 1855 |
| 1842 | 1856 |
| 1843 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 1857 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1859 | 1873 |
| 1860 | 1874 |
| 1861 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1875 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 1862 HEnvironment* outer = current_block_->last_environment()->outer(); | 1876 HEnvironment* outer = current_block_->last_environment()->outer(); |
| 1863 current_block_->UpdateEnvironment(outer); | 1877 current_block_->UpdateEnvironment(outer); |
| 1864 return NULL; | 1878 return NULL; |
| 1865 } | 1879 } |
| 1866 | 1880 |
| 1867 | 1881 |
| 1868 } } // namespace v8::internal | 1882 } } // namespace v8::internal |
| OLD | NEW |