[JSC] Use reifying system for "name" property of builtin JSFunction
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Aug 2017 00:06:43 +0000 (00:06 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Aug 2017 00:06:43 +0000 (00:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175260

Reviewed by Saam Barati.

JSTests:

* stress/accessors-get-set-prefix.js:
* stress/builtin-function-name.js: Added.
(shouldBe):
(shouldThrow):
(shouldBe.JSON.stringify.Object.getOwnPropertyDescriptor):
(shouldBe.JSON.stringify.Object.getOwnPropertyNames.Array.prototype.filter.sort):

Source/JavaScriptCore:

Currently builtin JSFunction uses direct property for "name", which is different
from usual JSFunction. Usual JSFunction uses reifying system for "name". We would like
to apply this reifying mechanism to builtin JSFunction to simplify code and drop
JSFunction::createBuiltinFunction.

We would like to store the "correct" name in FunctionExecutable. For example,
we would like to store the name like "get [Symbol.species]" to FunctionExecutable
instead of specifying name when creating JSFunction. To do so, we add a new
annotations, @getter and @overriddenName. When @getter is specified, the name of
the function becomes "get xxx". And when @overriddenName="xxx" is specified,
the name of the function becomes "xxx".

* Scripts/builtins/builtins_generate_combined_header.py:
(generate_section_for_code_table_macro):
* Scripts/builtins/builtins_generate_combined_implementation.py:
(BuiltinsCombinedImplementationGenerator.generate_secondary_header_includes):
* Scripts/builtins/builtins_generate_separate_header.py:
(generate_section_for_code_table_macro):
* Scripts/builtins/builtins_generate_separate_implementation.py:
(BuiltinsSeparateImplementationGenerator.generate_secondary_header_includes):
* Scripts/builtins/builtins_model.py:
(BuiltinFunction.__init__):
(BuiltinFunction.fromString):
* Scripts/builtins/builtins_templates.py:
* Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Combined.js:
(overriddenName.string_appeared_here.match):
(intrinsic.RegExpTestIntrinsic.test):
* Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Separate.js:
(overriddenName.string_appeared_here.match):
(intrinsic.RegExpTestIntrinsic.test):
* Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Combined.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Separate.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Combined.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Separate.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Combined.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Separate.js-result:
* Scripts/tests/builtins/expected/JavaScriptCore-InternalClashingNames-Combined.js-result:
* Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result:
* Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result:
* Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result:
* Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result:
* Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result:
* Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result:
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::BuiltinExecutables):
* builtins/BuiltinExecutables.h:
* builtins/FunctionPrototype.js:
(symbolHasInstance): Deleted.
* builtins/GlobalOperations.js:
(globalPrivate.speciesGetter): Deleted.
* builtins/IteratorPrototype.js:
(symbolIteratorGetter): Deleted.
* builtins/RegExpPrototype.js:
(match): Deleted.
(replace): Deleted.
(search): Deleted.
(split): Deleted.
* jsc.cpp:
(functionCreateBuiltin):
* runtime/FunctionPrototype.cpp:
(JSC::FunctionPrototype::addFunctionProperties):
* runtime/IteratorPrototype.cpp:
(JSC::IteratorPrototype::finishCreation):
* runtime/JSFunction.cpp:
(JSC::JSFunction::getOwnNonIndexPropertyNames):
(JSC::JSFunction::reifyLazyBoundNameIfNeeded):
(JSC::JSFunction::createBuiltinFunction): Deleted.
* runtime/JSFunction.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSObject.cpp:
(JSC::JSObject::putDirectBuiltinFunction):
(JSC::JSObject::putDirectBuiltinFunctionWithoutTransition):
* runtime/JSTypedArrayViewPrototype.cpp:
(JSC::JSTypedArrayViewPrototype::finishCreation):
* runtime/Lookup.cpp:
(JSC::reifyStaticAccessor):
* runtime/RegExpPrototype.cpp:
(JSC::RegExpPrototype::finishCreation):

Source/WebCore:

Use @getter for JSBuiltin getters.

* Modules/fetch/FetchResponse.js:
(bodyUsed): Deleted.
(body): Deleted.
* Modules/streams/ReadableByteStreamController.js:
(byobRequest): Deleted.
(desiredSize): Deleted.
* Modules/streams/ReadableStream.js:
(locked): Deleted.
* Modules/streams/ReadableStreamBYOBReader.js:
(closed): Deleted.
* Modules/streams/ReadableStreamBYOBRequest.js:
(view): Deleted.
* Modules/streams/ReadableStreamDefaultController.js:
(desiredSize): Deleted.
* Modules/streams/ReadableStreamDefaultReader.js:
(closed): Deleted.
* Modules/streams/WritableStream.js:
(closed): Deleted.
(ready): Deleted.
(state): Deleted.
* bindings/js/JSDOMBuiltinConstructor.h:
(WebCore::JSDOMBuiltinConstructor<JSClass>::finishCreation):

LayoutTests:

* js/dom/builtin-getter-name-expected.txt: Added.
* js/dom/builtin-getter-name.html: Added.

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

58 files changed:
JSTests/ChangeLog
JSTests/stress/accessors-get-set-prefix.js
JSTests/stress/builtin-function-name.js [new file with mode: 0644]
LayoutTests/ChangeLog
LayoutTests/js/dom/builtin-getter-name-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/builtin-getter-name.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py
Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py
Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py
Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py
Source/JavaScriptCore/Scripts/builtins/builtins_model.py
Source/JavaScriptCore/Scripts/builtins/builtins_templates.py
Source/JavaScriptCore/Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Combined.js
Source/JavaScriptCore/Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Separate.js
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Combined.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Combined.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Combined.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/JavaScriptCore-InternalClashingNames-Combined.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result
Source/JavaScriptCore/Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result
Source/JavaScriptCore/builtins/AsyncIteratorPrototype.js
Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
Source/JavaScriptCore/builtins/BuiltinExecutables.h
Source/JavaScriptCore/builtins/FunctionPrototype.js
Source/JavaScriptCore/builtins/GlobalOperations.js
Source/JavaScriptCore/builtins/IteratorPrototype.js
Source/JavaScriptCore/builtins/RegExpPrototype.js
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/AsyncIteratorPrototype.cpp
Source/JavaScriptCore/runtime/FunctionPrototype.cpp
Source/JavaScriptCore/runtime/IteratorPrototype.cpp
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSFunction.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
Source/JavaScriptCore/runtime/Lookup.cpp
Source/JavaScriptCore/runtime/MapPrototype.cpp
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/runtime/SetPrototype.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchResponse.js
Source/WebCore/Modules/streams/ReadableByteStreamController.js
Source/WebCore/Modules/streams/ReadableStream.js
Source/WebCore/Modules/streams/ReadableStreamBYOBReader.js
Source/WebCore/Modules/streams/ReadableStreamBYOBRequest.js
Source/WebCore/Modules/streams/ReadableStreamDefaultController.js
Source/WebCore/Modules/streams/ReadableStreamDefaultReader.js
Source/WebCore/Modules/streams/WritableStream.js
Source/WebCore/bindings/js/JSDOMBuiltinConstructor.h

index 174808b..cedf398 100644 (file)
@@ -1,3 +1,17 @@
+2017-08-29  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Use reifying system for "name" property of builtin JSFunction
+        https://bugs.webkit.org/show_bug.cgi?id=175260
+
+        Reviewed by Saam Barati.
+
+        * stress/accessors-get-set-prefix.js:
+        * stress/builtin-function-name.js: Added.
+        (shouldBe):
+        (shouldThrow):
+        (shouldBe.JSON.stringify.Object.getOwnPropertyDescriptor):
+        (shouldBe.JSON.stringify.Object.getOwnPropertyNames.Array.prototype.filter.sort):
+
 2017-08-25  Saam Barati  <sbarati@apple.com>
 
         Support compiling catch in the DFG
index c2d3a5e..655bc6c 100644 (file)
@@ -14,8 +14,15 @@ function tryGetOwnPropertyDescriptorGetName(obj, property, expectedName)
 }
 
 tryGetOwnPropertyDescriptorGetName(Array, Symbol.species, "get [Symbol.species]");
+tryGetOwnPropertyDescriptorGetName(Map, Symbol.species, "get [Symbol.species]");
+tryGetOwnPropertyDescriptorGetName(Set, Symbol.species, "get [Symbol.species]");
+tryGetOwnPropertyDescriptorGetName(RegExp, Symbol.species, "get [Symbol.species]");
+tryGetOwnPropertyDescriptorGetName(Promise, Symbol.species, "get [Symbol.species]");
 tryGetOwnPropertyDescriptorGetName(Map.prototype, "size", "get size");
 tryGetOwnPropertyDescriptorGetName(Set.prototype, "size", "get size");
+tryGetOwnPropertyDescriptorGetName(RegExp.prototype, "flags", "get flags");
+tryGetOwnPropertyDescriptorGetName(RegExp.prototype, "sticky", "get sticky");
+tryGetOwnPropertyDescriptorGetName(RegExp.prototype, "source", "get source");
 
 if (Object.__lookupGetter__("__proto__").name !== "get __proto__")
     throw "Expected Object __proto__ getter to be named \"get __proto\"";
