Title: [221449] trunk/Tools
Revision
221449
Author
fpi...@apple.com
Date
2017-08-31 15:22:59 -0700 (Thu, 31 Aug 2017)

Log Message

There should only be one callFunction API in WSL
https://bugs.webkit.org/show_bug.cgi?id=176189

Reviewed by Saam Barati.
        
This removes the need for callFunctionByRef, which was weird. It's now the case the TypedValue
is always a tuple of type and ePtr, and TypedValue has a super simple API for boxing and
unboxing single-cell values like ints.

* WebGPUShadingLanguageRI/CallFunction.js:
(callFunction):
(callFunctionByRef): Deleted.
* WebGPUShadingLanguageRI/Test.js:
(makeInt):
* WebGPUShadingLanguageRI/TypedValue.js:
(TypedValue):
(TypedValue.prototype.get type):
(TypedValue.prototype.get ePtr):
(TypedValue.box):
(TypedValue.prototype.get value):
(TypedValue.prototype.toString):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (221448 => 221449)


--- trunk/Tools/ChangeLog	2017-08-31 22:15:18 UTC (rev 221448)
+++ trunk/Tools/ChangeLog	2017-08-31 22:22:59 UTC (rev 221449)
@@ -1,5 +1,29 @@
 2017-08-31  Filip Pizlo  <fpi...@apple.com>
 
+        There should only be one callFunction API in WSL
+        https://bugs.webkit.org/show_bug.cgi?id=176189
+
+        Reviewed by Saam Barati.
+        
+        This removes the need for callFunctionByRef, which was weird. It's now the case the TypedValue
+        is always a tuple of type and ePtr, and TypedValue has a super simple API for boxing and
+        unboxing single-cell values like ints.
+
+        * WebGPUShadingLanguageRI/CallFunction.js:
+        (callFunction):
+        (callFunctionByRef): Deleted.
+        * WebGPUShadingLanguageRI/Test.js:
+        (makeInt):
+        * WebGPUShadingLanguageRI/TypedValue.js:
+        (TypedValue):
+        (TypedValue.prototype.get type):
+        (TypedValue.prototype.get ePtr):
+        (TypedValue.box):
+        (TypedValue.prototype.get value):
+        (TypedValue.prototype.toString):
+
+2017-08-31  Filip Pizlo  <fpi...@apple.com>
+
         WSL EPtr does not need to carry around the type
         https://bugs.webkit.org/show_bug.cgi?id=176188
 

Modified: trunk/Tools/WebGPUShadingLanguageRI/CallFunction.js (221448 => 221449)


--- trunk/Tools/WebGPUShadingLanguageRI/CallFunction.js	2017-08-31 22:15:18 UTC (rev 221448)
+++ trunk/Tools/WebGPUShadingLanguageRI/CallFunction.js	2017-08-31 22:22:59 UTC (rev 221449)
@@ -25,7 +25,7 @@
 "use strict";
 
 // This allows you to pass structs and arrays in-place, but it's a more annoying API.
-function callFunctionByRef(program, name, typeArguments, argumentList)
+function callFunction(program, name, typeArguments, argumentList)
 {
     let argumentTypes = argumentList.map(argument => argument.type);
     let func = resolveInlinedFunction(program, name, typeArguments, argumentTypes);
@@ -32,16 +32,8 @@
     if (!func)
         throw new WTypeError("<callFunction>", "Cannot resolve function call " + name + "<" + typeArguments + ">(" + argumentList + ")");
     for (let i = 0; i < func.parameters.length; ++i)
-        func.parameters[i].ePtr.copyFrom(argumentList[i].value, argumentTypes[i].size);
+        func.parameters[i].ePtr.copyFrom(argumentList[i].ePtr, argumentTypes[i].size);
     let result = new Evaluator(program).visitFunctionBody(func.body);
     return new TypedValue(func.returnType, result);
 }
 
-// This uses the simplified TypedValue object for wrapping values like integers and doubles.
-function callFunction(program, name, typeArguments, argumentList)
-{
-    let result = callFunctionByRef(
-        program, name, typeArguments,
-        argumentList.map(argument => new TypedValue(argument.type, EPtr.box(argument.value))));
-    return new TypedValue(result.type, result.value.loadValue());
-}

Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221448 => 221449)


--- trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-08-31 22:15:18 UTC (rev 221448)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-08-31 22:22:59 UTC (rev 221449)
@@ -33,7 +33,7 @@
 
 function makeInt(program, value)
 {
-    return new TypedValue(program.intrinsics.int32, value);
+    return TypedValue.box(program.intrinsics.int32, value);
 }
 
 function checkInt(program, result, expected)

Modified: trunk/Tools/WebGPUShadingLanguageRI/TypedValue.js (221448 => 221449)


--- trunk/Tools/WebGPUShadingLanguageRI/TypedValue.js	2017-08-31 22:15:18 UTC (rev 221448)
+++ trunk/Tools/WebGPUShadingLanguageRI/TypedValue.js	2017-08-31 22:22:59 UTC (rev 221449)
@@ -25,14 +25,24 @@
 "use strict";
 
 class TypedValue {
-    constructor(type, value)
+    constructor(type, ePtr)
     {
-        this.type = type;
-        this.value = value;
+        this._type = type;
+        this._ePtr = ePtr;
     }
     
+    get type() { return this._type; }
+    get ePtr() { return this._ePtr; }
+    
+    static box(type, value)
+    {
+        return new TypedValue(type, EPtr.box(value));
+    }
+    
+    get value() { return this.ePtr.loadValue(); }
+    
     toString()
     {
-        return this.type + "(" + this.value + ")";
+        return this.type + "(" + this.ePtr + ")";
     }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to