Title: [232831] releases/WebKitGTK/webkit-2.20
Revision
232831
Author
[email protected]
Date
2018-06-13 23:09:13 -0700 (Wed, 13 Jun 2018)

Log Message

Merge r230662 - Function.prototype.caller shouldn't return generator bodies
https://bugs.webkit.org/show_bug.cgi?id=184630

Reviewed by Yusuke Suzuki.
JSTests:

* stress/function-caller-async-arrow-function-body.js: Added.
* stress/function-caller-async-function-body.js: Added.
* stress/function-caller-async-generator-body.js: Added.
* stress/function-caller-generator-body.js: Added.
* stress/function-caller-generator-method-body.js: Added.

Source/_javascript_Core:

Function.prototype.caller no longer returns generator bodies. Those are meant to be
private.

Also added some builtin debugging tools so that it's easier to do the investigation that I
did.

* builtins/BuiltinNames.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::callerGetter):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncBuiltinDescribe):
* runtime/JSGlobalObjectFunctions.h:

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/JSTests/ChangeLog (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/ChangeLog	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/JSTests/ChangeLog	2018-06-14 06:09:13 UTC (rev 232831)
@@ -1,3 +1,16 @@
+2018-04-14  Filip Pizlo  <[email protected]>
+
+        Function.prototype.caller shouldn't return generator bodies
+        https://bugs.webkit.org/show_bug.cgi?id=184630
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/function-caller-async-arrow-function-body.js: Added.
+        * stress/function-caller-async-function-body.js: Added.
+        * stress/function-caller-async-generator-body.js: Added.
+        * stress/function-caller-generator-body.js: Added.
+        * stress/function-caller-generator-method-body.js: Added.
+
 2018-04-08  Yusuke Suzuki  <[email protected]>
 
         [JSC] Introduce op_get_by_id_direct

Added: releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-arrow-function-body.js (0 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-arrow-function-body.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-arrow-function-body.js	2018-06-14 06:09:13 UTC (rev 232831)
@@ -0,0 +1,26 @@
+//@ runDefault
+
+(function thingy() {
+    function bar()
+    {
+        return bar.caller;
+    }
+    
+    var ok = false;
+    var badError = null;
+    var foo = async () => {
+        try {
+            bar();
+            ok = true;
+        } catch (e) {
+            if (e.toString() != "TypeError: Function.caller used to retrieve async function body")
+                badError = e;
+        }
+    }
+    
+    foo();
+    if (ok)
+        throw "Error: did not throw error";
+    if (badError)
+        throw "Bad error: " + badError;
+})();

Added: releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-function-body.js (0 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-function-body.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-function-body.js	2018-06-14 06:09:13 UTC (rev 232831)
@@ -0,0 +1,27 @@
+//@ runDefault
+
+(function thingy() {
+    function bar()
+    {
+        return bar.caller;
+    }
+    
+    var ok = false;
+    var badError = null;
+    async function foo()
+    {
+        try {
+            bar();
+            ok = true;
+        } catch (e) {
+            if (e.toString() != "TypeError: Function.caller used to retrieve async function body")
+                badError = e;
+        }
+    }
+    
+    foo();
+    if (ok)
+        throw "Error: did not throw error";
+    if (badError)
+        throw "Bad error: " + badError;
+})();

Added: releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-generator-body.js (0 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-generator-body.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-async-generator-body.js	2018-06-14 06:09:13 UTC (rev 232831)
@@ -0,0 +1,27 @@
+//@ runDefault
+
+(function thingy() {
+    function bar()
+    {
+        return bar.caller;
+    }
+    
+    var ok = false;
+    var badError = null;
+    async function* foo()
+    {
+        try {
+            bar();
+            ok = true;
+        } catch (e) {
+            if (e.toString() != "TypeError: Function.caller used to retrieve generator body")
+                badError = e;
+        }
+    }
+    
+    foo().next();
+    if (ok)
+        throw "Error: did not throw error";
+    if (badError)
+        throw "Bad error: " + badError;
+})();

Added: releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-body.js (0 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-body.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-body.js	2018-06-14 06:09:13 UTC (rev 232831)
@@ -0,0 +1,24 @@
+//@ runDefault
+
+(function thingy() {
+    function bar()
+    {
+        return bar.caller;
+    }
+    
+    function* foo()
+    {
+        bar();
+    }
+    
+    var ok = false;
+    try {
+        foo().next();
+        ok = true;
+    } catch (e) {
+        if (e.toString() != "TypeError: Function.caller used to retrieve generator body")
+            throw "Error: bad error: " + e;
+    }
+    if (ok)
+        throw "Error: did not throw error";
+})();

Added: releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-method-body.js (0 => 232831)


--- releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-method-body.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.20/JSTests/stress/function-caller-generator-method-body.js	2018-06-14 06:09:13 UTC (rev 232831)
@@ -0,0 +1,26 @@
+//@ runDefault
+
+(function thingy() {
+    function bar()
+    {
+        return bar.caller;
+    }
+    
+    class C {
+        *foo()
+        {
+            bar();
+        }
+    }
+        
+    var ok = false;
+    try {
+        new C().foo().next();
+        ok = true;
+    } catch (e) {
+        if (e.toString() != "TypeError: Function.caller used to retrieve generator body")
+            throw "Error: bad error: " + e;
+    }
+    if (ok)
+        throw "Error: did not throw error";
+})();

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/ChangeLog (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/ChangeLog	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/ChangeLog	2018-06-14 06:09:13 UTC (rev 232831)
@@ -1,3 +1,25 @@
+2018-04-14  Filip Pizlo  <[email protected]>
+
+        Function.prototype.caller shouldn't return generator bodies
+        https://bugs.webkit.org/show_bug.cgi?id=184630
+
+        Reviewed by Yusuke Suzuki.
+        
+        Function.prototype.caller no longer returns generator bodies. Those are meant to be
+        private.
+        
+        Also added some builtin debugging tools so that it's easier to do the investigation that I
+        did.
+
+        * builtins/BuiltinNames.h:
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::callerGetter):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::globalFuncBuiltinDescribe):
+        * runtime/JSGlobalObjectFunctions.h:
+
 2018-04-08  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, follow-up patch for DFG 32bit

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/builtins/BuiltinNames.h (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/builtins/BuiltinNames.h	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/builtins/BuiltinNames.h	2018-06-14 06:09:13 UTC (rev 232831)
@@ -83,6 +83,7 @@
     macro(typedArrayGetOriginalConstructor) \
     macro(typedArraySubarrayCreate) \
     macro(BuiltinLog) \
+    macro(BuiltinDescribe) \
     macro(homeObject) \
     macro(templateRegistryKey) \
     macro(enqueueJob) \

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSFunction.cpp (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSFunction.cpp	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSFunction.cpp	2018-06-14 06:09:13 UTC (rev 232831)
@@ -364,9 +364,34 @@
     // Firefox returns null for native code callers, so we match that behavior.
     if (function->isHostOrBuiltinFunction())
         return JSValue::encode(jsNull());
-    if (!function->jsExecutable()->isStrictMode())
-        return JSValue::encode(caller);
-    return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Function.caller used to retrieve strict caller")));
+    SourceParseMode parseMode = function->jsExecutable()->parseMode();
+    switch (parseMode) {
+    case SourceParseMode::GeneratorBodyMode:
+    case SourceParseMode::AsyncGeneratorBodyMode:
+        return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Function.caller used to retrieve generator body")));
+    case SourceParseMode::AsyncFunctionBodyMode:
+    case SourceParseMode::AsyncArrowFunctionBodyMode:
+        return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Function.caller used to retrieve async function body")));
+    case SourceParseMode::NormalFunctionMode:
+    case SourceParseMode::GeneratorWrapperFunctionMode:
+    case SourceParseMode::GetterMode:
+    case SourceParseMode::SetterMode:
+    case SourceParseMode::MethodMode:
+    case SourceParseMode::ArrowFunctionMode:
+    case SourceParseMode::AsyncFunctionMode:
+    case SourceParseMode::AsyncMethodMode:
+    case SourceParseMode::AsyncArrowFunctionMode:
+    case SourceParseMode::ProgramMode:
+    case SourceParseMode::ModuleAnalyzeMode:
+    case SourceParseMode::ModuleEvaluateMode:
+    case SourceParseMode::AsyncGeneratorWrapperFunctionMode:
+    case SourceParseMode::AsyncGeneratorWrapperMethodMode:
+    case SourceParseMode::GeneratorWrapperMethodMode:
+        if (!function->jsExecutable()->isStrictMode())
+            return JSValue::encode(caller);
+        return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Function.caller used to retrieve strict caller")));
+    }
+    RELEASE_ASSERT_NOT_REACHED();
 }
 
 bool JSFunction::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObject.cpp (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2018-06-14 06:09:13 UTC (rev 232831)
@@ -773,6 +773,7 @@
         putDirectWithoutTransition(vm, vm.propertyNames->Loader, m_moduleLoader.get(), static_cast<unsigned>(PropertyAttribute::DontEnum));
 
     JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
+    JSFunction* builtinDescribe = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinDescribe);
 
     JSFunction* privateFuncAbs = JSFunction::create(vm, this, 0, String(), mathProtoFuncAbs, AbsIntrinsic);
     JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
@@ -863,6 +864,7 @@
         GlobalPropertyInfo(vm.propertyNames->builtinNames().hasInstanceBoundFunctionPrivateName(), privateFuncHasInstanceBoundFunction, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->builtinNames().instanceOfPrivateName(), privateFuncInstanceOf, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->builtinNames().BuiltinLogPrivateName(), builtinLog, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
+        GlobalPropertyInfo(vm.propertyNames->builtinNames().BuiltinDescribePrivateName(), builtinDescribe, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberPrivateName(), numberConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->builtinNames().RegExpPrivateName(), m_regExpConstructor.get(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->builtinNames().StringPrivateName(), stringConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2018-06-14 06:09:13 UTC (rev 232831)
@@ -774,6 +774,11 @@
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL globalFuncBuiltinDescribe(ExecState* exec)
+{
+    return JSValue::encode(jsString(exec, toString(exec->argument(0))));
+}
+
 EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState* exec)
 {
     VM& vm = exec->vm();

Modified: releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.h (232830 => 232831)


--- releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.h	2018-06-14 04:56:47 UTC (rev 232830)
+++ releases/WebKitGTK/webkit-2.20/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.h	2018-06-14 06:09:13 UTC (rev 232831)
@@ -52,6 +52,7 @@
 EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
 EncodedJSValue JSC_HOST_CALL globalFuncHostPromiseRejectionTracker(ExecState*);
 EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
+EncodedJSValue JSC_HOST_CALL globalFuncBuiltinDescribe(ExecState*);
 EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState*);
 EncodedJSValue JSC_HOST_CALL globalFuncPropertyIsEnumerable(ExecState*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to