Changeset 84679 in webkit


Ignore:
Timestamp:
Apr 22, 2011 2:17:20 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-04-22 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Object.create creates uncachable objects
https://bugs.webkit.org/show_bug.cgi?id=59164

Use the prototype object's inheritorID, as we
should always have done

  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset): (JSC::JSGlobalObject::visitChildren):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::nullPrototypeObjectStructure):
  • runtime/ObjectConstructor.cpp: (JSC::objectConstructorCreate):
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r84675 r84679  
     12011-04-22  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Object.create creates uncachable objects
     6        https://bugs.webkit.org/show_bug.cgi?id=59164
     7
     8        Use the prototype object's inheritorID, as we
     9        should always have done
     10
     11        * runtime/JSGlobalObject.cpp:
     12        (JSC::JSGlobalObject::reset):
     13        (JSC::JSGlobalObject::visitChildren):
     14        * runtime/JSGlobalObject.h:
     15        (JSC::JSGlobalObject::nullPrototypeObjectStructure):
     16        * runtime/ObjectConstructor.cpp:
     17        (JSC::objectConstructorCreate):
     18
    1192011-04-22  Gavin Barraclough  <barraclough@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r84556 r84679  
    182182
    183183    m_emptyObjectStructure.set(exec->globalData(), this, m_objectPrototype->inheritorID(exec->globalData()));
     184    m_nullPrototypeObjectStructure.set(exec->globalData(), this, createEmptyObjectStructure(exec->globalData(), jsNull()));
    184185
    185186    m_callbackFunctionStructure.set(exec->globalData(), this, JSCallbackFunction::createStructure(exec->globalData(), m_functionPrototype.get()));
     
    345346    visitIfNeeded(visitor, &m_dateStructure);
    346347    visitIfNeeded(visitor, &m_emptyObjectStructure);
     348    visitIfNeeded(visitor, &m_nullPrototypeObjectStructure);
    347349    visitIfNeeded(visitor, &m_errorStructure);
    348350    visitIfNeeded(visitor, &m_functionStructure);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r84670 r84679  
    9696        WriteBarrier<Structure> m_dateStructure;
    9797        WriteBarrier<Structure> m_emptyObjectStructure;
     98        WriteBarrier<Structure> m_nullPrototypeObjectStructure;
    9899        WriteBarrier<Structure> m_errorStructure;
    99100        WriteBarrier<Structure> m_functionStructure;
     
    203204        Structure* dateStructure() const { return m_dateStructure.get(); }
    204205        Structure* emptyObjectStructure() const { return m_emptyObjectStructure.get(); }
     206        Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); }
    205207        Structure* errorStructure() const { return m_errorStructure.get(); }
    206208        Structure* functionStructure() const { return m_functionStructure.get(); }
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r84599 r84679  
    342342    if (!exec->argument(0).isObject() && !exec->argument(0).isNull())
    343343        return throwVMError(exec, createTypeError(exec, "Object prototype may only be an Object or null."));
    344     JSObject* newObject = constructEmptyObject(exec);
    345     newObject->setPrototype(exec->globalData(), exec->argument(0));
     344    JSValue proto = exec->argument(0);
     345    JSObject* newObject = proto.isObject() ? constructEmptyObject(exec, asObject(proto)->inheritorID(exec->globalData())) : constructEmptyObject(exec, exec->lexicalGlobalObject()->nullPrototypeObjectStructure());
    346346    if (exec->argument(1).isUndefined())
    347347        return JSValue::encode(newObject);
Note: See TracChangeset for help on using the changeset viewer.