Title: [231688] trunk/Source/_javascript_Core
Revision
231688
Author
[email protected]
Date
2018-05-10 21:38:56 -0700 (Thu, 10 May 2018)

Log Message

[JSC] Make return types of construction functions tight
https://bugs.webkit.org/show_bug.cgi?id=185509

Reviewed by Saam Barati.

Array and Object construction functions should return strict types instead of returning JSObject*/JSValue.

* runtime/ArrayConstructor.cpp:
(JSC::constructArrayWithSizeQuirk):
* runtime/ArrayConstructor.h:
* runtime/ObjectConstructor.h:
(JSC::constructEmptyObject):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (231687 => 231688)


--- trunk/Source/_javascript_Core/ChangeLog	2018-05-11 03:38:10 UTC (rev 231687)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-05-11 04:38:56 UTC (rev 231688)
@@ -1,3 +1,18 @@
+2018-05-10  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Make return types of construction functions tight
+        https://bugs.webkit.org/show_bug.cgi?id=185509
+
+        Reviewed by Saam Barati.
+
+        Array and Object construction functions should return strict types instead of returning JSObject*/JSValue.
+
+        * runtime/ArrayConstructor.cpp:
+        (JSC::constructArrayWithSizeQuirk):
+        * runtime/ArrayConstructor.h:
+        * runtime/ObjectConstructor.h:
+        (JSC::constructEmptyObject):
+
 2018-05-09  Yusuke Suzuki  <[email protected]>
 
         [JSC] Object.assign for final objects should be faster

Modified: trunk/Source/_javascript_Core/runtime/ArrayConstructor.cpp (231687 => 231688)


--- trunk/Source/_javascript_Core/runtime/ArrayConstructor.cpp	2018-05-11 03:38:10 UTC (rev 231687)
+++ trunk/Source/_javascript_Core/runtime/ArrayConstructor.cpp	2018-05-11 04:38:56 UTC (rev 231688)
@@ -69,7 +69,7 @@
 
 // ------------------------------ Functions ---------------------------
 
-JSValue constructArrayWithSizeQuirk(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, JSValue length, JSValue newTarget)
+JSArray* constructArrayWithSizeQuirk(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, JSValue length, JSValue newTarget)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
@@ -79,13 +79,15 @@
     }
     
     uint32_t n = length.toUInt32(exec);
-    if (n != length.toNumber(exec))
-        return throwException(exec, scope, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
+    if (n != length.toNumber(exec)) {
+        throwException(exec, scope, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
+        return nullptr;
+    }
     scope.release();
     return constructEmptyArray(exec, profile, globalObject, n, newTarget);
 }
 
-static inline JSValue constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args, JSValue newTarget)
+static inline JSArray* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args, JSValue newTarget)
 {
     JSGlobalObject* globalObject = jsCast<InternalFunction*>(exec->jsCallee())->globalObject();
 

Modified: trunk/Source/_javascript_Core/runtime/ArrayConstructor.h (231687 => 231688)


--- trunk/Source/_javascript_Core/runtime/ArrayConstructor.h	2018-05-11 03:38:10 UTC (rev 231687)
+++ trunk/Source/_javascript_Core/runtime/ArrayConstructor.h	2018-05-11 04:38:56 UTC (rev 231688)
@@ -56,7 +56,7 @@
     ArrayConstructor(VM&, Structure*);
 };
 
-JSValue constructArrayWithSizeQuirk(ExecState*, ArrayAllocationProfile*, JSGlobalObject*, JSValue length, JSValue prototype = JSValue());
+JSArray* constructArrayWithSizeQuirk(ExecState*, ArrayAllocationProfile*, JSGlobalObject*, JSValue length, JSValue prototype = JSValue());
 
 EncodedJSValue JSC_HOST_CALL arrayConstructorPrivateFuncIsArrayConstructor(ExecState*);
 EncodedJSValue JSC_HOST_CALL arrayConstructorPrivateFuncIsArraySlow(ExecState*);

Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.h (231687 => 231688)


--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.h	2018-05-11 03:38:10 UTC (rev 231687)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.h	2018-05-11 04:38:56 UTC (rev 231688)
@@ -60,12 +60,12 @@
     ObjectConstructor(VM&, Structure*);
 };
 
-inline JSObject* constructEmptyObject(ExecState* exec, Structure* structure)
+inline JSFinalObject* constructEmptyObject(ExecState* exec, Structure* structure)
 {
     return JSFinalObject::create(exec, structure);
 }
 
-inline JSObject* constructEmptyObject(ExecState* exec, JSObject* prototype, unsigned inlineCapacity)
+inline JSFinalObject* constructEmptyObject(ExecState* exec, JSObject* prototype, unsigned inlineCapacity)
 {
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     StructureCache& structureCache = globalObject->vm().structureCache;
@@ -73,12 +73,12 @@
     return constructEmptyObject(exec, structure);
 }
 
-inline JSObject* constructEmptyObject(ExecState* exec, JSObject* prototype)
+inline JSFinalObject* constructEmptyObject(ExecState* exec, JSObject* prototype)
 {
     return constructEmptyObject(exec, prototype, JSFinalObject::defaultInlineCapacity());
 }
 
-inline JSObject* constructEmptyObject(ExecState* exec)
+inline JSFinalObject* constructEmptyObject(ExecState* exec)
 {
     return constructEmptyObject(exec, exec->lexicalGlobalObject()->objectStructureForObjectConstructor());
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to