Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index fa2dcdbfc4fc6b15a97c48e9964bf10a003176b0..589acb7d3aff25ec7fa94475be83c714f172fcc3 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -4724,6 +4724,36 @@ void Map::EnsureDescriptorSlack(Handle<Map> map, int slack) { |
map->UpdateDescriptors(*new_descriptors, layout_descriptor); |
} |
+// static |
+Handle<Map> Map::GetObjectCreateMap(Handle<HeapObject> prototype) { |
+ Isolate* isolate = prototype->GetIsolate(); |
+ Handle<Map> map(isolate->native_context()->object_function()->initial_map(), |
+ isolate); |
+ if (map->prototype() == *prototype) return map; |
+ if (prototype->IsNull(isolate)) { |
+ return isolate->slow_object_with_null_prototype_map(); |
+ } |
+ if (prototype->IsJSObject()) { |
+ Handle<JSObject> js_prototype = Handle<JSObject>::cast(prototype); |
+ if (!js_prototype->map()->is_prototype_map()) { |
+ JSObject::OptimizeAsPrototype(js_prototype, FAST_PROTOTYPE); |
+ } |
+ Handle<PrototypeInfo> info = |
+ Map::GetOrCreatePrototypeInfo(js_prototype, isolate); |
+ // TODO(verwaest): Use inobject slack tracking for this map. |
+ if (info->HasObjectCreateMap()) { |
+ map = handle(info->ObjectCreateMap(), isolate); |
+ } else { |
+ map = Map::CopyInitialMap(map); |
+ Map::SetPrototype(map, prototype, FAST_PROTOTYPE); |
+ PrototypeInfo::SetObjectCreateMap(info, map); |
+ } |
+ return map; |
+ } |
+ |
+ return Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE); |
+} |
+ |
template <class T> |
static int AppendUniqueCallbacks(Handle<TemplateList> callbacks, |
Handle<typename T::Array> array, |
@@ -8226,8 +8256,8 @@ bool Map::OnlyHasSimpleProperties() { |
// Wrapped string elements aren't explicitly stored in the elements backing |
// store, but are loaded indirectly from the underlying string. |
return !IsStringWrapperElementsKind(elements_kind()) && |
- instance_type() > LAST_SPECIAL_RECEIVER_TYPE && |
- !has_hidden_prototype() && !is_dictionary_map(); |
+ !IsSpecialReceiverMap() && !has_hidden_prototype() && |
+ !is_dictionary_map(); |
} |
MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( |