diff --git a/JSTests/stress/builtin-function-name.js b/JSTests/stress/builtin-function-name.js
new file mode 100644 (file)
index 0000000..989447d
--- /dev/null
@@ -0,0 +1,47 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function shouldThrow(func, errorMessage) {
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
+
+{
+    shouldBe(JSON.stringify(Object.getOwnPropertyNames(Array.prototype.filter).sort()), `["length","name"]`);
+    shouldBe(Array.prototype.filter.name, "filter");
+    shouldBe(JSON.stringify(Object.getOwnPropertyDescriptor(Array.prototype.filter, 'name')), `{"value":"filter","writable":false,"enumerable":false,"configurable":true}`);
+    shouldBe(delete Array.prototype.filter.name, true);
+    shouldBe(JSON.stringify(Object.getOwnPropertyNames(Array.prototype.filter).sort()), `["length"]`);
+}
+
+{
+    shouldThrow(function () {
+        "use strict";
+        Array.prototype.forEach.name = 42;
+    }, `TypeError: Attempted to assign to readonly property.`);
+}
+
+{
+    var resolve = null;
+    var reject = null;
+    new Promise(function (arg0, arg1) {
+        resolve = arg0;
+        reject = arg1;
+    });
+    shouldBe(resolve.name, "resolve");
+    shouldBe(JSON.stringify(Object.getOwnPropertyDescriptor(resolve, 'name')), `{"value":"resolve","writable":false,"enumerable":false,"configurable":true}`);
+    shouldBe(reject.name, "reject");
+    shouldBe(JSON.stringify(Object.getOwnPropertyDescriptor(reject, 'name')), `{"value":"reject","writable":false,"enumerable":false,"configurable":true}`);
+}
index d8eef14..36f3ce1 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-29  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Use reifying system for "name" property of builtin JSFunction
+        https://bugs.webkit.org/show_bug.cgi?id=175260
+
+        Reviewed by Saam Barati.
+
+        * js/dom/builtin-getter-name-expected.txt: Added.
+        * js/dom/builtin-getter-name.html: Added.
+
 2017-08-29  Per Arne Vollan  <pvollan@apple.com>
 
         Rebaseline editing/style/5084241.html after r220706.
diff --git a/LayoutTests/js/dom/builtin-getter-name-expected.txt b/LayoutTests/js/dom/builtin-getter-name-expected.txt
new file mode 100644 (file)
index 0000000..0d4ed17
--- /dev/null
@@ -0,0 +1,7 @@
+
+PASS FetchResponse property names 
+PASS ReadableStream property names 
+PASS ReadableStreamDefaultReader property names 
+PASS ReadableStreamBYOBReader property names 
+PASS WritableStream property names 
+
diff --git a/LayoutTests/js/dom/builtin-getter-name.html b/LayoutTests/js/dom/builtin-getter-name.html
new file mode 100644 (file)
index 0000000..75cf3a0
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Builtin JS getter names</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+
+function tryGetOwnPropertyDescriptorGetName(obj, property, expectedName)
+{
+    let descriptor = Object.getOwnPropertyDescriptor(obj, property);
+    assert_true(!!descriptor, `Should find property descriptor for ${property}`);
+
+    let getter = descriptor.get;
+    assert_true(!!getter, `Should find getter for ${property}`);
+
+    let getterName = getter.name;
+    assert_equals(getterName, expectedName);
+}
+
+test(() => {
+    tryGetOwnPropertyDescriptorGetName(Response.prototype, 'body', 'get body');
+    tryGetOwnPropertyDescriptorGetName(Response.prototype, 'bodyUsed', 'get bodyUsed');
+}, 'FetchResponse property names');
+
+test(() => {
+    tryGetOwnPropertyDescriptorGetName(ReadableStream.prototype, 'locked', 'get locked');
+}, 'ReadableStream property names');
+
+test(() => {
+    let stream = new ReadableStream();
+    let reader = stream.getReader();
+    tryGetOwnPropertyDescriptorGetName(reader.__proto__, 'closed', 'get closed');
+}, 'ReadableStreamDefaultReader property names');
+
+test(() => {
+    let stream = new ReadableStream({
+        start: function(c) {
+            controller = c;
+        },
+        type: "bytes"
+    });
+    let reader = stream.getReader({ mode: 'byob' });
+    tryGetOwnPropertyDescriptorGetName(reader.__proto__, 'closed', 'get closed');
+}, 'ReadableStreamBYOBReader property names');
+
+test(() => {
+    tryGetOwnPropertyDescriptorGetName(WritableStream.prototype, 'closed', 'get closed');
+    tryGetOwnPropertyDescriptorGetName(WritableStream.prototype, 'ready', 'get ready');
+    tryGetOwnPropertyDescriptorGetName(WritableStream.prototype, 'state', 'get state');
+}, 'WritableStream property names');
+
+</script>
+</body>
+</html>
index 3545bff..350fbeb 100644 (file)
@@ -1,3 +1,90 @@
+2017-08-29  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Use reifying system for "name" property of builtin JSFunction
+        https://bugs.webkit.org/show_bug.cgi?id=175260
+
+        Reviewed by Saam Barati.
+
+        Currently builtin JSFunction uses direct property for "name", which is different
+        from usual JSFunction. Usual JSFunction uses reifying system for "name". We would like
+        to apply this reifying mechanism to builtin JSFunction to simplify code and drop
+        JSFunction::createBuiltinFunction.
+
+        We would like to store the "correct" name in FunctionExecutable. For example,
+        we would like to store the name like "get [Symbol.species]" to FunctionExecutable
+        instead of specifying name when creating JSFunction. To do so, we add a new
+        annotations, @getter and @overriddenName. When @getter is specified, the name of
+        the function becomes "get xxx". And when @overriddenName="xxx" is specified,
+        the name of the function becomes "xxx".
+
+        * Scripts/builtins/builtins_generate_combined_header.py:
+        (generate_section_for_code_table_macro):
+        * Scripts/builtins/builtins_generate_combined_implementation.py:
+        (BuiltinsCombinedImplementationGenerator.generate_secondary_header_includes):
+        * Scripts/builtins/builtins_generate_separate_header.py:
+        (generate_section_for_code_table_macro):
+        * Scripts/builtins/builtins_generate_separate_implementation.py:
+        (BuiltinsSeparateImplementationGenerator.generate_secondary_header_includes):
+        * Scripts/builtins/builtins_model.py:
+        (BuiltinFunction.__init__):
+        (BuiltinFunction.fromString):
+        * Scripts/builtins/builtins_templates.py:
+        * Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Combined.js:
+        (overriddenName.string_appeared_here.match):
+        (intrinsic.RegExpTestIntrinsic.test):
+        * Scripts/tests/builtins/JavaScriptCore-Builtin.prototype-Separate.js:
+        (overriddenName.string_appeared_here.match):
+        (intrinsic.RegExpTestIntrinsic.test):
+        * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Combined.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.Promise-Separate.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Combined.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-Builtin.prototype-Separate.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Combined.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-BuiltinConstructor-Separate.js-result:
+        * Scripts/tests/builtins/expected/JavaScriptCore-InternalClashingNames-Combined.js-result:
+        * Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result:
+        * Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result:
+        * Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result:
+        * Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result:
+        * Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result:
+        * Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result:
+        * builtins/BuiltinExecutables.cpp:
+        (JSC::BuiltinExecutables::BuiltinExecutables):
+        * builtins/BuiltinExecutables.h:
+        * builtins/FunctionPrototype.js:
+        (symbolHasInstance): Deleted.
+        * builtins/GlobalOperations.js:
+        (globalPrivate.speciesGetter): Deleted.
+        * builtins/IteratorPrototype.js:
+        (symbolIteratorGetter): Deleted.
+        * builtins/RegExpPrototype.js:
+        (match): Deleted.
+        (replace): Deleted.
+        (search): Deleted.
+        (split): Deleted.
+        * jsc.cpp:
+        (functionCreateBuiltin):
+        * runtime/FunctionPrototype.cpp:
+        (JSC::FunctionPrototype::addFunctionProperties):
+        * runtime/IteratorPrototype.cpp:
+        (JSC::IteratorPrototype::finishCreation):
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::getOwnNonIndexPropertyNames):
+        (JSC::JSFunction::reifyLazyBoundNameIfNeeded):
+        (JSC::JSFunction::createBuiltinFunction): Deleted.
+        * runtime/JSFunction.h:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::putDirectBuiltinFunction):
+        (JSC::JSObject::putDirectBuiltinFunctionWithoutTransition):
+        * runtime/JSTypedArrayViewPrototype.cpp:
+        (JSC::JSTypedArrayViewPrototype::finishCreation):
+        * runtime/Lookup.cpp:
+        (JSC::reifyStaticAccessor):
+        * runtime/RegExpPrototype.cpp:
+        (JSC::RegExpPrototype::finishCreation):
+
 2017-08-29  Saam Barati  <sbarati@apple.com>
 
         Throwing an exception in the DFG/FTL should not be a jettison-able OSR exit
index 42334ff..cde357c 100755 (executable)
@@ -123,10 +123,11 @@ extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function
         for function in self.model().all_functions():
             function_args = {
                 'funcName': function.function_name,
+                'overriddenName': function.overridden_name,
                 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
             }
 
-            lines.append("    macro(%(codeName)s, %(funcName)s, s_%(codeName)sLength) \\" % function_args)
+            lines.append("    macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args)
         return '\n'.join(lines)
 
     def generate_section_for_code_name_macro(self):
index 728beba..7874dca 100644 (file)
@@ -90,6 +90,9 @@ class BuiltinsCombinedImplementationGenerator(BuiltinsGenerator):
                 ("JavaScriptCore", "runtime/VM.h"),
             ),
             (["JavaScriptCore", "WebCore"],
+                ("JavaScriptCore", "runtime/IdentifierInlines.h"),
+            ),
+            (["JavaScriptCore", "WebCore"],
                 ("JavaScriptCore", "runtime/Intrinsic.h"),
             ),
         ]
index 9058367..58c8f2a 100755 (executable)
@@ -172,10 +172,11 @@ extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function
         for function in self.object.functions:
             function_args = {
                 'funcName': function.function_name,
+                'overriddenName': function.overridden_name,
                 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
             }
 
-            lines.append("    macro(%(codeName)s, %(funcName)s, s_%(codeName)sLength) \\" % function_args)
+            lines.append("    macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args)
         return '\n'.join(lines)
 
     def generate_section_for_code_name_macro(self):
index d5362bd..ced9a53 100644 (file)
@@ -102,6 +102,9 @@ class BuiltinsSeparateImplementationGenerator(BuiltinsGenerator):
                 ("WebCore", "bindings/js/WebCoreJSClientData.h"),
             ),
             (["JavaScriptCore", "WebCore"],
+                ("JavaScriptCore", "runtime/IdentifierInlines.h"),
+            ),
+            (["JavaScriptCore", "WebCore"],
                 ("JavaScriptCore", "runtime/Intrinsic.h"),
             ),
         ]
index c35bd3e..02340b7 100755 (executable)
@@ -42,11 +42,13 @@ _FRAMEWORK_CONFIG_MAP = {
     },
 }
 
-functionHeadRegExp = re.compile(r"(?:@[\w|=]+\s*\n)*function\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL)
+functionHeadRegExp = re.compile(r"(?:@[\w|=\[\] \"\.]+\s*\n)*function\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL)
 functionGlobalPrivateRegExp = re.compile(r".*^@globalPrivate", re.MULTILINE | re.DOTALL)
 functionIntrinsicRegExp = re.compile(r".*^@intrinsic=(\w+)", re.MULTILINE | re.DOTALL)
 functionIsConstructorRegExp = re.compile(r".*^@constructor", re.MULTILINE | re.DOTALL)
+functionIsGetterRegExp = re.compile(r".*^@getter", re.MULTILINE | re.DOTALL)
 functionNameRegExp = re.compile(r"function\s+(\w+)\s*\(", re.MULTILINE | re.DOTALL)
+functionOverriddenNameRegExp = re.compile(r".*^@overriddenName=(\".+\")$", re.MULTILINE | re.DOTALL)
 functionParameterFinder = re.compile(r"^function\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.DOTALL)
 
 multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.DOTALL)
@@ -97,13 +99,14 @@ class BuiltinObject:
 
 
 class BuiltinFunction:
-    def __init__(self, function_name, function_source, parameters, is_constructor, is_global_private, intrinsic):
+    def __init__(self, function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name):
         self.function_name = function_name
         self.function_source = function_source
         self.parameters = parameters
         self.is_constructor = is_constructor
         self.is_global_private = is_global_private
         self.intrinsic = intrinsic
+        self.overridden_name = overridden_name
         self.object = None  # Set by the owning BuiltinObject
 
     @staticmethod
@@ -116,6 +119,12 @@ class BuiltinFunction:
             intrinsic = intrinsicMatch.group(1)
             function_source = functionIntrinsicRegExp.sub("", function_source)
 
+        overridden_name = None
+        overriddenNameMatch = functionOverriddenNameRegExp.search(function_source)
+        if overriddenNameMatch:
+            overridden_name = overriddenNameMatch.group(1)
+            function_source = functionOverriddenNameRegExp.sub("", function_source)
+
         if os.getenv("CONFIGURATION", "Debug").startswith("Debug"):
             function_source = lineWithOnlySingleLineCommentRegExp.sub("", function_source)
             function_source = lineWithTrailingSingleLineCommentRegExp.sub("\n", function_source)
@@ -123,12 +132,19 @@ class BuiltinFunction:
 
         function_name = functionNameRegExp.findall(function_source)[0]
         is_constructor = functionIsConstructorRegExp.match(function_source) != None
+        is_getter = functionIsGetterRegExp.match(function_source) != None
         is_global_private = functionGlobalPrivateRegExp.match(function_source) != None
         parameters = [s.strip() for s in functionParameterFinder.findall(function_source)[0].split(',')]
         if len(parameters[0]) == 0:
             parameters = []
 
-        return BuiltinFunction(function_name, function_source, parameters, is_constructor, is_global_private, intrinsic)
+        if is_getter and not overridden_name:
+            overridden_name = "\"get %s\"" % (function_name)
+
+        if not overridden_name:
+            overridden_name = "static_cast<const char*>(nullptr)"
+
+        return BuiltinFunction(function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name)
 
     def __str__(self):
         interface = "%s(%s)" % (self.function_name, ', '.join(self.parameters))
index f848680..907a6d7 100644 (file)
@@ -67,14 +67,14 @@ THE POSSIBILITY OF SUCH DAMAGE.
     """} // namespace ${namespace}""")
 
     CombinedHeaderStaticMacros = (
-    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 ${macroPrefix}_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 #undef DECLARE_BUILTIN_GENERATOR""")
 
     SeparateHeaderStaticMacros = (
-    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -82,7 +82,7 @@ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
     CombinedJSCImplementationStaticMacros = (
     """
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
 {\\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
@@ -93,7 +93,7 @@ ${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
 
     SeparateJSCImplementationStaticMacros = (
     """
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
 {\\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
@@ -104,7 +104,7 @@ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
 
     CombinedWebCoreImplementationStaticMacros = (
         """
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
 {\\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\
@@ -116,7 +116,7 @@ ${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
 
     SeparateWebCoreImplementationStaticMacros = (
         """
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \\
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
 {\\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\
@@ -132,13 +132,13 @@ public:
     explicit ${objectName}BuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \\
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\
     JSC::UnlinkedFunctionExecutable* name##Executable(); \\
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -153,7 +153,7 @@ private:
 
     ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \\
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \\
     JSC::SourceCode m_##name##Source;\\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -161,11 +161,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \\
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\
 inline JSC::UnlinkedFunctionExecutable* ${objectName}BuiltinsWrapper::name##Executable() \\
 {\\
-    if (!m_##name##Executable)\\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\\
+    if (!m_##name##Executable) {\\
+        JSC::Identifier executableName = functionName##PublicName();\\
+        if (overriddenName)\\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\\
+    }\\
     return m_##name##Executable.get();\\
 }
 ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -197,8 +201,8 @@ public:
 
 inline void ${objectName}BuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
 {
-#define EXPORT_FUNCTION(codeName, functionName, length)\\
-    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::createBuiltinFunction(m_vm, codeName##Generator(m_vm), &globalObject));
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\\
+    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
     ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPORT_FUNCTION)
 #undef EXPORT_FUNCTION
 }
index 5448b98..0159c29 100644 (file)
@@ -76,3 +76,83 @@ function forEach(callback /*, thisArg */)
             callback.@call(thisArg, array[i], i, array);
     }
 }
+
+@overriddenName="[Symbol.match]"
+function match(strArg)
+{
+    "use strict";
+
+    if (!@isObject(this))
+        @throwTypeError("RegExp.prototype.@@match requires that |this| be an Object");
+
+    let regexp = this;
+
+    // Check for observable side effects and call the fast path if there aren't any.
+    if (!@hasObservableSideEffectsForRegExpMatch(regexp))
+        return @regExpMatchFast.@call(regexp, strArg);
+
+    let str = @toString(strArg);
+
+    if (!regexp.global)
+        return @regExpExec(regexp, str);
+    
+    let unicode = regexp.unicode;
+    regexp.lastIndex = 0;
+    let resultList = [];
+
+    // FIXME: It would be great to implement a solution similar to what we do in
+    // RegExpObject::matchGlobal(). It's not clear if this is possible, since this loop has
+    // effects. https://bugs.webkit.org/show_bug.cgi?id=158145
+    const maximumReasonableMatchSize = 100000000;
+
+    while (true) {
+        let result = @regExpExec(regexp, str);
+        
+        if (result === null) {
+            if (resultList.length === 0)
+                return null;
+            return resultList;
+        }
+
+        if (resultList.length > maximumReasonableMatchSize)
+            @throwOutOfMemoryError();
+
+        if (!@isObject(result))
+            @throwTypeError("RegExp.prototype.@@match call to RegExp.exec didn't return null or an object");
+
+        let resultString = @toString(result[0]);
+
+        if (!resultString.length)
+            regexp.lastIndex = @advanceStringIndex(str, regexp.lastIndex, unicode);
+
+        resultList.@push(resultString);
+    }
+}
+
+@intrinsic=RegExpTestIntrinsic
+function test(strArg)
+{
+    "use strict";
+
+    let regexp = this;
+
+    // Check for observable side effects and call the fast path if there aren't any.
+    if (@isRegExpObject(regexp) && @tryGetById(regexp, "exec") === @regExpBuiltinExec)
+        return @regExpTestFast.@call(regexp, strArg);
+
+    // 1. Let R be the this value.
+    // 2. If Type(R) is not Object, throw a TypeError exception.
+    if (!@isObject(regexp))
+        @throwTypeError("RegExp.prototype.test requires that |this| be an Object");
+
+    // 3. Let string be ? ToString(S).
+    let str = @toString(strArg);
+
+    // 4. Let match be ? RegExpExec(R, string).
+    let match = @regExpExec(regexp, str);
+
+    // 5. If match is not null, return true; else return false.
+    if (match !== null)
+        return true;
+    return false;
+}
index 5448b98..0159c29 100644 (file)
@@ -76,3 +76,83 @@ function forEach(callback /*, thisArg */)
             callback.@call(thisArg, array[i], i, array);
     }
 }
+
+@overriddenName="[Symbol.match]"
+function match(strArg)
+{
+    "use strict";
+
+    if (!@isObject(this))
+        @throwTypeError("RegExp.prototype.@@match requires that |this| be an Object");
+
+    let regexp = this;
+
+    // Check for observable side effects and call the fast path if there aren't any.
+    if (!@hasObservableSideEffectsForRegExpMatch(regexp))
+        return @regExpMatchFast.@call(regexp, strArg);
+
+    let str = @toString(strArg);
+
+    if (!regexp.global)
+        return @regExpExec(regexp, str);
+    
+    let unicode = regexp.unicode;
+    regexp.lastIndex = 0;
+    let resultList = [];
+
+    // FIXME: It would be great to implement a solution similar to what we do in
+    // RegExpObject::matchGlobal(). It's not clear if this is possible, since this loop has
+    // effects. https://bugs.webkit.org/show_bug.cgi?id=158145
+    const maximumReasonableMatchSize = 100000000;
+
+    while (true) {
+        let result = @regExpExec(regexp, str);
+        
+        if (result === null) {
+            if (resultList.length === 0)
+                return null;
+            return resultList;
+        }
+
+        if (resultList.length > maximumReasonableMatchSize)
+            @throwOutOfMemoryError();
+
+        if (!@isObject(result))
+            @throwTypeError("RegExp.prototype.@@match call to RegExp.exec didn't return null or an object");
+
+        let resultString = @toString(result[0]);
+
+        if (!resultString.length)
+            regexp.lastIndex = @advanceStringIndex(str, regexp.lastIndex, unicode);
+
+        resultList.@push(resultString);
+    }
+}
+
+@intrinsic=RegExpTestIntrinsic
+function test(strArg)
+{
+    "use strict";
+
+    let regexp = this;
+
+    // Check for observable side effects and call the fast path if there aren't any.
+    if (@isRegExpObject(regexp) && @tryGetById(regexp, "exec") === @regExpBuiltinExec)
+        return @regExpTestFast.@call(regexp, strArg);
+
+    // 1. Let R be the this value.
+    // 2. If Type(R) is not Object, throw a TypeError exception.
+    if (!@isObject(regexp))
+        @throwTypeError("RegExp.prototype.test requires that |this| be an Object");
+
+    // 3. Let string be ? ToString(S).
+    let str = @toString(strArg);
+
+    // 4. Let match be ? RegExpExec(R, string).
+    let match = @regExpExec(regexp, str);
+
+    // 5. If match is not null, return true; else return false.
+    if (match !== null)
+        return true;
+    return false;
+}
index 9bb21d6..9960129 100644 (file)
@@ -53,8 +53,8 @@ extern const JSC::ConstructAbility s_builtinPromiseFulfillPromiseCodeConstructAb
     macro(fulfillPromise, builtinPromiseFulfillPromise, 2) \
 
 #define JSC_FOREACH_BUILTIN_CODE(macro) \
-    macro(builtinPromiseRejectPromiseCode, rejectPromise, s_builtinPromiseRejectPromiseCodeLength) \
-    macro(builtinPromiseFulfillPromiseCode, fulfillPromise, s_builtinPromiseFulfillPromiseCodeLength) \
+    macro(builtinPromiseRejectPromiseCode, rejectPromise, static_cast<const char*>(nullptr), s_builtinPromiseRejectPromiseCodeLength) \
+    macro(builtinPromiseFulfillPromiseCode, fulfillPromise, static_cast<const char*>(nullptr), s_builtinPromiseFulfillPromiseCodeLength) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \
     macro(fulfillPromise) \
@@ -62,7 +62,7 @@ extern const JSC::ConstructAbility s_builtinPromiseFulfillPromiseCodeConstructAb
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -107,6 +107,7 @@ JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "UnlinkedFunctionExecutable.h"
@@ -149,7 +150,7 @@ const char* s_builtinPromiseFulfillPromiseCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 87fdaee..1a4d83b 100644 (file)
@@ -55,14 +55,14 @@ extern const JSC::ConstructAbility s_builtinPromiseFulfillPromiseCodeConstructAb
 #define JSC_BUILTIN_BUILTIN_PROMISE_FULFILLPROMISE 1
 
 #define JSC_FOREACH_BUILTIN.PROMISE_BUILTIN_CODE(macro) \
-    macro(builtinPromiseRejectPromiseCode, rejectPromise, s_builtinPromiseRejectPromiseCodeLength) \
-    macro(builtinPromiseFulfillPromiseCode, fulfillPromise, s_builtinPromiseFulfillPromiseCodeLength) \
+    macro(builtinPromiseRejectPromiseCode, rejectPromise, static_cast<const char*>(nullptr), s_builtinPromiseRejectPromiseCodeLength) \
+    macro(builtinPromiseFulfillPromiseCode, fulfillPromise, static_cast<const char*>(nullptr), s_builtinPromiseFulfillPromiseCodeLength) \
 
 #define JSC_FOREACH_BUILTIN.PROMISE_BUILTIN_FUNCTION_NAME(macro) \
     macro(fulfillPromise) \
     macro(rejectPromise) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN.PROMISE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -107,6 +107,7 @@ JSC_FOREACH_BUILTIN.PROMISE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "VM.h"
@@ -148,7 +149,7 @@ const char* s_builtinPromiseFulfillPromiseCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 6bf696f..e4b6c2a 100644 (file)
@@ -47,22 +47,34 @@ extern const JSC::ConstructAbility s_builtinPrototypeEveryCodeConstructAbility;
 extern const char* s_builtinPrototypeForEachCode;
 extern const int s_builtinPrototypeForEachCodeLength;
 extern const JSC::ConstructAbility s_builtinPrototypeForEachCodeConstructAbility;
+extern const char* s_builtinPrototypeMatchCode;
+extern const int s_builtinPrototypeMatchCodeLength;
+extern const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility;
+extern const char* s_builtinPrototypeTestCode;
+extern const int s_builtinPrototypeTestCodeLength;
+extern const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility;
 
 #define JSC_FOREACH_BUILTINPROTOTYPE_BUILTIN_DATA(macro) \
     macro(every, builtinPrototypeEvery, 1) \
     macro(forEach, builtinPrototypeForEach, 1) \
+    macro(match, builtinPrototypeMatch, 1) \
+    macro(test, builtinPrototypeTest, 1) \
 
 #define JSC_FOREACH_BUILTIN_CODE(macro) \
-    macro(builtinPrototypeEveryCode, every, s_builtinPrototypeEveryCodeLength) \
-    macro(builtinPrototypeForEachCode, forEach, s_builtinPrototypeForEachCodeLength) \
+    macro(builtinPrototypeEveryCode, every, static_cast<const char*>(nullptr), s_builtinPrototypeEveryCodeLength) \
+    macro(builtinPrototypeForEachCode, forEach, static_cast<const char*>(nullptr), s_builtinPrototypeForEachCodeLength) \
+    macro(builtinPrototypeMatchCode, match, "[Symbol.match]", s_builtinPrototypeMatchCodeLength) \
+    macro(builtinPrototypeTestCode, test, static_cast<const char*>(nullptr), s_builtinPrototypeTestCodeLength) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \
     macro(every) \
     macro(forEach) \
+    macro(match) \
+    macro(test) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -107,6 +119,7 @@ JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "UnlinkedFunctionExecutable.h"
@@ -172,8 +185,68 @@ const char* s_builtinPrototypeForEachCode =
     "})\n" \
 ;
 
+const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const int s_builtinPrototypeMatchCodeLength = 1198;
+static const JSC::Intrinsic s_builtinPrototypeMatchCodeIntrinsic = JSC::NoIntrinsic;
+const char* s_builtinPrototypeMatchCode =
+    "(function (strArg)\n" \
+    "{\n" \
+    "    \"use strict\";\n" \
+    "    if (!@isObject(this))\n" \
+    "        @throwTypeError(\"RegExp.prototype.@@match requires that |this| be an Object\");\n" \
+    "    let regexp = this;\n" \
+    "    if (!@hasObservableSideEffectsForRegExpMatch(regexp))\n" \
+    "        return @regExpMatchFast.@call(regexp, strArg);\n" \
+    "    let str = @toString(strArg);\n" \
+    "    if (!regexp.global)\n" \
+    "        return @regExpExec(regexp, str);\n" \
+    "    \n" \
+    "    let unicode = regexp.unicode;\n" \
+    "    regexp.lastIndex = 0;\n" \
+    "    let resultList = [];\n" \
+    "    const maximumReasonableMatchSize = 100000000;\n" \
+    "    while (true) {\n" \
+    "        let result = @regExpExec(regexp, str);\n" \
+    "        \n" \
+    "        if (result === null) {\n" \
+    "            if (resultList.length === 0)\n" \
+    "                return null;\n" \
+    "            return resultList;\n" \
+    "        }\n" \
+    "        if (resultList.length > maximumReasonableMatchSize)\n" \
+    "            @throwOutOfMemoryError();\n" \
+    "        if (!@isObject(result))\n" \
+    "            @throwTypeError(\"RegExp.prototype.@@match call to RegExp.exec didn't return null or an object\");\n" \
+    "        let resultString = @toString(result[0]);\n" \
+    "        if (!resultString.length)\n" \
+    "            regexp.lastIndex = @advanceStringIndex(str, regexp.lastIndex, unicode);\n" \
+    "        resultList.@push(resultString);\n" \
+    "    }\n" \
+    "})\n" \
+;
+
+const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const int s_builtinPrototypeTestCodeLength = 456;
+static const JSC::Intrinsic s_builtinPrototypeTestCodeIntrinsic = JSC::RegExpTestIntrinsic;
+const char* s_builtinPrototypeTestCode =
+    "(function (strArg)\n" \
+    "{\n" \
+    "    \"use strict\";\n" \
+    "    let regexp = this;\n" \
+    "    if (@isRegExpObject(regexp) && @tryGetById(regexp, \"exec\") === @regExpBuiltinExec)\n" \
+    "        return @regExpTestFast.@call(regexp, strArg);\n" \
+    "    if (!@isObject(regexp))\n" \
+    "        @throwTypeError(\"RegExp.prototype.test requires that |this| be an Object\");\n" \
+    "    let str = @toString(strArg);\n" \
+    "    let match = @regExpExec(regexp, str);\n" \
+    "    if (match !== null)\n" \
+    "        return true;\n" \
+    "    return false;\n" \
+    "})\n" \
+;
+
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index d0c8f26..7c875d7 100644 (file)
@@ -46,23 +46,37 @@ extern const JSC::ConstructAbility s_builtinPrototypeEveryCodeConstructAbility;
 extern const char* s_builtinPrototypeForEachCode;
 extern const int s_builtinPrototypeForEachCodeLength;
 extern const JSC::ConstructAbility s_builtinPrototypeForEachCodeConstructAbility;
+extern const char* s_builtinPrototypeMatchCode;
+extern const int s_builtinPrototypeMatchCodeLength;
+extern const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility;
+extern const char* s_builtinPrototypeTestCode;
+extern const int s_builtinPrototypeTestCodeLength;
+extern const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility;
 
 #define JSC_FOREACH_BUILTIN_PROTOTYPE_BUILTIN_DATA(macro) \
     macro(every, builtinPrototypeEvery, 1) \
     macro(forEach, builtinPrototypeForEach, 1) \
+    macro(match, builtinPrototypeMatch, 1) \
+    macro(test, builtinPrototypeTest, 1) \
 
 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_EVERY 1
 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_FOREACH 1
+#define JSC_BUILTIN_BUILTIN_PROTOTYPE_MATCH 1
+#define JSC_BUILTIN_BUILTIN_PROTOTYPE_TEST 1
 
 #define JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(macro) \
-    macro(builtinPrototypeEveryCode, every, s_builtinPrototypeEveryCodeLength) \
-    macro(builtinPrototypeForEachCode, forEach, s_builtinPrototypeForEachCodeLength) \
+    macro(builtinPrototypeEveryCode, every, static_cast<const char*>(nullptr), s_builtinPrototypeEveryCodeLength) \
+    macro(builtinPrototypeForEachCode, forEach, static_cast<const char*>(nullptr), s_builtinPrototypeForEachCodeLength) \
+    macro(builtinPrototypeMatchCode, match, "[Symbol.match]", s_builtinPrototypeMatchCodeLength) \
+    macro(builtinPrototypeTestCode, test, static_cast<const char*>(nullptr), s_builtinPrototypeTestCodeLength) \
 
 #define JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \
     macro(every) \
     macro(forEach) \
+    macro(match) \
+    macro(test) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -107,6 +121,7 @@ JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "VM.h"
@@ -171,8 +186,68 @@ const char* s_builtinPrototypeForEachCode =
     "})\n" \
 ;
 
+const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const int s_builtinPrototypeMatchCodeLength = 1198;
+static const JSC::Intrinsic s_builtinPrototypeMatchCodeIntrinsic = JSC::NoIntrinsic;
+const char* s_builtinPrototypeMatchCode =
+    "(function (strArg)\n" \
+    "{\n" \
+    "    \"use strict\";\n" \
+    "    if (!@isObject(this))\n" \
+    "        @throwTypeError(\"RegExp.prototype.@@match requires that |this| be an Object\");\n" \
+    "    let regexp = this;\n" \
+    "    if (!@hasObservableSideEffectsForRegExpMatch(regexp))\n" \
+    "        return @regExpMatchFast.@call(regexp, strArg);\n" \
+    "    let str = @toString(strArg);\n" \
+    "    if (!regexp.global)\n" \
+    "        return @regExpExec(regexp, str);\n" \
+    "    \n" \
+    "    let unicode = regexp.unicode;\n" \
+    "    regexp.lastIndex = 0;\n" \
+    "    let resultList = [];\n" \
+    "    const maximumReasonableMatchSize = 100000000;\n" \
+    "    while (true) {\n" \
+    "        let result = @regExpExec(regexp, str);\n" \
+    "        \n" \
+    "        if (result === null) {\n" \
+    "            if (resultList.length === 0)\n" \
+    "                return null;\n" \
+    "            return resultList;\n" \
+    "        }\n" \
+    "        if (resultList.length > maximumReasonableMatchSize)\n" \
+    "            @throwOutOfMemoryError();\n" \
+    "        if (!@isObject(result))\n" \
+    "            @throwTypeError(\"RegExp.prototype.@@match call to RegExp.exec didn't return null or an object\");\n" \
+    "        let resultString = @toString(result[0]);\n" \
+    "        if (!resultString.length)\n" \
+    "            regexp.lastIndex = @advanceStringIndex(str, regexp.lastIndex, unicode);\n" \
+    "        resultList.@push(resultString);\n" \
+    "    }\n" \
+    "})\n" \
+;
+
+const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const int s_builtinPrototypeTestCodeLength = 456;
+static const JSC::Intrinsic s_builtinPrototypeTestCodeIntrinsic = JSC::RegExpTestIntrinsic;
+const char* s_builtinPrototypeTestCode =
+    "(function (strArg)\n" \
+    "{\n" \
+    "    \"use strict\";\n" \
+    "    let regexp = this;\n" \
+    "    if (@isRegExpObject(regexp) && @tryGetById(regexp, \"exec\") === @regExpBuiltinExec)\n" \
+    "        return @regExpTestFast.@call(regexp, strArg);\n" \
+    "    if (!@isObject(regexp))\n" \
+    "        @throwTypeError(\"RegExp.prototype.test requires that |this| be an Object\");\n" \
+    "    let str = @toString(strArg);\n" \
+    "    let match = @regExpExec(regexp, str);\n" \
+    "    if (match !== null)\n" \
+    "        return true;\n" \
+    "    return false;\n" \
+    "})\n" \
+;
+
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 023a829..98b613f 100644 (file)
@@ -52,8 +52,8 @@ extern const JSC::ConstructAbility s_builtinConstructorFromCodeConstructAbility;
     macro(from, builtinConstructorFrom, 1) \
 
 #define JSC_FOREACH_BUILTIN_CODE(macro) \
-    macro(builtinConstructorOfCode, of, s_builtinConstructorOfCodeLength) \
-    macro(builtinConstructorFromCode, from, s_builtinConstructorFromCodeLength) \
+    macro(builtinConstructorOfCode, of, static_cast<const char*>(nullptr), s_builtinConstructorOfCodeLength) \
+    macro(builtinConstructorFromCode, from, static_cast<const char*>(nullptr), s_builtinConstructorFromCodeLength) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \
     macro(from) \
@@ -61,7 +61,7 @@ extern const JSC::ConstructAbility s_builtinConstructorFromCodeConstructAbility;
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -105,6 +105,7 @@ JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "UnlinkedFunctionExecutable.h"
@@ -186,7 +187,7 @@ const char* s_builtinConstructorFromCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 8000b69..353ee6e 100644 (file)
@@ -54,14 +54,14 @@ extern const JSC::ConstructAbility s_builtinConstructorFromCodeConstructAbility;
 #define JSC_BUILTIN_BUILTINCONSTRUCTOR_FROM 1
 
 #define JSC_FOREACH_BUILTINCONSTRUCTOR_BUILTIN_CODE(macro) \
-    macro(builtinConstructorOfCode, of, s_builtinConstructorOfCodeLength) \
-    macro(builtinConstructorFromCode, from, s_builtinConstructorFromCodeLength) \
+    macro(builtinConstructorOfCode, of, static_cast<const char*>(nullptr), s_builtinConstructorOfCodeLength) \
+    macro(builtinConstructorFromCode, from, static_cast<const char*>(nullptr), s_builtinConstructorFromCodeLength) \
 
 #define JSC_FOREACH_BUILTINCONSTRUCTOR_BUILTIN_FUNCTION_NAME(macro) \
     macro(from) \
     macro(of) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTINCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -105,6 +105,7 @@ JSC_FOREACH_BUILTINCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "VM.h"
@@ -185,7 +186,7 @@ const char* s_builtinConstructorFromCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 8cbb539..b3006b8 100644 (file)
@@ -53,15 +53,15 @@ extern const JSC::ConstructAbility s_internalClashingNamesIsReadableStreamLocked
     macro(isReadableStreamLocked, internalClashingNamesIsReadableStreamLocked, 1) \
 
 #define JSC_FOREACH_BUILTIN_CODE(macro) \
-    macro(internalClashingNamesIsReadableStreamLockedCode, isReadableStreamLocked, s_internalClashingNamesIsReadableStreamLockedCodeLength) \
-    macro(internalClashingNamesIsReadableStreamLockedCode, isReadableStreamLocked, s_internalClashingNamesIsReadableStreamLockedCodeLength) \
+    macro(internalClashingNamesIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_internalClashingNamesIsReadableStreamLockedCodeLength) \
+    macro(internalClashingNamesIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_internalClashingNamesIsReadableStreamLockedCodeLength) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \
     macro(isReadableStreamLocked) \
 
 #define JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -106,6 +106,7 @@ JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
 
 #include "BuiltinExecutables.h"
 #include "HeapInlines.h"
+#include "IdentifierInlines.h"
 #include "Intrinsic.h"
 #include "JSCellInlines.h"
 #include "UnlinkedFunctionExecutable.h"
@@ -136,7 +137,7 @@ const char* s_internalClashingNamesIsReadableStreamLockedCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); }
index 4ccc65c..8d8fcab 100644 (file)
@@ -54,12 +54,12 @@ extern const JSC::ConstructAbility s_anotherGuardedInternalBuiltinLetsFetchCodeC
 #define WEBCORE_BUILTIN_ANOTHERGUARDEDINTERNALBUILTIN_LETSFETCH 1
 
 #define WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(macro) \
-    macro(anotherGuardedInternalBuiltinLetsFetchCode, letsFetch, s_anotherGuardedInternalBuiltinLetsFetchCodeLength) \
+    macro(anotherGuardedInternalBuiltinLetsFetchCode, letsFetch, static_cast<const char*>(nullptr), s_anotherGuardedInternalBuiltinLetsFetchCodeLength) \
 
 #define WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(macro) \
     macro(letsFetch) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -70,13 +70,13 @@ public:
     explicit AnotherGuardedInternalBuiltinBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -91,7 +91,7 @@ private:
 
     WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -99,11 +99,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* AnotherGuardedInternalBuiltinBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -134,8 +138,8 @@ public:
 
 inline void AnotherGuardedInternalBuiltinBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
 {
-#define EXPORT_FUNCTION(codeName, functionName, length)\
-    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::createBuiltinFunction(m_vm, codeName##Generator(m_vm), &globalObject));
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
     WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(EXPORT_FUNCTION)
 #undef EXPORT_FUNCTION
 }
@@ -190,6 +194,7 @@ inline void AnotherGuardedInternalBuiltinBuiltinFunctions::visit(JSC::SlotVisito
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -210,7 +215,7 @@ const char* s_anotherGuardedInternalBuiltinLetsFetchCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index e626d67..eadd07a 100644 (file)
@@ -55,12 +55,12 @@ extern const JSC::ConstructAbility s_arbitraryConditionalGuardIsReadableStreamLo
 #define WEBCORE_BUILTIN_ARBITRARYCONDITIONALGUARD_ISREADABLESTREAMLOCKED 1
 
 #define WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(macro) \
-    macro(arbitraryConditionalGuardIsReadableStreamLockedCode, isReadableStreamLocked, s_arbitraryConditionalGuardIsReadableStreamLockedCodeLength) \
+    macro(arbitraryConditionalGuardIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_arbitraryConditionalGuardIsReadableStreamLockedCodeLength) \
 
 #define WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_FUNCTION_NAME(macro) \
     macro(isReadableStreamLocked) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -71,13 +71,13 @@ public:
     explicit ArbitraryConditionalGuardBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -92,7 +92,7 @@ private:
 
     WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -100,11 +100,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* ArbitraryConditionalGuardBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -160,6 +164,7 @@ inline void ArbitraryConditionalGuardBuiltinsWrapper::exportNames()
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -180,7 +185,7 @@ const char* s_arbitraryConditionalGuardIsReadableStreamLockedCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index 0747487..435644a 100644 (file)
@@ -55,12 +55,12 @@ extern const JSC::ConstructAbility s_guardedBuiltinIsReadableStreamLockedCodeCon
 #define WEBCORE_BUILTIN_GUARDEDBUILTIN_ISREADABLESTREAMLOCKED 1
 
 #define WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(macro) \
-    macro(guardedBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, s_guardedBuiltinIsReadableStreamLockedCodeLength) \
+    macro(guardedBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_guardedBuiltinIsReadableStreamLockedCodeLength) \
 
 #define WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(macro) \
     macro(isReadableStreamLocked) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -71,13 +71,13 @@ public:
     explicit GuardedBuiltinBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -92,7 +92,7 @@ private:
 
     WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -100,11 +100,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* GuardedBuiltinBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -160,6 +164,7 @@ inline void GuardedBuiltinBuiltinsWrapper::exportNames()
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -180,7 +185,7 @@ const char* s_guardedBuiltinIsReadableStreamLockedCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index 9d83dee..ec509e8 100644 (file)
@@ -55,12 +55,12 @@ extern const JSC::ConstructAbility s_guardedInternalBuiltinIsReadableStreamLocke
 #define WEBCORE_BUILTIN_GUARDEDINTERNALBUILTIN_ISREADABLESTREAMLOCKED 1
 
 #define WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(macro) \
-    macro(guardedInternalBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, s_guardedInternalBuiltinIsReadableStreamLockedCodeLength) \
+    macro(guardedInternalBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_guardedInternalBuiltinIsReadableStreamLockedCodeLength) \
 
 #define WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(macro) \
     macro(isReadableStreamLocked) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -71,13 +71,13 @@ public:
     explicit GuardedInternalBuiltinBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -92,7 +92,7 @@ private:
 
     WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -100,11 +100,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* GuardedInternalBuiltinBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -135,8 +139,8 @@ public:
 
 inline void GuardedInternalBuiltinBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
 {
-#define EXPORT_FUNCTION(codeName, functionName, length)\
-    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::createBuiltinFunction(m_vm, codeName##Generator(m_vm), &globalObject));
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
     WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(EXPORT_FUNCTION)
 #undef EXPORT_FUNCTION
 }
@@ -192,6 +196,7 @@ inline void GuardedInternalBuiltinBuiltinFunctions::visit(JSC::SlotVisitor& visi
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -212,7 +217,7 @@ const char* s_guardedInternalBuiltinIsReadableStreamLockedCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index 0352b8c..44fa4c0 100644 (file)
@@ -53,12 +53,12 @@ extern const JSC::ConstructAbility s_unguardedBuiltinIsReadableStreamLockedCodeC
 #define WEBCORE_BUILTIN_UNGUARDEDBUILTIN_ISREADABLESTREAMLOCKED 1
 
 #define WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(macro) \
-    macro(unguardedBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, s_unguardedBuiltinIsReadableStreamLockedCodeLength) \
+    macro(unguardedBuiltinIsReadableStreamLockedCode, isReadableStreamLocked, static_cast<const char*>(nullptr), s_unguardedBuiltinIsReadableStreamLockedCodeLength) \
 
 #define WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(macro) \
     macro(isReadableStreamLocked) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -69,13 +69,13 @@ public:
     explicit UnguardedBuiltinBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -90,7 +90,7 @@ private:
 
     WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -98,11 +98,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* UnguardedBuiltinBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -154,6 +158,7 @@ inline void UnguardedBuiltinBuiltinsWrapper::exportNames()
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -174,7 +179,7 @@ const char* s_unguardedBuiltinIsReadableStreamLockedCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index 7846ee8..4da78b3 100644 (file)
@@ -65,16 +65,16 @@ extern const JSC::ConstructAbility s_xmlCasingTestUrlCasingTestCodeConstructAbil
 #define WEBCORE_BUILTIN_XMLCASINGTEST_URLCASINGTEST 1
 
 #define WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(macro) \
-    macro(xmlCasingTestXMLCasingTestCode, xmlCasingTest, s_xmlCasingTestXMLCasingTestCodeLength) \
-    macro(xmlCasingTestCssCasingTestCode, cssCasingTest, s_xmlCasingTestCssCasingTestCodeLength) \
-    macro(xmlCasingTestUrlCasingTestCode, urlCasingTest, s_xmlCasingTestUrlCasingTestCodeLength) \
+    macro(xmlCasingTestXMLCasingTestCode, xmlCasingTest, static_cast<const char*>(nullptr), s_xmlCasingTestXMLCasingTestCodeLength) \
+    macro(xmlCasingTestCssCasingTestCode, cssCasingTest, static_cast<const char*>(nullptr), s_xmlCasingTestCssCasingTestCodeLength) \
+    macro(xmlCasingTestUrlCasingTestCode, urlCasingTest, static_cast<const char*>(nullptr), s_xmlCasingTestUrlCasingTestCodeLength) \
 
 #define WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_FUNCTION_NAME(macro) \
     macro(cssCasingTest) \
     macro(urlCasingTest) \
     macro(xmlCasingTest) \
 
-#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
 
 WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
@@ -85,13 +85,13 @@ public:
     explicit xmlCasingTestBuiltinsWrapper(JSC::VM* vm)
         : m_vm(*vm)
         WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
         WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
     {
     }
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
     JSC::UnlinkedFunctionExecutable* name##Executable(); \
     const JSC::SourceCode& name##Source() const { return m_##name##Source; }
     WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
@@ -106,7 +106,7 @@ private:
 
     WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) \
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
     JSC::SourceCode m_##name##Source;\
     JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
     WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
@@ -114,11 +114,15 @@ private:
 
 };
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 inline JSC::UnlinkedFunctionExecutable* xmlCasingTestBuiltinsWrapper::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        JSC::Identifier executableName = functionName##PublicName();\
+        if (overriddenName)\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
@@ -149,8 +153,8 @@ public:
 
 inline void xmlCasingTestBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
 {
-#define EXPORT_FUNCTION(codeName, functionName, length)\
-    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::createBuiltinFunction(m_vm, codeName##Generator(m_vm), &globalObject));
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
     WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(EXPORT_FUNCTION)
 #undef EXPORT_FUNCTION
 }
@@ -206,6 +210,7 @@ inline void xmlCasingTestBuiltinFunctions::visit(JSC::SlotVisitor& visitor)
 
 #include "WebCoreJSClientData.h"
 #include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
 #include <runtime/Intrinsic.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
@@ -263,7 +268,7 @@ const char* s_xmlCasingTestUrlCasingTestCode =
 ;
 
 
-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
 {\
     JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
index 12cca5d..114fc74 100644 (file)
@@ -23,6 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+@overriddenName="[Symbol.asyncIterator]"
 function symbolAsyncIteratorGetter()
 {
     "use strict";
index 9e0d461..ad0d839 100644 (file)
@@ -36,7 +36,7 @@ namespace JSC {
 
 BuiltinExecutables::BuiltinExecutables(VM& vm)
     : m_vm(vm)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overrideName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
     JSC_FOREACH_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
 #undef EXPOSE_BUILTIN_STRINGS
 {
@@ -114,11 +114,15 @@ void BuiltinExecutables::finalize(Handle<Unknown>, void* context)
     static_cast<Weak<UnlinkedFunctionExecutable>*>(context)->clear();
 }
 
-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overrideName, length) \
 UnlinkedFunctionExecutable* BuiltinExecutables::name##Executable() \
 {\
-    if (!m_##name##Executable)\
-        m_##name##Executable = Weak<UnlinkedFunctionExecutable>(createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\
+    if (!m_##name##Executable) {\
+        Identifier executableName = m_vm.propertyNames->builtinNames().functionName##PublicName();\
+        if (overrideName)\
+            executableName = Identifier::fromString(&m_vm, overrideName);\
+        m_##name##Executable = Weak<UnlinkedFunctionExecutable>(createBuiltinExecutable(m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\
+    }\
     return m_##name##Executable.get();\
 }
 JSC_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
index ee0eaad..368a31b 100644 (file)
@@ -42,7 +42,7 @@ class BuiltinExecutables final: private WeakHandleOwner {
 public:
     explicit BuiltinExecutables(VM&);
 
-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
 UnlinkedFunctionExecutable* name##Executable(); \
 const SourceCode& name##Source() { return m_##name##Source; }
     
@@ -59,7 +59,7 @@ private:
 
     UnlinkedFunctionExecutable* createBuiltinExecutable(const SourceCode&, const Identifier&, ConstructAbility);
 
-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length)\
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length)\
     SourceCode m_##name##Source; \
     Weak<UnlinkedFunctionExecutable> m_##name##Executable;
     JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
index f1ee867..e40a696 100644 (file)
@@ -42,7 +42,7 @@ function apply(thisValue, argumentValues)
     return this.@apply(thisValue, argumentValues);
 }
 
-// FIXME: this should have a different name: https://bugs.webkit.org/show_bug.cgi?id=151363
+@overriddenName="[Symbol.hasInstance]"
 function symbolHasInstance(value)
 {
     "use strict";
index 72011f5..43c6fa1 100644 (file)
@@ -57,9 +57,9 @@ function isDictionary(object)
     return object == null || typeof object === "object";
 }
 
-// FIXME: this needs to have it's name changed to "get [Symbol.species]".
-// see: https://bugs.webkit.org/show_bug.cgi?id=151363
 @globalPrivate
+@getter
+@overriddenName="get [Symbol.species]"
 function speciesGetter()
 {
     return this;
index 5c1691a..f5f33ad 100644 (file)
@@ -23,6 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+@overriddenName="[Symbol.iterator]"
 function symbolIteratorGetter()
 {
     "use strict";
index 60a728b..604cce2 100644 (file)
@@ -79,6 +79,7 @@ function hasObservableSideEffectsForRegExpMatch(regexp) {
     return !@isRegExpObject(regexp);
 }
 
+@overriddenName="[Symbol.match]"
 function match(strArg)
 {
     "use strict";
@@ -130,6 +131,7 @@ function match(strArg)
     }
 }
 
+@overriddenName="[Symbol.replace]"
 function replace(strArg, replace)
 {
     "use strict";
@@ -297,6 +299,7 @@ function replace(strArg, replace)
 }
 
 // 21.2.5.9 RegExp.prototype[@@search] (string)
+@overriddenName="[Symbol.search]"
 function search(strArg)
 {
     "use strict";
@@ -380,6 +383,7 @@ function hasObservableSideEffectsForRegExpSplit(regexp) {
 }
 
 // ES 21.2.5.11 RegExp.prototype[@@split](string, limit)
+@overriddenName="[Symbol.split]"
 function split(string, limit)
 {
     "use strict";
index 52f1dc6..56fda57 100644 (file)
@@ -3046,7 +3046,7 @@ EncodedJSValue JSC_HOST_CALL functionCreateBuiltin(ExecState* exec)
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     const SourceCode& source = makeSource(functionText, { });
-    JSFunction* func = JSFunction::createBuiltinFunction(vm, createBuiltinExecutable(vm, source, Identifier::fromString(&vm, "foo"), ConstructorKind::None, ConstructAbility::CannotConstruct)->link(vm, source), exec->lexicalGlobalObject());
+    JSFunction* func = JSFunction::create(vm, createBuiltinExecutable(vm, source, Identifier::fromString(&vm, "foo"), ConstructorKind::None, ConstructAbility::CannotConstruct)->link(vm, source), exec->lexicalGlobalObject());
 
     return JSValue::encode(func);
 }
index 5427780..3beda47 100644 (file)
@@ -41,7 +41,7 @@ void AsyncIteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject
     ASSERT(inherits(vm, info()));
     vm.prototypeMap.addPrototype(this);
 
-    JSFunction* asyncIteratorPrototypeFunction = JSFunction::createBuiltinFunction(vm, asyncIteratorPrototypeSymbolAsyncIteratorGetterCodeGenerator(vm), globalObject, "[Symbol.asyncIterator]");
+    JSFunction* asyncIteratorPrototypeFunction = JSFunction::create(vm, asyncIteratorPrototypeSymbolAsyncIteratorGetterCodeGenerator(vm), globalObject);
     putDirectWithoutTransition(vm, vm.propertyNames->asyncIteratorSymbol, asyncIteratorPrototypeFunction, DontEnum);
 }
 
index 42f194e..37c0b47 100644 (file)
@@ -65,7 +65,7 @@ void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* g
     *callFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().callPublicName(), functionPrototypeCallCodeGenerator(vm), DontEnum);
     putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->bind, functionPrototypeBindCodeGenerator(vm), DontEnum);
 
-    *hasInstanceSymbolFunction = JSFunction::createBuiltinFunction(vm, functionPrototypeSymbolHasInstanceCodeGenerator(vm), globalObject, ASCIILiteral("[Symbol.hasInstance]"));
+    *hasInstanceSymbolFunction = JSFunction::create(vm, functionPrototypeSymbolHasInstanceCodeGenerator(vm), globalObject);
     putDirectWithoutTransition(vm, vm.propertyNames->hasInstanceSymbol, *hasInstanceSymbolFunction, DontDelete | ReadOnly | DontEnum);
 }
     
index f2981ca..0ecebff 100644 (file)
@@ -41,8 +41,7 @@ void IteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     ASSERT(inherits(vm, info()));
     vm.prototypeMap.addPrototype(this);
 
-    JSFunction* iteratorPrototypeFunction = JSFunction::createBuiltinFunction(vm, iteratorPrototypeSymbolIteratorGetterCodeGenerator(vm), globalObject, "[Symbol.iterator]");
-    putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, iteratorPrototypeFunction, DontEnum);
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->iteratorSymbol, iteratorPrototypeSymbolIteratorGetterCodeGenerator, DontEnum);
 }
 
 } // namespace JSC
