Skip to content

Experiment: What if locals are never free'd #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export class Flow {

/** Frees the temporary local for reuse. */
freeTempLocal(local: Local): void {
/*
if (local.is(CommonFlags.INLINED)) return;
assert(local.index >= 0);
var parentFunction = this.parentFunction;
Expand Down Expand Up @@ -390,6 +391,7 @@ export class Flow {
}
assert(local.index >= 0);
temps.push(local);
*/
}

/** Gets the scoped local of the specified name. */
Expand Down
43 changes: 23 additions & 20 deletions tests/compiler/abi.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
(func $start:abi
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
call $abi/internal
drop
i32.const 0
Expand All @@ -42,28 +45,28 @@
unreachable
end
i32.const 256
local.set $0
local.set $1
global.get $abi/condition
if
local.get $0
local.get $1
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.const 2
i32.div_s
local.set $0
local.set $1
else
local.get $0
local.get $1
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.const 2
i32.div_s
local.set $0
local.set $1
end
local.get $0
local.get $1
i32.const 24
i32.shl
i32.const 24
Expand All @@ -79,24 +82,24 @@
unreachable
end
i32.const 256
local.set $0
local.set $2
global.get $abi/condition
if
local.get $0
local.get $2
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.const 24
i32.shr_s
local.set $0
local.set $2
else
local.get $0
local.get $2
i32.const 127
i32.and
local.set $0
local.set $2
end
local.get $0
local.get $2
i32.eqz
i32.eqz
if
Expand Down Expand Up @@ -126,8 +129,8 @@
end
i32.const 2
i32.ctz
local.set $0
local.get $0
local.set $3
local.get $3
i32.const 0
i32.ne
i32.eqz
Expand All @@ -141,8 +144,8 @@
end
i32.const 1
i32.clz
local.set $0
local.get $0
local.set $3
local.get $3
i32.const 0
i32.ne
i32.eqz
Expand All @@ -156,8 +159,8 @@
end
i32.const 2
i32.ctz
local.set $1
local.get $1
local.set $4
local.get $4
i32.eqz
if
i32.const 0
Expand All @@ -169,8 +172,8 @@
end
i32.const 1
i32.clz
local.set $1
local.get $1
local.set $4
local.get $4
i32.eqz
if
i32.const 0
Expand Down
72 changes: 43 additions & 29 deletions tests/compiler/assert-nonnull.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
(func $assert-nonnull/testVar (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -50,13 +51,14 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $1
local.set $2
local.get $0
call $~lib/rt/stub/__release
local.get $1
local.get $2
)
(func $assert-nonnull/testObj (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -74,13 +76,14 @@
end
i32.load
call $~lib/rt/stub/__retain
local.set $1
local.set $2
local.get $0
call $~lib/rt/stub/__release
local.get $1
local.get $2
)
(func $assert-nonnull/testProp (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -98,10 +101,10 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $1
local.set $2
local.get $0
call $~lib/rt/stub/__release
local.get $1
local.get $2
)
(func $~lib/array/Array<assert-nonnull/Foo>#__uget (param $0 i32) (param $1 i32) (result i32)
local.get $0
Expand Down Expand Up @@ -152,6 +155,7 @@
)
(func $assert-nonnull/testArr (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -169,10 +173,10 @@
end
i32.const 0
call $~lib/array/Array<assert-nonnull/Foo>#__get
local.set $1
local.set $2
local.get $0
call $~lib/rt/stub/__release
local.get $1
local.get $2
)
(func $~lib/array/Array<assert-nonnull/Foo | null>#__uget (param $0 i32) (param $1 i32) (result i32)
local.get $0
Expand Down Expand Up @@ -211,6 +215,7 @@
)
(func $assert-nonnull/testElem (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -229,14 +234,17 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $1
local.set $2
local.get $0
call $~lib/rt/stub/__release
local.get $1
local.get $2
)
(func $assert-nonnull/testAll (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -254,10 +262,10 @@
end
i32.const 0
call $~lib/array/Array<assert-nonnull/Foo | null>#__get
local.tee $1
local.tee $2
local.tee $3
if (result i32)
local.get $2
local.get $3
else
i32.const 0
i32.const 32
Expand All @@ -267,9 +275,9 @@
unreachable
end
i32.load
local.tee $2
local.tee $4
if (result i32)
local.get $2
local.get $4
else
i32.const 0
i32.const 32
Expand All @@ -279,16 +287,19 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $2
local.get $1
local.set $5
local.get $2
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
local.get $2
local.get $5
)
(func $assert-nonnull/testAll2 (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -306,10 +317,10 @@
end
i32.const 0
call $~lib/array/Array<assert-nonnull/Foo | null>#__get
local.tee $1
local.tee $2
local.tee $3
if (result i32)
local.get $2
local.get $3
else
i32.const 0
i32.const 32
Expand All @@ -319,9 +330,9 @@
unreachable
end
i32.load
local.tee $2
local.tee $4
if (result i32)
local.get $2
local.get $4
else
i32.const 0
i32.const 32
Expand All @@ -331,12 +342,12 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $2
local.get $1
local.set $5
local.get $2
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
local.get $2
local.get $5
)
(func $~setArgumentsLength (param $0 i32)
local.get $0
Expand All @@ -353,6 +364,7 @@
(func $assert-nonnull/testFn2 (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
local.tee $1
if (result i32)
Expand All @@ -370,11 +382,12 @@
global.set $~argumentsLength
local.get $2
call_indirect (type $none_=>_i32)
local.tee $1
local.tee $3
)
(func $assert-nonnull/testRet (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
i32.const 0
global.set $~argumentsLength
local.get $0
Expand All @@ -392,10 +405,10 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $2
local.set $3
local.get $1
call $~lib/rt/stub/__release
local.get $2
local.get $3
)
(func $assert-nonnull/testObjFn (param $0 i32) (result i32)
(local $1 i32)
Expand All @@ -417,6 +430,7 @@
(func $assert-nonnull/testObjRet (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
call $~lib/rt/stub/__retain
local.set $0
Expand All @@ -438,11 +452,11 @@
unreachable
end
call $~lib/rt/stub/__retain
local.set $2
local.set $3
local.get $1
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
local.get $2
local.get $3
)
)
Loading