| 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::kNumAllocatableRegisters; ++i) { | 45 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) { |
| 46 register_spills_[i] = NULL; | 46 register_spills_[i] = NULL; |
| 47 } | 47 } |
| 48 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) { | 48 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++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(); |
| 615 #ifdef DEBUG | 616 #ifdef DEBUG |
| 616 instr->VerifyCall(); | 617 instr->VerifyCall(); |
| 617 #endif | 618 #endif |
| 618 instr->MarkAsCall(); | 619 instr->MarkAsCall(); |
| 619 instr = AssignPointerMap(instr); | 620 instr = AssignPointerMap(instr); |
| 620 | 621 |
| 621 if (hinstr->HasObservableSideEffects()) { | 622 if (hinstr->HasObservableSideEffects()) { |
| 622 ASSERT(hinstr->next()->IsSimulate()); | 623 ASSERT(hinstr->next()->IsSimulate()); |
| 623 HSimulate* sim = HSimulate::cast(hinstr->next()); | 624 HSimulate* sim = HSimulate::cast(hinstr->next()); |
| 624 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | 625 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 UNREACHABLE(); | 1678 UNREACHABLE(); |
| 1678 return NULL; | 1679 return NULL; |
| 1679 } | 1680 } |
| 1680 | 1681 |
| 1681 | 1682 |
| 1682 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1683 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
| 1683 Representation from = instr->from(); | 1684 Representation from = instr->from(); |
| 1684 Representation to = instr->to(); | 1685 Representation to = instr->to(); |
| 1685 if (from.IsTagged()) { | 1686 if (from.IsTagged()) { |
| 1686 if (to.IsDouble()) { | 1687 if (to.IsDouble()) { |
| 1688 info()->MarkAsDeferredCalling(); |
| 1687 LOperand* value = UseRegister(instr->value()); | 1689 LOperand* value = UseRegister(instr->value()); |
| 1688 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1690 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
| 1689 return AssignEnvironment(DefineAsRegister(res)); | 1691 return AssignEnvironment(DefineAsRegister(res)); |
| 1690 } else { | 1692 } else { |
| 1691 ASSERT(to.IsInteger32()); | 1693 ASSERT(to.IsInteger32()); |
| 1692 LOperand* value = UseRegisterAtStart(instr->value()); | 1694 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1693 LInstruction* res = NULL; | 1695 LInstruction* res = NULL; |
| 1694 if (instr->value()->type().IsSmi()) { | 1696 if (instr->value()->type().IsSmi()) { |
| 1695 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1697 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
| 1696 } else { | 1698 } else { |
| 1697 LOperand* temp1 = TempRegister(); | 1699 LOperand* temp1 = TempRegister(); |
| 1698 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1700 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
| 1699 : NULL; | 1701 : NULL; |
| 1700 LOperand* temp3 = FixedTemp(d11); | 1702 LOperand* temp3 = FixedTemp(d11); |
| 1701 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1703 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
| 1702 temp1, | 1704 temp1, |
| 1703 temp2, | 1705 temp2, |
| 1704 temp3)); | 1706 temp3)); |
| 1705 res = AssignEnvironment(res); | 1707 res = AssignEnvironment(res); |
| 1706 } | 1708 } |
| 1707 return res; | 1709 return res; |
| 1708 } | 1710 } |
| 1709 } else if (from.IsDouble()) { | 1711 } else if (from.IsDouble()) { |
| 1710 if (to.IsTagged()) { | 1712 if (to.IsTagged()) { |
| 1713 info()->MarkAsDeferredCalling(); |
| 1711 LOperand* value = UseRegister(instr->value()); | 1714 LOperand* value = UseRegister(instr->value()); |
| 1712 LOperand* temp1 = TempRegister(); | 1715 LOperand* temp1 = TempRegister(); |
| 1713 LOperand* temp2 = TempRegister(); | 1716 LOperand* temp2 = TempRegister(); |
| 1714 | 1717 |
| 1715 // Make sure that the temp and result_temp registers are | 1718 // Make sure that the temp and result_temp registers are |
| 1716 // different. | 1719 // different. |
| 1717 LUnallocated* result_temp = TempRegister(); | 1720 LUnallocated* result_temp = TempRegister(); |
| 1718 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | 1721 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); |
| 1719 Define(result, result_temp); | 1722 Define(result, result_temp); |
| 1720 return AssignPointerMap(result); | 1723 return AssignPointerMap(result); |
| 1721 } else { | 1724 } else { |
| 1722 ASSERT(to.IsInteger32()); | 1725 ASSERT(to.IsInteger32()); |
| 1723 LOperand* value = UseRegister(instr->value()); | 1726 LOperand* value = UseRegister(instr->value()); |
| 1724 LOperand* temp1 = TempRegister(); | 1727 LOperand* temp1 = TempRegister(); |
| 1725 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; | 1728 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; |
| 1726 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); | 1729 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); |
| 1727 return AssignEnvironment(DefineAsRegister(res)); | 1730 return AssignEnvironment(DefineAsRegister(res)); |
| 1728 } | 1731 } |
| 1729 } else if (from.IsInteger32()) { | 1732 } else if (from.IsInteger32()) { |
| 1733 info()->MarkAsDeferredCalling(); |
| 1730 if (to.IsTagged()) { | 1734 if (to.IsTagged()) { |
| 1731 HValue* val = instr->value(); | 1735 HValue* val = instr->value(); |
| 1732 LOperand* value = UseRegisterAtStart(val); | 1736 LOperand* value = UseRegisterAtStart(val); |
| 1733 if (val->CheckFlag(HInstruction::kUint32)) { | 1737 if (val->CheckFlag(HInstruction::kUint32)) { |
| 1734 LNumberTagU* result = new(zone()) LNumberTagU(value); | 1738 LNumberTagU* result = new(zone()) LNumberTagU(value); |
| 1735 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1739 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1736 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1740 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 1737 return DefineAsRegister(new(zone()) LSmiTag(value)); | 1741 return DefineAsRegister(new(zone()) LSmiTag(value)); |
| 1738 } else { | 1742 } else { |
| 1739 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1743 LNumberTagI* result = new(zone()) LNumberTagI(value); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 } | 1961 } |
| 1958 result = new(zone()) LLoadKeyed(obj, key); | 1962 result = new(zone()) LLoadKeyed(obj, key); |
| 1959 } else { | 1963 } else { |
| 1960 ASSERT( | 1964 ASSERT( |
| 1961 (instr->representation().IsInteger32() && | 1965 (instr->representation().IsInteger32() && |
| 1962 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1966 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 1963 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 1967 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 1964 (instr->representation().IsDouble() && | 1968 (instr->representation().IsDouble() && |
| 1965 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 1969 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 1966 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 1970 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 1967 LOperand* external_pointer = UseRegister(instr->elements()); | 1971 // float->double conversion on non-VFP2 requires an extra scratch |
| 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()); |
| 1968 result = new(zone()) LLoadKeyed(external_pointer, key); | 1981 result = new(zone()) LLoadKeyed(external_pointer, key); |
| 1969 } | 1982 } |
| 1970 | 1983 |
| 1971 DefineAsRegister(result); | 1984 DefineAsRegister(result); |
| 1972 // An unsigned int array load might overflow and cause a deopt, make sure it | 1985 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1973 // has an environment. | 1986 // has an environment. |
| 1974 bool can_deoptimize = instr->RequiresHoleCheck() || | 1987 bool can_deoptimize = instr->RequiresHoleCheck() || |
| 1975 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 1988 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 1976 return can_deoptimize ? AssignEnvironment(result) : result; | 1989 return can_deoptimize ? AssignEnvironment(result) : result; |
| 1977 } | 1990 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 | 2188 |
| 2176 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 2189 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
| 2177 ASSERT(argument_count_ == 0); | 2190 ASSERT(argument_count_ == 0); |
| 2178 allocator_->MarkAsOsrEntry(); | 2191 allocator_->MarkAsOsrEntry(); |
| 2179 current_block_->last_environment()->set_ast_id(instr->ast_id()); | 2192 current_block_->last_environment()->set_ast_id(instr->ast_id()); |
| 2180 return AssignEnvironment(new(zone()) LOsrEntry); | 2193 return AssignEnvironment(new(zone()) LOsrEntry); |
| 2181 } | 2194 } |
| 2182 | 2195 |
| 2183 | 2196 |
| 2184 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2197 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
| 2185 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | 2198 LParameter* result = new(zone()) LParameter; |
| 2186 return DefineAsSpilled(new(zone()) LParameter, spill_index); | 2199 if (info()->IsOptimizing()) { |
| 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 } |
| 2187 } | 2209 } |
| 2188 | 2210 |
| 2189 | 2211 |
| 2190 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2212 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
| 2191 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2213 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
| 2192 if (spill_index > LUnallocated::kMaxFixedIndex) { | 2214 if (spill_index > LUnallocated::kMaxFixedIndex) { |
| 2193 Abort("Too many spill slots needed for OSR"); | 2215 Abort("Too many spill slots needed for OSR"); |
| 2194 spill_index = 0; | 2216 spill_index = 0; |
| 2195 } | 2217 } |
| 2196 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2218 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 | 2377 |
| 2356 | 2378 |
| 2357 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2379 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2358 LOperand* object = UseRegister(instr->object()); | 2380 LOperand* object = UseRegister(instr->object()); |
| 2359 LOperand* index = UseRegister(instr->index()); | 2381 LOperand* index = UseRegister(instr->index()); |
| 2360 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2382 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2361 } | 2383 } |
| 2362 | 2384 |
| 2363 | 2385 |
| 2364 } } // namespace v8::internal | 2386 } } // namespace v8::internal |
| OLD | NEW |