Title: [209295] trunk
Revision
209295
Author
[email protected]
Date
2016-12-02 22:40:37 -0800 (Fri, 02 Dec 2016)

Log Message

[JSC] add additional bit to JSTokenType bitfield
https://bugs.webkit.org/show_bug.cgi?id=165091

Patch by Caitlin Potter <[email protected]> on 2016-12-02
Reviewed by Geoffrey Garen.

JSTests:

* stress/bug-165091.js: Added.
(shouldThrowSyntaxError):

Source/_javascript_Core:

Avoid overflow which causes keyword tokens to be treated as unary
tokens now that "async" is tokenized as a keyword, by granting an
additional 64 bits to be occupied by token IDs.

* parser/ParserTokens.h:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (209294 => 209295)


--- trunk/JSTests/ChangeLog	2016-12-03 03:58:56 UTC (rev 209294)
+++ trunk/JSTests/ChangeLog	2016-12-03 06:40:37 UTC (rev 209295)
@@ -29,6 +29,16 @@
         Add Wasm floating point nearest and trunc
         https://bugs.webkit.org/show_bug.cgi?id=165339
 
+        Reviewed by Saam Barati.
+
+        * wasm/function-tests/nearest.js: Added.
+        * wasm/function-tests/trunc.js: Added.
+
+2016-12-02  Keith Miller  <[email protected]>
+
+        Add Wasm floating point nearest and trunc
+        https://bugs.webkit.org/show_bug.cgi?id=165339
+
         Reviewed by Filip Pizlo.
 
         * wasm/function-tests/nearest.js: Added.

Added: trunk/JSTests/wasm/function-tests/nearest.js (0 => 209295)


--- trunk/JSTests/wasm/function-tests/nearest.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/nearest.js	2016-12-03 06:40:37 UTC (rev 209295)
@@ -0,0 +1,55 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["f32"], ret: "f32" }, [])
+    .GetLocal(0)
+    .F32Nearest()
+    .End()
+
+    .Function({ params: ["f64"], ret: "f64" }, [])
+    .GetLocal(0)
+    .F64Nearest()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 2,
+                        [[{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x0p+0" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x0p+0" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-149" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-149" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-126" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-126" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-1" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-1" }]],
+                         [{ type: "f32", value: "-0x1p+0" }, [{ type: "f32", value: "-0x1p+0" }]],
+                         [{ type: "f32", value: "0x1p+0" }, [{ type: "f32", value: "0x1p+0" }]],
+                         [{ type: "f32", value: "-0x1.8p+2" }, [{ type: "f32", value: "-0x1.921fb6p+2" }]],
+                         [{ type: "f32", value: "0x1.8p+2" }, [{ type: "f32", value: "0x1.921fb6p+2" }]],
+                         [{ type: "f32", value: "-0x1.fffffep+127" }, [{ type: "f32", value: "-0x1.fffffep+127" }]],
+                         [{ type: "f32", value: "0x1.fffffep+127" }, [{ type: "f32", value: "0x1.fffffep+127" }]],
+                         [{ type: "f32", value: "-infinity" }, [{ type: "f32", value: "-infinity" }]],
+                         [{ type: "f32", value: "infinity" }, [{ type: "f32", value: "infinity" }]],
+                        ],
+
+                        [[{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x0p+0" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x0p+0" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x0.0000000000001p-1022" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x0.0000000000001p-1022" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x1p-1022" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x1p-1022" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x1p-1" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x1p-1" }]],
+                         [{ type: "f64", value: "-0x1p+0" }, [{ type: "f64", value: "-0x1p+0" }]],
+                         [{ type: "f64", value: "0x1p+0" }, [{ type: "f64", value: "0x1p+0" }]],
+                         [{ type: "f64", value: "-0x1.8p+2" }, [{ type: "f64", value: "-0x1.921fb54442d18p+2" }]],
+                         [{ type: "f64", value: "0x1.8p+2" }, [{ type: "f64", value: "0x1.921fb54442d18p+2" }]],
+                         [{ type: "f64", value: "-0x1.fffffffffffffp+1023" }, [{ type: "f64", value: "-0x1.fffffffffffffp+1023" }]],
+                         [{ type: "f64", value: "0x1.fffffffffffffp+1023" }, [{ type: "f64", value: "0x1.fffffffffffffp+1023" }]],
+                         [{ type: "f64", value: "-infinity" }, [{ type: "f64", value: "-infinity" }]],
+                         [{ type: "f64", value: "infinity" }, [{ type: "f64", value: "infinity" }]],
+                        ],
+                       );

Added: trunk/JSTests/wasm/function-tests/trunc.js (0 => 209295)


