Title: [253264] trunk
- Revision
- 253264
- Author
- [email protected]
- Date
- 2019-12-07 14:57:17 -0800 (Sat, 07 Dec 2019)
Log Message
Object.prototype.isPrototypeOf() should check if the passed in value is a non-object first.
https://bugs.webkit.org/show_bug.cgi?id=204971
<rdar://problem/57730080>
Reviewed by Saam Barati.
JSTests:
* stress/object-prototype-isPrototypeOf-should-check-for-non-object-first.js: Added.
Source/_javascript_Core:
The spec says Object.prototype.isPrototypeOf() should do checks in the following
order:
1. If Type(V) is not Object, return false.
2. Let O be ? ToObject(this value).
...
We were previously checking (2) before (1). This patch fixes this order.
Ref: http://www.ecma-international.org/ecma-262/10.0/index.html#sec-object.prototype.isprototypeof
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncIsPrototypeOf):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (253263 => 253264)
--- trunk/JSTests/ChangeLog 2019-12-07 22:25:18 UTC (rev 253263)
+++ trunk/JSTests/ChangeLog 2019-12-07 22:57:17 UTC (rev 253264)
@@ -1,3 +1,13 @@
+2019-12-07 Mark Lam <[email protected]>
+
+ Object.prototype.isPrototypeOf() should check if the passed in value is a non-object first.
+ https://bugs.webkit.org/show_bug.cgi?id=204971
+ <rdar://problem/57730080>
+
+ Reviewed by Saam Barati.
+
+ * stress/object-prototype-isPrototypeOf-should-check-for-non-object-first.js: Added.
+
2019-12-06 Mark Lam <[email protected]>
The compiler thread should not adjust Identifier refCounts.
Added: trunk/JSTests/stress/object-prototype-isPrototypeOf-should-check-for-non-object-first.js (0 => 253264)
--- trunk/JSTests/stress/object-prototype-isPrototypeOf-should-check-for-non-object-first.js (rev 0)
+++ trunk/JSTests/stress/object-prototype-isPrototypeOf-should-check-for-non-object-first.js 2019-12-07 22:57:17 UTC (rev 253264)
@@ -0,0 +1,16 @@
+//@ runDefault
+
+var result;
+var exception = undefined;
+try {
+ result = Object.prototype.isPrototypeOf.call(null);
+} catch (e) {
+ exception = e;
+}
+
+if (typeof exception != "undefined")
+ throw "FAILED";
+if (typeof result != "boolean")
+ throw "FAILED";
+if (result != false)
+ throw "FAILED";
Modified: trunk/Source/_javascript_Core/ChangeLog (253263 => 253264)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-07 22:25:18 UTC (rev 253263)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-07 22:57:17 UTC (rev 253264)
@@ -1,3 +1,23 @@
+2019-12-07 Mark Lam <[email protected]>
+
+ Object.prototype.isPrototypeOf() should check if the passed in value is a non-object first.
+ https://bugs.webkit.org/show_bug.cgi?id=204971
+ <rdar://problem/57730080>
+
+ Reviewed by Saam Barati.
+
+ The spec says Object.prototype.isPrototypeOf() should do checks in the following
+ order:
+ 1. If Type(V) is not Object, return false.
+ 2. Let O be ? ToObject(this value).
+ ...
+ We were previously checking (2) before (1). This patch fixes this order.
+
+ Ref: http://www.ecma-international.org/ecma-262/10.0/index.html#sec-object.prototype.isprototypeof
+
+ * runtime/ObjectPrototype.cpp:
+ (JSC::objectProtoFuncIsPrototypeOf):
+
2019-12-07 Saam Barati <[email protected]>
Unreviewed. Roll out r253201. It was not a progression on any benchmarks, and was 8% slower on JetStream 2 ML.
Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (253263 => 253264)
--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2019-12-07 22:25:18 UTC (rev 253263)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2019-12-07 22:57:17 UTC (rev 253264)
@@ -121,6 +121,9 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
+ if (!callFrame->argument(0).isObject())
+ return JSValue::encode(jsBoolean(false));
+
JSValue thisValue = callFrame->thisValue().toThis(globalObject, StrictMode);
JSObject* thisObj = thisValue.toObject(globalObject);
EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
@@ -127,9 +130,6 @@
if (UNLIKELY(!thisObj))
return encodedJSValue();
- if (!callFrame->argument(0).isObject())
- return JSValue::encode(jsBoolean(false));
-
JSValue v = asObject(callFrame->argument(0))->getPrototype(vm, globalObject);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes