Changeset 247589 in webkit


Ignore:
Timestamp:
Jul 18, 2019 1:23:41 PM (5 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r247474. rdar://problem/53229615

JSGlobalObject type macros should support feature flags and WeakRef should have one
https://bugs.webkit.org/show_bug.cgi?id=199601

Reviewed by Mark Lam.

Source/JavaScriptCore:

This patch refactors the various builtin type macros to have a
parameter, which is the feature flag enabling it. Since most
builtin types are enabled by default this patch adds a new global
bool typeExposedByDefault for clarity. Note, because static hash
tables have no concept of feature flags we can't use feature flags
with lazy properties. This is probably not a big deal as features
that are off by default won't be allocated anywhere we care about
memory usage anyway.

  • runtime/CommonIdentifiers.h:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::stringObjectStructure const): (JSC::JSGlobalObject::bigIntObjectStructure const): Deleted.
  • runtime/Options.h:
  • wasm/js/JSWebAssembly.cpp:

Tools:

JSC options need to be set before the window is created for the test.

  • DumpRenderTree/mac/DumpRenderTree.mm: (resetWebViewToConsistentStateBeforeTesting):
  • DumpRenderTree/win/DumpRenderTree.cpp: (setJSCOptions): (resetWebViewToConsistentStateBeforeTesting):

LayoutTests:

