Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 3a60a322a139ad3c495423cb05ca4581bd3662f3..2ea4aab572a02bf3c493276bf25c97d809105f0f 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -6671,6 +6671,37 @@ MaybeObject* Map::CopyAsElementsKind(ElementsKind kind, TransitionFlag flag) { |
} |
+MaybeObject* Map::CopyForObserved() { |
+ ASSERT(!is_observed()); |
+ |
+ Map* new_map; |
+ MaybeObject* maybe_new_map; |
+ if (owns_descriptors()) { |
+ maybe_new_map = CopyDropDescriptors(); |
+ } else { |
+ maybe_new_map = Copy(); |
+ } |
+ if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
+ |
+ TransitionArray* transitions; |
+ MaybeObject* maybe_transitions = AddTransition(GetHeap()->observed_symbol(), |
+ new_map, |
+ FULL_TRANSITION); |
+ if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
+ set_transitions(transitions); |
+ |
+ new_map->set_is_observed(true); |
+ |
+ if (owns_descriptors()) { |
+ new_map->InitializeDescriptors(instance_descriptors()); |
+ set_owns_descriptors(false); |
+ } |
+ |
+ new_map->SetBackPointer(this); |
+ return new_map; |
+} |
+ |
+ |
MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() { |
if (pre_allocated_property_fields() == 0) return CopyDropDescriptors(); |