Updated to latest spec and minor fix on block insn insertion count

This commit is contained in:
Chad Retz 2018-09-13 13:10:11 -05:00
parent 6352efaa96
commit 46a8ce3f52
3 changed files with 7 additions and 16 deletions

View File

@ -130,19 +130,11 @@ open class InsnReworker {
// if we are at 0, add the result of said block if necessary to the count. // if we are at 0, add the result of said block if necessary to the count.
if (insideOfBlocks > 0) { if (insideOfBlocks > 0) {
// If it's not a block, just ignore it // If it's not a block, just ignore it
val blockStackDiff = insns[insnIndex].let { (insns[insnIndex] as? Node.Instr.Args.Type)?.let {
when (it) {
is Node.Instr.Block -> if (it.type == null) 0 else 1
is Node.Instr.Loop -> 0
is Node.Instr.If -> if (it.type == null) -1 else 0
else -> null
}
}
if (blockStackDiff != null) {
insideOfBlocks-- insideOfBlocks--
ctx.trace { "Found block begin, number of blocks we're still inside: $insideOfBlocks" } ctx.trace { "Found block begin, number of blocks we're still inside: $insideOfBlocks" }
// We're back on our block, change the count // We're back on our block, change the count if it had a result
if (insideOfBlocks == 0) countSoFar += blockStackDiff if (insideOfBlocks == 0 && it.type != null) countSoFar++
} }
if (insideOfBlocks > 0) continue if (insideOfBlocks > 0) continue
} }
@ -221,10 +213,9 @@ open class InsnReworker {
fun insnStackDiff(ctx: ClsContext, insn: Node.Instr) = when (insn) { fun insnStackDiff(ctx: ClsContext, insn: Node.Instr) = when (insn) {
is Node.Instr.Unreachable, is Node.Instr.Nop, is Node.Instr.Block, is Node.Instr.Unreachable, is Node.Instr.Nop, is Node.Instr.Block,
is Node.Instr.Loop, is Node.Instr.If, is Node.Instr.Else, is Node.Instr.Loop, is Node.Instr.Else, is Node.Instr.End, is Node.Instr.Br,
is Node.Instr.End, is Node.Instr.Br, is Node.Instr.BrIf,
is Node.Instr.Return -> NOP is Node.Instr.Return -> NOP
is Node.Instr.BrTable -> POP_PARAM is Node.Instr.If, is Node.Instr.BrIf, is Node.Instr.BrTable -> POP_PARAM
is Node.Instr.Call -> ctx.funcTypeAtIndex(insn.index).let { is Node.Instr.Call -> ctx.funcTypeAtIndex(insn.index).let {
// All calls pop params and any return is a push // All calls pop params and any return is a push
(POP_PARAM * it.params.size) + (if (it.ret == null) NOP else PUSH_RESULT) (POP_PARAM * it.params.size) + (if (it.ret == null) NOP else PUSH_RESULT)

View File

@ -16,7 +16,7 @@ class SpecTestUnit(name: String, wast: String, expectedOutput: String?) : BaseTe
"nop" -> 20 "nop" -> 20
"memory_grow" -> 830 "memory_grow" -> 830
"imports" -> 5 "imports" -> 5
else -> 1 else -> 2
} }
override fun warningInsteadOfErrReason(t: Throwable) = when (name) { override fun warningInsteadOfErrReason(t: Throwable) = when (name) {

@ -1 +1 @@
Subproject commit b9cddea4dddd103324e45f96e642aebc2b43b7fd Subproject commit fda397a56f1e97e57eb8231eb0466d0cbfa3a6b8