| 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 <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 12521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12532 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); | 12532 TransitionArray::TraverseTransitionTree(this, &ShrinkInstanceSize, &slack); |
| 12533 } else { | 12533 } else { |
| 12534 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr); | 12534 TransitionArray::TraverseTransitionTree(this, &StopSlackTracking, nullptr); |
| 12535 } | 12535 } |
| 12536 } | 12536 } |
| 12537 | 12537 |
| 12538 | 12538 |
| 12539 static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) { | 12539 static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) { |
| 12540 DisallowHeapAllocation no_gc; | 12540 DisallowHeapAllocation no_gc; |
| 12541 if (!object->HasFastProperties()) return false; | 12541 if (!object->HasFastProperties()) return false; |
| 12542 Map* map = object->map(); | 12542 if (object->IsJSGlobalProxy()) return false; |
| 12543 if (map->is_prototype_map()) return false; | 12543 if (object->GetIsolate()->bootstrapper()->IsActive()) return false; |
| 12544 DescriptorArray* descriptors = map->instance_descriptors(); | 12544 return !object->map()->is_prototype_map() || |
| 12545 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 12545 !object->map()->should_be_fast_prototype_map(); |
| 12546 PropertyDetails details = descriptors->GetDetails(i); | |
| 12547 if (details.location() == kDescriptor) continue; | |
| 12548 if (details.representation().IsHeapObject() || | |
| 12549 details.representation().IsTagged()) { | |
| 12550 FieldIndex index = FieldIndex::ForDescriptor(map, i); | |
| 12551 if (object->RawFastPropertyAt(index)->IsJSFunction()) return true; | |
| 12552 } | |
| 12553 } | |
| 12554 return false; | |
| 12555 } | 12546 } |
| 12556 | 12547 |
| 12557 // static | 12548 // static |
| 12558 void JSObject::MakePrototypesFast(Handle<Object> receiver, | 12549 void JSObject::MakePrototypesFast(Handle<Object> receiver, |
| 12559 WhereToStart where_to_start, | 12550 WhereToStart where_to_start, |
| 12560 Isolate* isolate) { | 12551 Isolate* isolate) { |
| 12561 if (!receiver->IsJSReceiver()) return; | 12552 if (!receiver->IsJSReceiver()) return; |
| 12562 for (PrototypeIterator iter(isolate, Handle<JSReceiver>::cast(receiver), | 12553 for (PrototypeIterator iter(isolate, Handle<JSReceiver>::cast(receiver), |
| 12563 where_to_start); | 12554 where_to_start); |
| 12564 !iter.IsAtEnd(); iter.Advance()) { | 12555 !iter.IsAtEnd(); iter.Advance()) { |
| 12565 Handle<Object> current = PrototypeIterator::GetCurrent(iter); | 12556 Handle<Object> current = PrototypeIterator::GetCurrent(iter); |
| 12566 if (!current->IsJSObject()) return; | 12557 if (!current->IsJSObject()) return; |
| 12567 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); | 12558 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); |
| 12568 Map* current_map = current_obj->map(); | 12559 Map* current_map = current_obj->map(); |
| 12569 if (current_map->is_prototype_map() && | 12560 if (current_map->is_prototype_map()) { |
| 12570 !current_map->should_be_fast_prototype_map()) { | 12561 // If the map is already marked as should be fast, we're done. Its |
| 12562 // prototypes will have been marked already as well. |
| 12563 if (current_map->should_be_fast_prototype_map()) return; |
| 12571 Handle<Map> map(current_map); | 12564 Handle<Map> map(current_map); |
| 12572 Map::SetShouldBeFastPrototypeMap(map, true, isolate); | 12565 Map::SetShouldBeFastPrototypeMap(map, true, isolate); |
| 12573 JSObject::OptimizeAsPrototype(current_obj, FAST_PROTOTYPE); | 12566 JSObject::OptimizeAsPrototype(current_obj, FAST_PROTOTYPE); |
| 12574 } | 12567 } |
| 12575 } | 12568 } |
| 12576 } | 12569 } |
| 12577 | 12570 |
| 12578 // static | 12571 // static |
| 12579 void JSObject::OptimizeAsPrototype(Handle<JSObject> object, | 12572 void JSObject::OptimizeAsPrototype(Handle<JSObject> object, |
| 12580 PrototypeOptimizationMode mode) { | 12573 PrototypeOptimizationMode mode) { |
| (...skipping 7846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20427 // depend on this. | 20420 // depend on this. |
| 20428 return DICTIONARY_ELEMENTS; | 20421 return DICTIONARY_ELEMENTS; |
| 20429 } | 20422 } |
| 20430 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20423 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20431 return kind; | 20424 return kind; |
| 20432 } | 20425 } |
| 20433 } | 20426 } |
| 20434 | 20427 |
| 20435 } // namespace internal | 20428 } // namespace internal |
| 20436 } // namespace v8 | 20429 } // namespace v8 |
| OLD | NEW |