--- trunk/JSTests/wasm/function-tests/trunc.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/trunc.js	2016-12-03 06:40:37 UTC (rev 209295)
@@ -0,0 +1,55 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["f32"], ret: "f32" }, [])
+    .GetLocal(0)
+    .F32Trunc()
+    .End()
+
+    .Function({ params: ["f64"], ret: "f64" }, [])
+    .GetLocal(0)
+    .F64Trunc()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 2,
+                        [[{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x0p+0" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x0p+0" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-149" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-149" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-126" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-126" }]],
+                         [{ type: "f32", value: "-0x0p+0" }, [{ type: "f32", value: "-0x1p-1" }]],
+                         [{ type: "f32", value: "0x0p+0" }, [{ type: "f32", value: "0x1p-1" }]],
+                         [{ type: "f32", value: "-0x1p+0" }, [{ type: "f32", value: "-0x1p+0" }]],
+                         [{ type: "f32", value: "0x1p+0" }, [{ type: "f32", value: "0x1p+0" }]],
+                         [{ type: "f32", value: "-0x1.8p+2" }, [{ type: "f32", value: "-0x1.921fb6p+2" }]],
+                         [{ type: "f32", value: "0x1.8p+2" }, [{ type: "f32", value: "0x1.921fb6p+2" }]],
+                         [{ type: "f32", value: "-0x1.fffffep+127" }, [{ type: "f32", value: "-0x1.fffffep+127" }]],
+                         [{ type: "f32", value: "0x1.fffffep+127" }, [{ type: "f32", value: "0x1.fffffep+127" }]],
+                         [{ type: "f32", value: "-infinity" }, [{ type: "f32", value: "-infinity" }]],
+                         [{ type: "f32", value: "infinity" }, [{ type: "f32", value: "infinity" }]],
+                        ],
+
+                        [[{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x0p+0" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x0p+0" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x0.0000000000001p-1022" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x0.0000000000001p-1022" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x1p-1022" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x1p-1022" }]],
+                         [{ type: "f64", value: "-0x0p+0" }, [{ type: "f64", value: "-0x1p-1" }]],
+                         [{ type: "f64", value: "0x0p+0" }, [{ type: "f64", value: "0x1p-1" }]],
+                         [{ type: "f64", value: "-0x1p+0" }, [{ type: "f64", value: "-0x1p+0" }]],
+                         [{ type: "f64", value: "0x1p+0" }, [{ type: "f64", value: "0x1p+0" }]],
+                         [{ type: "f64", value: "-0x1.8p+2" }, [{ type: "f64", value: "-0x1.921fb54442d18p+2" }]],
+                         [{ type: "f64", value: "0x1.8p+2" }, [{ type: "f64", value: "0x1.921fb54442d18p+2" }]],
+                         [{ type: "f64", value: "-0x1.fffffffffffffp+1023" }, [{ type: "f64", value: "-0x1.fffffffffffffp+1023" }]],
+                         [{ type: "f64", value: "0x1.fffffffffffffp+1023" }, [{ type: "f64", value: "0x1.fffffffffffffp+1023" }]],
+                         [{ type: "f64", value: "-infinity" }, [{ type: "f64", value: "-infinity" }]],
+                         [{ type: "f64", value: "infinity" }, [{ type: "f64", value: "infinity" }]],
+                        ],
+                       );

Modified: trunk/Source/_javascript_Core/ChangeLog (209294 => 209295)


--- trunk/Source/_javascript_Core/ChangeLog	2016-12-03 03:58:56 UTC (rev 209294)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-12-03 06:40:37 UTC (rev 209295)
@@ -50,6 +50,36 @@
 
 2016-12-02  Keith Miller  <[email protected]>
 
+        Add Wasm floating point nearest and trunc
+        https://bugs.webkit.org/show_bug.cgi?id=165339
+
+        Reviewed by Saam Barati.
+
+        This patch also allows any wasm primitive type to be passed as a
+        string.
+
+        * assembler/MacroAssemblerARM64.h:
+        (JSC::MacroAssemblerARM64::nearestIntDouble):
+        (JSC::MacroAssemblerARM64::nearestIntFloat):
+        (JSC::MacroAssemblerARM64::truncDouble):
+        (JSC::MacroAssemblerARM64::truncFloat):
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::nearestIntDouble):
+        (JSC::MacroAssemblerX86Common::nearestIntFloat):
+        * jsc.cpp:
+        (box):
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::addOp<F64ConvertUI64>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32ConvertUI64>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Nearest>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Nearest>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F64Trunc>):
+        (JSC::Wasm::B3IRGenerator::addOp<OpType::F32Trunc>):
+        * wasm/WasmFunctionParser.h:
+        (JSC::Wasm::FunctionParser<Context>::parseExpression):
+
+2016-12-02  Keith Miller  <[email protected]>
+
         Unreviewed, forgot to change instruction after renaming.
 
         * assembler/MacroAssemblerARM64.h:

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h (209294 => 209295)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2016-12-03 03:58:56 UTC (rev 209294)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h	2016-12-03 06:40:37 UTC (rev 209295)
@@ -1560,6 +1560,16 @@
         m_assembler.frintm<32>(dest, src);
     }
 
