12017-03-17 JF Bastien <jfbastien@apple.com>
2
3 WebAssembly: spec-tests/memory.wast.js fails in debug
4 https://bugs.webkit.org/show_bug.cgi?id=169794
5
6 Reviewed by NOBODY (OOPS!).
7
8 The failure was due to empty memories (with maximum size 0). Those
9 only occur in tests and in code that's trying to trip us. This
10 patch adds memory mode "none" which represents no memory. It can
11 work with either bounds checked or signaling code because it never
12 contains loads and stores.
13
14 The spec tests which were failing did the following:
15 > (module (memory (data)) (func (export "memsize") (result i32) (current_memory)))
16 > (assert_return (invoke "memsize") (i32.const 0))
17 > (module (memory (data "")) (func (export "memsize") (result i32) (current_memory)))
18 > (assert_return (invoke "memsize") (i32.const 0))
19 > (module (memory (data "x")) (func (export "memsize") (result i32) (current_memory)))
20 > (assert_return (invoke "memsize") (i32.const 1))
21
22 * wasm/WasmB3IRGenerator.cpp:
23 (JSC::Wasm::B3IRGenerator::memoryKind):
24 * wasm/WasmMemory.cpp:
25 (JSC::Wasm::tryGetFastMemory):
26 (JSC::Wasm::releaseFastMemory):
27 (JSC::Wasm::Memory::Memory):
28 (JSC::Wasm::Memory::createImpl):
29 (JSC::Wasm::Memory::create):
30 (JSC::Wasm::Memory::grow):
31 (JSC::Wasm::Memory::makeString):
32 * wasm/WasmMemory.h:
33 * wasm/WasmMemoryInformation.cpp:
34 (JSC::Wasm::MemoryInformation::MemoryInformation):
35 * wasm/js/JSWebAssemblyCodeBlock.cpp:
36 (JSC::JSWebAssemblyCodeBlock::isSafeToRun):
37 * wasm/js/JSWebAssemblyModule.cpp:
38 (JSC::JSWebAssemblyModule::codeBlock):
39 (JSC::JSWebAssemblyModule::finishCreation):
40 * wasm/js/JSWebAssemblyModule.h:
41 (JSC::JSWebAssemblyModule::codeBlock):
42 (JSC::JSWebAssemblyModule::codeBlockFor):
43 * wasm/js/WebAssemblyInstanceConstructor.cpp:
44 (JSC::WebAssemblyInstanceConstructor::createInstance):
45 * wasm/js/WebAssemblyMemoryConstructor.cpp:
46 (JSC::constructJSWebAssemblyMemory):
47