index 8119cd6..08150c2 100644 (file)
@@ -102,20 +102,6 @@ void JSFunction::finishCreation(VM& vm, NativeExecutable* executable, int length
     putDirect(vm, vm.propertyNames->length, jsNumber(length), ReadOnly | DontEnum);
 }
 
-JSFunction* JSFunction::createBuiltinFunction(VM& vm, FunctionExecutable* executable, JSGlobalObject* globalObject)
-{
-    JSFunction* function = create(vm, executable, globalObject);
-    function->putDirect(vm, vm.propertyNames->name, jsString(&vm, executable->name().string()), ReadOnly | DontEnum);
-    return function;
-}
-
-JSFunction* JSFunction::createBuiltinFunction(VM& vm, FunctionExecutable* executable, JSGlobalObject* globalObject, const String& name)
-{
-    JSFunction* function = create(vm, executable, globalObject);
-    function->putDirect(vm, vm.propertyNames->name, jsString(&vm, name), ReadOnly | DontEnum);
-    return function;
-}
-
 FunctionRareData* JSFunction::allocateRareData(VM& vm)
 {
     ASSERT(!m_rareData);
@@ -420,7 +406,7 @@ void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec,
         } else {
             if (thisObject->isBuiltinFunction() && !thisObject->hasReifiedLength())
                 propertyNames.add(vm.propertyNames->length);
-            if (thisObject->inherits(vm, JSBoundFunction::info()) && !thisObject->hasReifiedName())
+            if ((thisObject->isBuiltinFunction() || thisObject->inherits(vm, JSBoundFunction::info())) && !thisObject->hasReifiedName())
                 propertyNames.add(vm.propertyNames->name);
         }
     }
