From c6a3422c04810897412ca90eab0099349f5ea210 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Thu, 22 Sep 2011 12:57:54 +0000 Subject: [PATCH] Give each function prototype a fresh copy of the object function map. This avoid unwanted sharing between different function prototypes and in general should help inlining because constant function properties on one prototype don't affect other prototypes anymore. BUG=v8:1716 Review URL: http://codereview.chromium.org/7994001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9393 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.cc | 12 +++++++++++- src/objects.cc | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/heap.cc b/src/heap.cc index 9000c2d..f2f9985 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -3265,8 +3265,18 @@ MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) { // different context. JSFunction* object_function = function->context()->global_context()->object_function(); + + // Each function prototype gets a copy of the object function map. + // This avoid unwanted sharing of maps between prototypes of different + // constructors. + Map* new_map; + ASSERT(object_function->has_initial_map()); + { MaybeObject* maybe_map = + object_function->initial_map()->CopyDropTransitions(); + if (!maybe_map->To(&new_map)) return maybe_map; + } Object* prototype; - { MaybeObject* maybe_prototype = AllocateJSObject(object_function); + { MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map); if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; } // When creating the prototype for the function we must set its diff --git a/src/objects.cc b/src/objects.cc index f894bc5..ce0259b 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -1070,7 +1070,6 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) { void HeapObject::HeapObjectShortPrint(StringStream* accumulator) { - // if (!HEAP->InNewSpace(this)) PrintF("*", this); Heap* heap = GetHeap(); if (!heap->Contains(this)) { accumulator->Add("!!!INVALID POINTER!!!"); -- 2.7.4