Placate exception check validation in genericTypedArrayViewProtoFuncLastIndexOf().
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 17:59:07 +0000 (17:59 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 17:59:07 +0000 (17:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196154
<rdar://problem/49145307>

Reviewed by Filip Pizlo.

JSTests:

Also added //@ runDefault constraint to web-assembly-link-error-exception-check.js.
There's no need to run this test on more than 1 test configuration.

* stress/typed-array-lastIndexOf-exception-check.js: Added.
* stress/web-assembly-link-error-exception-check.js:

Source/JavaScriptCore:

* runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::genericTypedArrayViewProtoFuncLastIndexOf):

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

JSTests/ChangeLog
JSTests/stress/typed-array-lastIndexOf-exception-check.js [new file with mode: 0644]
JSTests/stress/web-assembly-link-error-exception-check.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

index 099a21b..aeb8feb 100644 (file)
@@ -1,5 +1,19 @@
 2019-03-22  Mark Lam  <mark.lam@apple.com>
 
+        Placate exception check validation in genericTypedArrayViewProtoFuncLastIndexOf().
+        https://bugs.webkit.org/show_bug.cgi?id=196154
+        <rdar://problem/49145307>
+
+        Reviewed by Filip Pizlo.
+
+        Also added //@ runDefault constraint to web-assembly-link-error-exception-check.js.
+        There's no need to run this test on more than 1 test configuration.
+
+        * stress/typed-array-lastIndexOf-exception-check.js: Added.
+        * stress/web-assembly-link-error-exception-check.js:
+
+2019-03-22  Mark Lam  <mark.lam@apple.com>
+
         Placate exception check validation in constructJSWebAssemblyLinkError().
         https://bugs.webkit.org/show_bug.cgi?id=196152
         <rdar://problem/49145257>
diff --git a/JSTests/stress/typed-array-lastIndexOf-exception-check.js b/JSTests/stress/typed-array-lastIndexOf-exception-check.js
new file mode 100644 (file)
index 0000000..33ab51b
--- /dev/null
@@ -0,0 +1,5 @@
+//@ runDefault
+
+new Uint8Array().lastIndexOf(0, {
+    valueOf: () => -1
+});
index 4e8f6fc..cf4a394 100644 (file)
@@ -1,5 +1,16 @@
 2019-03-22  Mark Lam  <mark.lam@apple.com>
 
+        Placate exception check validation in genericTypedArrayViewProtoFuncLastIndexOf().
+        https://bugs.webkit.org/show_bug.cgi?id=196154
+        <rdar://problem/49145307>
+
+        Reviewed by Filip Pizlo.
+
+        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
+        (JSC::genericTypedArrayViewProtoFuncLastIndexOf):
+
+2019-03-22  Mark Lam  <mark.lam@apple.com>
+
         Placate exception check validation in constructJSWebAssemblyLinkError().
         https://bugs.webkit.org/show_bug.cgi?id=196152
         <rdar://problem/49145257>
index e549f3b..89a9717 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -317,6 +317,7 @@ EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncLastIndexOf(VM& vm, E
     if (exec->argumentCount() >= 2) {
         JSValue fromValue = exec->uncheckedArgument(1);
         double fromDouble = fromValue.toInteger(exec);
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
         if (fromDouble < 0) {
             fromDouble += length;
             if (fromDouble < 0)
@@ -326,8 +327,6 @@ EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncLastIndexOf(VM& vm, E
             index = static_cast<unsigned>(fromDouble);
     }
 
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
     if (thisObject->isNeutered())
         return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);