@@ -726,7 +712,9 @@ JSFunction::LazyPropertyType JSFunction::reifyLazyBoundNameIfNeeded(VM& vm, Exec
     if (hasReifiedName())
         return LazyPropertyType::IsLazyProperty;
 
-    if (this->inherits(vm, JSBoundFunction::info())) {
+    if (isBuiltinFunction())
+        reifyName(vm, exec);
+    else if (this->inherits(vm, JSBoundFunction::info())) {
         FunctionRareData* rareData = this->rareData(vm);
         String name = makeString("bound ", static_cast<NativeExecutable*>(m_executable.get())->name());
         unsigned initialAttributes = DontEnum | ReadOnly;
index 8c85730..4423c30 100644 (file)
@@ -74,12 +74,9 @@ public:
     
     static JSFunction* createWithInvalidatedReallocationWatchpoint(VM&, FunctionExecutable*, JSScope*);
 
-    static JSFunction* create(VM&, FunctionExecutable*, JSScope*);
+    JS_EXPORT_PRIVATE static JSFunction* create(VM&, FunctionExecutable*, JSScope*);
     static JSFunction* create(VM&, FunctionExecutable*, JSScope*, Structure*);
 
-    JS_EXPORT_PRIVATE static JSFunction* createBuiltinFunction(VM&, FunctionExecutable*, JSGlobalObject*);
-    static JSFunction* createBuiltinFunction(VM&, FunctionExecutable*, JSGlobalObject*, const String& name);
-
     JS_EXPORT_PRIVATE String name(VM&);
     JS_EXPORT_PRIVATE String displayName(VM&);
     const String calculatedDisplayName(VM&);
index 33097a9..f916a46 100644 (file)
@@ -416,24 +416,24 @@ void JSGlobalObject::init(VM& vm)
         });
     m_arrayProtoValuesFunction.initLater(
         [] (const Initializer<JSFunction>& init) {
-            init.set(JSFunction::createBuiltinFunction(init.vm, arrayPrototypeValuesCodeGenerator(init.vm), init.owner));
+            init.set(JSFunction::create(init.vm, arrayPrototypeValuesCodeGenerator(init.vm), init.owner));
         });
     m_initializePromiseFunction.initLater(
         [] (const Initializer<JSFunction>& init) {
-            init.set(JSFunction::createBuiltinFunction(init.vm, promiseOperationsInitializePromiseCodeGenerator(init.vm), init.owner));
+            init.set(JSFunction::create(init.vm, promiseOperationsInitializePromiseCodeGenerator(init.vm), init.owner));
         });
 
     m_iteratorProtocolFunction.initLater(
         [] (const Initializer<JSFunction>& init) {
-            init.set(JSFunction::createBuiltinFunction(init.vm, iteratorHelpersPerformIterationCodeGenerator(init.vm), init.owner));
+            init.set(JSFunction::create(init.vm, iteratorHelpersPerformIterationCodeGenerator(init.vm), init.owner));
         });
 
     m_promiseResolveFunction.initLater(
         [] (const Initializer<JSFunction>& init) {
-            init.set(JSFunction::createBuiltinFunction(init.vm, promiseConstructorResolveCodeGenerator(init.vm), init.owner));
+            init.set(JSFunction::create(init.vm, promiseConstructorResolveCodeGenerator(init.vm), init.owner));
         });
 
-    m_newPromiseCapabilityFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
+    m_newPromiseCapabilityFunction.set(vm, this, JSFunction::create(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
     m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
     m_throwTypeErrorGetterSetter.initLater(
         [] (const Initializer<GetterSetter>& init) {
@@ -464,7 +464,7 @@ void JSGlobalObject::init(VM& vm)
     m_functionPrototype->initRestrictedProperties(exec, this);
 
     m_speciesGetterSetter.set(vm, this, GetterSetter::create(vm, this));
-    m_speciesGetterSetter->setGetter(vm, this, JSFunction::createBuiltinFunction(vm, globalOperationsSpeciesGetterCodeGenerator(vm), this, "get [Symbol.species]"));
+    m_speciesGetterSetter->setGetter(vm, this, JSFunction::create(vm, globalOperationsSpeciesGetterCodeGenerator(vm), this));
 
     m_typedArrayProto.initLater(
         [] (const Initializer<JSTypedArrayViewPrototype>& init) {
@@ -779,7 +779,7 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
     JSObject* regExpSymbolReplace = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol).asCell());
     m_regExpProtoSymbolReplace.set(vm, this, regExpSymbolReplace);
 
-#define CREATE_PRIVATE_GLOBAL_FUNCTION(name, code) JSFunction* name ## PrivateFunction = JSFunction::createBuiltinFunction(vm, code ## CodeGenerator(vm), this);
+#define CREATE_PRIVATE_GLOBAL_FUNCTION(name, code) JSFunction* name ## PrivateFunction = JSFunction::create(vm, code ## CodeGenerator(vm), this);
     JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(CREATE_PRIVATE_GLOBAL_FUNCTION)
 #undef CREATE_PRIVATE_GLOBAL_FUNCTION
 
index 1a33e87..031c0c6 100644 (file)
@@ -2969,14 +2969,14 @@ JSFunction* JSObject::putDirectBuiltinFunction(VM& vm, JSGlobalObject* globalObj
     if (!name)
         name = vm.propertyNames->anonymous.impl();
     ASSERT(name);
-    JSFunction* function = JSFunction::createBuiltinFunction(vm, static_cast<FunctionExecutable*>(functionExecutable), globalObject);
+    JSFunction* function = JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), globalObject);
     putDirect(vm, propertyName, function, attributes);
     return function;
 }
 
 JSFunction* JSObject::putDirectBuiltinFunctionWithoutTransition(VM& vm, JSGlobalObject* globalObject, const PropertyName& propertyName, FunctionExecutable* functionExecutable, unsigned attributes)
 {
-    JSFunction* function = JSFunction::createBuiltinFunction(vm, static_cast<FunctionExecutable*>(functionExecutable), globalObject);
+    JSFunction* function = JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), globalObject);
     putDirectWithoutTransition(vm, propertyName, function, attributes);
     return function;
 }
index 3d8970e..59ea647 100644 (file)
@@ -330,7 +330,7 @@ void JSTypedArrayViewPrototype::finishCreation(VM& vm, JSGlobalObject* globalObj
     toStringTagAccessor->setGetter(vm, globalObject, toStringTagFunction);
     putDirectNonIndexAccessor(vm, vm.propertyNames->toStringTagSymbol, toStringTagAccessor, DontEnum | ReadOnly | Accessor);
 
-    JSFunction* valuesFunction = JSFunction::createBuiltinFunction(vm, typedArrayPrototypeValuesCodeGenerator(vm), globalObject);
+    JSFunction* valuesFunction = JSFunction::create(vm, typedArrayPrototypeValuesCodeGenerator(vm), globalObject);
 
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), valuesFunction, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, valuesFunction, DontEnum);
index 3005abb..862f63c 100644 (file)
@@ -31,12 +31,16 @@ void reifyStaticAccessor(VM& vm, const HashTableValue& value, JSObject& thisObje
     JSGlobalObject* globalObject = thisObject.globalObject();
     GetterSetter* accessor = GetterSetter::create(vm, globalObject);
     if (value.accessorGetter()) {
-        String getterName = tryMakeString(ASCIILiteral("get "), String(*propertyName.publicName()));
-        if (!getterName)
-            return;
-        accessor->setGetter(vm, globalObject, value.attributes() & Builtin
-            ? JSFunction::createBuiltinFunction(vm, value.builtinAccessorGetterGenerator()(vm), globalObject, getterName)
-            : JSFunction::create(vm, globalObject, 0, getterName, value.accessorGetter()));
+        JSFunction* function = nullptr;
+        if (value.attributes() & Builtin)
+            function = JSFunction::create(vm, value.builtinAccessorGetterGenerator()(vm), globalObject);
+        else {
+            String getterName = tryMakeString(ASCIILiteral("get "), String(*propertyName.publicName()));
+            if (!getterName)
+                return;
+            function = JSFunction::create(vm, globalObject, 0, getterName, value.accessorGetter());
+        }
+        accessor->setGetter(vm, globalObject, function);
     }
     thisObject.putDirectNonIndexAccessor(vm, propertyName, accessor, attributesForStructure(value.attributes()));
 }
