Skip to content

Commit d62d845

Browse files
committed
Reduce inlining verbosity
With debug info and source maps in place there is not much value anymore in emitting explicitly named blocks.
1 parent 04a0cb8 commit d62d845

18 files changed

+2654
-3083
lines changed

src/compiler.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5492,7 +5492,11 @@ export class Compiler extends DiagnosticEmitter {
54925492
);
54935493
return module.createUnreachable();
54945494
}
5495-
return module.createBlock(returnLabel, body, returnType.toNativeType());
5495+
return flow.is(FlowFlags.RETURNS)
5496+
? module.createBlock(returnLabel, body, returnType.toNativeType())
5497+
: body.length > 1
5498+
? module.createBlock(null, body, returnType.toNativeType())
5499+
: body[0];
54965500
}
54975501

54985502
/** Gets the trampoline for the specified function. */

tests/compiler/inlining-recursive.untouched.wat

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
call $inlining-recursive/bar
1717
)
1818
(func $inlining-recursive/bar (; 2 ;) (type $v)
19-
block $inlining-recursive/bar|inlined.0
20-
call $inlining-recursive/baz
21-
end
19+
call $inlining-recursive/baz
2220
)
2321
(func $null (; 3 ;) (type $v)
2422
)

tests/compiler/inlining.untouched.wat

+2-4
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,8 @@
214214
call $~lib/env/abort
215215
unreachable
216216
end
217-
block $inlining/func_iv|inlined.0
218-
i32.const 0
219-
set_local $2
220-
end
217+
i32.const 0
218+
set_local $2
221219
block (result i32)
222220
i32.const 1
223221
set_global $~argc

tests/compiler/std/allocator_arena.untouched.wat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@
18881888
call $~lib/env/abort
18891889
unreachable
18901890
end
1891-
block $~lib/memory/memory.fill|inlined.0
1891+
block
18921892
get_global $std/allocator_arena/ptr1
18931893
set_local $0
18941894
i32.const 18
@@ -1933,7 +1933,7 @@
19331933
end
19341934
unreachable
19351935
end
1936-
block $~lib/memory/memory.copy|inlined.0
1936+
block
19371937
get_global $std/allocator_arena/ptr2
19381938
set_local $2
19391939
get_global $std/allocator_arena/ptr1

tests/compiler/std/array-literal.untouched.wat

+40-48
Original file line numberDiff line numberDiff line change
@@ -507,18 +507,16 @@
507507
get_local $0
508508
get_local $1
509509
i32.store offset=4
510-
block $~lib/memory/memory.fill|inlined.0
511-
get_local $3
512-
get_global $~lib/internal/arraybuffer/HEADER_SIZE
513-
i32.add
514-
set_local $4
515-
i32.const 0
516-
set_local $5
517-
get_local $4
518-
get_local $5
519-
get_local $2
520-
call $~lib/internal/memory/memset
521-
end
510+
get_local $3
511+
get_global $~lib/internal/arraybuffer/HEADER_SIZE
512+
i32.add
513+
set_local $4
514+
i32.const 0
515+
set_local $5
516+
get_local $4
517+
get_local $5
518+
get_local $2
519+
call $~lib/internal/memory/memset
522520
get_local $0
523521
)
524522
(func $~lib/array/Array<i8>#__unchecked_set (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
@@ -581,18 +579,16 @@
581579
get_local $0
582580
get_local $1
583581
i32.store offset=4
584-
block $~lib/memory/memory.fill|inlined.1
585-
get_local $3
586-
get_global $~lib/internal/arraybuffer/HEADER_SIZE
587-
i32.add
588-
set_local $4
589-
i32.const 0
590-
set_local $5
591-
get_local $4
592-
get_local $5
593-
get_local $2
594-
call $~lib/internal/memory/memset
595-
end
582+
get_local $3
583+
get_global $~lib/internal/arraybuffer/HEADER_SIZE
584+
i32.add
585+
set_local $4
586+
i32.const 0
587+
set_local $5
588+
get_local $4
589+
get_local $5
590+
get_local $2
591+
call $~lib/internal/memory/memset
596592
get_local $0
597593
)
598594
(func $~lib/array/Array<i32>#__unchecked_set (; 11 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
@@ -655,18 +651,16 @@
655651
get_local $0
656652
get_local $1
657653
i32.store offset=4
658-
block $~lib/memory/memory.fill|inlined.2
659-
get_local $3
660-
get_global $~lib/internal/arraybuffer/HEADER_SIZE
661-
i32.add
662-
set_local $4
663-
i32.const 0
664-
set_local $5
665-
get_local $4
666-
get_local $5
667-
get_local $2
668-
call $~lib/internal/memory/memset
669-
end
654+
get_local $3
655+
get_global $~lib/internal/arraybuffer/HEADER_SIZE
656+
i32.add
657+
set_local $4
658+
i32.const 0
659+
set_local $5
660+
get_local $4
661+
get_local $5
662+
get_local $2
663+
call $~lib/internal/memory/memset
670664
get_local $0
671665
)
672666
(func $~lib/array/Array<Ref>#__unchecked_set (; 13 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
@@ -745,18 +739,16 @@
745739
get_local $0
746740
get_local $1
747741
i32.store offset=4
748-
block $~lib/memory/memory.fill|inlined.3
749-
get_local $3
750-
get_global $~lib/internal/arraybuffer/HEADER_SIZE
751-
i32.add
752-
set_local $4
753-
i32.const 0
754-
set_local $5
755-
get_local $4
756-
get_local $5
757-
get_local $2
758-
call $~lib/internal/memory/memset
759-
end
742+
get_local $3
743+
get_global $~lib/internal/arraybuffer/HEADER_SIZE
744+
i32.add
745+
set_local $4
746+
i32.const 0
747+
set_local $5
748+
get_local $4
749+
get_local $5
750+
get_local $2
751+
call $~lib/internal/memory/memset
760752
get_local $0
761753
)
762754
(func $~lib/array/Array<RefWithCtor>#__unchecked_set (; 16 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)

0 commit comments

Comments
 (0)