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 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 // Operations that operatate on bits are safe. | 2708 // Operations that operatate on bits are safe. |
2709 if (use->IsBitwise() || | 2709 if (use->IsBitwise() || |
2710 use->IsShl() || | 2710 use->IsShl() || |
2711 use->IsSar() || | 2711 use->IsSar() || |
2712 use->IsShr() || | 2712 use->IsShr() || |
2713 use->IsBitNot()) { | 2713 use->IsBitNot()) { |
2714 return true; | 2714 return true; |
2715 } else if (use->IsChange() || use->IsSimulate()) { | 2715 } else if (use->IsChange() || use->IsSimulate()) { |
2716 // Conversions and deoptimization have special support for unt32. | 2716 // Conversions and deoptimization have special support for unt32. |
2717 return true; | 2717 return true; |
2718 } else if (use->IsStoreKeyedSpecializedArrayElement()) { | 2718 } else if (use->IsStoreKeyed()) { |
2719 // Storing a value into an external integer array is a bit level operation. | 2719 HStoreKeyed* store = HStoreKeyed::cast(use); |
2720 HStoreKeyedSpecializedArrayElement* store = | 2720 if (store->is_external()) { |
2721 HStoreKeyedSpecializedArrayElement::cast(use); | 2721 // Storing a value into an external integer array is a bit level |
2722 | 2722 // operation. |
2723 if (store->value() == val) { | 2723 if (store->value() == val) { |
2724 // Clamping or a conversion to double should have beed inserted. | 2724 // Clamping or a conversion to double should have beed inserted. |
2725 ASSERT(store->elements_kind() != EXTERNAL_PIXEL_ELEMENTS); | 2725 ASSERT(store->elements_kind() != EXTERNAL_PIXEL_ELEMENTS); |
2726 ASSERT(store->elements_kind() != EXTERNAL_FLOAT_ELEMENTS); | 2726 ASSERT(store->elements_kind() != EXTERNAL_FLOAT_ELEMENTS); |
2727 ASSERT(store->elements_kind() != EXTERNAL_DOUBLE_ELEMENTS); | 2727 ASSERT(store->elements_kind() != EXTERNAL_DOUBLE_ELEMENTS); |
2728 return true; | 2728 return true; |
| 2729 } |
2729 } | 2730 } |
2730 } | 2731 } |
2731 | 2732 |
2732 return false; | 2733 return false; |
2733 } | 2734 } |
2734 | 2735 |
2735 | 2736 |
2736 // Iterate over all uses and verify that they are uint32 safe: either don't | 2737 // Iterate over all uses and verify that they are uint32 safe: either don't |
2737 // distinguish between int32 and uint32 due to their bitwise nature or | 2738 // distinguish between int32 and uint32 due to their bitwise nature or |
2738 // have special support for uint32 values. | 2739 // have special support for uint32 values. |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 | 3751 |
3751 void HGraph::DehoistSimpleArrayIndexComputations() { | 3752 void HGraph::DehoistSimpleArrayIndexComputations() { |
3752 if (!FLAG_array_index_dehoisting) return; | 3753 if (!FLAG_array_index_dehoisting) return; |
3753 | 3754 |
3754 HPhase phase("H_Dehoist index computations", this); | 3755 HPhase phase("H_Dehoist index computations", this); |
3755 for (int i = 0; i < blocks()->length(); ++i) { | 3756 for (int i = 0; i < blocks()->length(); ++i) { |
3756 for (HInstruction* instr = blocks()->at(i)->first(); | 3757 for (HInstruction* instr = blocks()->at(i)->first(); |
3757 instr != NULL; | 3758 instr != NULL; |
3758 instr = instr->next()) { | 3759 instr = instr->next()) { |
3759 ArrayInstructionInterface* array_instruction = NULL; | 3760 ArrayInstructionInterface* array_instruction = NULL; |
3760 if (instr->IsLoadKeyedFastElement()) { | 3761 if (instr->IsLoadKeyed()) { |
3761 HLoadKeyedFastElement* op = HLoadKeyedFastElement::cast(instr); | 3762 HLoadKeyed* op = HLoadKeyed::cast(instr); |
3762 array_instruction = static_cast<ArrayInstructionInterface*>(op); | 3763 array_instruction = static_cast<ArrayInstructionInterface*>(op); |
3763 } else if (instr->IsLoadKeyedFastDoubleElement()) { | 3764 } else if (instr->IsStoreKeyed()) { |
3764 HLoadKeyedFastDoubleElement* op = | 3765 HStoreKeyed* op = HStoreKeyed::cast(instr); |
3765 HLoadKeyedFastDoubleElement::cast(instr); | |
3766 array_instruction = static_cast<ArrayInstructionInterface*>(op); | |
3767 } else if (instr->IsLoadKeyedSpecializedArrayElement()) { | |
3768 HLoadKeyedSpecializedArrayElement* op = | |
3769 HLoadKeyedSpecializedArrayElement::cast(instr); | |
3770 array_instruction = static_cast<ArrayInstructionInterface*>(op); | |
3771 } else if (instr->IsStoreKeyedFastElement()) { | |
3772 HStoreKeyedFastElement* op = HStoreKeyedFastElement::cast(instr); | |
3773 array_instruction = static_cast<ArrayInstructionInterface*>(op); | |
3774 } else if (instr->IsStoreKeyedFastDoubleElement()) { | |
3775 HStoreKeyedFastDoubleElement* op = | |
3776 HStoreKeyedFastDoubleElement::cast(instr); | |
3777 array_instruction = static_cast<ArrayInstructionInterface*>(op); | |
3778 } else if (instr->IsStoreKeyedSpecializedArrayElement()) { | |
3779 HStoreKeyedSpecializedArrayElement* op = | |
3780 HStoreKeyedSpecializedArrayElement::cast(instr); | |
3781 array_instruction = static_cast<ArrayInstructionInterface*>(op); | 3766 array_instruction = static_cast<ArrayInstructionInterface*>(op); |
3782 } else { | 3767 } else { |
3783 continue; | 3768 continue; |
3784 } | 3769 } |
3785 DehoistArrayIndex(array_instruction); | 3770 DehoistArrayIndex(array_instruction); |
3786 } | 3771 } |
3787 } | 3772 } |
3788 } | 3773 } |
3789 | 3774 |
3790 | 3775 |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4610 compare_index->SetSuccessorAt(0, loop_body); | 4595 compare_index->SetSuccessorAt(0, loop_body); |
4611 compare_index->SetSuccessorAt(1, loop_successor); | 4596 compare_index->SetSuccessorAt(1, loop_successor); |
4612 current_block()->Finish(compare_index); | 4597 current_block()->Finish(compare_index); |
4613 | 4598 |
4614 set_current_block(loop_successor); | 4599 set_current_block(loop_successor); |
4615 Drop(5); | 4600 Drop(5); |
4616 | 4601 |
4617 set_current_block(loop_body); | 4602 set_current_block(loop_body); |
4618 | 4603 |
4619 HValue* key = AddInstruction( | 4604 HValue* key = AddInstruction( |
4620 new(zone()) HLoadKeyedFastElement( | 4605 new(zone()) HLoadKeyed( |
4621 environment()->ExpressionStackAt(2), // Enum cache. | 4606 environment()->ExpressionStackAt(2), // Enum cache. |
4622 environment()->ExpressionStackAt(0), // Iteration index. | 4607 environment()->ExpressionStackAt(0), // Iteration index. |
4623 environment()->ExpressionStackAt(0))); | 4608 environment()->ExpressionStackAt(0), |
| 4609 FAST_ELEMENTS)); |
4624 | 4610 |
4625 // Check if the expected map still matches that of the enumerable. | 4611 // Check if the expected map still matches that of the enumerable. |
4626 // If not just deoptimize. | 4612 // If not just deoptimize. |
4627 AddInstruction(new(zone()) HCheckMapValue( | 4613 AddInstruction(new(zone()) HCheckMapValue( |
4628 environment()->ExpressionStackAt(4), | 4614 environment()->ExpressionStackAt(4), |
4629 environment()->ExpressionStackAt(3))); | 4615 environment()->ExpressionStackAt(3))); |
4630 | 4616 |
4631 Bind(each_var, key); | 4617 Bind(each_var, key); |
4632 | 4618 |
4633 BreakAndContinueInfo break_info(stmt, 5); | 4619 BreakAndContinueInfo break_info(stmt, 5); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5218 Representation::Integer32())); | 5204 Representation::Integer32())); |
5219 | 5205 |
5220 switch (boilerplate_elements_kind) { | 5206 switch (boilerplate_elements_kind) { |
5221 case FAST_SMI_ELEMENTS: | 5207 case FAST_SMI_ELEMENTS: |
5222 case FAST_HOLEY_SMI_ELEMENTS: | 5208 case FAST_HOLEY_SMI_ELEMENTS: |
5223 // Smi-only arrays need a smi check. | 5209 // Smi-only arrays need a smi check. |
5224 AddInstruction(new(zone()) HCheckSmi(value)); | 5210 AddInstruction(new(zone()) HCheckSmi(value)); |
5225 // Fall through. | 5211 // Fall through. |
5226 case FAST_ELEMENTS: | 5212 case FAST_ELEMENTS: |
5227 case FAST_HOLEY_ELEMENTS: | 5213 case FAST_HOLEY_ELEMENTS: |
5228 AddInstruction(new(zone()) HStoreKeyedFastElement( | 5214 case FAST_DOUBLE_ELEMENTS: |
| 5215 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 5216 AddInstruction(new(zone()) HStoreKeyed( |
5229 elements, | 5217 elements, |
5230 key, | 5218 key, |
5231 value, | 5219 value, |
5232 boilerplate_elements_kind)); | 5220 boilerplate_elements_kind)); |
5233 break; | 5221 break; |
5234 case FAST_DOUBLE_ELEMENTS: | |
5235 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
5236 AddInstruction(new(zone()) HStoreKeyedFastDoubleElement(elements, | |
5237 key, | |
5238 value)); | |
5239 break; | |
5240 default: | 5222 default: |
5241 UNREACHABLE(); | 5223 UNREACHABLE(); |
5242 break; | 5224 break; |
5243 } | 5225 } |
5244 | 5226 |
5245 AddSimulate(expr->GetIdForElement(i)); | 5227 AddSimulate(expr->GetIdForElement(i)); |
5246 } | 5228 } |
5247 return ast_context()->ReturnValue(Pop()); | 5229 return ast_context()->ReturnValue(Pop()); |
5248 } | 5230 } |
5249 | 5231 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6078 case FAST_ELEMENTS: | 6060 case FAST_ELEMENTS: |
6079 case FAST_DOUBLE_ELEMENTS: | 6061 case FAST_DOUBLE_ELEMENTS: |
6080 case FAST_HOLEY_SMI_ELEMENTS: | 6062 case FAST_HOLEY_SMI_ELEMENTS: |
6081 case FAST_HOLEY_ELEMENTS: | 6063 case FAST_HOLEY_ELEMENTS: |
6082 case FAST_HOLEY_DOUBLE_ELEMENTS: | 6064 case FAST_HOLEY_DOUBLE_ELEMENTS: |
6083 case DICTIONARY_ELEMENTS: | 6065 case DICTIONARY_ELEMENTS: |
6084 case NON_STRICT_ARGUMENTS_ELEMENTS: | 6066 case NON_STRICT_ARGUMENTS_ELEMENTS: |
6085 UNREACHABLE(); | 6067 UNREACHABLE(); |
6086 break; | 6068 break; |
6087 } | 6069 } |
6088 return new(zone()) HStoreKeyedSpecializedArrayElement( | 6070 return new(zone()) HStoreKeyed(external_elements, |
6089 external_elements, checked_key, val, elements_kind); | 6071 checked_key, |
| 6072 val, |
| 6073 elements_kind); |
6090 } else { | 6074 } else { |
6091 ASSERT(val == NULL); | 6075 ASSERT(val == NULL); |
6092 HLoadKeyedSpecializedArrayElement* load = | 6076 HLoadKeyed* load = |
6093 new(zone()) HLoadKeyedSpecializedArrayElement( | 6077 new(zone()) HLoadKeyed( |
6094 external_elements, checked_key, dependency, elements_kind); | 6078 external_elements, checked_key, dependency, elements_kind); |
6095 if (FLAG_opt_safe_uint32_operations && | 6079 if (FLAG_opt_safe_uint32_operations && |
6096 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { | 6080 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { |
6097 graph()->RecordUint32Instruction(load); | 6081 graph()->RecordUint32Instruction(load); |
6098 } | 6082 } |
6099 return load; | 6083 return load; |
6100 } | 6084 } |
6101 } | 6085 } |
6102 | 6086 |
6103 | 6087 |
6104 HInstruction* HGraphBuilder::BuildFastElementAccess(HValue* elements, | 6088 HInstruction* HGraphBuilder::BuildFastElementAccess(HValue* elements, |
6105 HValue* checked_key, | 6089 HValue* checked_key, |
6106 HValue* val, | 6090 HValue* val, |
6107 HValue* load_dependency, | 6091 HValue* load_dependency, |
6108 ElementsKind elements_kind, | 6092 ElementsKind elements_kind, |
6109 bool is_store) { | 6093 bool is_store) { |
6110 if (is_store) { | 6094 if (is_store) { |
6111 ASSERT(val != NULL); | 6095 ASSERT(val != NULL); |
6112 switch (elements_kind) { | 6096 switch (elements_kind) { |
6113 case FAST_DOUBLE_ELEMENTS: | |
6114 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
6115 return new(zone()) HStoreKeyedFastDoubleElement( | |
6116 elements, checked_key, val); | |
6117 case FAST_SMI_ELEMENTS: | 6097 case FAST_SMI_ELEMENTS: |
6118 case FAST_HOLEY_SMI_ELEMENTS: | 6098 case FAST_HOLEY_SMI_ELEMENTS: |
6119 // Smi-only arrays need a smi check. | 6099 // Smi-only arrays need a smi check. |
6120 AddInstruction(new(zone()) HCheckSmi(val)); | 6100 AddInstruction(new(zone()) HCheckSmi(val)); |
6121 // Fall through. | 6101 // Fall through. |
6122 case FAST_ELEMENTS: | 6102 case FAST_ELEMENTS: |
6123 case FAST_HOLEY_ELEMENTS: | 6103 case FAST_HOLEY_ELEMENTS: |
6124 return new(zone()) HStoreKeyedFastElement( | 6104 case FAST_DOUBLE_ELEMENTS: |
| 6105 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 6106 return new(zone()) HStoreKeyed( |
6125 elements, checked_key, val, elements_kind); | 6107 elements, checked_key, val, elements_kind); |
6126 default: | 6108 default: |
6127 UNREACHABLE(); | 6109 UNREACHABLE(); |
6128 return NULL; | 6110 return NULL; |
6129 } | 6111 } |
6130 } | 6112 } |
6131 // It's an element load (!is_store). | 6113 // It's an element load (!is_store). |
6132 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ? | 6114 return new(zone()) HLoadKeyed(elements, |
6133 OMIT_HOLE_CHECK : | 6115 checked_key, |
6134 PERFORM_HOLE_CHECK; | 6116 load_dependency, |
6135 if (IsFastDoubleElementsKind(elements_kind)) { | 6117 elements_kind); |
6136 return new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key, | |
6137 load_dependency, mode); | |
6138 } else { // Smi or Object elements. | |
6139 return new(zone()) HLoadKeyedFastElement(elements, checked_key, | |
6140 load_dependency, elements_kind); | |
6141 } | |
6142 } | 6118 } |
6143 | 6119 |
6144 | 6120 |
6145 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, | 6121 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, |
6146 HValue* key, | 6122 HValue* key, |
6147 HValue* val, | 6123 HValue* val, |
6148 HValue* dependency, | 6124 HValue* dependency, |
6149 Handle<Map> map, | 6125 Handle<Map> map, |
6150 bool is_store) { | 6126 bool is_store) { |
6151 HCheckMaps* mapcheck = new(zone()) HCheckMaps(object, map, | 6127 HCheckMaps* mapcheck = new(zone()) HCheckMaps(object, map, |
(...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9973 } | 9949 } |
9974 } | 9950 } |
9975 | 9951 |
9976 #ifdef DEBUG | 9952 #ifdef DEBUG |
9977 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9953 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9978 if (allocator_ != NULL) allocator_->Verify(); | 9954 if (allocator_ != NULL) allocator_->Verify(); |
9979 #endif | 9955 #endif |
9980 } | 9956 } |
9981 | 9957 |
9982 } } // namespace v8::internal | 9958 } } // namespace v8::internal |
OLD | NEW |