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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 709 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
710 return AssignEnvironment(new(zone()) LDeoptimize); | 710 return AssignEnvironment(new(zone()) LDeoptimize); |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 714 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
715 HBitwiseBinaryOperation* instr) { | 715 HBitwiseBinaryOperation* instr) { |
716 if (instr->representation().IsTagged()) { | 716 if (instr->representation().IsSmiOrTagged()) { |
717 ASSERT(instr->left()->representation().IsTagged()); | 717 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
718 ASSERT(instr->right()->representation().IsTagged()); | 718 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
719 | 719 |
720 LOperand* left = UseFixed(instr->left(), a1); | 720 LOperand* left = UseFixed(instr->left(), a1); |
721 LOperand* right = UseFixed(instr->right(), a0); | 721 LOperand* right = UseFixed(instr->right(), a0); |
722 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); | 722 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); |
723 return MarkAsCall(DefineFixed(result, v0), instr); | 723 return MarkAsCall(DefineFixed(result, v0), instr); |
724 } | 724 } |
725 | 725 |
726 ASSERT(instr->representation().IsSmiOrInteger32()); | 726 ASSERT(instr->representation().IsInteger32()); |
727 ASSERT(instr->left()->representation().Equals(instr->representation())); | 727 ASSERT(instr->left()->representation().IsInteger32()); |
728 ASSERT(instr->right()->representation().Equals(instr->representation())); | 728 ASSERT(instr->right()->representation().IsInteger32()); |
729 LOperand* left = UseRegisterAtStart(instr->left()); | 729 LOperand* left = UseRegisterAtStart(instr->left()); |
730 | 730 |
731 HValue* right_value = instr->right(); | 731 HValue* right_value = instr->right(); |
732 LOperand* right = NULL; | 732 LOperand* right = NULL; |
733 int constant_value = 0; | 733 int constant_value = 0; |
734 bool does_deopt = false; | |
735 if (right_value->IsConstant()) { | 734 if (right_value->IsConstant()) { |
736 HConstant* constant = HConstant::cast(right_value); | 735 HConstant* constant = HConstant::cast(right_value); |
737 right = chunk_->DefineConstantOperand(constant); | 736 right = chunk_->DefineConstantOperand(constant); |
738 constant_value = constant->Integer32Value() & 0x1f; | 737 constant_value = constant->Integer32Value() & 0x1f; |
739 // Left shifts can deoptimize if we shift by > 0 and the result cannot be | |
740 // truncated to smi. | |
741 if (instr->representation().IsSmi() && constant_value > 0) { | |
742 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | |
743 if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { | |
744 does_deopt = true; | |
745 break; | |
746 } | |
747 } | |
748 } | |
749 } else { | 738 } else { |
750 right = UseRegisterAtStart(right_value); | 739 right = UseRegisterAtStart(right_value); |
751 } | 740 } |
752 | 741 |
753 // Shift operations can deoptimize if we do a logical shift | 742 // Shift operations can only deoptimize if we do a logical shift |
754 // by 0 and the result cannot be truncated to int32. | 743 // by 0 and the result cannot be truncated to int32. |
| 744 bool does_deopt = false; |
755 if (op == Token::SHR && constant_value == 0) { | 745 if (op == Token::SHR && constant_value == 0) { |
756 if (FLAG_opt_safe_uint32_operations) { | 746 if (FLAG_opt_safe_uint32_operations) { |
757 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | 747 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
758 } else { | 748 } else { |
759 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 749 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
760 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { | 750 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
761 does_deopt = true; | 751 does_deopt = true; |
762 break; | 752 break; |
763 } | 753 } |
764 } | 754 } |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 | 2000 |
2011 | 2001 |
2012 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { | 2002 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { |
2013 Representation r = instr->representation(); | 2003 Representation r = instr->representation(); |
2014 if (r.IsSmi()) { | 2004 if (r.IsSmi()) { |
2015 return DefineAsRegister(new(zone()) LConstantS); | 2005 return DefineAsRegister(new(zone()) LConstantS); |
2016 } else if (r.IsInteger32()) { | 2006 } else if (r.IsInteger32()) { |
2017 return DefineAsRegister(new(zone()) LConstantI); | 2007 return DefineAsRegister(new(zone()) LConstantI); |
2018 } else if (r.IsDouble()) { | 2008 } else if (r.IsDouble()) { |
2019 return DefineAsRegister(new(zone()) LConstantD); | 2009 return DefineAsRegister(new(zone()) LConstantD); |
2020 } else if (r.IsExternal()) { | |
2021 return DefineAsRegister(new(zone()) LConstantE); | |
2022 } else if (r.IsTagged()) { | 2010 } else if (r.IsTagged()) { |
2023 return DefineAsRegister(new(zone()) LConstantT); | 2011 return DefineAsRegister(new(zone()) LConstantT); |
2024 } else { | 2012 } else { |
2025 UNREACHABLE(); | 2013 UNREACHABLE(); |
2026 return NULL; | 2014 return NULL; |
2027 } | 2015 } |
2028 } | 2016 } |
2029 | 2017 |
2030 | 2018 |
2031 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 2019 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr); | 2228 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr); |
2241 } | 2229 } |
2242 | 2230 |
2243 | 2231 |
2244 LInstruction* LChunkBuilder::DoTransitionElementsKind( | 2232 LInstruction* LChunkBuilder::DoTransitionElementsKind( |
2245 HTransitionElementsKind* instr) { | 2233 HTransitionElementsKind* instr) { |
2246 LOperand* object = UseRegister(instr->object()); | 2234 LOperand* object = UseRegister(instr->object()); |
2247 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { | 2235 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { |
2248 LOperand* new_map_reg = TempRegister(); | 2236 LOperand* new_map_reg = TempRegister(); |
2249 LTransitionElementsKind* result = | 2237 LTransitionElementsKind* result = |
2250 new(zone()) LTransitionElementsKind(object, new_map_reg); | 2238 new(zone()) LTransitionElementsKind(object, new_map_reg, NULL); |
2251 return result; | 2239 return result; |
| 2240 } else if (FLAG_compiled_transitions) { |
| 2241 LTransitionElementsKind* result = |
| 2242 new(zone()) LTransitionElementsKind(object, NULL, NULL); |
| 2243 return AssignPointerMap(result); |
2252 } else { | 2244 } else { |
| 2245 LOperand* object = UseFixed(instr->object(), a0); |
| 2246 LOperand* fixed_object_reg = FixedTemp(a2); |
| 2247 LOperand* new_map_reg = FixedTemp(a3); |
2253 LTransitionElementsKind* result = | 2248 LTransitionElementsKind* result = |
2254 new(zone()) LTransitionElementsKind(object, NULL); | 2249 new(zone()) LTransitionElementsKind(object, |
2255 return AssignPointerMap(result); | 2250 new_map_reg, |
| 2251 fixed_object_reg); |
| 2252 return MarkAsCall(result, instr); |
2256 } | 2253 } |
2257 } | 2254 } |
2258 | 2255 |
2259 | 2256 |
2260 LInstruction* LChunkBuilder::DoTrapAllocationMemento( | 2257 LInstruction* LChunkBuilder::DoTrapAllocationMemento( |
2261 HTrapAllocationMemento* instr) { | 2258 HTrapAllocationMemento* instr) { |
2262 LOperand* object = UseRegister(instr->object()); | 2259 LOperand* object = UseRegister(instr->object()); |
2263 LOperand* temp = TempRegister(); | 2260 LOperand* temp = TempRegister(); |
2264 LTrapAllocationMemento* result = | 2261 LTrapAllocationMemento* result = |
2265 new(zone()) LTrapAllocationMemento(object, temp); | 2262 new(zone()) LTrapAllocationMemento(object, temp); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 | 2559 |
2563 | 2560 |
2564 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2561 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2565 LOperand* object = UseRegister(instr->object()); | 2562 LOperand* object = UseRegister(instr->object()); |
2566 LOperand* index = UseRegister(instr->index()); | 2563 LOperand* index = UseRegister(instr->index()); |
2567 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2564 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2568 } | 2565 } |
2569 | 2566 |
2570 | 2567 |
2571 } } // namespace v8::internal | 2568 } } // namespace v8::internal |
OLD | NEW |