index ec2d702..2dc104b 100644 (file)
@@ -71,7 +71,7 @@ void MapPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().getPrivateName(), mapProtoFuncGet, DontEnum, 1, JSMapGetIntrinsic);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().setPrivateName(), mapProtoFuncSet, DontEnum, 2);
 
-    JSFunction* entries = JSFunction::createBuiltinFunction(vm, mapPrototypeEntriesCodeGenerator(vm), globalObject);
+    JSFunction* entries = JSFunction::create(vm, mapPrototypeEntriesCodeGenerator(vm), globalObject);
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().entriesPublicName(), entries, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, entries, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map"), DontEnum | ReadOnly);
index 146c255..6c5d19b 100644 (file)
@@ -78,16 +78,10 @@ void RegExpPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     JSC_NATIVE_GETTER(vm.propertyNames->unicode, regExpProtoGetterUnicode, DontEnum | Accessor);
     JSC_NATIVE_GETTER(vm.propertyNames->source, regExpProtoGetterSource, DontEnum | Accessor);
     JSC_NATIVE_GETTER(vm.propertyNames->flags, regExpProtoGetterFlags, DontEnum | Accessor);
-
-    JSFunction* matchFunction = JSFunction::createBuiltinFunction(vm, regExpPrototypeMatchCodeGenerator(vm), globalObject, ASCIILiteral("[Symbol.match]"));
-    putDirectWithoutTransition(vm, vm.propertyNames->matchSymbol, matchFunction, DontEnum);
-    JSFunction* replaceFunction = JSFunction::createBuiltinFunction(vm, regExpPrototypeReplaceCodeGenerator(vm), globalObject, ASCIILiteral("[Symbol.replace]"));
-    putDirectWithoutTransition(vm, vm.propertyNames->replaceSymbol, replaceFunction, DontEnum);
-    JSFunction* searchFunction = JSFunction::createBuiltinFunction(vm, regExpPrototypeSearchCodeGenerator(vm), globalObject, ASCIILiteral("[Symbol.search]"));
-    putDirectWithoutTransition(vm, vm.propertyNames->searchSymbol, searchFunction, DontEnum);
-    JSFunction* splitFunction = JSFunction::createBuiltinFunction(vm, regExpPrototypeSplitCodeGenerator(vm), globalObject, ASCIILiteral("[Symbol.split]"));
-    putDirectWithoutTransition(vm, vm.propertyNames->splitSymbol, splitFunction, DontEnum);
-
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->matchSymbol, regExpPrototypeMatchCodeGenerator, DontEnum);
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->replaceSymbol, regExpPrototypeReplaceCodeGenerator, DontEnum);
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->searchSymbol, regExpPrototypeSearchCodeGenerator, DontEnum);
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->splitSymbol, regExpPrototypeSplitCodeGenerator, DontEnum);
     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->test, regExpPrototypeTestCodeGenerator, DontEnum);
 
     m_emptyRegExp.set(vm, this, RegExp::create(vm, "", NoFlags));
