Changeset 259587 in webkit


Ignore:
Timestamp:
Apr 6, 2020 12:01:57 PM (4 years ago)
Author:
Alexey Shvayka
Message:

Remove unnecessary Test262 harness file and implement $262.IsHTMLDDA
https://bugs.webkit.org/show_bug.cgi?id=187526

Reviewed by Darin Adler.

JSTests:

  • stress/optional-chaining.js: Adjust test for callable masquerader.

Source/JavaScriptCore:

Test262 harness requires [1] $262.IsHTMLDDA to be an object with IsHTMLDDA? slot [2],
much like document.all. It is used in a few tests to make sure that runtimes strictly
compare values with null and undefined.

With this change, makeMasquerader returns callable masquerader to mimic document.all
in the wild. In order to avoid masqueradesAsUndefinedWatchpoint being fired during
initialization of JSC shell, $262.IsHTMLDDA is a getter.

[1]: https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
[2]: https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot

  • jsc.cpp:

(functionMakeMasquerader):
(functionCallMasquerader):
(JSC::Masquerader::Masquerader): Deleted.
(JSC::Masquerader::subspaceFor): Deleted.
(JSC::Masquerader::create): Deleted.
(JSC::Masquerader::createStructure): Deleted.

  • runtime/JSObject.h:

Tools:

Removed file duplicates functionality of jsc.cpp's GlobalObject::finishCreation.

  • Scripts/test262/Runner.pm:
  • Scripts/test262/agent.js: Removed.
Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r259583 r259587  
     12020-04-06  Rick Waldron  <waldron.rick@gmail.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Remove unnecessary Test262 harness file and implement $262.IsHTMLDDA
     4        https://bugs.webkit.org/show_bug.cgi?id=187526
     5
     6        Reviewed by Darin Adler.
     7
     8        * stress/optional-chaining.js: Adjust test for callable masquerader.
     9
    1102020-04-06  Justin Michaud  <justin_michaud@apple.com>
    211
  • trunk/JSTests/stress/optional-chaining.js

    r252679 r259587  
    8080    shouldThrowTypeError(() => []?.(), '[] is not a function');
    8181    shouldThrowTypeError(() => ['hi']?.(), '[\'hi\'] is not a function');
    82     shouldThrowTypeError(() => masquerader?.(), 'masquerader is not a function');
    8382}
    8483noInline(testBasicFailureCases);
     
    106105shouldBe((() => {})?.()?.(), undefined);
    107106shouldBe(null?.()().a['b'], undefined);
     107shouldBe(masquerader?.(), null);
    108108
    109109const o0 = { a: { b() { return this._b.bind(this); }, _b() { return this.__b; }, __b: { c: 42 } } };
  • trunk/Source/JavaScriptCore/ChangeLog

    r259583 r259587  
     12020-04-06  Rick Waldron  <waldron.rick@gmail.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Remove unnecessary Test262 harness file and implement $262.IsHTMLDDA
     4        https://bugs.webkit.org/show_bug.cgi?id=187526
     5
     6        Reviewed by Darin Adler.
     7
     8        Test262 harness requires [1] $262.IsHTMLDDA to be an object with [[IsHTMLDDA]] slot [2],
     9        much like `document.all`. It is used in a few tests to make sure that runtimes strictly
     10        compare values with `null` and `undefined`.
     11
     12        With this change, `makeMasquerader` returns callable masquerader to mimic `document.all`
     13        in the wild. In order to avoid `masqueradesAsUndefinedWatchpoint` being fired during
     14        initialization of JSC shell, $262.IsHTMLDDA is a getter.
     15
     16        [1]: https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
     17        [2]: https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
     18
     19        * jsc.cpp:
     20        (functionMakeMasquerader):
     21        (functionCallMasquerader):
     22        (JSC::Masquerader::Masquerader): Deleted.
     23        (JSC::Masquerader::subspaceFor): Deleted.
     24        (JSC::Masquerader::create): Deleted.
     25        (JSC::Masquerader::createStructure): Deleted.
     26        * runtime/JSObject.h:
     27
    1282020-04-06  Justin Michaud  <justin_michaud@apple.com>
    229
  • trunk/Source/JavaScriptCore/jsc.cpp

    r259564 r259587  
    197197}
    198198
    199 class Masquerader : public JSNonFinalObject {
    200 public:
    201     Masquerader(VM& vm, Structure* structure)
    202         : Base(vm, structure)
    203     {
    204     }
    205 
    206     typedef JSNonFinalObject Base;
    207     static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::MasqueradesAsUndefined;
    208 
    209     template<typename CellType, SubspaceAccess>
    210     static CompleteSubspace* subspaceFor(VM& vm)
    211     {
    212         return &vm.cellSpace;
    213     }
    214 
    215     static Masquerader* create(VM& vm, JSGlobalObject* globalObject)
    216     {
    217         globalObject->masqueradesAsUndefinedWatchpoint()->fireAll(vm, "Masquerading object allocated");
    218         Structure* structure = createStructure(vm, globalObject, jsNull());
    219         Masquerader* result = new (NotNull, allocateCell<Masquerader>(vm.heap)) Masquerader(vm, structure);
    220         result->finishCreation(vm);
    221         return result;
    222     }
    223 
    224     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    225     {
    226         return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
    227     }
    228 
    229     DECLARE_INFO;
    230 };
    231 
    232 const ClassInfo Masquerader::s_info = { "Masquerader", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(Masquerader) };
    233199static unsigned asyncTestPasses { 0 };
    234200static unsigned asyncTestExpectedPasses { 0 };
     
    349315static EncodedJSValue JSC_HOST_CALL functionIdentity(JSGlobalObject*, CallFrame*);
    350316static EncodedJSValue JSC_HOST_CALL functionMakeMasquerader(JSGlobalObject*, CallFrame*);
     317static EncodedJSValue JSC_HOST_CALL functionCallMasquerader(JSGlobalObject*, CallFrame*);
    351318static EncodedJSValue JSC_HOST_CALL functionHasCustomProperties(JSGlobalObject*, CallFrame*);
    352319static EncodedJSValue JSC_HOST_CALL functionDumpTypesForAllVariables(JSGlobalObject*, CallFrame*);
     
    630597       
    631598        dollar->putDirect(vm, Identifier::fromString(vm, "global"), this);
     599
     600        JSFunction* IsHTMLDDAGetter = JSFunction::create(vm, this, 0, "IsHTMLDDA"_s, functionMakeMasquerader);
     601        dollar->putGetter(this, Identifier::fromString(vm, "IsHTMLDDA"), IsHTMLDDAGetter, static_cast<unsigned>(PropertyAttribute::Accessor));
    632602       
    633603        JSObject* agent = JSFinalObject::create(vm, plainObjectStructure);
     
    22202190{
    22212191    VM& vm = globalObject->vm();
    2222     return JSValue::encode(Masquerader::create(vm, globalObject));
     2192    return JSValue::encode(JSFunction::createFunctionThatMasqueradesAsUndefined(vm, globalObject, 0, "IsHTMLDDA"_s, functionCallMasquerader));
     2193}
     2194
     2195EncodedJSValue JSC_HOST_CALL functionCallMasquerader(JSGlobalObject*, CallFrame*)
     2196{
     2197    return JSValue::encode(jsNull());
    22232198}
    22242199
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r259463 r259587  
    608608    JS_EXPORT_PRIVATE bool putDirectCustomAccessor(VM&, PropertyName, JSValue, unsigned attributes);
    609609
    610     bool putGetter(JSGlobalObject*, PropertyName, JSValue, unsigned attributes);
     610    JS_EXPORT_PRIVATE bool putGetter(JSGlobalObject*, PropertyName, JSValue, unsigned attributes);
    611611    bool putSetter(JSGlobalObject*, PropertyName, JSValue, unsigned attributes);
    612612
  • trunk/Tools/ChangeLog

    r259582 r259587  
     12020-04-06  Rick Waldron  <waldron.rick@gmail.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Remove unnecessary Test262 harness file and implement $262.IsHTMLDDA
     4        https://bugs.webkit.org/show_bug.cgi?id=187526
     5
     6        Reviewed by Darin Adler.
     7
     8        Removed file duplicates functionality of jsc.cpp's GlobalObject::finishCreation.
     9
     10        * Scripts/test262/Runner.pm:
     11        * Scripts/test262/agent.js: Removed.
     12
    1132020-04-06  Saam Barati  <sbarati@apple.com>
    214
  • trunk/Tools/Scripts/test262/Runner.pm

    r258286 r259587  
    328328        "$harnessDir/assert.js",
    329329        "$harnessDir/doneprintHandle.js",
    330         "$Bin/agent.js"
    331330    );
    332331
Note: See TracChangeset for help on using the changeset viewer.