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