Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: src/hydrogen.cc

Issue 11238016: Consolidated all the key store/load classes in the Hydrogen and Lithium (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Oops, removed a TODO Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
danno 2012/10/29 14:56:13 total nit: M-Q is your emacs friend (reflow paragr
mvstanton 2012/10/29 15:23:57 Thanks!
2722 2722 // bit level 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3736 if (!constant->HasInteger32Value()) return; 3737 if (!constant->HasInteger32Value()) return;
3737 int32_t value = constant->Integer32Value() * sign; 3738 int32_t value = constant->Integer32Value() * sign;
3738 // We limit offset values to 30 bits because we want to avoid the risk of 3739 // We limit offset values to 30 bits because we want to avoid the risk of
3739 // overflows when the offset is added to the object header size. 3740 // overflows when the offset is added to the object header size.
3740 if (value >= 1 << 30 || value < 0) return; 3741 if (value >= 1 << 30 || value < 0) return;
3741 array_operation->SetKey(subexpression); 3742 array_operation->SetKey(subexpression);
3742 if (index->HasNoUses()) { 3743 if (index->HasNoUses()) {
3743 index->DeleteAndReplaceWith(NULL); 3744 index->DeleteAndReplaceWith(NULL);
3744 } 3745 }
3745 ASSERT(value >= 0); 3746 ASSERT(value >= 0);
3747
danno 2012/10/29 14:56:13 nit: Remove extraneous LF
mvstanton 2012/10/29 15:23:57 Done.
3746 array_operation->SetIndexOffset(static_cast<uint32_t>(value)); 3748 array_operation->SetIndexOffset(static_cast<uint32_t>(value));
3747 array_operation->SetDehoisted(true); 3749 array_operation->SetDehoisted(true);
3748 } 3750 }
3749 3751
3750 3752
3751 void HGraph::DehoistSimpleArrayIndexComputations() { 3753 void HGraph::DehoistSimpleArrayIndexComputations() {
3752 if (!FLAG_array_index_dehoisting) return; 3754 if (!FLAG_array_index_dehoisting) return;
3753 3755
3754 HPhase phase("H_Dehoist index computations", this); 3756 HPhase phase("H_Dehoist index computations", this);
3755 for (int i = 0; i < blocks()->length(); ++i) { 3757 for (int i = 0; i < blocks()->length(); ++i) {
3756 for (HInstruction* instr = blocks()->at(i)->first(); 3758 for (HInstruction* instr = blocks()->at(i)->first();
3757 instr != NULL; 3759 instr != NULL;
3758 instr = instr->next()) { 3760 instr = instr->next()) {
3759 ArrayInstructionInterface* array_instruction = NULL; 3761 ArrayInstructionInterface* array_instruction = NULL;
3760 if (instr->IsLoadKeyedFastElement()) { 3762 if (instr->IsLoadKeyed()) {
3761 HLoadKeyedFastElement* op = HLoadKeyedFastElement::cast(instr); 3763 HLoadKeyed* op = HLoadKeyed::cast(instr);
3762 array_instruction = static_cast<ArrayInstructionInterface*>(op); 3764 array_instruction = static_cast<ArrayInstructionInterface*>(op);
3763 } else if (instr->IsLoadKeyedFastDoubleElement()) { 3765 } else if (instr->IsStoreKeyed()) {
3764 HLoadKeyedFastDoubleElement* op = 3766 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); 3767 array_instruction = static_cast<ArrayInstructionInterface*>(op);
3782 } else { 3768 } else {
3783 continue; 3769 continue;
3784 } 3770 }
3785 DehoistArrayIndex(array_instruction); 3771 DehoistArrayIndex(array_instruction);
3786 } 3772 }
3787 } 3773 }
3788 } 3774 }
3789 3775
3790 3776
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 compare_index->SetSuccessorAt(0, loop_body); 4596 compare_index->SetSuccessorAt(0, loop_body);
4611 compare_index->SetSuccessorAt(1, loop_successor); 4597 compare_index->SetSuccessorAt(1, loop_successor);
4612 current_block()->Finish(compare_index); 4598 current_block()->Finish(compare_index);
4613 4599
4614 set_current_block(loop_successor); 4600 set_current_block(loop_successor);
4615 Drop(5); 4601 Drop(5);
4616 4602
4617 set_current_block(loop_body); 4603 set_current_block(loop_body);
4618 4604
4619 HValue* key = AddInstruction( 4605 HValue* key = AddInstruction(
4620 new(zone()) HLoadKeyedFastElement( 4606 new(zone()) HLoadKeyed(
4621 environment()->ExpressionStackAt(2), // Enum cache. 4607 environment()->ExpressionStackAt(2), // Enum cache.
4622 environment()->ExpressionStackAt(0), // Iteration index. 4608 environment()->ExpressionStackAt(0), // Iteration index.
4623 environment()->ExpressionStackAt(0))); 4609 environment()->ExpressionStackAt(0),
4610 FAST_ELEMENTS));
4624 4611
4625 // Check if the expected map still matches that of the enumerable. 4612 // Check if the expected map still matches that of the enumerable.
4626 // If not just deoptimize. 4613 // If not just deoptimize.
4627 AddInstruction(new(zone()) HCheckMapValue( 4614 AddInstruction(new(zone()) HCheckMapValue(
4628 environment()->ExpressionStackAt(4), 4615 environment()->ExpressionStackAt(4),
4629 environment()->ExpressionStackAt(3))); 4616 environment()->ExpressionStackAt(3)));
4630 4617
4631 Bind(each_var, key); 4618 Bind(each_var, key);
4632 4619
4633 BreakAndContinueInfo break_info(stmt, 5); 4620 BreakAndContinueInfo break_info(stmt, 5);
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
5218 Representation::Integer32())); 5205 Representation::Integer32()));
5219 5206
5220 switch (boilerplate_elements_kind) { 5207 switch (boilerplate_elements_kind) {
5221 case FAST_SMI_ELEMENTS: 5208 case FAST_SMI_ELEMENTS:
5222 case FAST_HOLEY_SMI_ELEMENTS: 5209 case FAST_HOLEY_SMI_ELEMENTS:
5223 // Smi-only arrays need a smi check. 5210 // Smi-only arrays need a smi check.
5224 AddInstruction(new(zone()) HCheckSmi(value)); 5211 AddInstruction(new(zone()) HCheckSmi(value));
5225 // Fall through. 5212 // Fall through.
5226 case FAST_ELEMENTS: 5213 case FAST_ELEMENTS:
5227 case FAST_HOLEY_ELEMENTS: 5214 case FAST_HOLEY_ELEMENTS:
5228 AddInstruction(new(zone()) HStoreKeyedFastElement( 5215 case FAST_DOUBLE_ELEMENTS:
5216 case FAST_HOLEY_DOUBLE_ELEMENTS:
5217 AddInstruction(new(zone()) HStoreKeyed(
5229 elements, 5218 elements,
5230 key, 5219 key,
5231 value, 5220 value,
5232 boilerplate_elements_kind)); 5221 boilerplate_elements_kind));
5233 break; 5222 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: 5223 default:
5241 UNREACHABLE(); 5224 UNREACHABLE();
5242 break; 5225 break;
5243 } 5226 }
5244 5227
5245 AddSimulate(expr->GetIdForElement(i)); 5228 AddSimulate(expr->GetIdForElement(i));
5246 } 5229 }
5247 return ast_context()->ReturnValue(Pop()); 5230 return ast_context()->ReturnValue(Pop());
5248 } 5231 }
5249 5232
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
6078 case FAST_ELEMENTS: 6061 case FAST_ELEMENTS:
6079 case FAST_DOUBLE_ELEMENTS: 6062 case FAST_DOUBLE_ELEMENTS:
6080 case FAST_HOLEY_SMI_ELEMENTS: 6063 case FAST_HOLEY_SMI_ELEMENTS:
6081 case FAST_HOLEY_ELEMENTS: 6064 case FAST_HOLEY_ELEMENTS:
6082 case FAST_HOLEY_DOUBLE_ELEMENTS: 6065 case FAST_HOLEY_DOUBLE_ELEMENTS:
6083 case DICTIONARY_ELEMENTS: 6066 case DICTIONARY_ELEMENTS:
6084 case NON_STRICT_ARGUMENTS_ELEMENTS: 6067 case NON_STRICT_ARGUMENTS_ELEMENTS:
6085 UNREACHABLE(); 6068 UNREACHABLE();
6086 break; 6069 break;
6087 } 6070 }
6088 return new(zone()) HStoreKeyedSpecializedArrayElement( 6071 return new(zone()) HStoreKeyed(external_elements,
6089 external_elements, checked_key, val, elements_kind); 6072 checked_key,
6073 val,
6074 elements_kind);
6090 } else { 6075 } else {
6091 ASSERT(val == NULL); 6076 ASSERT(val == NULL);
6092 HLoadKeyedSpecializedArrayElement* load = 6077 HLoadKeyed* load =
6093 new(zone()) HLoadKeyedSpecializedArrayElement( 6078 new(zone()) HLoadKeyed(
6094 external_elements, checked_key, dependency, elements_kind); 6079 external_elements, checked_key, dependency, elements_kind);
6095 if (FLAG_opt_safe_uint32_operations && 6080 if (FLAG_opt_safe_uint32_operations &&
6096 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { 6081 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
6097 graph()->RecordUint32Instruction(load); 6082 graph()->RecordUint32Instruction(load);
6098 } 6083 }
6099 return load; 6084 return load;
6100 } 6085 }
6101 } 6086 }
6102 6087
6103 6088
6104 HInstruction* HGraphBuilder::BuildFastElementAccess(HValue* elements, 6089 HInstruction* HGraphBuilder::BuildFastElementAccess(HValue* elements,
6105 HValue* checked_key, 6090 HValue* checked_key,
6106 HValue* val, 6091 HValue* val,
6107 HValue* load_dependency, 6092 HValue* load_dependency,
6108 ElementsKind elements_kind, 6093 ElementsKind elements_kind,
6109 bool is_store) { 6094 bool is_store) {
6110 if (is_store) { 6095 if (is_store) {
6111 ASSERT(val != NULL); 6096 ASSERT(val != NULL);
6112 switch (elements_kind) { 6097 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: 6098 case FAST_SMI_ELEMENTS:
6118 case FAST_HOLEY_SMI_ELEMENTS: 6099 case FAST_HOLEY_SMI_ELEMENTS:
6119 // Smi-only arrays need a smi check. 6100 // Smi-only arrays need a smi check.
6120 AddInstruction(new(zone()) HCheckSmi(val)); 6101 AddInstruction(new(zone()) HCheckSmi(val));
6121 // Fall through. 6102 // Fall through.
6122 case FAST_ELEMENTS: 6103 case FAST_ELEMENTS:
6123 case FAST_HOLEY_ELEMENTS: 6104 case FAST_HOLEY_ELEMENTS:
6124 return new(zone()) HStoreKeyedFastElement( 6105 case FAST_DOUBLE_ELEMENTS:
6106 case FAST_HOLEY_DOUBLE_ELEMENTS:
6107 return new(zone()) HStoreKeyed(
6125 elements, checked_key, val, elements_kind); 6108 elements, checked_key, val, elements_kind);
6126 default: 6109 default:
6127 UNREACHABLE(); 6110 UNREACHABLE();
6128 return NULL; 6111 return NULL;
6129 } 6112 }
6130 } 6113 }
6131 // It's an element load (!is_store). 6114 // It's an element load (!is_store).
6132 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ? 6115 return new(zone()) HLoadKeyed(elements,
6133 OMIT_HOLE_CHECK : 6116 checked_key,
6134 PERFORM_HOLE_CHECK; 6117 load_dependency,
6135 if (IsFastDoubleElementsKind(elements_kind)) { 6118 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 } 6119 }
6143 6120
6144 6121
6145 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, 6122 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object,
6146 HValue* key, 6123 HValue* key,
6147 HValue* val, 6124 HValue* val,
6148 HValue* dependency, 6125 HValue* dependency,
6149 Handle<Map> map, 6126 Handle<Map> map,
6150 bool is_store) { 6127 bool is_store) {
6151 HCheckMaps* mapcheck = new(zone()) HCheckMaps(object, map, 6128 HCheckMaps* mapcheck = new(zone()) HCheckMaps(object, map,
(...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after
9973 } 9950 }
9974 } 9951 }
9975 9952
9976 #ifdef DEBUG 9953 #ifdef DEBUG
9977 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9954 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9978 if (allocator_ != NULL) allocator_->Verify(); 9955 if (allocator_ != NULL) allocator_->Verify();
9979 #endif 9956 #endif
9980 } 9957 }
9981 9958
9982 } } // namespace v8::internal 9959 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698