зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1466464 - Part 1: Recognize memory.grow and memory.size syntax. r=jseward
This only recognizes the new syntax and adds a minimal amount of testing for that. A subsequent patch will do a massive renaming in the wasm module to change CurrentMemory to MemSize and GrowMemory to MemGrow, and change all test cases. A final patch will remove support for the old syntax.
This commit is contained in:
Родитель
b2a784a8bf
Коммит
b2d8132d07
|
@ -1,11 +1,11 @@
|
|||
function linearModule(min, max, ops) {
|
||||
function linearModule(min, max, ops, current_memory, grow_memory) {
|
||||
var opsText = ops.map(function (op) {
|
||||
if (op[0] == "CM") {
|
||||
res = `(if i32 (i32.ne (current_memory) (i32.const ${op[1]}))
|
||||
res = `(if i32 (i32.ne (${current_memory}) (i32.const ${op[1]}))
|
||||
(i32.load offset=10 (i32.const 4294967295))
|
||||
(i32.const 0))`
|
||||
} else if (op[0] == "GM") {
|
||||
res = `(if i32 (i32.ne (grow_memory (i32.const ${op[1]})) (i32.const ${op[2]}))
|
||||
res = `(if i32 (i32.ne (${grow_memory} (i32.const ${op[1]})) (i32.const ${op[2]}))
|
||||
(i32.load offset=10 (i32.const 4294967295))
|
||||
(i32.const 0))`
|
||||
} else if (op[0] == "L") {
|
||||
|
@ -35,11 +35,12 @@ function linearModule(min, max, ops) {
|
|||
`
|
||||
(func (result i32)
|
||||
(drop ` + opsText + `)
|
||||
(current_memory)
|
||||
(${current_memory})
|
||||
) (export "run" 0))`;
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
// Just grow some memory
|
||||
wasmFullPass(linearModule(3,5, [["CM", 3]]), 3);
|
||||
wasmFullPass(linearModule(3,5, [["CM", 3]], "current_memory", "grow_memory"), 3); // Old opcode names
|
||||
wasmFullPass(linearModule(3,5, [["CM", 3]], "memory.size", "memory.grow"), 3); // New opcode names
|
||||
|
|
|
@ -1656,15 +1656,19 @@ WasmTokenStream::next()
|
|||
break;
|
||||
|
||||
case 'm':
|
||||
#ifdef ENABLE_WASM_BULKMEM_OPS
|
||||
if (consume(u"memory.")) {
|
||||
#ifdef ENABLE_WASM_BULKMEM_OPS
|
||||
if (consume(u"copy"))
|
||||
return WasmToken(WasmToken::MemCopy, begin, cur_);
|
||||
if (consume(u"fill"))
|
||||
return WasmToken(WasmToken::MemFill, begin, cur_);
|
||||
#endif
|
||||
if (consume(u"grow"))
|
||||
return WasmToken(WasmToken::GrowMemory, begin, cur_);
|
||||
if (consume(u"size"))
|
||||
return WasmToken(WasmToken::CurrentMemory, begin, cur_);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (consume(u"module"))
|
||||
return WasmToken(WasmToken::Module, begin, cur_);
|
||||
if (consume(u"memory"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче