Ignore:
Timestamp:
Mar 2, 2016, 2:39:02 PM (9 years ago)
Author:
[email protected]
Message:

SetPrototypeOf should be a fully virtual method in ClassInfo::methodTable
https://bugs.webkit.org/show_bug.cgi?id=154897

Reviewed by Filip Pizlo.

This patch makes us more consistent with how the ES6 specification models the
SetPrototypeOf trap. Moving this method into ClassInfo::methodTable
is a prerequisite for implementing Proxy.SetPrototypeOf. This patch
still allows directly setting the prototype for situations where this
is the desired behavior. This is equivalent to setting the internal
Prototype field as described in the specification.

  • API/JSClassRef.cpp:

(OpaqueJSClass::prototype):

  • API/JSObjectRef.cpp:

(JSObjectMake):
(JSObjectSetPrototype):
(JSObjectHasProperty):

  • API/JSWrapperMap.mm:

(makeWrapper):

  • runtime/ClassInfo.h:
  • runtime/IntlCollatorConstructor.cpp:

(JSC::constructIntlCollator):

  • runtime/IntlDateTimeFormatConstructor.cpp:

(JSC::constructIntlDateTimeFormat):

  • runtime/IntlNumberFormatConstructor.cpp:

(JSC::constructIntlNumberFormat):

  • runtime/JSCell.cpp:

(JSC::JSCell::isExtensible):
(JSC::JSCell::setPrototypeOf):

  • runtime/JSCell.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::resetPrototype):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoSetter):

  • runtime/JSObject.cpp:

(JSC::JSObject::switchToSlowPutArrayStorage):
(JSC::JSObject::setPrototypeDirect):
(JSC::JSObject::setPrototypeWithCycleCheck):
(JSC::JSObject::setPrototypeOf):
(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::setPrototype): Deleted.

  • runtime/JSObject.h:

(JSC::JSObject::setPrototypeOfInline):
(JSC::JSObject::mayInterceptIndexedAccesses):

  • runtime/JSProxy.cpp:

(JSC::JSProxy::setTarget):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorSetPrototypeOf):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectSetPrototypeOf):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r197412 r197467  
    11721172}
    11731173
    1174 void JSObject::setPrototype(VM& vm, JSValue prototype)
     1174void JSObject::setPrototypeDirect(VM& vm, JSValue prototype)
    11751175{
    11761176    ASSERT(prototype);
     
    11981198}
    11991199
    1200 bool JSObject::setPrototypeWithCycleCheck(ExecState* exec, JSValue prototype)
    1201 {
    1202     ASSERT(methodTable(exec->vm())->toThis(this, exec, NotStrictMode) == this);
     1200bool JSObject::setPrototypeWithCycleCheck(VM& vm, ExecState* exec, JSValue prototype)
     1201{
     1202    UNUSED_PARAM(exec);
     1203    ASSERT(methodTable(vm)->toThis(this, exec, NotStrictMode) == this);
    12031204    JSValue nextPrototype = prototype;
    12041205    while (nextPrototype && nextPrototype.isObject()) {
     
    12071208        nextPrototype = asObject(nextPrototype)->prototype();
    12081209    }
    1209     setPrototype(exec->vm(), prototype);
     1210    setPrototypeDirect(vm, prototype);
    12101211    return true;
     1212}
     1213
     1214bool JSObject::setPrototypeOf(JSObject* object, ExecState* exec, JSValue prototype)
     1215{
     1216    return object->setPrototypeWithCycleCheck(exec->vm(), exec, prototype);
    12111217}
    12121218
Note: See TracChangeset for help on using the changeset viewer.