index ace9adf..3b20ed1 100644 (file)
@@ -68,7 +68,7 @@ void SetPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().hasPrivateName(), setProtoFuncHas, DontEnum, 1, JSSetHasIntrinsic);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().addPrivateName(), setProtoFuncAdd, DontEnum, 1);
 
-    JSFunction* values = JSFunction::createBuiltinFunction(vm, setPrototypeValuesCodeGenerator(vm), globalObject);
+    JSFunction* values = JSFunction::create(vm, setPrototypeValuesCodeGenerator(vm), globalObject);
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), values, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().keysPublicName(), values, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, values, DontEnum);
index 915133a..14b105d 100644 (file)
@@ -1,3 +1,35 @@
+2017-08-29  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Use reifying system for "name" property of builtin JSFunction
+        https://bugs.webkit.org/show_bug.cgi?id=175260
+
+        Reviewed by Saam Barati.
+
+        Use @getter for JSBuiltin getters.
+
+        * Modules/fetch/FetchResponse.js:
+        (bodyUsed): Deleted.
+        (body): Deleted.
+        * Modules/streams/ReadableByteStreamController.js:
+        (byobRequest): Deleted.
+        (desiredSize): Deleted.
+        * Modules/streams/ReadableStream.js:
+        (locked): Deleted.
+        * Modules/streams/ReadableStreamBYOBReader.js:
+        (closed): Deleted.
+        * Modules/streams/ReadableStreamBYOBRequest.js:
+        (view): Deleted.
+        * Modules/streams/ReadableStreamDefaultController.js:
+        (desiredSize): Deleted.
+        * Modules/streams/ReadableStreamDefaultReader.js:
+        (closed): Deleted.
+        * Modules/streams/WritableStream.js:
+        (closed): Deleted.
+        (ready): Deleted.
+        (state): Deleted.
+        * bindings/js/JSDOMBuiltinConstructor.h:
+        (WebCore::JSDOMBuiltinConstructor<JSClass>::finishCreation):
+
 2017-08-29  Andy Estes  <aestes@apple.com>
 
         REGRESSION (r215290): "Where From" metadata is empty when dragging an image out of Safari