Add JSC option requirements for WeakRef tests.

  • js/script-tests/weakref-async-is-collected.js:
  • js/script-tests/weakref-eventually-collects-values.js:
  • js/script-tests/weakref-microtasks-dont-collect.js:
  • js/script-tests/weakref-weakset-consistency.js:
  • js/weakref-async-is-collected.html:
  • js/weakref-eventually-collects-values.html:
  • js/weakref-microtasks-dont-collect.html:
  • js/weakref-weakset-consistency.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247474 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/LayoutTests/ChangeLog

    r247587 r247589  
     12019-07-17  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r247474. rdar://problem/53229615
     4
     5    JSGlobalObject type macros should support feature flags and WeakRef should have one
     6    https://bugs.webkit.org/show_bug.cgi?id=199601
     7   
     8    Reviewed by Mark Lam.
     9   
     10    Source/JavaScriptCore:
     11   
     12    This patch refactors the various builtin type macros to have a
     13    parameter, which is the feature flag enabling it.  Since most
     14    builtin types are enabled by default this patch adds a new global
     15    bool typeExposedByDefault for clarity. Note, because static hash
     16    tables have no concept of feature flags we can't use feature flags
     17    with lazy properties. This is probably not a big deal as features
     18    that are off by default won't be allocated anywhere we care about
     19    memory usage anyway.
     20   
     21    * runtime/CommonIdentifiers.h:
     22    * runtime/JSGlobalObject.cpp:
     23    (JSC::JSGlobalObject::init):
     24    (JSC::JSGlobalObject::visitChildren):
     25    * runtime/JSGlobalObject.h:
     26    (JSC::JSGlobalObject::stringObjectStructure const):
     27    (JSC::JSGlobalObject::bigIntObjectStructure const): Deleted.
     28    * runtime/Options.h:
     29    * wasm/js/JSWebAssembly.cpp:
     30   
     31    Tools:
     32   
     33    JSC options need to be set before the window is created for the test.
     34   
     35    * DumpRenderTree/mac/DumpRenderTree.mm:
     36    (resetWebViewToConsistentStateBeforeTesting):
     37    * DumpRenderTree/win/DumpRenderTree.cpp:
     38    (setJSCOptions):
     39    (resetWebViewToConsistentStateBeforeTesting):
     40   
     41    LayoutTests:
     42   
     43    Add JSC option requirements for WeakRef tests.
     44   
     45    * js/script-tests/weakref-async-is-collected.js:
     46    * js/script-tests/weakref-eventually-collects-values.js:
     47    * js/script-tests/weakref-microtasks-dont-collect.js:
     48    * js/script-tests/weakref-weakset-consistency.js:
     49    * js/weakref-async-is-collected.html:
     50    * js/weakref-eventually-collects-values.html:
     51    * js/weakref-microtasks-dont-collect.html:
     52    * js/weakref-weakset-consistency.html:
     53   
     54    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     55
     56    2019-07-15  Keith Miller  <keith_miller@apple.com>
     57
     58            JSGlobalObject type macros should support feature flags and WeakRef should have one
     59            https://bugs.webkit.org/show_bug.cgi?id=199601
     60
     61            Reviewed by Mark Lam.
     62
     63            Add JSC option requirements for WeakRef tests.
     64
     65            * js/script-tests/weakref-async-is-collected.js:
     66            * js/script-tests/weakref-eventually-collects-values.js:
     67            * js/script-tests/weakref-microtasks-dont-collect.js:
     68            * js/script-tests/weakref-weakset-consistency.js:
     69            * js/weakref-async-is-collected.html:
     70            * js/weakref-eventually-collects-values.html:
     71            * js/weakref-microtasks-dont-collect.html:
     72            * js/weakref-weakset-consistency.html:
     73
    1742019-07-17  Kocsen Chung  <kocsen_chung@apple.com>
    275
  • branches/safari-608-branch/LayoutTests/js/script-tests/weakref-async-is-collected.js

    r246565 r247589  
     1//@ requireOptions("--useWeakRefs=true")
     2
    13asyncTestStart(1);
    24function makeWeakRef() { return new WeakRef({foo: 1 }); }
  • branches/safari-608-branch/LayoutTests/js/script-tests/weakref-eventually-collects-values.js

    r246565 r247589  
     1//@ requireOptions("--useWeakRefs=true")
     2
    13asyncTestStart(1);
    24
  • branches/safari-608-branch/LayoutTests/js/script-tests/weakref-microtasks-dont-collect.js

    r246565 r247589  
     1//@ requireOptions("--useWeakRefs=true")
     2
    13asyncTestStart(1);
    24
  • branches/safari-608-branch/LayoutTests/js/script-tests/weakref-weakset-consistency.js

    r246565 r247589  
     1//@ requireOptions("--useWeakRefs=true")
     2
    13asyncTestStart(1);
    24function makeWeakRef() { return new WeakRef({foo: 1 }); }
  • branches/safari-608-branch/LayoutTests/js/weakref-async-is-collected.html

    r246565 r247589  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
    22<html>
    33<head>
  • branches/safari-608-branch/LayoutTests/js/weakref-eventually-collects-values.html

    r246565 r247589  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
    22<html>
    33<head>
  • branches/safari-608-branch/LayoutTests/js/weakref-microtasks-dont-collect.html

    r246565 r247589  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
    22<html>
    33<head>
  • branches/safari-608-branch/LayoutTests/js/weakref-weakset-consistency.html

    r246565 r247589  
    1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
    22<html>
    33<head>
  • branches/safari-608-branch/Source/JavaScriptCore/ChangeLog

    r247432 r247589  
     12019-07-17  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r247474. rdar://problem/53229615
     4
     5    JSGlobalObject type macros should support feature flags and WeakRef should have one
     6    https://bugs.webkit.org/show_bug.cgi?id=199601
     7   
     8    Reviewed by Mark Lam.
     9   
     10    Source/JavaScriptCore:
     11   
     12    This patch refactors the various builtin type macros to have a
     13    parameter, which is the feature flag enabling it.  Since most
     14    builtin types are enabled by default this patch adds a new global
     15    bool typeExposedByDefault for clarity. Note, because static hash
     16    tables have no concept of feature flags we can't use feature flags
     17    with lazy properties. This is probably not a big deal as features
     18    that are off by default won't be allocated anywhere we care about
     19    memory usage anyway.
     20   
     21    * runtime/CommonIdentifiers.h:
     22    * runtime/JSGlobalObject.cpp:
     23    (JSC::JSGlobalObject::init):
     24    (JSC::JSGlobalObject::visitChildren):
     25    * runtime/JSGlobalObject.h:
     26    (JSC::JSGlobalObject::stringObjectStructure const):
     27    (JSC::JSGlobalObject::bigIntObjectStructure const): Deleted.
     28    * runtime/Options.h:
     29    * wasm/js/JSWebAssembly.cpp:
     30   
     31    Tools:
     32   
     33    JSC options need to be set before the window is created for the test.
     34   
     35    * DumpRenderTree/mac/DumpRenderTree.mm:
     36    (resetWebViewToConsistentStateBeforeTesting):
     37    * DumpRenderTree/win/DumpRenderTree.cpp:
     38    (setJSCOptions):
     39    (resetWebViewToConsistentStateBeforeTesting):
     40   
     41    LayoutTests:
     42   
     43    Add JSC option requirements for WeakRef tests.
     44   
     45    * js/script-tests/weakref-async-is-collected.js:
     46    * js/script-tests/weakref-eventually-collects-values.js:
     47    * js/script-tests/weakref-microtasks-dont-collect.js:
     48    * js/script-tests/weakref-weakset-consistency.js:
     49    * js/weakref-async-is-collected.html:
     50    * js/weakref-eventually-collects-values.html:
     51    * js/weakref-microtasks-dont-collect.html:
     52    * js/weakref-weakset-consistency.html:
     53   
     54    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     55
     56    2019-07-15  Keith Miller  <keith_miller@apple.com>
     57
     58            JSGlobalObject type macros should support feature flags and WeakRef should have one
     59            https://bugs.webkit.org/show_bug.cgi?id=199601
     60
     61            Reviewed by Mark Lam.
     62
     63            This patch refactors the various builtin type macros to have a
     64            parameter, which is the feature flag enabling it.  Since most
     65            builtin types are enabled by default this patch adds a new global
     66            bool typeExposedByDefault for clarity. Note, because static hash
     67            tables have no concept of feature flags we can't use feature flags
     68            with lazy properties. This is probably not a big deal as features
     69            that are off by default won't be allocated anywhere we care about
     70            memory usage anyway.
     71
     72            * runtime/CommonIdentifiers.h:
     73            * runtime/JSGlobalObject.cpp:
     74            (JSC::JSGlobalObject::init):
     75            (JSC::JSGlobalObject::visitChildren):
     76            * runtime/JSGlobalObject.h:
     77            (JSC::JSGlobalObject::stringObjectStructure const):
     78            (JSC::JSGlobalObject::bigIntObjectStructure const): Deleted.
     79            * runtime/Options.h:
     80            * wasm/js/JSWebAssembly.cpp:
     81
    1822019-07-15  Ryan Haddad  <ryanhaddad@apple.com>
    283
  • branches/safari-608-branch/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r246567 r247589  
    5454    macro(String) \
    5555    macro(Symbol) \
     56    macro(WeakRef) \
    5657    macro(__defineGetter__) \
    5758    macro(__defineSetter__) \
  • branches/safari-608-branch/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r247173 r247589  
    210210namespace JSC {
    211211
     212#define CHECK_FEATURE_FLAG_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
     213static_assert(std::is_same_v<std::remove_cv_t<decltype(featureFlag)>, bool> || std::is_same_v<std::remove_cv_t<decltype(featureFlag)>, bool&>);
     214
     215FOR_EACH_SIMPLE_BUILTIN_TYPE(CHECK_FEATURE_FLAG_TYPE)
     216FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CHECK_FEATURE_FLAG_TYPE)
     217FOR_EACH_LAZY_BUILTIN_TYPE(CHECK_FEATURE_FLAG_TYPE)
     218
    212219static JSValue createProxyProperty(VM& vm, JSObject* object)
    213220{
     
    364371  Symbol                JSGlobalObject::m_symbolObjectStructure      DontEnum|ClassStructure
    365372  WeakMap               JSGlobalObject::m_weakMapStructure           DontEnum|ClassStructure
    366   WeakRef               JSGlobalObject::m_weakObjectRefStructure     DontEnum|ClassStructure
    367373  WeakSet               JSGlobalObject::m_weakSetStructure           DontEnum|ClassStructure
    368374@end
     
    703709    m_asyncGeneratorPrototype.set(vm, this, AsyncGeneratorPrototype::create(vm, this, AsyncGeneratorPrototype::createStructure(vm, this, m_asyncIteratorPrototype.get())));
    704710
    705 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
     711#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
    706712        m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
    707713        m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get())); \
    708     } while (0);
     714    }
    709715   
    710716    FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
    711 
    712     if (UNLIKELY(Options::useBigInt()))
    713         FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
    714 
    715717    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
    716718   
    717719#undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
    718720
    719 #define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     721#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
    720722    m_ ## properName ## Structure.initLater(\
    721723        [] (LazyClassStructure::Initializer& init) { \
     
    723725            init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
    724726            init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), jsCast<capitalName ## Prototype*>(init.prototype), init.global->m_speciesGetterSetter.get())); \
    725         });
     727        }); \
     728    }
    726729   
    727730    FOR_EACH_LAZY_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_LAZY_TYPE)
     
    751754#endif
    752755
    753 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    754 capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
    755 m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
     756#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
     757capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()) : nullptr; \
     758    if (featureFlag) \
     759        m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
    756760
    757761    FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE)
    758     BigIntConstructor* bigIntConstructor = nullptr;
    759     if (UNLIKELY(Options::useBigInt())) {
    760         bigIntConstructor = BigIntConstructor::create(vm, BigIntConstructor::createStructure(vm, this, m_functionPrototype.get()), m_bigIntPrototype.get(), m_speciesGetterSetter.get());
    761         m_bigIntPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, bigIntConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
    762     }
    763762   
    764763#undef CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE
     
    831830#endif
    832831
    833 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    834 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
     832#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
     833    if (featureFlag) \
     834        putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
     835
    835836
    836837    FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
    837     if (UNLIKELY(Options::useBigInt()))
    838         FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
    839838
    840839#undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
     
    10851084        putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, static_cast<unsigned>(PropertyAttribute::DontEnum));
    10861085
    1087 #define CREATE_WEBASSEMBLY_PROTOTYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    1088     m_ ## properName ## Structure.initLater(\
    1089         [] (LazyClassStructure::Initializer& init) { \
    1090             init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->prototypeBase ## Prototype()))); \
    1091             init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
    1092             init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<capitalName ## Prototype*>(init.prototype))); \
    1093         });
     1086#define CREATE_WEBASSEMBLY_PROTOTYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
     1087    if (featureFlag) {\
     1088        m_ ## properName ## Structure.initLater(\
     1089            [] (LazyClassStructure::Initializer& init) { \
     1090                init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->prototypeBase ## Prototype()))); \
     1091                init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
     1092                init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<capitalName ## Prototype*>(init.prototype))); \
     1093            }); \
     1094    }
    10941095
    10951096        FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_PROTOTYPE)
     
    17351736    visitor.append(thisObject->m_getterSetterStructure);
    17361737    thisObject->m_nativeStdFunctionStructure.visit(visitor);
    1737     visitor.append(thisObject->m_bigIntObjectStructure);
    17381738    visitor.append(thisObject->m_regExpStructure);
    17391739    visitor.append(thisObject->m_generatorFunctionStructure);
     
    17541754#endif
    17551755
    1756 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
     1756#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
    17571757        visitor.append(thisObject->m_ ## lowerName ## Prototype); \
    17581758        visitor.append(thisObject->m_ ## properName ## Structure); \
    1759     } while (0);
    1760 
    1761 #define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    1762     thisObject->m_ ## properName ## Structure.visit(visitor);
     1759    }
    17631760
    17641761    FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
    1765     if (UNLIKELY(Options::useBigInt()))
    1766         FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(VISIT_SIMPLE_TYPE)
    17671762    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(VISIT_SIMPLE_TYPE)
    17681763
     1764#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) \
     1765        thisObject->m_ ## properName ## Structure.visit(visitor);
     1766
    17691767    FOR_EACH_LAZY_BUILTIN_TYPE(VISIT_LAZY_TYPE)
    1770    
     1768
    17711769#if ENABLE(WEBASSEMBLY)
    17721770    thisObject->m_webAssemblyModuleRecordStructure.visit(visitor);
  • branches/safari-608-branch/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r247346 r247589  
    126126template<typename Watchpoint> class ObjectPropertyChangeAdaptiveWatchpoint;
    127127
    128 #define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object)
     128constexpr bool typeExposedByDefault = true;
     129
     130#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object, typeExposedByDefault)
    129131
    130132#define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    131     macro(String, string, stringObject, StringObject, String, object) \
    132     macro(Map, map, map, JSMap, Map, object) \
    133     macro(Set, set, set, JSSet, Set, object) \
    134     macro(JSPromise, promise, promise, JSPromise, Promise, object)
    135 
    136 #define FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    137     macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object)
     133    macro(String, string, stringObject, StringObject, String, object, typeExposedByDefault) \
     134    macro(Map, map, map, JSMap, Map, object, typeExposedByDefault) \
     135    macro(Set, set, set, JSSet, Set, object, typeExposedByDefault) \
     136    macro(JSPromise, promise, promise, JSPromise, Promise, object, typeExposedByDefault) \
     137    macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object, Options::useBigInt()) \
     138    macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object, Options::useWeakRefs()) \
    138139
    139140#define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
    140     macro(StringIterator, stringIterator, stringIterator, JSStringIterator, StringIterator, iterator) \
     141    macro(StringIterator, stringIterator, stringIterator, JSStringIterator, StringIterator, iterator, typeExposedByDefault) \
    141142
    142143#define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
    143144    FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    144     macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object) \
     145    macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object, typeExposedByDefault) \
    145146
    146147#define FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
    147     macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object) \
    148     macro(Date, date, date, DateInstance, Date, object) \
    149     macro(Error, error, error, ErrorInstance, Error, object) \
    150     macro(Number, number, numberObject, NumberObject, Number, object) \
    151     macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object) \
    152     macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object) \
     148    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object, typeExposedByDefault) \
     149    macro(Date, date, date, DateInstance, Date, object, typeExposedByDefault) \
     150    macro(Error, error, error, ErrorInstance, Error, object, typeExposedByDefault) \
     151    macro(Number, number, numberObject, NumberObject, Number, object, typeExposedByDefault) \
     152    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object, typeExposedByDefault) \
    153153    DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
    154154    DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
     
    156156#define FOR_EACH_LAZY_BUILTIN_TYPE(macro) \
    157157    FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
    158     macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object) \
     158    macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object, typeExposedByDefault) \
    159159
    160160#if ENABLE(WEBASSEMBLY)
    161161#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro) \
    162     macro(WebAssemblyCompileError, webAssemblyCompileError, webAssemblyCompileError, JSWebAssemblyCompileError, CompileError, error) \
    163     macro(WebAssemblyInstance,     webAssemblyInstance,     webAssemblyInstance,     JSWebAssemblyInstance,     Instance,     object) \
    164     macro(WebAssemblyLinkError,    webAssemblyLinkError,    webAssemblyLinkError,    JSWebAssemblyLinkError,    LinkError,    error) \
    165     macro(WebAssemblyMemory,       webAssemblyMemory,       webAssemblyMemory,       JSWebAssemblyMemory,       Memory,       object) \
    166     macro(WebAssemblyModule,       webAssemblyModule,       webAssemblyModule,       JSWebAssemblyModule,       Module,       object) \
    167     macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, webAssemblyRuntimeError, JSWebAssemblyRuntimeError, RuntimeError, error) \
    168     macro(WebAssemblyTable,        webAssemblyTable,        webAssemblyTable,        JSWebAssemblyTable,        Table,        object)
     162    macro(WebAssemblyCompileError, webAssemblyCompileError, webAssemblyCompileError, JSWebAssemblyCompileError, CompileError, error, typeExposedByDefault) \
     163    macro(WebAssemblyInstance,     webAssemblyInstance,     webAssemblyInstance,     JSWebAssemblyInstance,     Instance,     object, typeExposedByDefault) \
     164    macro(WebAssemblyLinkError,    webAssemblyLinkError,    webAssemblyLinkError,    JSWebAssemblyLinkError,    LinkError,    error, typeExposedByDefault) \
     165    macro(WebAssemblyMemory,       webAssemblyMemory,       webAssemblyMemory,       JSWebAssemblyMemory,       Memory,       object, typeExposedByDefault) \
     166    macro(WebAssemblyModule,       webAssemblyModule,       webAssemblyModule,       JSWebAssemblyModule,       Module,       object, typeExposedByDefault) \
     167    macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, webAssemblyRuntimeError, JSWebAssemblyRuntimeError, RuntimeError, error, typeExposedByDefault) \
     168    macro(WebAssemblyTable,        webAssemblyTable,        webAssemblyTable,        JSWebAssemblyTable,        Table,        object, typeExposedByDefault)
    169169#else
    170170#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro)
    171171#endif // ENABLE(WEBASSEMBLY)
    172172
    173 #define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     173#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    174174    class JS ## capitalName; \
    175175    class capitalName ## Prototype; \
     
    178178class IteratorPrototype;
    179179FOR_EACH_SIMPLE_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
    180 FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DECLARE_SIMPLE_BUILTIN_TYPE)
    181180FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(DECLARE_SIMPLE_BUILTIN_TYPE)
    182181FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
     
    389388#endif
    390389
    391 #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     390#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    392391    WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
    393392    WriteBarrier<Structure> m_ ## properName ## Structure;
    394393
    395 #define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     394#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    396395    LazyClassStructure m_ ## properName ## Structure;
    397396
    398397    FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
    399     FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
    400398    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
    401399   
     
    754752    Structure* asyncGeneratorFunctionStructure() const { return m_asyncGeneratorFunctionStructure.get(); }
    755753    Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
    756     Structure* bigIntObjectStructure() const { return m_bigIntObjectStructure.get(); }
    757754    Structure* iteratorResultObjectStructure() const { return m_iteratorResultObjectStructure.get(this); }
    758755    Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
     
    841838    }
    842839
    843 #define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     840#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    844841    Structure* properName ## Structure() { return m_ ## properName ## Structure.get(); }
    845842
    846843    FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
    847     FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
    848844    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
    849845
    850846#undef DEFINE_ACCESSORS_FOR_SIMPLE_TYPE
    851847
    852 #define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     848#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    853849    Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); } \
    854850    JSObject* properName ## Constructor() { return m_ ## properName ## Structure.constructor(this); }
  • branches/safari-608-branch/Source/JavaScriptCore/runtime/Options.h

    r247247 r247589  
    492492    v(bool, useEagerWebAssemblyModuleHashing, false, Normal, "Unnamed WebAssembly modules are identified in backtraces through their hash, if available.") \
    493493    v(bool, useWebAssemblyReferences, false, Normal, "Allow types from the wasm references spec.") \
     494    v(bool, useWeakRefs, false, Normal, "Expose the WeakRef constructor.") \
    494495    v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \
    495496    v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.") \
  • branches/safari-608-branch/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp

    r243011 r247589  
    3535STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSWebAssembly);
    3636
    37 #define DEFINE_CALLBACK_FOR_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     37#define DEFINE_CALLBACK_FOR_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
    3838static JSValue create##capitalName(VM& vm, JSObject* object) \
    3939{ \
  • branches/safari-608-branch/Tools/ChangeLog

    r247586 r247589  
     12019-07-17  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r247474. rdar://problem/53229615
     4
     5    JSGlobalObject type macros should support feature flags and WeakRef should have one
     6    https://bugs.webkit.org/show_bug.cgi?id=199601
     7   
     8    Reviewed by Mark Lam.
     9   
     10    Source/JavaScriptCore:
     11   
     12    This patch refactors the various builtin type macros to have a
     13    parameter, which is the feature flag enabling it.  Since most
     14    builtin types are enabled by default this patch adds a new global
     15    bool typeExposedByDefault for clarity. Note, because static hash
     16    tables have no concept of feature flags we can't use feature flags
     17    with lazy properties. This is probably not a big deal as features
     18    that are off by default won't be allocated anywhere we care about
     19    memory usage anyway.
     20   
     21    * runtime/CommonIdentifiers.h:
     22    * runtime/JSGlobalObject.cpp:
     23    (JSC::JSGlobalObject::init):
     24    (JSC::JSGlobalObject::visitChildren):
     25    * runtime/JSGlobalObject.h:
     26    (JSC::JSGlobalObject::stringObjectStructure const):
     27    (JSC::JSGlobalObject::bigIntObjectStructure const): Deleted.
     28    * runtime/Options.h:
     29    * wasm/js/JSWebAssembly.cpp:
     30   
     31    Tools:
     32   
     33    JSC options need to be set before the window is created for the test.
     34   
     35    * DumpRenderTree/mac/DumpRenderTree.mm:
     36    (resetWebViewToConsistentStateBeforeTesting):
     37    * DumpRenderTree/win/DumpRenderTree.cpp:
     38    (setJSCOptions):
     39    (resetWebViewToConsistentStateBeforeTesting):
     40   
     41    LayoutTests:
     42   
     43    Add JSC option requirements for WeakRef tests.
     44   
     45    * js/script-tests/weakref-async-is-collected.js:
     46    * js/script-tests/weakref-eventually-collects-values.js:
     47    * js/script-tests/weakref-microtasks-dont-collect.js:
     48    * js/script-tests/weakref-weakset-consistency.js:
     49    * js/weakref-async-is-collected.html:
     50    * js/weakref-eventually-collects-values.html:
     51    * js/weakref-microtasks-dont-collect.html:
     52    * js/weakref-weakset-consistency.html:
     53   
     54    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     55
     56    2019-07-15  Keith Miller  <keith_miller@apple.com>
     57
     58            JSGlobalObject type macros should support feature flags and WeakRef should have one
     59            https://bugs.webkit.org/show_bug.cgi?id=199601
     60
     61            Reviewed by Mark Lam.
     62
     63            JSC options need to be set before the window is created for the test.
     64
     65            * DumpRenderTree/mac/DumpRenderTree.mm:
     66            (resetWebViewToConsistentStateBeforeTesting):
     67            * DumpRenderTree/win/DumpRenderTree.cpp:
     68            (setJSCOptions):
     69            (resetWebViewToConsistentStateBeforeTesting):
     70
    1712019-07-17  Kocsen Chung  <kocsen_chung@apple.com>
    272
  • branches/safari-608-branch/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r246285 r247589  
    18421842static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
    18431843{
     1844    setJSCOptions(options);
     1845
    18441846    WebView *webView = [mainFrame webView];
    18451847
     
    19161918#endif
    19171919
    1918     setJSCOptions(options);
    1919 
    19201920    WebCoreTestSupport::setAdditionalSupportedImageTypesForTesting(options.additionalSupportedImageTypes.c_str());
    19211921
  • branches/safari-608-branch/Tools/DumpRenderTree/win/DumpRenderTree.cpp

    r245733 r247589  
    4646
    4747#include <CoreFoundation/CoreFoundation.h>
     48#include <JavaScriptCore/Options.h>
    4849#include <JavaScriptCore/TestRunnerUtils.h>
    4950#include <WebKitLegacy/WebKit.h>
     
    6667#include <wtf/Vector.h>
    6768#include <wtf/text/CString.h>
     69#include <wtf/text/StringBuilder.h>
    6870#include <wtf/text/StringConcatenateNumbers.h>
    6971#include <wtf/text/StringHash.h>
     
    942944}
    943945
     946static void setJSCOptions(const TestOptions& options)
     947{
     948    static WTF::StringBuilder savedOptions;
     949
     950    if (!savedOptions.isEmpty()) {
     951        JSC::Options::setOptions(savedOptions.toString().ascii().data());
     952        savedOptions.clear();
     953    }
     954
     955    if (options.jscOptions.length()) {
     956        JSC::Options::dumpAllOptionsInALine(savedOptions);
     957        JSC::Options::setOptions(options.jscOptions.c_str());
     958    }
     959}
     960
    944961static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
    945962{
     963    setJSCOptions(options);
     964
    946965    COMPtr<IWebView> webView;
    947966    if (FAILED(frame->webView(&webView)))
Note: See TracChangeset for help on using the changeset viewer.