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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 } | 754 } |
755 | 755 |
756 | 756 |
757 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 757 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
758 return AssignEnvironment(new(zone()) LDeoptimize); | 758 return AssignEnvironment(new(zone()) LDeoptimize); |
759 } | 759 } |
760 | 760 |
761 | 761 |
762 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 762 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
763 HBitwiseBinaryOperation* instr) { | 763 HBitwiseBinaryOperation* instr) { |
764 if (instr->representation().IsTagged()) { | 764 if (instr->representation().IsSmiOrTagged()) { |
765 ASSERT(instr->left()->representation().IsSmiOrTagged()); | 765 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
766 ASSERT(instr->right()->representation().IsSmiOrTagged()); | 766 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
767 | 767 |
768 LOperand* context = UseFixed(instr->context(), esi); | 768 LOperand* context = UseFixed(instr->context(), esi); |
769 LOperand* left = UseFixed(instr->left(), edx); | 769 LOperand* left = UseFixed(instr->left(), edx); |
770 LOperand* right = UseFixed(instr->right(), eax); | 770 LOperand* right = UseFixed(instr->right(), eax); |
771 LArithmeticT* result = new(zone()) LArithmeticT(op, context, left, right); | 771 LArithmeticT* result = new(zone()) LArithmeticT(op, context, left, right); |
772 return MarkAsCall(DefineFixed(result, eax), instr); | 772 return MarkAsCall(DefineFixed(result, eax), instr); |
773 } | 773 } |
774 | 774 |
775 ASSERT(instr->representation().IsSmiOrInteger32()); | 775 ASSERT(instr->representation().IsInteger32()); |
776 ASSERT(instr->left()->representation().Equals(instr->representation())); | 776 ASSERT(instr->left()->representation().IsInteger32()); |
777 ASSERT(instr->right()->representation().Equals(instr->representation())); | 777 ASSERT(instr->right()->representation().IsInteger32()); |
778 LOperand* left = UseRegisterAtStart(instr->left()); | 778 LOperand* left = UseRegisterAtStart(instr->left()); |
779 | 779 |
780 HValue* right_value = instr->right(); | 780 HValue* right_value = instr->right(); |
781 LOperand* right = NULL; | 781 LOperand* right = NULL; |
782 int constant_value = 0; | 782 int constant_value = 0; |
783 bool does_deopt = false; | |
784 if (right_value->IsConstant()) { | 783 if (right_value->IsConstant()) { |
785 HConstant* constant = HConstant::cast(right_value); | 784 HConstant* constant = HConstant::cast(right_value); |
786 right = chunk_->DefineConstantOperand(constant); | 785 right = chunk_->DefineConstantOperand(constant); |
787 constant_value = constant->Integer32Value() & 0x1f; | 786 constant_value = constant->Integer32Value() & 0x1f; |
788 // Left shifts can deoptimize if we shift by > 0 and the result cannot be | |
789 // truncated to smi. | |
790 if (instr->representation().IsSmi() && constant_value > 0) { | |
791 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | |
792 if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { | |
793 does_deopt = true; | |
794 break; | |
795 } | |
796 } | |
797 } | |
798 } else { | 787 } else { |
799 right = UseFixed(right_value, ecx); | 788 right = UseFixed(right_value, ecx); |
800 } | 789 } |
801 | 790 |
802 // Shift operations can only deoptimize if we do a logical shift by 0 and | 791 // Shift operations can only deoptimize if we do a logical shift by 0 and |
803 // the result cannot be truncated to int32. | 792 // the result cannot be truncated to int32. |
| 793 bool does_deopt = false; |
804 if (op == Token::SHR && constant_value == 0) { | 794 if (op == Token::SHR && constant_value == 0) { |
805 if (FLAG_opt_safe_uint32_operations) { | 795 if (FLAG_opt_safe_uint32_operations) { |
806 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | 796 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
807 } else { | 797 } else { |
808 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 798 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
809 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { | 799 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
810 does_deopt = true; | 800 does_deopt = true; |
811 break; | 801 break; |
812 } | 802 } |
813 } | 803 } |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 Representation r = instr->representation(); | 2129 Representation r = instr->representation(); |
2140 if (r.IsSmi()) { | 2130 if (r.IsSmi()) { |
2141 return DefineAsRegister(new(zone()) LConstantS); | 2131 return DefineAsRegister(new(zone()) LConstantS); |
2142 } else if (r.IsInteger32()) { | 2132 } else if (r.IsInteger32()) { |
2143 return DefineAsRegister(new(zone()) LConstantI); | 2133 return DefineAsRegister(new(zone()) LConstantI); |
2144 } else if (r.IsDouble()) { | 2134 } else if (r.IsDouble()) { |
2145 double value = instr->DoubleValue(); | 2135 double value = instr->DoubleValue(); |
2146 bool value_is_zero = BitCast<uint64_t, double>(value) == 0; | 2136 bool value_is_zero = BitCast<uint64_t, double>(value) == 0; |
2147 LOperand* temp = value_is_zero ? NULL : TempRegister(); | 2137 LOperand* temp = value_is_zero ? NULL : TempRegister(); |
2148 return DefineAsRegister(new(zone()) LConstantD(temp)); | 2138 return DefineAsRegister(new(zone()) LConstantD(temp)); |
2149 } else if (r.IsExternal()) { | |
2150 return DefineAsRegister(new(zone()) LConstantE); | |
2151 } else if (r.IsTagged()) { | 2139 } else if (r.IsTagged()) { |
2152 return DefineAsRegister(new(zone()) LConstantT); | 2140 return DefineAsRegister(new(zone()) LConstantT); |
2153 } else { | 2141 } else { |
2154 UNREACHABLE(); | 2142 UNREACHABLE(); |
2155 return NULL; | 2143 return NULL; |
2156 } | 2144 } |
2157 } | 2145 } |
2158 | 2146 |
2159 | 2147 |
2160 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 2148 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 } else { | 2205 } else { |
2218 value = UseRegister(instr->value()); | 2206 value = UseRegister(instr->value()); |
2219 temp = NULL; | 2207 temp = NULL; |
2220 } | 2208 } |
2221 LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); | 2209 LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); |
2222 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; | 2210 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
2223 } | 2211 } |
2224 | 2212 |
2225 | 2213 |
2226 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { | 2214 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { |
2227 LOperand* obj = (instr->access().IsExternalMemory() && | 2215 LOperand* obj = UseRegisterAtStart(instr->object()); |
2228 instr->access().offset() == 0) | |
2229 ? UseRegisterOrConstantAtStart(instr->object()) | |
2230 : UseRegisterAtStart(instr->object()); | |
2231 return DefineAsRegister(new(zone()) LLoadNamedField(obj)); | 2216 return DefineAsRegister(new(zone()) LLoadNamedField(obj)); |
2232 } | 2217 } |
2233 | 2218 |
2234 | 2219 |
2235 LInstruction* LChunkBuilder::DoLoadNamedFieldPolymorphic( | 2220 LInstruction* LChunkBuilder::DoLoadNamedFieldPolymorphic( |
2236 HLoadNamedFieldPolymorphic* instr) { | 2221 HLoadNamedFieldPolymorphic* instr) { |
2237 ASSERT(instr->representation().IsTagged()); | 2222 ASSERT(instr->representation().IsTagged()); |
2238 if (instr->need_generic()) { | 2223 if (instr->need_generic()) { |
2239 LOperand* context = UseFixed(instr->context(), esi); | 2224 LOperand* context = UseFixed(instr->context(), esi); |
2240 LOperand* obj = UseFixed(instr->object(), edx); | 2225 LOperand* obj = UseFixed(instr->object(), edx); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 HTransitionElementsKind* instr) { | 2398 HTransitionElementsKind* instr) { |
2414 LOperand* object = UseRegister(instr->object()); | 2399 LOperand* object = UseRegister(instr->object()); |
2415 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { | 2400 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { |
2416 LOperand* object = UseRegister(instr->object()); | 2401 LOperand* object = UseRegister(instr->object()); |
2417 LOperand* new_map_reg = TempRegister(); | 2402 LOperand* new_map_reg = TempRegister(); |
2418 LOperand* temp_reg = TempRegister(); | 2403 LOperand* temp_reg = TempRegister(); |
2419 LTransitionElementsKind* result = | 2404 LTransitionElementsKind* result = |
2420 new(zone()) LTransitionElementsKind(object, NULL, | 2405 new(zone()) LTransitionElementsKind(object, NULL, |
2421 new_map_reg, temp_reg); | 2406 new_map_reg, temp_reg); |
2422 return result; | 2407 return result; |
2423 } else { | 2408 } else if (FLAG_compiled_transitions) { |
2424 LOperand* context = UseRegister(instr->context()); | 2409 LOperand* context = UseRegister(instr->context()); |
2425 LTransitionElementsKind* result = | 2410 LTransitionElementsKind* result = |
2426 new(zone()) LTransitionElementsKind(object, context, NULL, NULL); | 2411 new(zone()) LTransitionElementsKind(object, context, NULL, NULL); |
2427 return AssignPointerMap(result); | 2412 return AssignPointerMap(result); |
| 2413 } else { |
| 2414 LOperand* object = UseFixed(instr->object(), eax); |
| 2415 LOperand* fixed_object_reg = FixedTemp(edx); |
| 2416 LOperand* new_map_reg = FixedTemp(ebx); |
| 2417 LTransitionElementsKind* result = |
| 2418 new(zone()) LTransitionElementsKind(object, |
| 2419 NULL, |
| 2420 new_map_reg, |
| 2421 fixed_object_reg); |
| 2422 return MarkAsCall(result, instr); |
2428 } | 2423 } |
2429 } | 2424 } |
2430 | 2425 |
2431 | 2426 |
2432 LInstruction* LChunkBuilder::DoTrapAllocationMemento( | 2427 LInstruction* LChunkBuilder::DoTrapAllocationMemento( |
2433 HTrapAllocationMemento* instr) { | 2428 HTrapAllocationMemento* instr) { |
2434 LOperand* object = UseRegister(instr->object()); | 2429 LOperand* object = UseRegister(instr->object()); |
2435 LOperand* temp = TempRegister(); | 2430 LOperand* temp = TempRegister(); |
2436 LTrapAllocationMemento* result = | 2431 LTrapAllocationMemento* result = |
2437 new(zone()) LTrapAllocationMemento(object, temp); | 2432 new(zone()) LTrapAllocationMemento(object, temp); |
2438 return AssignEnvironment(result); | 2433 return AssignEnvironment(result); |
2439 } | 2434 } |
2440 | 2435 |
2441 | 2436 |
2442 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2437 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
2443 bool is_in_object = instr->access().IsInobject(); | 2438 bool is_in_object = instr->access().IsInobject(); |
2444 bool is_external_location = instr->access().IsExternalMemory() && | |
2445 instr->access().offset() == 0; | |
2446 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2439 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2447 bool needs_write_barrier_for_map = !instr->transition().is_null() && | 2440 bool needs_write_barrier_for_map = !instr->transition().is_null() && |
2448 instr->NeedsWriteBarrierForMap(); | 2441 instr->NeedsWriteBarrierForMap(); |
2449 | 2442 |
2450 LOperand* obj; | 2443 LOperand* obj; |
2451 if (needs_write_barrier) { | 2444 if (needs_write_barrier) { |
2452 obj = is_in_object | 2445 obj = is_in_object |
2453 ? UseRegister(instr->object()) | 2446 ? UseRegister(instr->object()) |
2454 : UseTempRegister(instr->object()); | 2447 : UseTempRegister(instr->object()); |
2455 } else if (is_external_location) { | |
2456 ASSERT(!is_in_object); | |
2457 ASSERT(!needs_write_barrier); | |
2458 ASSERT(!needs_write_barrier_for_map); | |
2459 obj = UseRegisterOrConstant(instr->object()); | |
2460 } else { | 2448 } else { |
2461 obj = needs_write_barrier_for_map | 2449 obj = needs_write_barrier_for_map |
2462 ? UseRegister(instr->object()) | 2450 ? UseRegister(instr->object()) |
2463 : UseRegisterAtStart(instr->object()); | 2451 : UseRegisterAtStart(instr->object()); |
2464 } | 2452 } |
2465 | 2453 |
2466 bool can_be_constant = instr->value()->IsConstant() && | 2454 bool can_be_constant = instr->value()->IsConstant() && |
2467 HConstant::cast(instr->value())->NotInNewSpace() && | 2455 HConstant::cast(instr->value())->NotInNewSpace() && |
2468 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); | 2456 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); |
2469 | 2457 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2765 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2778 LOperand* object = UseRegister(instr->object()); | 2766 LOperand* object = UseRegister(instr->object()); |
2779 LOperand* index = UseTempRegister(instr->index()); | 2767 LOperand* index = UseTempRegister(instr->index()); |
2780 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2768 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2781 } | 2769 } |
2782 | 2770 |
2783 | 2771 |
2784 } } // namespace v8::internal | 2772 } } // namespace v8::internal |
2785 | 2773 |
2786 #endif // V8_TARGET_ARCH_IA32 | 2774 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |