OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 7415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7426 } | 7426 } |
7427 } | 7427 } |
7428 if (!has_double_maps && !has_smi_or_object_maps) return NULL; | 7428 if (!has_double_maps && !has_smi_or_object_maps) return NULL; |
7429 | 7429 |
7430 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); | 7430 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); |
7431 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. | 7431 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. |
7432 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. | 7432 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. |
7433 ElementsKind consolidated_elements_kind = has_seen_holey_elements | 7433 ElementsKind consolidated_elements_kind = has_seen_holey_elements |
7434 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) | 7434 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) |
7435 : most_general_consolidated_map->elements_kind(); | 7435 : most_general_consolidated_map->elements_kind(); |
| 7436 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
| 7437 if (has_seen_holey_elements) { |
| 7438 if (!isolate()->IsFastArrayConstructorPrototypeChainIntact()) { |
| 7439 return NULL; |
| 7440 } |
| 7441 |
| 7442 // Make sure that all of the maps we are handling have the initial array |
| 7443 // prototype. |
| 7444 for (int i = 0; i < maps->length(); ++i) { |
| 7445 Handle<Map> map = maps->at(i); |
| 7446 if (map->prototype() != *isolate()->initial_array_prototype()) { |
| 7447 // We can't guarantee that loading the hole is safe. The prototype may |
| 7448 // have an element at this position. |
| 7449 return NULL; |
| 7450 } |
| 7451 } |
| 7452 |
| 7453 Handle<Map> holey_map = |
| 7454 handle(isolate()->get_initial_js_array_map(consolidated_elements_kind)); |
| 7455 load_mode = BuildKeyedHoleMode(holey_map); |
| 7456 if (load_mode == NEVER_RETURN_HOLE) { |
| 7457 return NULL; |
| 7458 } |
| 7459 |
| 7460 for (int i = 0; i < maps->length(); ++i) { |
| 7461 Handle<Map> map = maps->at(i); |
| 7462 // The prototype check was already done for the holey map in |
| 7463 // BuildKeyedHoleMode. |
| 7464 if (!map.is_identical_to(holey_map)) { |
| 7465 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); |
| 7466 Handle<JSObject> object_prototype = |
| 7467 isolate()->initial_object_prototype(); |
| 7468 BuildCheckPrototypeMaps(prototype, object_prototype); |
| 7469 } |
| 7470 } |
| 7471 } |
7436 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( | 7472 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( |
7437 checked_object, key, val, | 7473 checked_object, key, val, |
7438 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, | 7474 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, |
7439 consolidated_elements_kind, | 7475 consolidated_elements_kind, LOAD, load_mode, STANDARD_STORE); |
7440 LOAD, NEVER_RETURN_HOLE, STANDARD_STORE); | |
7441 return instr; | 7476 return instr; |
7442 } | 7477 } |
7443 | 7478 |
7444 | 7479 |
7445 HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( | 7480 HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( |
7446 Expression* expr, FeedbackVectorICSlot slot, HValue* object, HValue* key, | 7481 Expression* expr, FeedbackVectorICSlot slot, HValue* object, HValue* key, |
7447 HValue* val, SmallMapList* maps, PropertyAccessType access_type, | 7482 HValue* val, SmallMapList* maps, PropertyAccessType access_type, |
7448 KeyedAccessStoreMode store_mode, bool* has_side_effects) { | 7483 KeyedAccessStoreMode store_mode, bool* has_side_effects) { |
7449 *has_side_effects = false; | 7484 *has_side_effects = false; |
7450 BuildCheckHeapObject(object); | 7485 BuildCheckHeapObject(object); |
(...skipping 5993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13444 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13479 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13445 } | 13480 } |
13446 | 13481 |
13447 #ifdef DEBUG | 13482 #ifdef DEBUG |
13448 graph_->Verify(false); // No full verify. | 13483 graph_->Verify(false); // No full verify. |
13449 #endif | 13484 #endif |
13450 } | 13485 } |
13451 | 13486 |
13452 } // namespace internal | 13487 } // namespace internal |
13453 } // namespace v8 | 13488 } // namespace v8 |
OLD | NEW |