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: http://svn.webkit.org/repository/webkit/trunk@247474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1a181c7..479ca3b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2019-07-15 Keith Miller <keith_miller@apple.com>
+
+ 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.
+
+ 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:
+
2019-07-15 Ryan Haddad <ryanhaddad@apple.com>
Unreviewed, rolling out r247444.
diff --git a/LayoutTests/js/script-tests/weakref-async-is-collected.js b/LayoutTests/js/script-tests/weakref-async-is-collected.js
index 3cec803..406637a 100644
--- a/LayoutTests/js/script-tests/weakref-async-is-collected.js
+++ b/LayoutTests/js/script-tests/weakref-async-is-collected.js
@@ -1,3 +1,5 @@
+//@ requireOptions("--useWeakRefs=true")
+
asyncTestStart(1);
function makeWeakRef() { return new WeakRef({foo: 1 }); }
noInline(makeWeakRef);
diff --git a/LayoutTests/js/script-tests/weakref-eventually-collects-values.js b/LayoutTests/js/script-tests/weakref-eventually-collects-values.js
index 8cf0394..5afff23 100644
--- a/LayoutTests/js/script-tests/weakref-eventually-collects-values.js
+++ b/LayoutTests/js/script-tests/weakref-eventually-collects-values.js
@@ -1,3 +1,5 @@
+//@ requireOptions("--useWeakRefs=true")
+
asyncTestStart(1);
function makeWeakRef() { return new WeakRef({foo: 1}); }
diff --git a/LayoutTests/js/script-tests/weakref-microtasks-dont-collect.js b/LayoutTests/js/script-tests/weakref-microtasks-dont-collect.js
index dd7e9af..ccec700 100644
--- a/LayoutTests/js/script-tests/weakref-microtasks-dont-collect.js
+++ b/LayoutTests/js/script-tests/weakref-microtasks-dont-collect.js
@@ -1,3 +1,5 @@
+//@ requireOptions("--useWeakRefs=true")
+
asyncTestStart(1);
function makeWeakRef() { return new WeakRef({foo: 1 }); }
diff --git a/LayoutTests/js/script-tests/weakref-weakset-consistency.js b/LayoutTests/js/script-tests/weakref-weakset-consistency.js
index 57941e9..f3357dc 100644
--- a/LayoutTests/js/script-tests/weakref-weakset-consistency.js
+++ b/LayoutTests/js/script-tests/weakref-weakset-consistency.js
@@ -1,3 +1,5 @@
+//@ requireOptions("--useWeakRefs=true")
+
asyncTestStart(1);
function makeWeakRef() { return new WeakRef({foo: 1 }); }
noInline(makeWeakRef);
diff --git a/LayoutTests/js/weakref-async-is-collected.html b/LayoutTests/js/weakref-async-is-collected.html
index f50cfda..9fb64b1 100644
--- a/LayoutTests/js/weakref-async-is-collected.html
+++ b/LayoutTests/js/weakref-async-is-collected.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
diff --git a/LayoutTests/js/weakref-eventually-collects-values.html b/LayoutTests/js/weakref-eventually-collects-values.html
index f36d7d7..90dcdaa 100644
--- a/LayoutTests/js/weakref-eventually-collects-values.html
+++ b/LayoutTests/js/weakref-eventually-collects-values.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
diff --git a/LayoutTests/js/weakref-microtasks-dont-collect.html b/LayoutTests/js/weakref-microtasks-dont-collect.html
index 2c4853c..b7b9b9d 100644
--- a/LayoutTests/js/weakref-microtasks-dont-collect.html
+++ b/LayoutTests/js/weakref-microtasks-dont-collect.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
diff --git a/LayoutTests/js/weakref-weakset-consistency.html b/LayoutTests/js/weakref-weakset-consistency.html
index c3ae9b60..04f2303 100644
--- a/LayoutTests/js/weakref-weakset-consistency.html
+++ b/LayoutTests/js/weakref-weakset-consistency.html
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- webkit-test-runner [ jscOptions=--useWeakRefs=true ] -->
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 56f24d9..1acebbd 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,5 +1,31 @@
2019-07-15 Keith Miller <keith_miller@apple.com>
+ 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.
+
+ 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:
+
+2019-07-15 Keith Miller <keith_miller@apple.com>
+
A Possible Issue of Object.create method
https://bugs.webkit.org/show_bug.cgi?id=199744
diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
index 0605910..3e6f51c 100644
--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h
+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
@@ -53,6 +53,7 @@
macro(SharedArrayBuffer) \
macro(String) \
macro(Symbol) \
+ macro(WeakRef) \
macro(__defineGetter__) \
macro(__defineSetter__) \
macro(__lookupGetter__) \
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
index b7cf0d0..1a57ef3 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -231,6 +231,13 @@
namespace JSC {
+#define CHECK_FEATURE_FLAG_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
+static_assert(std::is_same_v<std::remove_cv_t<decltype(featureFlag)>, bool> || std::is_same_v<std::remove_cv_t<decltype(featureFlag)>, bool&>);
+
+FOR_EACH_SIMPLE_BUILTIN_TYPE(CHECK_FEATURE_FLAG_TYPE)
+FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CHECK_FEATURE_FLAG_TYPE)
+FOR_EACH_LAZY_BUILTIN_TYPE(CHECK_FEATURE_FLAG_TYPE)
+
static JSValue createProxyProperty(VM& vm, JSObject* object)
{
JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
@@ -385,7 +392,6 @@
Number JSGlobalObject::m_numberObjectStructure DontEnum|ClassStructure
Symbol JSGlobalObject::m_symbolObjectStructure DontEnum|ClassStructure
WeakMap JSGlobalObject::m_weakMapStructure DontEnum|ClassStructure
- WeakRef JSGlobalObject::m_weakObjectRefStructure DontEnum|ClassStructure
WeakSet JSGlobalObject::m_weakSetStructure DontEnum|ClassStructure
@end
*/
@@ -724,27 +730,24 @@
m_generatorPrototype.set(vm, this, GeneratorPrototype::create(vm, this, GeneratorPrototype::createStructure(vm, this, m_iteratorPrototype.get())));
m_asyncGeneratorPrototype.set(vm, this, AsyncGeneratorPrototype::create(vm, this, AsyncGeneratorPrototype::createStructure(vm, this, m_asyncIteratorPrototype.get())));
-#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
+#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get())); \
- } while (0);
+ }
FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
-
- if (UNLIKELY(Options::useBigInt()))
- FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
-
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
#undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
-#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
m_ ## properName ## Structure.initLater(\
[] (LazyClassStructure::Initializer& init) { \
init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_ ## prototypeBase ## Prototype.get()))); \
init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
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())); \
- });
+ }); \
+ }
FOR_EACH_LAZY_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_LAZY_TYPE)
@@ -772,16 +775,12 @@
AtomicsObject* atomicsObject = AtomicsObject::create(vm, this, AtomicsObject::createStructure(vm, this, m_objectPrototype.get()));
#endif
-#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
-capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
-m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
+#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
+capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()) : nullptr; \
+ if (featureFlag) \
+ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE)
- BigIntConstructor* bigIntConstructor = nullptr;
- if (UNLIKELY(Options::useBigInt())) {
- bigIntConstructor = BigIntConstructor::create(vm, BigIntConstructor::createStructure(vm, this, m_functionPrototype.get()), m_bigIntPrototype.get(), m_speciesGetterSetter.get());
- m_bigIntPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, bigIntConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
- }
#undef CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE
@@ -852,12 +851,12 @@
putDirectWithoutTransition(vm, Identifier::fromString(exec, "Atomics"), atomicsObject, static_cast<unsigned>(PropertyAttribute::DontEnum));
#endif
-#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
-putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); \
+#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
+ if (featureFlag) \
+ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, static_cast<unsigned>(PropertyAttribute::DontEnum));
+
FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
- if (UNLIKELY(Options::useBigInt()))
- FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
#undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
m_iteratorResultObjectStructure.initLater(
@@ -1105,13 +1104,15 @@
auto* webAssembly = JSWebAssembly::create(vm, this, JSWebAssembly::createStructure(vm, this, m_objectPrototype.get()));
putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, static_cast<unsigned>(PropertyAttribute::DontEnum));
-#define CREATE_WEBASSEMBLY_PROTOTYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
- m_ ## properName ## Structure.initLater(\
- [] (LazyClassStructure::Initializer& init) { \
- init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->prototypeBase ## Prototype()))); \
- init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
- init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<capitalName ## Prototype*>(init.prototype))); \
- });
+#define CREATE_WEBASSEMBLY_PROTOTYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
+ if (featureFlag) {\
+ m_ ## properName ## Structure.initLater(\
+ [] (LazyClassStructure::Initializer& init) { \
+ init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->prototypeBase ## Prototype()))); \
+ init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
+ init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<capitalName ## Prototype*>(init.prototype))); \
+ }); \
+ }
FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_PROTOTYPE)
@@ -1755,7 +1756,6 @@
thisObject->m_boundFunctionStructure.visit(visitor);
visitor.append(thisObject->m_getterSetterStructure);
thisObject->m_nativeStdFunctionStructure.visit(visitor);
- visitor.append(thisObject->m_bigIntObjectStructure);
visitor.append(thisObject->m_regExpStructure);
visitor.append(thisObject->m_generatorFunctionStructure);
visitor.append(thisObject->m_asyncFunctionStructure);
@@ -1774,21 +1774,19 @@
visitor.append(thisObject->m_sharedArrayBufferStructure);
#endif
-#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
+#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) { \
visitor.append(thisObject->m_ ## lowerName ## Prototype); \
visitor.append(thisObject->m_ ## properName ## Structure); \
- } while (0);
-
-#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
- thisObject->m_ ## properName ## Structure.visit(visitor);
+ }
FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
- if (UNLIKELY(Options::useBigInt()))
- FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(VISIT_SIMPLE_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(VISIT_SIMPLE_TYPE)
+#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) if (featureFlag) \
+ thisObject->m_ ## properName ## Structure.visit(visitor);
+
FOR_EACH_LAZY_BUILTIN_TYPE(VISIT_LAZY_TYPE)
-
+
#if ENABLE(WEBASSEMBLY)
thisObject->m_webAssemblyModuleRecordStructure.visit(visitor);
thisObject->m_webAssemblyFunctionStructure.visit(visitor);
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h
index dbc2ef0..047c166 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h
@@ -125,59 +125,58 @@
template<typename Watchpoint> class ObjectPropertyChangeAdaptiveWatchpoint;
-#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object)
+constexpr bool typeExposedByDefault = true;
+
+#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object, typeExposedByDefault)
#define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
- macro(String, string, stringObject, StringObject, String, object) \
- macro(Map, map, map, JSMap, Map, object) \
- macro(Set, set, set, JSSet, Set, object) \
- macro(JSPromise, promise, promise, JSPromise, Promise, object)
-
-#define FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
- macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object)
+ macro(String, string, stringObject, StringObject, String, object, typeExposedByDefault) \
+ macro(Map, map, map, JSMap, Map, object, typeExposedByDefault) \
+ macro(Set, set, set, JSSet, Set, object, typeExposedByDefault) \
+ macro(JSPromise, promise, promise, JSPromise, Promise, object, typeExposedByDefault) \
+ macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object, Options::useBigInt()) \
+ macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object, Options::useWeakRefs()) \
#define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
- macro(StringIterator, stringIterator, stringIterator, JSStringIterator, StringIterator, iterator) \
+ macro(StringIterator, stringIterator, stringIterator, JSStringIterator, StringIterator, iterator, typeExposedByDefault) \
#define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
- macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object) \
+ macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object, typeExposedByDefault) \
#define FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
- macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object) \
- macro(Date, date, date, DateInstance, Date, object) \
- macro(Error, error, error, ErrorInstance, Error, object) \
- macro(Number, number, numberObject, NumberObject, Number, object) \
- macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object) \
- macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object) \
+ macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object, typeExposedByDefault) \
+ macro(Date, date, date, DateInstance, Date, object, typeExposedByDefault) \
+ macro(Error, error, error, ErrorInstance, Error, object, typeExposedByDefault) \
+ macro(Number, number, numberObject, NumberObject, Number, object, typeExposedByDefault) \
+ macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object, typeExposedByDefault) \
DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
#define FOR_EACH_LAZY_BUILTIN_TYPE(macro) \
FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
- macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object) \
+ macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object, typeExposedByDefault) \
#if ENABLE(WEBASSEMBLY)
#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro) \
- macro(WebAssemblyCompileError, webAssemblyCompileError, webAssemblyCompileError, JSWebAssemblyCompileError, CompileError, error) \
- macro(WebAssemblyInstance, webAssemblyInstance, webAssemblyInstance, JSWebAssemblyInstance, Instance, object) \
- macro(WebAssemblyLinkError, webAssemblyLinkError, webAssemblyLinkError, JSWebAssemblyLinkError, LinkError, error) \
- macro(WebAssemblyMemory, webAssemblyMemory, webAssemblyMemory, JSWebAssemblyMemory, Memory, object) \
- macro(WebAssemblyModule, webAssemblyModule, webAssemblyModule, JSWebAssemblyModule, Module, object) \
- macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, webAssemblyRuntimeError, JSWebAssemblyRuntimeError, RuntimeError, error) \
- macro(WebAssemblyTable, webAssemblyTable, webAssemblyTable, JSWebAssemblyTable, Table, object)
+ macro(WebAssemblyCompileError, webAssemblyCompileError, webAssemblyCompileError, JSWebAssemblyCompileError, CompileError, error, typeExposedByDefault) \
+ macro(WebAssemblyInstance, webAssemblyInstance, webAssemblyInstance, JSWebAssemblyInstance, Instance, object, typeExposedByDefault) \
+ macro(WebAssemblyLinkError, webAssemblyLinkError, webAssemblyLinkError, JSWebAssemblyLinkError, LinkError, error, typeExposedByDefault) \
+ macro(WebAssemblyMemory, webAssemblyMemory, webAssemblyMemory, JSWebAssemblyMemory, Memory, object, typeExposedByDefault) \
+ macro(WebAssemblyModule, webAssemblyModule, webAssemblyModule, JSWebAssemblyModule, Module, object, typeExposedByDefault) \
+ macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, webAssemblyRuntimeError, JSWebAssemblyRuntimeError, RuntimeError, error, typeExposedByDefault) \
+ macro(WebAssemblyTable, webAssemblyTable, webAssemblyTable, JSWebAssemblyTable, Table, object, typeExposedByDefault)
#else
#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro)
#endif // ENABLE(WEBASSEMBLY)
-#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
class JS ## capitalName; \
class capitalName ## Prototype; \
class capitalName ## Constructor;
class IteratorPrototype;
FOR_EACH_SIMPLE_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
-FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
@@ -388,15 +387,14 @@
WriteBarrier<Structure> m_sharedArrayBufferStructure;
#endif
-#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
WriteBarrier<Structure> m_ ## properName ## Structure;
-#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
LazyClassStructure m_ ## properName ## Structure;
FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
- FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
#if ENABLE(WEBASSEMBLY)
@@ -753,7 +751,6 @@
Structure* asyncFunctionStructure() const { return m_asyncFunctionStructure.get(); }
Structure* asyncGeneratorFunctionStructure() const { return m_asyncGeneratorFunctionStructure.get(); }
Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
- Structure* bigIntObjectStructure() const { return m_bigIntObjectStructure.get(); }
Structure* iteratorResultObjectStructure() const { return m_iteratorResultObjectStructure.get(this); }
Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
Structure* regExpMatchesArrayWithGroupsStructure() const { return m_regExpMatchesArrayWithGroupsStructure.get(); }
@@ -840,16 +837,15 @@
return nullptr;
}
-#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
Structure* properName ## Structure() { return m_ ## properName ## Structure.get(); }
FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
- FOR_BIG_INT_BUILTIN_TYPE_WITH_CONSTRUCTOR(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
#undef DEFINE_ACCESSORS_FOR_SIMPLE_TYPE
-#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); } \
JSObject* properName ## Constructor() { return m_ ## properName ## Structure.constructor(this); }
diff --git a/Source/JavaScriptCore/runtime/Options.h b/Source/JavaScriptCore/runtime/Options.h
index c6f7419..03a6c2d 100644
--- a/Source/JavaScriptCore/runtime/Options.h
+++ b/Source/JavaScriptCore/runtime/Options.h
@@ -491,6 +491,7 @@
v(bool, useCallICsForWebAssemblyToJSCalls, true, Normal, "If true, we will use CallLinkInfo to inline cache Wasm to JS calls.") \
v(bool, useEagerWebAssemblyModuleHashing, false, Normal, "Unnamed WebAssembly modules are identified in backtraces through their hash, if available.") \
v(bool, useWebAssemblyReferences, false, Normal, "Allow types from the wasm references spec.") \
+ v(bool, useWeakRefs, false, Normal, "Expose the WeakRef constructor.") \
v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \
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.") \
v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \
diff --git a/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp b/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp
index 9cbb0bb..ee8347e 100644
--- a/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp
+++ b/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp
@@ -57,7 +57,7 @@
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSWebAssembly);
-#define DEFINE_CALLBACK_FOR_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+#define DEFINE_CALLBACK_FOR_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
static JSValue create##capitalName(VM& vm, JSObject* object) \
{ \
JSWebAssembly* webAssembly = jsCast<JSWebAssembly*>(object); \
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 7674946..4260f7b 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,18 @@
+2019-07-15 Keith Miller <keith_miller@apple.com>
+
+ 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.
+
+ 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):
+
2019-07-15 Said Abou-Hallawa <sabouhallawa@apple.com>
[ Mojave WK1 ] Some Image tests are flakey failures and are failing in tandem with zoomed in or blank image results
diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm
index 6660c32..02ad95b 100644
--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm
+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm
@@ -1841,6 +1841,8 @@
static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
{
+ setJSCOptions(options);
+
WebView *webView = [mainFrame webView];
#if PLATFORM(IOS_FAMILY)
@@ -1915,8 +1917,6 @@
[[NSPasteboard generalPasteboard] declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
#endif
- setJSCOptions(options);
-
WebCoreTestSupport::setAdditionalSupportedImageTypesForTesting(options.additionalSupportedImageTypes.c_str());
[mainFrame _clearOpener];
diff --git a/Tools/DumpRenderTree/win/DumpRenderTree.cpp b/Tools/DumpRenderTree/win/DumpRenderTree.cpp
index 6d21385..3a35347 100644
--- a/Tools/DumpRenderTree/win/DumpRenderTree.cpp
+++ b/Tools/DumpRenderTree/win/DumpRenderTree.cpp
@@ -45,6 +45,7 @@
#include "WorkQueue.h"
#include <CoreFoundation/CoreFoundation.h>
+#include <JavaScriptCore/Options.h>
#include <JavaScriptCore/TestRunnerUtils.h>
#include <WebKitLegacy/WebKit.h>
#include <WebKitLegacy/WebKitCOMAPI.h>
@@ -65,6 +66,7 @@
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenateNumbers.h>
#include <wtf/text/StringHash.h>
@@ -941,8 +943,25 @@
#endif
}
+static void setJSCOptions(const TestOptions& options)
+{
+ static WTF::StringBuilder savedOptions;
+
+ if (!savedOptions.isEmpty()) {
+ JSC::Options::setOptions(savedOptions.toString().ascii().data());
+ savedOptions.clear();
+ }
+
+ if (options.jscOptions.length()) {
+ JSC::Options::dumpAllOptionsInALine(savedOptions);
+ JSC::Options::setOptions(options.jscOptions.c_str());
+ }
+}
+
static void resetWebViewToConsistentStateBeforeTesting(const TestOptions& options)
{
+ setJSCOptions(options);
+
COMPtr<IWebView> webView;
if (FAILED(frame->webView(&webView)))
return;