@@ -823,9 +823,14 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func, bool standalo
823823 Ref visitLoop (Loop* curr) {
824824 Name asmLabel = curr->name ;
825825 continueLabels.insert (asmLabel);
826- Ref body = blockify (visit (curr->body , result));
827- flattenAppend (body, ValueBuilder::makeBreak (fromName (asmLabel, NameScope::Label)));
828- Ref ret = ValueBuilder::makeDo (body, ValueBuilder::makeInt (1 ));
826+ Ref body = visit (curr->body , result);
827+ // if we can reach the end of the block, we must leave the while (1) loop
828+ if (curr->body ->type != unreachable) {
829+ assert (curr->body ->type == none); // flat IR
830+ body = blockify (body);
831+ flattenAppend (body, ValueBuilder::makeBreak (fromName (asmLabel, NameScope::Label)));
832+ }
833+ Ref ret = ValueBuilder::makeWhile (ValueBuilder::makeInt (1 ), body);
829834 return ValueBuilder::makeLabel (fromName (asmLabel, NameScope::Label), ret);
830835 }
831836
@@ -1207,10 +1212,8 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func, bool standalo
12071212 << std::endl;
12081213 WASM_UNREACHABLE ();
12091214 case EqZInt32:
1210- return ValueBuilder::makeBinary (
1211- makeAsmCoercion (visit (curr->value ,
1212- EXPRESSION_RESULT), ASM_INT), EQ,
1213- makeAsmCoercion (ValueBuilder::makeInt (0 ), ASM_INT));
1215+ // XXX !x does change the type to bool, which is correct, but may be slower?
1216+ return ValueBuilder::makeUnary (L_NOT, visit (curr->value , EXPRESSION_RESULT));
12141217 case ReinterpretFloat32: {
12151218 ABI::wasm2js::ensureScratchMemoryHelpers (module , ABI::wasm2js::SCRATCH_STORE_F32);
12161219 ABI::wasm2js::ensureScratchMemoryHelpers (module , ABI::wasm2js::SCRATCH_LOAD_I32);
0 commit comments