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 26 matching lines...) Expand all Loading... |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 #define DEFINE_COMPILE(type) \ | 39 #define DEFINE_COMPILE(type) \ |
40 void L##type::CompileToNative(LCodeGen* generator) { \ | 40 void L##type::CompileToNative(LCodeGen* generator) { \ |
41 generator->Do##type(this); \ | 41 generator->Do##type(this); \ |
42 } | 42 } |
43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
44 #undef DEFINE_COMPILE | 44 #undef DEFINE_COMPILE |
45 | 45 |
46 LOsrEntry::LOsrEntry() { | 46 LOsrEntry::LOsrEntry() { |
47 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) { | 47 for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
48 register_spills_[i] = NULL; | 48 register_spills_[i] = NULL; |
49 } | 49 } |
50 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { | 50 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) { |
51 double_register_spills_[i] = NULL; | 51 double_register_spills_[i] = NULL; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 void LOsrEntry::MarkSpilledRegister(int allocation_index, | 56 void LOsrEntry::MarkSpilledRegister(int allocation_index, |
57 LOperand* spill_operand) { | 57 LOperand* spill_operand) { |
58 ASSERT(spill_operand->IsStackSlot()); | 58 ASSERT(spill_operand->IsStackSlot()); |
59 ASSERT(register_spills_[allocation_index] == NULL); | 59 ASSERT(register_spills_[allocation_index] == NULL); |
60 register_spills_[allocation_index] = spill_operand; | 60 register_spills_[allocation_index] = spill_operand; |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 int argument_index_accumulator = 0; | 612 int argument_index_accumulator = 0; |
613 instr->set_environment(CreateEnvironment(hydrogen_env, | 613 instr->set_environment(CreateEnvironment(hydrogen_env, |
614 &argument_index_accumulator)); | 614 &argument_index_accumulator)); |
615 return instr; | 615 return instr; |
616 } | 616 } |
617 | 617 |
618 | 618 |
619 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 619 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
620 HInstruction* hinstr, | 620 HInstruction* hinstr, |
621 CanDeoptimize can_deoptimize) { | 621 CanDeoptimize can_deoptimize) { |
622 info()->MarkAsNonDeferredCalling(); | |
623 | |
624 #ifdef DEBUG | 622 #ifdef DEBUG |
625 instr->VerifyCall(); | 623 instr->VerifyCall(); |
626 #endif | 624 #endif |
627 instr->MarkAsCall(); | 625 instr->MarkAsCall(); |
628 instr = AssignPointerMap(instr); | 626 instr = AssignPointerMap(instr); |
629 | 627 |
630 if (hinstr->HasObservableSideEffects()) { | 628 if (hinstr->HasObservableSideEffects()) { |
631 ASSERT(hinstr->next()->IsSimulate()); | 629 ASSERT(hinstr->next()->IsSimulate()); |
632 HSimulate* sim = HSimulate::cast(hinstr->next()); | 630 HSimulate* sim = HSimulate::cast(hinstr->next()); |
633 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | 631 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 // All HForceRepresentation instructions should be eliminated in the | 1621 // All HForceRepresentation instructions should be eliminated in the |
1624 // representation change phase of Hydrogen. | 1622 // representation change phase of Hydrogen. |
1625 UNREACHABLE(); | 1623 UNREACHABLE(); |
1626 return NULL; | 1624 return NULL; |
1627 } | 1625 } |
1628 | 1626 |
1629 | 1627 |
1630 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1628 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1631 Representation from = instr->from(); | 1629 Representation from = instr->from(); |
1632 Representation to = instr->to(); | 1630 Representation to = instr->to(); |
1633 // Only mark conversions that might need to allocate as calling rather than | |
1634 // all changes. This makes simple, non-allocating conversion not have to force | |
1635 // building a stack frame. | |
1636 if (from.IsTagged()) { | 1631 if (from.IsTagged()) { |
1637 if (to.IsDouble()) { | 1632 if (to.IsDouble()) { |
1638 info()->MarkAsDeferredCalling(); | |
1639 LOperand* value = UseRegister(instr->value()); | 1633 LOperand* value = UseRegister(instr->value()); |
1640 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1634 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
1641 return AssignEnvironment(DefineAsRegister(res)); | 1635 return AssignEnvironment(DefineAsRegister(res)); |
1642 } else { | 1636 } else { |
1643 ASSERT(to.IsInteger32()); | 1637 ASSERT(to.IsInteger32()); |
1644 LOperand* value = UseRegister(instr->value()); | 1638 LOperand* value = UseRegister(instr->value()); |
1645 if (instr->value()->type().IsSmi()) { | 1639 if (instr->value()->type().IsSmi()) { |
1646 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); | 1640 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); |
1647 } else { | 1641 } else { |
1648 bool truncating = instr->CanTruncateToInt32(); | 1642 bool truncating = instr->CanTruncateToInt32(); |
1649 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); | 1643 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); |
1650 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); | 1644 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); |
1651 return AssignEnvironment(DefineSameAsFirst(res)); | 1645 return AssignEnvironment(DefineSameAsFirst(res)); |
1652 } | 1646 } |
1653 } | 1647 } |
1654 } else if (from.IsDouble()) { | 1648 } else if (from.IsDouble()) { |
1655 if (to.IsTagged()) { | 1649 if (to.IsTagged()) { |
1656 info()->MarkAsDeferredCalling(); | |
1657 LOperand* value = UseRegister(instr->value()); | 1650 LOperand* value = UseRegister(instr->value()); |
1658 LOperand* temp = TempRegister(); | 1651 LOperand* temp = TempRegister(); |
1659 | 1652 |
1660 // Make sure that temp and result_temp are different registers. | 1653 // Make sure that temp and result_temp are different registers. |
1661 LUnallocated* result_temp = TempRegister(); | 1654 LUnallocated* result_temp = TempRegister(); |
1662 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); | 1655 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); |
1663 return AssignPointerMap(Define(result, result_temp)); | 1656 return AssignPointerMap(Define(result, result_temp)); |
1664 } else { | 1657 } else { |
1665 ASSERT(to.IsInteger32()); | 1658 ASSERT(to.IsInteger32()); |
1666 LOperand* value = UseRegister(instr->value()); | 1659 LOperand* value = UseRegister(instr->value()); |
1667 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToI(value))); | 1660 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToI(value))); |
1668 } | 1661 } |
1669 } else if (from.IsInteger32()) { | 1662 } else if (from.IsInteger32()) { |
1670 info()->MarkAsDeferredCalling(); | |
1671 if (to.IsTagged()) { | 1663 if (to.IsTagged()) { |
1672 HValue* val = instr->value(); | 1664 HValue* val = instr->value(); |
1673 LOperand* value = UseRegister(val); | 1665 LOperand* value = UseRegister(val); |
1674 if (val->CheckFlag(HInstruction::kUint32)) { | 1666 if (val->CheckFlag(HInstruction::kUint32)) { |
1675 LOperand* temp = FixedTemp(xmm1); | 1667 LOperand* temp = FixedTemp(xmm1); |
1676 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); | 1668 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); |
1677 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1669 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1678 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1670 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1679 return DefineSameAsFirst(new(zone()) LSmiTag(value)); | 1671 return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
1680 } else { | 1672 } else { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 | 2119 |
2128 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 2120 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
2129 ASSERT(argument_count_ == 0); | 2121 ASSERT(argument_count_ == 0); |
2130 allocator_->MarkAsOsrEntry(); | 2122 allocator_->MarkAsOsrEntry(); |
2131 current_block_->last_environment()->set_ast_id(instr->ast_id()); | 2123 current_block_->last_environment()->set_ast_id(instr->ast_id()); |
2132 return AssignEnvironment(new(zone()) LOsrEntry); | 2124 return AssignEnvironment(new(zone()) LOsrEntry); |
2133 } | 2125 } |
2134 | 2126 |
2135 | 2127 |
2136 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2128 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
2137 LParameter* result = new(zone()) LParameter; | 2129 int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
2138 if (info()->IsOptimizing()) { | 2130 return DefineAsSpilled(new(zone()) LParameter, spill_index); |
2139 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | |
2140 return DefineAsSpilled(result, spill_index); | |
2141 } else { | |
2142 ASSERT(info()->IsStub()); | |
2143 CodeStubInterfaceDescriptor* descriptor = | |
2144 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | |
2145 Register reg = descriptor->register_params_[instr->index()]; | |
2146 return DefineFixed(result, reg); | |
2147 } | |
2148 } | 2131 } |
2149 | 2132 |
2150 | 2133 |
2151 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2134 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2152 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2135 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2153 if (spill_index > LUnallocated::kMaxFixedIndex) { | 2136 if (spill_index > LUnallocated::kMaxFixedIndex) { |
2154 Abort("Too many spill slots needed for OSR"); | 2137 Abort("Too many spill slots needed for OSR"); |
2155 spill_index = 0; | 2138 spill_index = 0; |
2156 } | 2139 } |
2157 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2140 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 instruction_pending_deoptimization_environment_ = NULL; | 2216 instruction_pending_deoptimization_environment_ = NULL; |
2234 pending_deoptimization_ast_id_ = BailoutId::None(); | 2217 pending_deoptimization_ast_id_ = BailoutId::None(); |
2235 return result; | 2218 return result; |
2236 } | 2219 } |
2237 | 2220 |
2238 return NULL; | 2221 return NULL; |
2239 } | 2222 } |
2240 | 2223 |
2241 | 2224 |
2242 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2225 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2243 info()->MarkAsDeferredCalling(); | |
2244 if (instr->is_function_entry()) { | 2226 if (instr->is_function_entry()) { |
2245 return MarkAsCall(new(zone()) LStackCheck, instr); | 2227 return MarkAsCall(new(zone()) LStackCheck, instr); |
2246 } else { | 2228 } else { |
2247 ASSERT(instr->is_backwards_branch()); | 2229 ASSERT(instr->is_backwards_branch()); |
2248 return AssignEnvironment(AssignPointerMap(new(zone()) LStackCheck)); | 2230 return AssignEnvironment(AssignPointerMap(new(zone()) LStackCheck)); |
2249 } | 2231 } |
2250 } | 2232 } |
2251 | 2233 |
2252 | 2234 |
2253 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 2235 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2302 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2321 LOperand* object = UseRegister(instr->object()); | 2303 LOperand* object = UseRegister(instr->object()); |
2322 LOperand* index = UseTempRegister(instr->index()); | 2304 LOperand* index = UseTempRegister(instr->index()); |
2323 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2305 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2324 } | 2306 } |
2325 | 2307 |
2326 | 2308 |
2327 } } // namespace v8::internal | 2309 } } // namespace v8::internal |
2328 | 2310 |
2329 #endif // V8_TARGET_ARCH_X64 | 2311 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |