Title: [210228] trunk
Revision
210228
Author
[email protected]
Date
2017-01-02 16:32:05 -0800 (Mon, 02 Jan 2017)

Log Message

WebAssembly: Some loads don't take into account the offset
https://bugs.webkit.org/show_bug.cgi?id=166616
<rdar://problem/29841541>

Reviewed by Keith Miller.

JSTests:

* wasm/function-tests/load-offset.js: Added.

Source/_javascript_Core:

* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::emitLoadOp):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (210227 => 210228)


--- trunk/JSTests/ChangeLog	2017-01-02 21:22:19 UTC (rev 210227)
+++ trunk/JSTests/ChangeLog	2017-01-03 00:32:05 UTC (rev 210228)
@@ -1,3 +1,13 @@
+2017-01-02  Saam Barati  <[email protected]>
+
+        WebAssembly: Some loads don't take into account the offset
+        https://bugs.webkit.org/show_bug.cgi?id=166616
+        <rdar://problem/29841541>
+
+        Reviewed by Keith Miller.
+
+        * wasm/function-tests/load-offset.js: Added.
+
 2016-12-29  Saam Barati  <[email protected]>
 
         WebAssembly: Rebase spec-tests now that wabt has been updated to produce certain kinds of invalid modules

Added: trunk/JSTests/wasm/function-tests/load-offset.js (0 => 210228)


--- trunk/JSTests/wasm/function-tests/load-offset.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/load-offset.js	2017-01-03 00:32:05 UTC (rev 210228)
@@ -0,0 +1,165 @@
+import Builder from '../Builder.js'
+import * as assert from '../assert.js'
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "i32"})
+                .GetLocal(0)
+                .I32Load(2, 4)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = 0x0abbccdd;
+    (new Uint32Array(memory.buffer))[1] = number;
+    assert.eq(instance.exports.foo(0), number);
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "i32"})
+                .GetLocal(0)
+                .I64Load32U(2, 4)
+                .I64Popcnt()
+                .I32WrapI64()
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = 2**32 - 1;
+    (new Uint32Array(memory.buffer))[1] = number;
+    assert.eq(instance.exports.foo(0), 32);
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "i32"})
+                .GetLocal(0)
+                .I64Load32S(2, 4)
+                .I64Popcnt()
+                .I32WrapI64()
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = 2**32 - 1;
+    (new Uint32Array(memory.buffer))[1] = number;
+    assert.eq(instance.exports.foo(0), 64);
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "i32"})
+                .GetLocal(0)
+                .I64Load(2, 4)
+                .I64Popcnt()
+                .I32WrapI64()
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = 2**32 - 1;
+    (new Uint32Array(memory.buffer))[1] = number;
+    (new Uint32Array(memory.buffer))[2] = 0xff00ff00;
+    assert.eq(instance.exports.foo(0), 32 + 16);
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "f32"})
+                .GetLocal(0)
+                .F32Load(2, 4)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = Math.PI;
+    (new Float32Array(memory.buffer))[1] = number;
+    assert.eq(instance.exports.foo(0), Math.fround(number));
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory("imp", "mem", {initial: 1})
+        .End()
+        .Function().End()
+        .Export().Function("foo").End()
+        .Code()
+            .Function("foo", {params: ["i32"], ret: "f64"})
+                .GetLocal(0)
+                .F64Load(2, 8)
+                .Return()
+            .End()
+        .End();
+
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 1});
+    const instance = new WebAssembly.Instance(module, {imp: {mem: memory}});
+    
+    const number = Math.PI;
+    (new Float64Array(memory.buffer))[1] = number;
+    assert.eq(instance.exports.foo(0), number);
+}

Modified: trunk/JSTests/wasm.yaml (210227 => 210228)


--- trunk/JSTests/wasm.yaml	2017-01-02 21:22:19 UTC (rev 210227)
+++ trunk/JSTests/wasm.yaml	2017-01-03 00:32:05 UTC (rev 210228)
@@ -149,10 +149,10 @@
   cmd: runWebAssemblySpecTest :skip
 
 - path: wasm/spec-tests/nop.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/resizing.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/return.wast.js
   cmd: runWebAssemblySpecTest :normal

Modified: trunk/Source/_javascript_Core/ChangeLog (210227 => 210228)


--- trunk/Source/_javascript_Core/ChangeLog	2017-01-02 21:22:19 UTC (rev 210227)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-01-03 00:32:05 UTC (rev 210228)
@@ -1,3 +1,14 @@
+2017-01-02  Saam Barati  <[email protected]>
+
+        WebAssembly: Some loads don't take into account the offset
+        https://bugs.webkit.org/show_bug.cgi?id=166616
+        <rdar://problem/29841541>
+
+        Reviewed by Keith Miller.
+
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::emitLoadOp):
+
 2017-01-01  Jeff Miller  <[email protected]>
 
         Update user-visible copyright strings to include 2017

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (210227 => 210228)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-01-02 21:22:19 UTC (rev 210227)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-01-03 00:32:05 UTC (rev 210228)
@@ -514,29 +514,29 @@
     }
 
     case LoadOpType::I32Load: {
-        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer);
+        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer, offset);
     }
 
     case LoadOpType::I64Load32U: {
-        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer);
+        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer, offset);
         return m_currentBlock->appendNew<Value>(m_proc, ZExt32, origin, value);
     }
 
     case LoadOpType::I64Load32S: {
-        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer);
+        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin, pointer, offset);
         return m_currentBlock->appendNew<Value>(m_proc, SExt32, origin, value);
     }
 
     case LoadOpType::I64Load: {
-        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int64, origin, pointer);
+        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int64, origin, pointer, offset);
     }
 
     case LoadOpType::F32Load: {
-        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Float, origin, pointer);
+        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Float, origin, pointer, offset);
     }
 
     case LoadOpType::F64Load: {
-        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Double, origin, pointer);
+        return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Double, origin, pointer, offset);
     }
 
     // FIXME: B3 doesn't support Load16Z yet. We should lower to that value when
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to