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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 UNREACHABLE(); | 1687 UNREACHABLE(); |
1689 return NULL; | 1688 return NULL; |
1690 } | 1689 } |
1691 | 1690 |
1692 | 1691 |
1693 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1692 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
1694 Representation from = instr->from(); | 1693 Representation from = instr->from(); |
1695 Representation to = instr->to(); | 1694 Representation to = instr->to(); |
1696 if (from.IsTagged()) { | 1695 if (from.IsTagged()) { |
1697 if (to.IsDouble()) { | 1696 if (to.IsDouble()) { |
1698 info()->MarkAsDeferredCalling(); | |
1699 LOperand* value = UseRegister(instr->value()); | 1697 LOperand* value = UseRegister(instr->value()); |
1700 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1698 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
1701 return AssignEnvironment(DefineAsRegister(res)); | 1699 return AssignEnvironment(DefineAsRegister(res)); |
1702 } else { | 1700 } else { |
1703 ASSERT(to.IsInteger32()); | 1701 ASSERT(to.IsInteger32()); |
1704 LOperand* value = UseRegisterAtStart(instr->value()); | 1702 LOperand* value = UseRegisterAtStart(instr->value()); |
1705 LInstruction* res = NULL; | 1703 LInstruction* res = NULL; |
1706 if (instr->value()->type().IsSmi()) { | 1704 if (instr->value()->type().IsSmi()) { |
1707 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1705 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
1708 } else { | 1706 } else { |
1709 LOperand* temp1 = TempRegister(); | 1707 LOperand* temp1 = TempRegister(); |
1710 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1708 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
1711 : NULL; | 1709 : NULL; |
1712 LOperand* temp3 = FixedTemp(d11); | 1710 LOperand* temp3 = FixedTemp(d11); |
1713 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1711 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
1714 temp1, | 1712 temp1, |
1715 temp2, | 1713 temp2, |
1716 temp3)); | 1714 temp3)); |
1717 res = AssignEnvironment(res); | 1715 res = AssignEnvironment(res); |
1718 } | 1716 } |
1719 return res; | 1717 return res; |
1720 } | 1718 } |
1721 } else if (from.IsDouble()) { | 1719 } else if (from.IsDouble()) { |
1722 if (to.IsTagged()) { | 1720 if (to.IsTagged()) { |
1723 info()->MarkAsDeferredCalling(); | |
1724 LOperand* value = UseRegister(instr->value()); | 1721 LOperand* value = UseRegister(instr->value()); |
1725 LOperand* temp1 = TempRegister(); | 1722 LOperand* temp1 = TempRegister(); |
1726 LOperand* temp2 = TempRegister(); | 1723 LOperand* temp2 = TempRegister(); |
1727 | 1724 |
1728 // Make sure that the temp and result_temp registers are | 1725 // Make sure that the temp and result_temp registers are |
1729 // different. | 1726 // different. |
1730 LUnallocated* result_temp = TempRegister(); | 1727 LUnallocated* result_temp = TempRegister(); |
1731 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | 1728 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); |
1732 Define(result, result_temp); | 1729 Define(result, result_temp); |
1733 return AssignPointerMap(result); | 1730 return AssignPointerMap(result); |
1734 } else { | 1731 } else { |
1735 ASSERT(to.IsInteger32()); | 1732 ASSERT(to.IsInteger32()); |
1736 LOperand* value = UseRegister(instr->value()); | 1733 LOperand* value = UseRegister(instr->value()); |
1737 LOperand* temp1 = TempRegister(); | 1734 LOperand* temp1 = TempRegister(); |
1738 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; | 1735 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; |
1739 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); | 1736 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); |
1740 return AssignEnvironment(DefineAsRegister(res)); | 1737 return AssignEnvironment(DefineAsRegister(res)); |
1741 } | 1738 } |
1742 } else if (from.IsInteger32()) { | 1739 } else if (from.IsInteger32()) { |
1743 info()->MarkAsDeferredCalling(); | |
1744 if (to.IsTagged()) { | 1740 if (to.IsTagged()) { |
1745 HValue* val = instr->value(); | 1741 HValue* val = instr->value(); |
1746 LOperand* value = UseRegisterAtStart(val); | 1742 LOperand* value = UseRegisterAtStart(val); |
1747 if (val->CheckFlag(HInstruction::kUint32)) { | 1743 if (val->CheckFlag(HInstruction::kUint32)) { |
1748 LNumberTagU* result = new(zone()) LNumberTagU(value); | 1744 LNumberTagU* result = new(zone()) LNumberTagU(value); |
1749 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1745 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1750 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1746 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1751 return DefineAsRegister(new(zone()) LSmiTag(value)); | 1747 return DefineAsRegister(new(zone()) LSmiTag(value)); |
1752 } else { | 1748 } else { |
1753 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1749 LNumberTagI* result = new(zone()) LNumberTagI(value); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 } | 1967 } |
1972 result = new(zone()) LLoadKeyed(obj, key); | 1968 result = new(zone()) LLoadKeyed(obj, key); |
1973 } else { | 1969 } else { |
1974 ASSERT( | 1970 ASSERT( |
1975 (instr->representation().IsInteger32() && | 1971 (instr->representation().IsInteger32() && |
1976 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1972 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
1977 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 1973 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
1978 (instr->representation().IsDouble() && | 1974 (instr->representation().IsDouble() && |
1979 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 1975 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
1980 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 1976 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
1981 // float->double conversion on non-VFP2 requires an extra scratch | 1977 LOperand* external_pointer = UseRegister(instr->elements()); |
1982 // register. For convenience, just mark the elements register as "UseTemp" | |
1983 // so that it can be used as a temp during the float->double conversion | |
1984 // after it's no longer needed after the float load. | |
1985 bool needs_temp = | |
1986 !CpuFeatures::IsSupported(VFP2) && | |
1987 (elements_kind == EXTERNAL_FLOAT_ELEMENTS); | |
1988 LOperand* external_pointer = needs_temp | |
1989 ? UseTempRegister(instr->elements()) | |
1990 : UseRegister(instr->elements()); | |
1991 result = new(zone()) LLoadKeyed(external_pointer, key); | 1978 result = new(zone()) LLoadKeyed(external_pointer, key); |
1992 } | 1979 } |
1993 | 1980 |
1994 DefineAsRegister(result); | 1981 DefineAsRegister(result); |
1995 // An unsigned int array load might overflow and cause a deopt, make sure it | 1982 // An unsigned int array load might overflow and cause a deopt, make sure it |
1996 // has an environment. | 1983 // has an environment. |
1997 bool can_deoptimize = instr->RequiresHoleCheck() || | 1984 bool can_deoptimize = instr->RequiresHoleCheck() || |
1998 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 1985 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
1999 return can_deoptimize ? AssignEnvironment(result) : result; | 1986 return can_deoptimize ? AssignEnvironment(result) : result; |
2000 } | 1987 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 | 2185 |
2199 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 2186 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
2200 ASSERT(argument_count_ == 0); | 2187 ASSERT(argument_count_ == 0); |
2201 allocator_->MarkAsOsrEntry(); | 2188 allocator_->MarkAsOsrEntry(); |
2202 current_block_->last_environment()->set_ast_id(instr->ast_id()); | 2189 current_block_->last_environment()->set_ast_id(instr->ast_id()); |
2203 return AssignEnvironment(new(zone()) LOsrEntry); | 2190 return AssignEnvironment(new(zone()) LOsrEntry); |
2204 } | 2191 } |
2205 | 2192 |
2206 | 2193 |
2207 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2194 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
2208 LParameter* result = new(zone()) LParameter; | 2195 int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
2209 if (info()->IsOptimizing()) { | 2196 return DefineAsSpilled(new(zone()) LParameter, spill_index); |
2210 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | |
2211 return DefineAsSpilled(result, spill_index); | |
2212 } else { | |
2213 ASSERT(info()->IsStub()); | |
2214 CodeStubInterfaceDescriptor* descriptor = | |
2215 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | |
2216 Register reg = descriptor->register_params_[instr->index()]; | |
2217 return DefineFixed(result, reg); | |
2218 } | |
2219 } | 2197 } |
2220 | 2198 |
2221 | 2199 |
2222 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2200 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2223 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2201 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2224 if (spill_index > LUnallocated::kMaxFixedIndex) { | 2202 if (spill_index > LUnallocated::kMaxFixedIndex) { |
2225 Abort("Too many spill slots needed for OSR"); | 2203 Abort("Too many spill slots needed for OSR"); |
2226 spill_index = 0; | 2204 spill_index = 0; |
2227 } | 2205 } |
2228 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2206 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 | 2365 |
2388 | 2366 |
2389 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2367 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2390 LOperand* object = UseRegister(instr->object()); | 2368 LOperand* object = UseRegister(instr->object()); |
2391 LOperand* index = UseRegister(instr->index()); | 2369 LOperand* index = UseRegister(instr->index()); |
2392 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2370 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2393 } | 2371 } |
2394 | 2372 |
2395 | 2373 |
2396 } } // namespace v8::internal | 2374 } } // namespace v8::internal |
OLD | NEW |