+    void roundTowardNearestIntDouble(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.frintn<64>(dest, src);
+    }
+
+    void roundTowardNearestIntFloat(FPRegisterID src, FPRegisterID dest)
+    {
+        m_assembler.frintn<32>(dest, src);
+    }
+
     void roundTowardZeroDouble(FPRegisterID src, FPRegisterID dest)
     {
         m_assembler.frintz<64>(dest, src);
@@ -1570,6 +1580,7 @@
         m_assembler.frintz<32>(dest, src);
     }
 
+
     // Convert 'src' to an integer, and places the resulting 'dest'.
     // If the result is not representable as a 32 bit value, branch.
     // May also branch for some values that are representable in 32 bits

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h (209294 => 209295)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2016-12-03 03:58:56 UTC (rev 209294)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2016-12-03 06:40:37 UTC (rev 209295)
@@ -797,6 +797,16 @@
         m_assembler.roundss_mr(src.offset, src.base, dst, X86Assembler::RoundingType::TowardNegativeInfiniti);
     }
 
+    void roundTowardNearestIntDouble(FPRegisterID src, FPRegisterID dst)
+    {
+        m_assembler.roundsd_rr(src, dst, X86Assembler::RoundingType::ToNearestWithTiesToEven);
+    }
+
+    void roundTowardNearestIntFloat(FPRegisterID src, FPRegisterID dst)
+    {
+        m_assembler.roundss_rr(src, dst, X86Assembler::RoundingType::ToNearestWithTiesToEven);
+    }
+
     void roundTowardZeroDouble(FPRegisterID src, FPRegisterID dst)
     {
         m_assembler.roundsd_rr(src, dst, X86Assembler::RoundingType::TowardZero);

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (209294 => 209295)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2016-12-03 03:58:56 UTC (rev 209294)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2016-12-03 06:40:37 UTC (rev 209295)
@@ -783,6 +783,58 @@
     return true;
 }
 
+template<>
+bool B3IRGenerator::addOp<OpType::F64Nearest>(ExpressionType arg, ExpressionType& result)
+{
+    PatchpointValue* patchpoint = m_currentBlock->appendNew<PatchpointValue>(m_proc, Double, Origin());
+    patchpoint->append(arg, ValueRep::SomeRegister);
+    patchpoint->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
+        jit.roundTowardNearestIntDouble(params[1].fpr(), params[0].fpr());
+    });
+    patchpoint->effects = Effects::none();
+    result = patchpoint;
+    return true;
+}
+
+template<>
+bool B3IRGenerator::addOp<OpType::F32Nearest>(ExpressionType arg, ExpressionType& result)
+{
+    PatchpointValue* patchpoint = m_currentBlock->appendNew<PatchpointValue>(m_proc, Float, Origin());
+    patchpoint->append(arg, ValueRep::SomeRegister);
+    patchpoint->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
+        jit.roundTowardNearestIntFloat(params[1].fpr(), params[0].fpr());
+    });
+    patchpoint->effects = Effects::none();
+    result = patchpoint;
+    return true;
+}
+
+template<>
+bool B3IRGenerator::addOp<OpType::F64Trunc>(ExpressionType arg, ExpressionType& result)
+{
+    PatchpointValue* patchpoint = m_currentBlock->appendNew<PatchpointValue>(m_proc, Double, Origin());
+    patchpoint->append(arg, ValueRep::SomeRegister);
+    patchpoint->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
+        jit.roundTowardZeroDouble(params[1].fpr(), params[0].fpr());
+    });
+    patchpoint->effects = Effects::none();
+    result = patchpoint;
+    return true;
+}
+
+template<>
+bool B3IRGenerator::addOp<OpType::F32Trunc>(ExpressionType arg, ExpressionType& result)
+{
+    PatchpointValue* patchpoint = m_currentBlock->appendNew<PatchpointValue>(m_proc, Float, Origin());
+    patchpoint->append(arg, ValueRep::SomeRegister);
+    patchpoint->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
+        jit.roundTowardZeroFloat(params[1].fpr(), params[0].fpr());
+    });
+    patchpoint->effects = Effects::none();
+    result = patchpoint;
+    return true;
+}
+
 } } // namespace JSC::Wasm
 
 #include "WasmB3IRGeneratorInlines.h"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to