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
This commit is contained in:
fschneider@chromium.org 2011-09-22 12:57:54 +00:00
parent f48c9f6557
commit c6a3422c04
2 changed files with 11 additions and 2 deletions

View File

@ -3265,8 +3265,18 @@ MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) {
// different context. // different context.
JSFunction* object_function = JSFunction* object_function =
function->context()->global_context()->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<Map>(&new_map)) return maybe_map;
}
Object* prototype; Object* prototype;
{ MaybeObject* maybe_prototype = AllocateJSObject(object_function); { MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map);
if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
} }
// When creating the prototype for the function we must set its // When creating the prototype for the function we must set its

View File

@ -1070,7 +1070,6 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
void HeapObject::HeapObjectShortPrint(StringStream* accumulator) { void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
// if (!HEAP->InNewSpace(this)) PrintF("*", this);
Heap* heap = GetHeap(); Heap* heap = GetHeap();
if (!heap->Contains(this)) { if (!heap->Contains(this)) {
accumulator->Add("!!!INVALID POINTER!!!"); accumulator->Add("!!!INVALID POINTER!!!");