index f6711ed..2341f0e 100644 (file)
@@ -59,6 +59,7 @@ function initializeFetchResponse(body, init)
     return this;
 }
 
+@getter
 function bodyUsed()
 {
    if (!(this instanceof @Response))
@@ -70,6 +71,7 @@ function bodyUsed()
     return @Response.prototype.@isDisturbed.@call(this);
 }
 
+@getter
 function body()
 {
     if (!(this instanceof @Response))
index 1b68a04..4c3b25e 100644 (file)
@@ -76,6 +76,7 @@ function close()
     @readableByteStreamControllerClose(this);
 }
 
+@getter
 function byobRequest()
 {
     "use strict";
@@ -94,6 +95,7 @@ function byobRequest()
     return this.@byobRequest;
 }
 
+@getter
 function desiredSize()
 {
     "use strict";
index 4b2b282..23de7e0 100644 (file)
@@ -216,6 +216,7 @@ function tee()
     return @readableStreamTee(this, false);
 }
 
+@getter
 function locked()
 {
     "use strict";
index 777e576..3411002 100644 (file)
@@ -75,6 +75,7 @@ function releaseLock()
     @readableStreamReaderGenericRelease(this);
 }
 
+@getter
 function closed()
 {
     "use strict";
index 7cf06fb..71099a0 100644 (file)
@@ -57,6 +57,7 @@ function respondWithNewView(view)
     return @readableByteStreamControllerRespondWithNewView(this.@associatedReadableByteStreamController, view);
 }
 
+@getter
 function view()
 {
     "use strict";
index 38747e8..0df0af1 100644 (file)
@@ -70,6 +70,7 @@ function close()
     @readableStreamDefaultControllerClose(this);
 }
 
+@getter
 function desiredSize()
 {
     "use strict";
index abba088..2d73045 100644 (file)
@@ -66,6 +66,7 @@ function releaseLock()
     @readableStreamReaderGenericRelease(this);
 }
 
+@getter
 function closed()
 {
     "use strict";
index 233eb7c..348da12 100644 (file)
@@ -145,6 +145,7 @@ function write(chunk)
     return promiseCapability.@promise;
 }
 
+@getter
 function closed()
 {
     "use strict";
@@ -155,6 +156,7 @@ function closed()
     return this.@closedPromiseCapability.@promise;
 }
 
+@getter
 function ready()
 {
     "use strict";
@@ -165,6 +167,7 @@ function ready()
     return this.@readyPromiseCapability.@promise;
 }
 
+@getter
 function state()
 {
     "use strict";
index 74ee3a5..6ab5ec0 100644 (file)
@@ -72,7 +72,7 @@ template<typename JSClass> inline void JSDOMBuiltinConstructor<JSClass>::finishC
 {
     Base::finishCreation(vm);
     ASSERT(inherits(vm, info()));
-    setInitializeFunction(vm, *JSC::JSFunction::createBuiltinFunction(vm, initializeExecutable(vm), &globalObject));
+    setInitializeFunction(vm, *JSC::JSFunction::create(vm, initializeExecutable(vm), &globalObject));
     initializeProperties(vm, globalObject);
 }