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 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 ElementsKind kind, | 1124 ElementsKind kind, |
1125 HValue* length, | 1125 HValue* length, |
1126 HValue* key, | 1126 HValue* key, |
1127 bool is_js_array) { | 1127 bool is_js_array) { |
1128 Zone* zone = this->zone(); | 1128 Zone* zone = this->zone(); |
1129 IfBuilder length_checker(this); | 1129 IfBuilder length_checker(this); |
1130 | 1130 |
1131 length_checker.IfCompare(length, key, Token::EQ); | 1131 length_checker.IfCompare(length, key, Token::EQ); |
1132 length_checker.Then(); | 1132 length_checker.Then(); |
1133 | 1133 |
1134 HValue* current_capacity = Add<HFixedArrayBaseLength>(elements); | 1134 HValue* current_capacity = AddLoadFixedArrayLength(elements); |
1135 | 1135 |
1136 IfBuilder capacity_checker(this); | 1136 IfBuilder capacity_checker(this); |
1137 | 1137 |
1138 capacity_checker.IfCompare(length, current_capacity, Token::EQ); | 1138 capacity_checker.IfCompare(length, current_capacity, Token::EQ); |
1139 capacity_checker.Then(); | 1139 capacity_checker.Then(); |
1140 | 1140 |
1141 HValue* context = environment()->LookupContext(); | 1141 HValue* context = environment()->LookupContext(); |
1142 | 1142 |
1143 HValue* new_capacity = | 1143 HValue* new_capacity = |
1144 BuildNewElementsCapacity(context, current_capacity); | 1144 BuildNewElementsCapacity(context, current_capacity); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 ElementsKind kind, | 1180 ElementsKind kind, |
1181 HValue* length) { | 1181 HValue* length) { |
1182 Heap* heap = isolate()->heap(); | 1182 Heap* heap = isolate()->heap(); |
1183 | 1183 |
1184 IfBuilder cow_checker(this); | 1184 IfBuilder cow_checker(this); |
1185 | 1185 |
1186 cow_checker.IfCompareMap(elements, | 1186 cow_checker.IfCompareMap(elements, |
1187 Handle<Map>(heap->fixed_cow_array_map())); | 1187 Handle<Map>(heap->fixed_cow_array_map())); |
1188 cow_checker.Then(); | 1188 cow_checker.Then(); |
1189 | 1189 |
1190 HValue* capacity = Add<HFixedArrayBaseLength>(elements); | 1190 HValue* capacity = AddLoadFixedArrayLength(elements); |
1191 | 1191 |
1192 HValue* new_elements = BuildGrowElementsCapacity(object, elements, | 1192 HValue* new_elements = BuildGrowElementsCapacity(object, elements, |
1193 kind, length, capacity); | 1193 kind, length, capacity); |
1194 | 1194 |
1195 environment()->Push(new_elements); | 1195 environment()->Push(new_elements); |
1196 | 1196 |
1197 cow_checker.Else(); | 1197 cow_checker.Else(); |
1198 | 1198 |
1199 environment()->Push(elements); | 1199 environment()->Push(elements); |
1200 | 1200 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { | 1235 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { |
1236 HCheckMaps* check_cow_map = HCheckMaps::New( | 1236 HCheckMaps* check_cow_map = HCheckMaps::New( |
1237 elements, isolate()->factory()->fixed_array_map(), zone); | 1237 elements, isolate()->factory()->fixed_array_map(), zone); |
1238 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); | 1238 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); |
1239 AddInstruction(check_cow_map); | 1239 AddInstruction(check_cow_map); |
1240 } | 1240 } |
1241 HInstruction* length = NULL; | 1241 HInstruction* length = NULL; |
1242 if (is_js_array) { | 1242 if (is_js_array) { |
1243 length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck, | 1243 length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck, |
1244 Representation::Smi()); | 1244 Representation::Smi()); |
1245 length->set_type(HType::Smi()); | |
1246 } else { | 1245 } else { |
1247 length = Add<HFixedArrayBaseLength>(elements); | 1246 length = AddLoadFixedArrayLength(elements); |
1248 } | 1247 } |
1248 length->set_type(HType::Smi()); | |
Massi
2013/07/02 10:48:26
AddLoadFixedArrayLength already sets the type to S
| |
1249 HValue* checked_key = NULL; | 1249 HValue* checked_key = NULL; |
1250 if (IsExternalArrayElementsKind(elements_kind)) { | 1250 if (IsExternalArrayElementsKind(elements_kind)) { |
1251 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { | 1251 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { |
1252 NoObservableSideEffectsScope no_effects(this); | 1252 NoObservableSideEffectsScope no_effects(this); |
1253 HLoadExternalArrayPointer* external_elements = | 1253 HLoadExternalArrayPointer* external_elements = |
1254 Add<HLoadExternalArrayPointer>(elements); | 1254 Add<HLoadExternalArrayPointer>(elements); |
1255 IfBuilder length_checker(this); | 1255 IfBuilder length_checker(this); |
1256 length_checker.IfCompare(key, length, Token::LT); | 1256 length_checker.IfCompare(key, length, Token::LT); |
1257 length_checker.Then(); | 1257 length_checker.Then(); |
1258 IfBuilder negative_checker(this); | 1258 IfBuilder negative_checker(this); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1408 return elements; | 1408 return elements; |
1409 } | 1409 } |
1410 | 1410 |
1411 | 1411 |
1412 HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, | 1412 HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, |
1413 HValue* typecheck) { | 1413 HValue* typecheck) { |
1414 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck); | 1414 return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck); |
1415 } | 1415 } |
1416 | 1416 |
1417 | 1417 |
1418 HLoadNamedField* HGraphBuilder::AddLoadFixedArrayLength(HValue* object) { | |
1419 HLoadNamedField* instr = AddLoad(object, HObjectAccess::ForFixedArrayLength(), | |
1420 NULL, Representation::Smi()); | |
1421 instr->set_type(HType::Smi()); | |
1422 return instr; | |
1423 } | |
1424 | |
1425 | |
1418 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, | 1426 HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, |
1419 HValue* old_capacity) { | 1427 HValue* old_capacity) { |
1420 Zone* zone = this->zone(); | 1428 Zone* zone = this->zone(); |
1421 HValue* half_old_capacity = | 1429 HValue* half_old_capacity = |
1422 AddInstruction(HShr::New(zone, context, old_capacity, | 1430 AddInstruction(HShr::New(zone, context, old_capacity, |
1423 graph_->GetConstant1())); | 1431 graph_->GetConstant1())); |
1424 half_old_capacity->ClearFlag(HValue::kCanOverflow); | 1432 half_old_capacity->ClearFlag(HValue::kCanOverflow); |
1425 | 1433 |
1426 HValue* new_capacity = AddInstruction( | 1434 HValue* new_capacity = AddInstruction( |
1427 HAdd::New(zone, context, half_old_capacity, old_capacity)); | 1435 HAdd::New(zone, context, half_old_capacity, old_capacity)); |
(...skipping 5595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7023 | 7031 |
7024 for (ElementsKind elements_kind = FIRST_ELEMENTS_KIND; | 7032 for (ElementsKind elements_kind = FIRST_ELEMENTS_KIND; |
7025 elements_kind <= LAST_ELEMENTS_KIND; | 7033 elements_kind <= LAST_ELEMENTS_KIND; |
7026 elements_kind = ElementsKind(elements_kind + 1)) { | 7034 elements_kind = ElementsKind(elements_kind + 1)) { |
7027 // After having handled FAST_* and DICTIONARY_ELEMENTS, we need to add some | 7035 // After having handled FAST_* and DICTIONARY_ELEMENTS, we need to add some |
7028 // code that's executed for all external array cases. | 7036 // code that's executed for all external array cases. |
7029 STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == | 7037 STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == |
7030 LAST_ELEMENTS_KIND); | 7038 LAST_ELEMENTS_KIND); |
7031 if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND | 7039 if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND |
7032 && todo_external_array) { | 7040 && todo_external_array) { |
7033 HInstruction* length = Add<HFixedArrayBaseLength>(elements); | 7041 HInstruction* length = AddLoadFixedArrayLength(elements); |
7034 checked_key = Add<HBoundsCheck>(key, length); | 7042 checked_key = Add<HBoundsCheck>(key, length); |
7035 external_elements = Add<HLoadExternalArrayPointer>(elements); | 7043 external_elements = Add<HLoadExternalArrayPointer>(elements); |
7036 } | 7044 } |
7037 if (type_todo[elements_kind]) { | 7045 if (type_todo[elements_kind]) { |
7038 HBasicBlock* if_true = graph()->CreateBasicBlock(); | 7046 HBasicBlock* if_true = graph()->CreateBasicBlock(); |
7039 HBasicBlock* if_false = graph()->CreateBasicBlock(); | 7047 HBasicBlock* if_false = graph()->CreateBasicBlock(); |
7040 HCompareConstantEqAndBranch* elements_kind_branch = | 7048 HCompareConstantEqAndBranch* elements_kind_branch = |
7041 new(zone()) HCompareConstantEqAndBranch( | 7049 new(zone()) HCompareConstantEqAndBranch( |
7042 elements_kind_instr, elements_kind, Token::EQ_STRICT); | 7050 elements_kind_instr, elements_kind, Token::EQ_STRICT); |
7043 elements_kind_branch->SetSuccessorAt(0, if_true); | 7051 elements_kind_branch->SetSuccessorAt(0, if_true); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7083 | 7091 |
7084 *has_side_effects |= access->HasObservableSideEffects(); | 7092 *has_side_effects |= access->HasObservableSideEffects(); |
7085 // The caller will use has_side_effects and add correct Simulate. | 7093 // The caller will use has_side_effects and add correct Simulate. |
7086 access->SetFlag(HValue::kHasNoObservableSideEffects); | 7094 access->SetFlag(HValue::kHasNoObservableSideEffects); |
7087 if (position != -1) { | 7095 if (position != -1) { |
7088 access->set_position(position); | 7096 access->set_position(position); |
7089 } | 7097 } |
7090 if_jsarray->GotoNoSimulate(join); | 7098 if_jsarray->GotoNoSimulate(join); |
7091 | 7099 |
7092 set_current_block(if_fastobject); | 7100 set_current_block(if_fastobject); |
7093 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); | 7101 length = AddLoadFixedArrayLength(elements); |
7094 checked_key = Add<HBoundsCheck>(key, length); | 7102 checked_key = Add<HBoundsCheck>(key, length); |
7095 access = AddInstruction(BuildFastElementAccess( | 7103 access = AddInstruction(BuildFastElementAccess( |
7096 elements, checked_key, val, elements_kind_branch, | 7104 elements, checked_key, val, elements_kind_branch, |
7097 elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE)); | 7105 elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE)); |
7098 } else if (elements_kind == DICTIONARY_ELEMENTS) { | 7106 } else if (elements_kind == DICTIONARY_ELEMENTS) { |
7099 if (is_store) { | 7107 if (is_store) { |
7100 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); | 7108 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); |
7101 } else { | 7109 } else { |
7102 access = AddInstruction(BuildLoadKeyedGeneric(object, key)); | 7110 access = AddInstruction(BuildLoadKeyedGeneric(object, key)); |
7103 } | 7111 } |
(...skipping 4137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11241 if (ShouldProduceTraceOutput()) { | 11249 if (ShouldProduceTraceOutput()) { |
11242 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11250 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11243 } | 11251 } |
11244 | 11252 |
11245 #ifdef DEBUG | 11253 #ifdef DEBUG |
11246 graph_->Verify(false); // No full verify. | 11254 graph_->Verify(false); // No full verify. |
11247 #endif | 11255 #endif |
11248 } | 11256 } |
11249 | 11257 |
11250 } } // namespace v8::internal | 11258 } } // namespace v8::internal |
OLD | NEW |