| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 9308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9319 result->set_bit_field2(map->bit_field2()); | 9319 result->set_bit_field2(map->bit_field2()); |
| 9320 int new_bit_field3 = map->bit_field3(); | 9320 int new_bit_field3 = map->bit_field3(); |
| 9321 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); | 9321 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); |
| 9322 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); | 9322 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); |
| 9323 new_bit_field3 = EnumLengthBits::update(new_bit_field3, | 9323 new_bit_field3 = EnumLengthBits::update(new_bit_field3, |
| 9324 kInvalidEnumCacheSentinel); | 9324 kInvalidEnumCacheSentinel); |
| 9325 new_bit_field3 = Deprecated::update(new_bit_field3, false); | 9325 new_bit_field3 = Deprecated::update(new_bit_field3, false); |
| 9326 if (!map->is_dictionary_map()) { | 9326 if (!map->is_dictionary_map()) { |
| 9327 new_bit_field3 = IsUnstable::update(new_bit_field3, false); | 9327 new_bit_field3 = IsUnstable::update(new_bit_field3, false); |
| 9328 } | 9328 } |
| 9329 new_bit_field3 = | |
| 9330 ConstructionCounter::update(new_bit_field3, kNoSlackTracking); | |
| 9331 result->set_bit_field3(new_bit_field3); | 9329 result->set_bit_field3(new_bit_field3); |
| 9332 return result; | 9330 return result; |
| 9333 } | 9331 } |
| 9334 | 9332 |
| 9335 | 9333 |
| 9336 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, | 9334 Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode, |
| 9337 const char* reason) { | 9335 const char* reason) { |
| 9338 DCHECK(!fast_map->is_dictionary_map()); | 9336 DCHECK(!fast_map->is_dictionary_map()); |
| 9339 | 9337 |
| 9340 Isolate* isolate = fast_map->GetIsolate(); | 9338 Isolate* isolate = fast_map->GetIsolate(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9407 } | 9405 } |
| 9408 | 9406 |
| 9409 Handle<Map> result = RawCopy(map, new_instance_size); | 9407 Handle<Map> result = RawCopy(map, new_instance_size); |
| 9410 | 9408 |
| 9411 if (mode != CLEAR_INOBJECT_PROPERTIES) { | 9409 if (mode != CLEAR_INOBJECT_PROPERTIES) { |
| 9412 result->SetInObjectProperties(map->GetInObjectProperties()); | 9410 result->SetInObjectProperties(map->GetInObjectProperties()); |
| 9413 } | 9411 } |
| 9414 | 9412 |
| 9415 result->set_dictionary_map(true); | 9413 result->set_dictionary_map(true); |
| 9416 result->set_migration_target(false); | 9414 result->set_migration_target(false); |
| 9415 result->set_construction_counter(kNoSlackTracking); |
| 9417 | 9416 |
| 9418 #ifdef VERIFY_HEAP | 9417 #ifdef VERIFY_HEAP |
| 9419 if (FLAG_verify_heap) result->DictionaryMapVerify(); | 9418 if (FLAG_verify_heap) result->DictionaryMapVerify(); |
| 9420 #endif | 9419 #endif |
| 9421 | 9420 |
| 9422 return result; | 9421 return result; |
| 9423 } | 9422 } |
| 9424 | 9423 |
| 9425 | 9424 |
| 9426 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, | 9425 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, |
| (...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12722 *reinterpret_cast<int*>(data) = slack; | 12721 *reinterpret_cast<int*>(data) = slack; |
| 12723 } | 12722 } |
| 12724 } | 12723 } |
| 12725 | 12724 |
| 12726 | 12725 |
| 12727 static void ShrinkInstanceSize(Map* map, void* data) { | 12726 static void ShrinkInstanceSize(Map* map, void* data) { |
| 12728 int slack = *reinterpret_cast<int*>(data); | 12727 int slack = *reinterpret_cast<int*>(data); |
| 12729 map->SetInObjectProperties(map->GetInObjectProperties() - slack); | 12728 map->SetInObjectProperties(map->GetInObjectProperties() - slack); |
| 12730 map->set_unused_property_fields(map->unused_property_fields() - slack); | 12729 map->set_unused_property_fields(map->unused_property_fields() - slack); |
| 12731 map->set_instance_size(map->instance_size() - slack * kPointerSize); | 12730 map->set_instance_size(map->instance_size() - slack * kPointerSize); |
| 12731 map->set_construction_counter(Map::kNoSlackTracking); |
| 12732 | 12732 |
| 12733 // Visitor id might depend on the instance size, recalculate it. | 12733 // Visitor id might depend on the instance size, recalculate it. |
| 12734 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); | 12734 map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map)); |
| 12735 } | 12735 } |
| 12736 | 12736 |
| 12737 | 12737 |
| 12738 void Map::CompleteInobjectSlackTracking() { | 12738 void Map::CompleteInobjectSlackTracking() { |
| 12739 // Has to be an initial map. | 12739 // Has to be an initial map. |
| 12740 DCHECK(GetBackPointer()->IsUndefined()); | 12740 DCHECK(GetBackPointer()->IsUndefined()); |
| 12741 | 12741 |
| 12742 set_construction_counter(kNoSlackTracking); | |
| 12743 | |
| 12744 int slack = unused_property_fields(); | 12742 int slack = unused_property_fields(); |
| 12745 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack); | 12743 TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack); |
| 12746 if (slack != 0) { | 12744 if (slack != 0) { |
| 12747 // Resize the initial map and all maps in its transition tree. | 12745 // Resize the initial map and all maps in its transition tree. |
| 12748 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); | 12746 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); |
| 12749 } | 12747 } |
| 12750 } | 12748 } |
| 12751 | 12749 |
| 12752 | 12750 |
| 12753 static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) { | 12751 static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) { |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13325 &in_object_properties); | 13323 &in_object_properties); |
| 13326 | 13324 |
| 13327 int unused_property_fields = in_object_properties - pre_allocated; | 13325 int unused_property_fields = in_object_properties - pre_allocated; |
| 13328 Handle<Map> map = | 13326 Handle<Map> map = |
| 13329 Map::CopyInitialMap(constructor_initial_map, instance_size, | 13327 Map::CopyInitialMap(constructor_initial_map, instance_size, |
| 13330 in_object_properties, unused_property_fields); | 13328 in_object_properties, unused_property_fields); |
| 13331 map->set_new_target_is_base(false); | 13329 map->set_new_target_is_base(false); |
| 13332 | 13330 |
| 13333 JSFunction::SetInitialMap(function, map, prototype); | 13331 JSFunction::SetInitialMap(function, map, prototype); |
| 13334 map->SetConstructor(*constructor); | 13332 map->SetConstructor(*constructor); |
| 13333 map->set_construction_counter(Map::kNoSlackTracking); |
| 13335 map->StartInobjectSlackTracking(); | 13334 map->StartInobjectSlackTracking(); |
| 13336 return map; | 13335 return map; |
| 13337 } | 13336 } |
| 13338 } | 13337 } |
| 13339 | 13338 |
| 13340 // Slow path, new.target is either a proxy or can't cache the map. | 13339 // Slow path, new.target is either a proxy or can't cache the map. |
| 13341 // new.target.prototype is not guaranteed to be a JSReceiver, and may need to | 13340 // new.target.prototype is not guaranteed to be a JSReceiver, and may need to |
| 13342 // fall back to the intrinsicDefaultProto. | 13341 // fall back to the intrinsicDefaultProto. |
| 13343 Handle<Object> prototype; | 13342 Handle<Object> prototype; |
| 13344 if (new_target->IsJSFunction()) { | 13343 if (new_target->IsJSFunction()) { |
| (...skipping 6642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19987 if (cell->value() != *new_value) { | 19986 if (cell->value() != *new_value) { |
| 19988 cell->set_value(*new_value); | 19987 cell->set_value(*new_value); |
| 19989 Isolate* isolate = cell->GetIsolate(); | 19988 Isolate* isolate = cell->GetIsolate(); |
| 19990 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19989 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19991 isolate, DependentCode::kPropertyCellChangedGroup); | 19990 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19992 } | 19991 } |
| 19993 } | 19992 } |
| 19994 | 19993 |
| 19995 } // namespace internal | 19994 } // namespace internal |
| 19996 } // namespace v8 | 19995 } // namespace v8 |
| OLD | NEW |