Ignore:
Timestamp:
Apr 17, 2016, 2:53:11 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

[ES6] Use @isObject to check Object Type instead of using instanceof
https://bugs.webkit.org/show_bug.cgi?id=156676

Reviewed by Darin Adler.

Use @isObject instead of instanceof @Object.
The instanceof check is not enough to check Object Type.
For example, given 2 realms, the object created in one realm does not inherit the Object of another realm.
Another example is that the object which does not inherit Object.
This object can be easily created by calling Object.create(null).

  • builtins/RegExpPrototype.js:

(match):

  • jsc.cpp:

(GlobalObject::finishCreation):
(functionCreateGlobalObject):

  • tests/stress/regexp-match-in-other-realm-should-work.js: Added.

(shouldBe):

  • tests/stress/regexp-match-should-work-with-objects-not-inheriting-object-prototype.js: Added.

(shouldBe):
(regexp.exec):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r199397 r199647  
    556556static EncodedJSValue JSC_HOST_CALL functionCreateCustomGetterObject(ExecState*);
    557557static EncodedJSValue JSC_HOST_CALL functionCreateBuiltin(ExecState*);
     558static EncodedJSValue JSC_HOST_CALL functionCreateGlobalObject(ExecState*);
    558559static EncodedJSValue JSC_HOST_CALL functionSetImpureGetterDelegate(ExecState*);
    559560
     
    801802        addFunction(vm, "createCustomGetterObject", functionCreateCustomGetterObject, 0);
    802803        addFunction(vm, "createBuiltin", functionCreateBuiltin, 2);
     804        addFunction(vm, "createGlobalObject", functionCreateGlobalObject, 0);
    803805        addFunction(vm, "setImpureGetterDelegate", functionSetImpureGetterDelegate, 2);
    804806
     
    17771779}
    17781780
     1781EncodedJSValue JSC_HOST_CALL functionCreateGlobalObject(ExecState* exec)
     1782{
     1783    VM& vm = exec->vm();
     1784    return JSValue::encode(GlobalObject::create(vm, GlobalObject::createStructure(vm, jsNull()), Vector<String>()));
     1785}
     1786
    17791787EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState* exec)
    17801788{
Note: See TracChangeset for help on using the changeset viewer.