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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 // All HForceRepresentation instructions should be eliminated in the | 1610 // All HForceRepresentation instructions should be eliminated in the |
1613 // representation change phase of Hydrogen. | 1611 // representation change phase of Hydrogen. |
1614 UNREACHABLE(); | 1612 UNREACHABLE(); |
1615 return NULL; | 1613 return NULL; |
1616 } | 1614 } |
1617 | 1615 |
1618 | 1616 |
1619 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1617 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1620 Representation from = instr->from(); | 1618 Representation from = instr->from(); |
1621 Representation to = instr->to(); | 1619 Representation to = instr->to(); |
1622 // Only mark conversions that might need to allocate as calling rather than | |
1623 // all changes. This makes simple, non-allocating conversion not have to force | |
1624 // building a stack frame. | |
1625 if (from.IsTagged()) { | 1620 if (from.IsTagged()) { |
1626 if (to.IsDouble()) { | 1621 if (to.IsDouble()) { |
1627 info()->MarkAsDeferredCalling(); | |
1628 LOperand* value = UseRegister(instr->value()); | 1622 LOperand* value = UseRegister(instr->value()); |
1629 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1623 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
1630 return AssignEnvironment(DefineAsRegister(res)); | 1624 return AssignEnvironment(DefineAsRegister(res)); |
1631 } else { | 1625 } else { |
1632 ASSERT(to.IsInteger32()); | 1626 ASSERT(to.IsInteger32()); |
1633 LOperand* value = UseRegister(instr->value()); | 1627 LOperand* value = UseRegister(instr->value()); |
1634 if (instr->value()->type().IsSmi()) { | 1628 if (instr->value()->type().IsSmi()) { |
1635 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); | 1629 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); |
1636 } else { | 1630 } else { |
1637 bool truncating = instr->CanTruncateToInt32(); | 1631 bool truncating = instr->CanTruncateToInt32(); |
1638 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); | 1632 LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1); |
1639 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); | 1633 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); |
1640 return AssignEnvironment(DefineSameAsFirst(res)); | 1634 return AssignEnvironment(DefineSameAsFirst(res)); |
1641 } | 1635 } |
1642 } | 1636 } |
1643 } else if (from.IsDouble()) { | 1637 } else if (from.IsDouble()) { |
1644 if (to.IsTagged()) { | 1638 if (to.IsTagged()) { |
1645 info()->MarkAsDeferredCalling(); | |
1646 LOperand* value = UseRegister(instr->value()); | 1639 LOperand* value = UseRegister(instr->value()); |
1647 LOperand* temp = TempRegister(); | 1640 LOperand* temp = TempRegister(); |
1648 | 1641 |
1649 // Make sure that temp and result_temp are different registers. | 1642 // Make sure that temp and result_temp are different registers. |
1650 LUnallocated* result_temp = TempRegister(); | 1643 LUnallocated* result_temp = TempRegister(); |
1651 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); | 1644 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); |
1652 return AssignPointerMap(Define(result, result_temp)); | 1645 return AssignPointerMap(Define(result, result_temp)); |
1653 } else { | 1646 } else { |
1654 ASSERT(to.IsInteger32()); | 1647 ASSERT(to.IsInteger32()); |
1655 LOperand* value = UseRegister(instr->value()); | 1648 LOperand* value = UseRegister(instr->value()); |
1656 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToI(value))); | 1649 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToI(value))); |
1657 } | 1650 } |
1658 } else if (from.IsInteger32()) { | 1651 } else if (from.IsInteger32()) { |
1659 info()->MarkAsDeferredCalling(); | |
1660 if (to.IsTagged()) { | 1652 if (to.IsTagged()) { |
1661 HValue* val = instr->value(); | 1653 HValue* val = instr->value(); |
1662 LOperand* value = UseRegister(val); | 1654 LOperand* value = UseRegister(val); |
1663 if (val->CheckFlag(HInstruction::kUint32)) { | 1655 if (val->CheckFlag(HInstruction::kUint32)) { |
1664 LOperand* temp = FixedTemp(xmm1); | 1656 LOperand* temp = FixedTemp(xmm1); |
1665 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); | 1657 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); |
1666 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1658 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1667 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1659 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1668 return DefineSameAsFirst(new(zone()) LSmiTag(value)); | 1660 return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
1669 } else { | 1661 } else { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 | 2108 |
2117 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 2109 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
2118 ASSERT(argument_count_ == 0); | 2110 ASSERT(argument_count_ == 0); |
2119 allocator_->MarkAsOsrEntry(); | 2111 allocator_->MarkAsOsrEntry(); |
2120 current_block_->last_environment()->set_ast_id(instr->ast_id()); | 2112 current_block_->last_environment()->set_ast_id(instr->ast_id()); |
2121 return AssignEnvironment(new(zone()) LOsrEntry); | 2113 return AssignEnvironment(new(zone()) LOsrEntry); |
2122 } | 2114 } |
2123 | 2115 |
2124 | 2116 |
2125 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2117 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
2126 LParameter* result = new(zone()) LParameter; | 2118 int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
2127 if (info()->IsOptimizing()) { | 2119 return DefineAsSpilled(new(zone()) LParameter, spill_index); |
2128 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | |
2129 return DefineAsSpilled(result, spill_index); | |
2130 } else { | |
2131 ASSERT(info()->IsStub()); | |
2132 CodeStubInterfaceDescriptor* descriptor = | |
2133 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | |
2134 Register reg = descriptor->register_params[instr->index()]; | |
2135 return DefineFixed(result, reg); | |
2136 } | |
2137 } | 2120 } |
2138 | 2121 |
2139 | 2122 |
2140 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2123 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2141 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2124 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2142 if (spill_index > LUnallocated::kMaxFixedIndex) { | 2125 if (spill_index > LUnallocated::kMaxFixedIndex) { |
2143 Abort("Too many spill slots needed for OSR"); | 2126 Abort("Too many spill slots needed for OSR"); |
2144 spill_index = 0; | 2127 spill_index = 0; |
2145 } | 2128 } |
2146 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2129 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 instruction_pending_deoptimization_environment_ = NULL; | 2205 instruction_pending_deoptimization_environment_ = NULL; |
2223 pending_deoptimization_ast_id_ = BailoutId::None(); | 2206 pending_deoptimization_ast_id_ = BailoutId::None(); |
2224 return result; | 2207 return result; |
2225 } | 2208 } |
2226 | 2209 |
2227 return NULL; | 2210 return NULL; |
2228 } | 2211 } |
2229 | 2212 |
2230 | 2213 |
2231 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2214 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2232 info()->MarkAsDeferredCalling(); | |
2233 if (instr->is_function_entry()) { | 2215 if (instr->is_function_entry()) { |
2234 return MarkAsCall(new(zone()) LStackCheck, instr); | 2216 return MarkAsCall(new(zone()) LStackCheck, instr); |
2235 } else { | 2217 } else { |
2236 ASSERT(instr->is_backwards_branch()); | 2218 ASSERT(instr->is_backwards_branch()); |
2237 return AssignEnvironment(AssignPointerMap(new(zone()) LStackCheck)); | 2219 return AssignEnvironment(AssignPointerMap(new(zone()) LStackCheck)); |
2238 } | 2220 } |
2239 } | 2221 } |
2240 | 2222 |
2241 | 2223 |
2242 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 2224 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2291 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2310 LOperand* object = UseRegister(instr->object()); | 2292 LOperand* object = UseRegister(instr->object()); |
2311 LOperand* index = UseTempRegister(instr->index()); | 2293 LOperand* index = UseTempRegister(instr->index()); |
2312 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2294 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2313 } | 2295 } |
2314 | 2296 |
2315 | 2297 |
2316 } } // namespace v8::internal | 2298 } } // namespace v8::internal |
2317 | 2299 |
2318 #endif // V8_TARGET_ARCH_X64 | 2300 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |