| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 9487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9498 | 9498 |
| 9499 void JSObject::OptimizeAsPrototype(Handle<JSObject> object, | 9499 void JSObject::OptimizeAsPrototype(Handle<JSObject> object, |
| 9500 PrototypeOptimizationMode mode) { | 9500 PrototypeOptimizationMode mode) { |
| 9501 if (object->IsGlobalObject()) return; | 9501 if (object->IsGlobalObject()) return; |
| 9502 if (object->IsJSGlobalProxy()) return; | 9502 if (object->IsJSGlobalProxy()) return; |
| 9503 if (mode == FAST_PROTOTYPE && !object->map()->is_prototype_map()) { | 9503 if (mode == FAST_PROTOTYPE && !object->map()->is_prototype_map()) { |
| 9504 // First normalize to ensure all JSFunctions are CONSTANT. | 9504 // First normalize to ensure all JSFunctions are CONSTANT. |
| 9505 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, | 9505 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, |
| 9506 "NormalizeAsPrototype"); | 9506 "NormalizeAsPrototype"); |
| 9507 } | 9507 } |
| 9508 bool has_just_copied_map = false; | |
| 9509 if (!object->HasFastProperties()) { | 9508 if (!object->HasFastProperties()) { |
| 9510 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); | 9509 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); |
| 9511 has_just_copied_map = true; | |
| 9512 } | 9510 } |
| 9513 if (mode == FAST_PROTOTYPE && object->HasFastProperties() && | 9511 if (mode == FAST_PROTOTYPE && object->HasFastProperties() && |
| 9514 !object->map()->is_prototype_map()) { | 9512 !object->map()->is_prototype_map()) { |
| 9515 if (!has_just_copied_map) { | 9513 Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); |
| 9516 Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); | 9514 JSObject::MigrateToMap(object, new_map); |
| 9517 JSObject::MigrateToMap(object, new_map); | |
| 9518 } | |
| 9519 object->map()->set_is_prototype_map(true); | 9515 object->map()->set_is_prototype_map(true); |
| 9520 } | 9516 } |
| 9521 } | 9517 } |
| 9522 | 9518 |
| 9523 | 9519 |
| 9524 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { | 9520 void JSObject::ReoptimizeIfPrototype(Handle<JSObject> object) { |
| 9525 if (!object->map()->is_prototype_map()) return; | 9521 if (!object->map()->is_prototype_map()) return; |
| 9526 OptimizeAsPrototype(object, FAST_PROTOTYPE); | 9522 OptimizeAsPrototype(object, FAST_PROTOTYPE); |
| 9527 } | 9523 } |
| 9528 | 9524 |
| (...skipping 7157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16686 Handle<DependentCode> codes = | 16682 Handle<DependentCode> codes = |
| 16687 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16683 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
| 16688 DependentCode::kPropertyCellChangedGroup, | 16684 DependentCode::kPropertyCellChangedGroup, |
| 16689 info->object_wrapper()); | 16685 info->object_wrapper()); |
| 16690 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16686 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 16691 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16687 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 16692 cell, info->zone()); | 16688 cell, info->zone()); |
| 16693 } | 16689 } |
| 16694 | 16690 |
| 16695 } } // namespace v8::internal | 16691 } } // namespace v8::internal |
| OLD | NEW |