OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 if (object->type().IsJSObject()) return object; | 1289 if (object->type().IsJSObject()) return object; |
1290 return Add<HWrapReceiver>(object, function); | 1290 return Add<HWrapReceiver>(object, function); |
1291 } | 1291 } |
1292 | 1292 |
1293 | 1293 |
1294 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, | 1294 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
1295 HValue* elements, | 1295 HValue* elements, |
1296 ElementsKind kind, | 1296 ElementsKind kind, |
1297 HValue* length, | 1297 HValue* length, |
1298 HValue* key, | 1298 HValue* key, |
1299 bool is_js_array) { | 1299 bool is_js_array, |
1300 bool is_store) { | |
1300 IfBuilder length_checker(this); | 1301 IfBuilder length_checker(this); |
1301 | 1302 |
1302 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; | 1303 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; |
1303 length_checker.If<HCompareNumericAndBranch>(key, length, token); | 1304 length_checker.If<HCompareNumericAndBranch>(key, length, token); |
1304 | 1305 |
1305 length_checker.Then(); | 1306 length_checker.Then(); |
1306 | 1307 |
1307 HValue* current_capacity = AddLoadFixedArrayLength(elements); | 1308 HValue* current_capacity = AddLoadFixedArrayLength(elements); |
1308 | 1309 |
1309 IfBuilder capacity_checker(this); | 1310 IfBuilder capacity_checker(this); |
(...skipping 22 matching lines...) Expand all Loading... | |
1332 capacity_checker.End(); | 1333 capacity_checker.End(); |
1333 | 1334 |
1334 if (is_js_array) { | 1335 if (is_js_array) { |
1335 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); | 1336 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); |
1336 new_length->ClearFlag(HValue::kCanOverflow); | 1337 new_length->ClearFlag(HValue::kCanOverflow); |
1337 | 1338 |
1338 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), | 1339 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), |
1339 new_length); | 1340 new_length); |
1340 } | 1341 } |
1341 | 1342 |
1343 if (is_store && IsFastPackedSmiElementsKind(kind)) { | |
1344 HValue* checked_elements = environment()->Top(); | |
1345 | |
1346 // Write zero to ensure that the new element is initialized with some smi. | |
1347 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind); | |
1348 } | |
1349 | |
1342 length_checker.Else(); | 1350 length_checker.Else(); |
1343 Add<HBoundsCheck>(key, length); | 1351 Add<HBoundsCheck>(key, length); |
1344 | 1352 |
1345 environment()->Push(elements); | 1353 environment()->Push(elements); |
1346 length_checker.End(); | 1354 length_checker.End(); |
1347 | 1355 |
1348 return environment()->Pop(); | 1356 return environment()->Pop(); |
1349 } | 1357 } |
1350 | 1358 |
1351 | 1359 |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2095 // deopt, leaving the backing store in an invalid state. | 2103 // deopt, leaving the backing store in an invalid state. |
2096 if (is_store && IsFastSmiElementsKind(elements_kind) && | 2104 if (is_store && IsFastSmiElementsKind(elements_kind) && |
2097 !val->type().IsSmi()) { | 2105 !val->type().IsSmi()) { |
2098 val = AddUncasted<HForceRepresentation>(val, Representation::Smi()); | 2106 val = AddUncasted<HForceRepresentation>(val, Representation::Smi()); |
2099 } | 2107 } |
2100 | 2108 |
2101 if (IsGrowStoreMode(store_mode)) { | 2109 if (IsGrowStoreMode(store_mode)) { |
2102 NoObservableSideEffectsScope no_effects(this); | 2110 NoObservableSideEffectsScope no_effects(this); |
2103 elements = BuildCheckForCapacityGrow(checked_object, elements, | 2111 elements = BuildCheckForCapacityGrow(checked_object, elements, |
2104 elements_kind, length, key, | 2112 elements_kind, length, key, |
2105 is_js_array); | 2113 is_js_array, is_store); |
2106 checked_key = key; | 2114 checked_key = key; |
2115 | |
Toon Verwaest
2013/12/17 13:53:04
spurious whitespace addition
Igor Sheludko
2013/12/18 10:01:33
Done.
| |
2107 } else { | 2116 } else { |
2108 checked_key = Add<HBoundsCheck>(key, length); | 2117 checked_key = Add<HBoundsCheck>(key, length); |
2109 | 2118 |
2110 if (is_store && (fast_elements || fast_smi_only_elements)) { | 2119 if (is_store && (fast_elements || fast_smi_only_elements)) { |
2111 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { | 2120 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { |
2112 NoObservableSideEffectsScope no_effects(this); | 2121 NoObservableSideEffectsScope no_effects(this); |
2113 elements = BuildCopyElementsOnWrite(checked_object, elements, | 2122 elements = BuildCopyElementsOnWrite(checked_object, elements, |
2114 elements_kind, length); | 2123 elements_kind, length); |
2115 } else { | 2124 } else { |
2116 HCheckMaps* check_cow_map = Add<HCheckMaps>( | 2125 HCheckMaps* check_cow_map = Add<HCheckMaps>( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2259 HValue* val, | 2268 HValue* val, |
2260 HValue* dependency, | 2269 HValue* dependency, |
2261 ElementsKind elements_kind, | 2270 ElementsKind elements_kind, |
2262 bool is_store, | 2271 bool is_store, |
2263 LoadKeyedHoleMode load_mode) { | 2272 LoadKeyedHoleMode load_mode) { |
2264 if (is_store) { | 2273 if (is_store) { |
2265 ASSERT(val != NULL); | 2274 ASSERT(val != NULL); |
2266 if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) { | 2275 if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) { |
2267 val = Add<HClampToUint8>(val); | 2276 val = Add<HClampToUint8>(val); |
2268 } | 2277 } |
2269 return Add<HStoreKeyed>(elements, checked_key, val, elements_kind); | 2278 HStoreKeyed* store = |
2279 Add<HStoreKeyed>(elements, checked_key, val, elements_kind); | |
2280 if (IsFastPackedSmiElementsKind(elements_kind)) { | |
Toon Verwaest
2013/12/17 13:53:04
store->set_store_to_initialize_element(elements_ki
Igor Sheludko
2013/12/18 10:01:33
Done.
| |
2281 store->set_store_to_initialized_element(true); | |
2282 } | |
2283 return store; | |
2270 } | 2284 } |
2271 | 2285 |
2272 ASSERT(!is_store); | 2286 ASSERT(!is_store); |
2273 ASSERT(val == NULL); | 2287 ASSERT(val == NULL); |
2274 HLoadKeyed* load = Add<HLoadKeyed>( | 2288 HLoadKeyed* load = Add<HLoadKeyed>( |
2275 elements, checked_key, dependency, elements_kind, load_mode); | 2289 elements, checked_key, dependency, elements_kind, load_mode); |
2276 if (FLAG_opt_safe_uint32_operations && | 2290 if (FLAG_opt_safe_uint32_operations && |
2277 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { | 2291 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { |
2278 graph()->RecordUint32Instruction(load); | 2292 graph()->RecordUint32Instruction(load); |
2279 } | 2293 } |
(...skipping 8533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10813 if (ShouldProduceTraceOutput()) { | 10827 if (ShouldProduceTraceOutput()) { |
10814 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10828 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10815 } | 10829 } |
10816 | 10830 |
10817 #ifdef DEBUG | 10831 #ifdef DEBUG |
10818 graph_->Verify(false); // No full verify. | 10832 graph_->Verify(false); // No full verify. |
10819 #endif | 10833 #endif |
10820 } | 10834 } |
10821 | 10835 |
10822 } } // namespace v8::internal | 10836 } } // namespace v8::internal |
OLD | NEW |