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 7434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7445 if (!has_double_maps && !has_smi_or_object_maps) return NULL; | 7445 if (!has_double_maps && !has_smi_or_object_maps) return NULL; |
7446 | 7446 |
7447 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); | 7447 HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); |
7448 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. | 7448 // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. |
7449 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. | 7449 // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. |
7450 ElementsKind consolidated_elements_kind = has_seen_holey_elements | 7450 ElementsKind consolidated_elements_kind = has_seen_holey_elements |
7451 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) | 7451 ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) |
7452 : most_general_consolidated_map->elements_kind(); | 7452 : most_general_consolidated_map->elements_kind(); |
7453 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; | 7453 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
7454 if (has_seen_holey_elements) { | 7454 if (has_seen_holey_elements) { |
7455 if (!isolate()->IsFastArrayConstructorPrototypeChainIntact()) { | |
7456 return NULL; | |
7457 } | |
7458 | |
7459 // Make sure that all of the maps we are handling have the initial array | 7455 // Make sure that all of the maps we are handling have the initial array |
7460 // prototype. | 7456 // prototype. |
| 7457 bool saw_non_array_prototype = false; |
7461 for (int i = 0; i < maps->length(); ++i) { | 7458 for (int i = 0; i < maps->length(); ++i) { |
7462 Handle<Map> map = maps->at(i); | 7459 Handle<Map> map = maps->at(i); |
7463 if (map->prototype() != *isolate()->initial_array_prototype()) { | 7460 if (map->prototype() != *isolate()->initial_array_prototype()) { |
7464 // We can't guarantee that loading the hole is safe. The prototype may | 7461 // We can't guarantee that loading the hole is safe. The prototype may |
7465 // have an element at this position. | 7462 // have an element at this position. |
7466 return NULL; | 7463 saw_non_array_prototype = true; |
| 7464 break; |
7467 } | 7465 } |
7468 } | 7466 } |
7469 | 7467 |
7470 Handle<Map> holey_map = | 7468 if (!saw_non_array_prototype) { |
7471 handle(isolate()->get_initial_js_array_map(consolidated_elements_kind)); | 7469 Handle<Map> holey_map = handle( |
7472 load_mode = BuildKeyedHoleMode(holey_map); | 7470 isolate()->get_initial_js_array_map(consolidated_elements_kind)); |
7473 if (load_mode == NEVER_RETURN_HOLE) { | 7471 load_mode = BuildKeyedHoleMode(holey_map); |
7474 return NULL; | 7472 if (load_mode != NEVER_RETURN_HOLE) { |
7475 } | 7473 for (int i = 0; i < maps->length(); ++i) { |
7476 | 7474 Handle<Map> map = maps->at(i); |
7477 for (int i = 0; i < maps->length(); ++i) { | 7475 // The prototype check was already done for the holey map in |
7478 Handle<Map> map = maps->at(i); | 7476 // BuildKeyedHoleMode. |
7479 // The prototype check was already done for the holey map in | 7477 if (!map.is_identical_to(holey_map)) { |
7480 // BuildKeyedHoleMode. | 7478 Handle<JSObject> prototype(JSObject::cast(map->prototype()), |
7481 if (!map.is_identical_to(holey_map)) { | 7479 isolate()); |
7482 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); | 7480 Handle<JSObject> object_prototype = |
7483 Handle<JSObject> object_prototype = | 7481 isolate()->initial_object_prototype(); |
7484 isolate()->initial_object_prototype(); | 7482 BuildCheckPrototypeMaps(prototype, object_prototype); |
7485 BuildCheckPrototypeMaps(prototype, object_prototype); | 7483 } |
| 7484 } |
7486 } | 7485 } |
7487 } | 7486 } |
7488 } | 7487 } |
7489 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( | 7488 HInstruction* instr = BuildUncheckedMonomorphicElementAccess( |
7490 checked_object, key, val, | 7489 checked_object, key, val, |
7491 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, | 7490 most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, |
7492 consolidated_elements_kind, LOAD, load_mode, STANDARD_STORE); | 7491 consolidated_elements_kind, LOAD, load_mode, STANDARD_STORE); |
7493 return instr; | 7492 return instr; |
7494 } | 7493 } |
7495 | 7494 |
(...skipping 6017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13513 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13512 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13514 } | 13513 } |
13515 | 13514 |
13516 #ifdef DEBUG | 13515 #ifdef DEBUG |
13517 graph_->Verify(false); // No full verify. | 13516 graph_->Verify(false); // No full verify. |
13518 #endif | 13517 #endif |
13519 } | 13518 } |
13520 | 13519 |
13521 } // namespace internal | 13520 } // namespace internal |
13522 } // namespace v8 | 13521 } // namespace v8 |
OLD | NEW |