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 24 matching lines...) Expand all Loading... |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 #define DEFINE_COMPILE(type) \ | 37 #define DEFINE_COMPILE(type) \ |
38 void L##type::CompileToNative(LCodeGen* generator) { \ | 38 void L##type::CompileToNative(LCodeGen* generator) { \ |
39 generator->Do##type(this); \ | 39 generator->Do##type(this); \ |
40 } | 40 } |
41 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 41 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
42 #undef DEFINE_COMPILE | 42 #undef DEFINE_COMPILE |
43 | 43 |
44 LOsrEntry::LOsrEntry() { | 44 LOsrEntry::LOsrEntry() { |
45 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) { | 45 for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
46 register_spills_[i] = NULL; | 46 register_spills_[i] = NULL; |
47 } | 47 } |
48 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { | 48 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) { |
49 double_register_spills_[i] = NULL; | 49 double_register_spills_[i] = NULL; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 void LOsrEntry::MarkSpilledRegister(int allocation_index, | 54 void LOsrEntry::MarkSpilledRegister(int allocation_index, |
55 LOperand* spill_operand) { | 55 LOperand* spill_operand) { |
56 ASSERT(spill_operand->IsStackSlot()); | 56 ASSERT(spill_operand->IsStackSlot()); |
57 ASSERT(register_spills_[allocation_index] == NULL); | 57 ASSERT(register_spills_[allocation_index] == NULL); |
58 register_spills_[allocation_index] = spill_operand; | 58 register_spills_[allocation_index] = spill_operand; |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 int argument_index_accumulator = 0; | 605 int argument_index_accumulator = 0; |
606 instr->set_environment(CreateEnvironment(hydrogen_env, | 606 instr->set_environment(CreateEnvironment(hydrogen_env, |
607 &argument_index_accumulator)); | 607 &argument_index_accumulator)); |
608 return instr; | 608 return instr; |
609 } | 609 } |
610 | 610 |
611 | 611 |
612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
613 HInstruction* hinstr, | 613 HInstruction* hinstr, |
614 CanDeoptimize can_deoptimize) { | 614 CanDeoptimize can_deoptimize) { |
615 info()->MarkAsNonDeferredCalling(); | |
616 #ifdef DEBUG | 615 #ifdef DEBUG |
617 instr->VerifyCall(); | 616 instr->VerifyCall(); |
618 #endif | 617 #endif |
619 instr->MarkAsCall(); | 618 instr->MarkAsCall(); |
620 instr = AssignPointerMap(instr); | 619 instr = AssignPointerMap(instr); |
621 | 620 |
622 if (hinstr->HasObservableSideEffects()) { | 621 if (hinstr->HasObservableSideEffects()) { |
623 ASSERT(hinstr->next()->IsSimulate()); | 622 ASSERT(hinstr->next()->IsSimulate()); |
624 HSimulate* sim = HSimulate::cast(hinstr->next()); | 623 HSimulate* sim = HSimulate::cast(hinstr->next()); |
625 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | 624 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 UNREACHABLE(); | 1677 UNREACHABLE(); |
1679 return NULL; | 1678 return NULL; |
1680 } | 1679 } |
1681 | 1680 |
1682 | 1681 |
1683 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1682 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1684 Representation from = instr->from(); | 1683 Representation from = instr->from(); |
1685 Representation to = instr->to(); | 1684 Representation to = instr->to(); |
1686 if (from.IsTagged()) { | 1685 if (from.IsTagged()) { |
1687 if (to.IsDouble()) { | 1686 if (to.IsDouble()) { |
1688 info()->MarkAsDeferredCalling(); | |
1689 LOperand* value = UseRegister(instr->value()); | 1687 LOperand* value = UseRegister(instr->value()); |
1690 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1688 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
1691 return AssignEnvironment(DefineAsRegister(res)); | 1689 return AssignEnvironment(DefineAsRegister(res)); |
1692 } else { | 1690 } else { |
1693 ASSERT(to.IsInteger32()); | 1691 ASSERT(to.IsInteger32()); |
1694 LOperand* value = UseRegisterAtStart(instr->value()); | 1692 LOperand* value = UseRegisterAtStart(instr->value()); |
1695 LInstruction* res = NULL; | 1693 LInstruction* res = NULL; |
1696 if (instr->value()->type().IsSmi()) { | 1694 if (instr->value()->type().IsSmi()) { |
1697 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1695 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
1698 } else { | 1696 } else { |
1699 LOperand* temp1 = TempRegister(); | 1697 LOperand* temp1 = TempRegister(); |
1700 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1698 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
1701 : NULL; | 1699 : NULL; |
1702 LOperand* temp3 = FixedTemp(d11); | 1700 LOperand* temp3 = FixedTemp(d11); |
1703 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1701 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
1704 temp1, | 1702 temp1, |
1705 temp2, | 1703 temp2, |
1706 temp3)); | 1704 temp3)); |
1707 res = AssignEnvironment(res); | 1705 res = AssignEnvironment(res); |
1708 } | 1706 } |
1709 return res; | 1707 return res; |
1710 } | 1708 } |
1711 } else if (from.IsDouble()) { | 1709 } else if (from.IsDouble()) { |
1712 if (to.IsTagged()) { | 1710 if (to.IsTagged()) { |
1713 info()->MarkAsDeferredCalling(); | |
1714 LOperand* value = UseRegister(instr->value()); | 1711 LOperand* value = UseRegister(instr->value()); |
1715 LOperand* temp1 = TempRegister(); | 1712 LOperand* temp1 = TempRegister(); |
1716 LOperand* temp2 = TempRegister(); | 1713 LOperand* temp2 = TempRegister(); |
1717 | 1714 |
1718 // Make sure that the temp and result_temp registers are | 1715 // Make sure that the temp and result_temp registers are |
1719 // different. | 1716 // different. |
1720 LUnallocated* result_temp = TempRegister(); | 1717 LUnallocated* result_temp = TempRegister(); |
1721 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | 1718 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); |
1722 Define(result, result_temp); | 1719 Define(result, result_temp); |
1723 return AssignPointerMap(result); | 1720 return AssignPointerMap(result); |
1724 } else { | 1721 } else { |
1725 ASSERT(to.IsInteger32()); | 1722 ASSERT(to.IsInteger32()); |
1726 LOperand* value = UseRegister(instr->value()); | 1723 LOperand* value = UseRegister(instr->value()); |
1727 LOperand* temp1 = TempRegister(); | 1724 LOperand* temp1 = TempRegister(); |
1728 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; | 1725 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; |
1729 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); | 1726 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); |
1730 return AssignEnvironment(DefineAsRegister(res)); | 1727 return AssignEnvironment(DefineAsRegister(res)); |
1731 } | 1728 } |
1732 } else if (from.IsInteger32()) { | 1729 } else if (from.IsInteger32()) { |
1733 info()->MarkAsDeferredCalling(); | |
1734 if (to.IsTagged()) { | 1730 if (to.IsTagged()) { |
1735 HValue* val = instr->value(); | 1731 HValue* val = instr->value(); |
1736 LOperand* value = UseRegisterAtStart(val); | 1732 LOperand* value = UseRegisterAtStart(val); |
1737 if (val->CheckFlag(HInstruction::kUint32)) { | 1733 if (val->CheckFlag(HInstruction::kUint32)) { |
1738 LNumberTagU* result = new(zone()) LNumberTagU(value); | 1734 LNumberTagU* result = new(zone()) LNumberTagU(value); |
1739 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1735 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1740 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1736 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1741 return DefineAsRegister(new(zone()) LSmiTag(value)); | 1737 return DefineAsRegister(new(zone()) LSmiTag(value)); |
1742 } else { | 1738 } else { |
1743 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1739 LNumberTagI* result = new(zone()) LNumberTagI(value); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 } | 1957 } |
1962 result = new(zone()) LLoadKeyed(obj, key); | 1958 result = new(zone()) LLoadKeyed(obj, key); |
1963 } else { | 1959 } else { |
1964 ASSERT( | 1960 ASSERT( |
1965 (instr->representation().IsInteger32() && | 1961 (instr->representation().IsInteger32() && |
1966 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1962 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
1967 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 1963 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
1968 (instr->representation().IsDouble() && | 1964 (instr->representation().IsDouble() && |
1969 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 1965 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
1970 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 1966 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
1971 // float->double conversion on non-VFP2 requires an extra scratch | 1967 LOperand* external_pointer = UseRegister(instr->elements()); |
1972 // register. For convenience, just mark the elements register as "UseTemp" | |
1973 // so that it can be used as a temp during the float->double conversion | |
1974 // after it's no longer needed after the float load. | |
1975 bool needs_temp = | |
1976 !CpuFeatures::IsSupported(VFP2) && | |
1977 (elements_kind == EXTERNAL_FLOAT_ELEMENTS); | |
1978 LOperand* external_pointer = needs_temp | |
1979 ? UseTempRegister(instr->elements()) | |
1980 : UseRegister(instr->elements()); | |
1981 result = new(zone()) LLoadKeyed(external_pointer, key); | 1968 result = new(zone()) LLoadKeyed(external_pointer, key); |
1982 } | 1969 } |
1983 | 1970 |
1984 DefineAsRegister(result); | 1971 DefineAsRegister(result); |
1985 // An unsigned int array load might overflow and cause a deopt, make sure it | 1972 // An unsigned int array load might overflow and cause a deopt, make sure it |
1986 // has an environment. | 1973 // has an environment. |
1987 bool can_deoptimize = instr->RequiresHoleCheck() || | 1974 bool can_deoptimize = instr->RequiresHoleCheck() || |
1988 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 1975 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
1989 return can_deoptimize ? AssignEnvironment(result) : result; | 1976 return can_deoptimize ? AssignEnvironment(result) : result; |
1990 } | 1977 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 | 2175 |
2189 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 2176 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
2190 ASSERT(argument_count_ == 0); | 2177 ASSERT(argument_count_ == 0); |
2191 allocator_->MarkAsOsrEntry(); | 2178 allocator_->MarkAsOsrEntry(); |
2192 current_block_->last_environment()->set_ast_id(instr->ast_id()); | 2179 current_block_->last_environment()->set_ast_id(instr->ast_id()); |
2193 return AssignEnvironment(new(zone()) LOsrEntry); | 2180 return AssignEnvironment(new(zone()) LOsrEntry); |
2194 } | 2181 } |
2195 | 2182 |
2196 | 2183 |
2197 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2184 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
2198 LParameter* result = new(zone()) LParameter; | 2185 int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
2199 if (info()->IsOptimizing()) { | 2186 return DefineAsSpilled(new(zone()) LParameter, spill_index); |
2200 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | |
2201 return DefineAsSpilled(result, spill_index); | |
2202 } else { | |
2203 ASSERT(info()->IsStub()); | |
2204 CodeStubInterfaceDescriptor* descriptor = | |
2205 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | |
2206 Register reg = descriptor->register_params[instr->index()]; | |
2207 return DefineFixed(result, reg); | |
2208 } | |
2209 } | 2187 } |
2210 | 2188 |
2211 | 2189 |
2212 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2190 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2213 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2191 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2214 if (spill_index > LUnallocated::kMaxFixedIndex) { | 2192 if (spill_index > LUnallocated::kMaxFixedIndex) { |
2215 Abort("Too many spill slots needed for OSR"); | 2193 Abort("Too many spill slots needed for OSR"); |
2216 spill_index = 0; | 2194 spill_index = 0; |
2217 } | 2195 } |
2218 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2196 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 | 2355 |
2378 | 2356 |
2379 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2357 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2380 LOperand* object = UseRegister(instr->object()); | 2358 LOperand* object = UseRegister(instr->object()); |
2381 LOperand* index = UseRegister(instr->index()); | 2359 LOperand* index = UseRegister(instr->index()); |
2382 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2360 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2383 } | 2361 } |
2384 | 2362 |
2385 | 2363 |
2386 } } // namespace v8::internal | 2364 } } // namespace v8::internal |
OLD | NEW |