Skip to content

Disable aggressive ARC optimizations #1323

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

Merged
merged 1 commit into from
Jun 10, 2020
Merged
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
13 changes: 7 additions & 6 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1488,12 +1488,13 @@ export class Module {
passes.push("rse");
passes.push("vacuum");
}
if (usesARC) {
if (optimizeLevel < 3) {
passes.push("flatten");
}
passes.push("post-assemblyscript");
}
// FIXME: see issue #1288
// if (usesARC) {
// if (optimizeLevel < 3) {
// passes.push("flatten");
// }
// passes.push("post-assemblyscript");
// }
passes.push("optimize-instructions");
passes.push("inlining");
passes.push("dce");
Expand Down
43 changes: 26 additions & 17 deletions tests/compiler/extends-baseaggregate.optimized.wat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(module
(type $i32_i32_=>_none (func (param i32 i32)))
(type $i32_=>_none (func (param i32)))
(type $i32_i32_=>_none (func (param i32 i32)))
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $none_=>_none (func))
Expand Down Expand Up @@ -1580,20 +1580,34 @@
end
end
)
(func $~lib/rt/pure/__release (param $0 i32)
local.get $0
i32.const 1564
i32.gt_u
if
local.get $0
i32.const 16
i32.sub
call $~lib/rt/pure/decrement
end
)
(func $~lib/array/Array<extends-baseaggregate/A2>#push (param $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
local.get $0
call $~lib/rt/pure/__retain
local.set $1
i32.const 1116
i32.load
local.tee $6
i32.const 1
i32.add
local.tee $2
local.set $1
local.set $0
local.get $2
i32.const 1112
i32.load
Expand All @@ -1602,7 +1616,7 @@
i32.shr_u
i32.gt_u
if
local.get $1
local.get $0
i32.const 268435452
i32.gt_u
if
Expand All @@ -1620,28 +1634,28 @@
call $~lib/rt/tlsf/maybeInitialize
local.get $4
call $~lib/rt/tlsf/checkUsedBlock
local.get $1
local.get $0
i32.const 2
i32.shl
local.tee $5
call $~lib/rt/tlsf/reallocateBlock
i32.const 16
i32.add
local.tee $1
local.tee $0
i32.add
local.get $5
local.get $3
i32.sub
call $~lib/memory/memory.fill
local.get $1
local.get $0
local.get $4
i32.ne
if
i32.const 1104
local.get $1
local.get $0
i32.store
i32.const 1108
local.get $1
local.get $0
i32.store
end
i32.const 1112
Expand All @@ -1654,12 +1668,14 @@
i32.const 2
i32.shl
i32.add
local.get $0
local.get $1
call $~lib/rt/pure/__retain
i32.store
i32.const 1116
local.get $2
i32.store
local.get $1
call $~lib/rt/pure/__release
)
(func $~start
(local $0 i32)
Expand Down Expand Up @@ -1688,14 +1704,7 @@
local.get $0
call $~lib/array/Array<extends-baseaggregate/A2>#push
local.get $0
i32.const 1564
i32.gt_u
if
local.get $0
i32.const 16
i32.sub
call $~lib/rt/pure/decrement
end
call $~lib/rt/pure/__release
)
(func $~lib/rt/pure/markGray (param $0 i32)
(local $1 i32)
Expand Down
26 changes: 16 additions & 10 deletions tests/compiler/issues/1095.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -958,18 +958,22 @@
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
call $~lib/rt/tlsf/maybeInitialize
call $~lib/rt/tlsf/allocateBlock
i32.const 16
i32.add
call $~lib/rt/pure/__retain
local.tee $1
local.tee $3
i32.const 1200
i32.store
local.get $3
call $~lib/rt/pure/__retain
local.tee $1
local.set $2
local.get $1
local.tee $0
i32.load
local.tee $2
local.tee $0
i32.eqz
if
i32.const 0
Expand All @@ -979,22 +983,24 @@
call $~lib/builtins/abort
unreachable
end
local.get $2
local.get $0
local.get $2
i32.load
local.tee $1
local.tee $2
i32.ne
if
local.get $2
local.get $0
call $~lib/rt/pure/__retain
local.set $2
local.get $1
local.set $0
local.get $2
call $~lib/rt/pure/__release
end
local.get $1
local.get $0
local.get $2
i32.store
local.get $0
local.get $1
call $~lib/rt/pure/__release
local.get $3
call $~lib/rt/pure/__release
)
(func $~lib/rt/pure/decrement (param $0 i32)
Expand Down
65 changes: 41 additions & 24 deletions tests/compiler/logical.optimized.wat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(module
(type $i32_=>_none (func (param i32)))
(type $i32_i32_=>_none (func (param i32 i32)))
(type $none_=>_i32 (func (result i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $none_=>_none (func))
(type $i32_i32_=>_none (func (param i32 i32)))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
Expand Down Expand Up @@ -891,22 +891,17 @@
call $~lib/rt/rtrace/onalloc
local.get $1
)
(func $logical/Obj#constructor (result i32)
(local $0 i32)
(func $~lib/rt/pure/__retain (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
call $~lib/rt/tlsf/maybeInitialize
call $~lib/rt/tlsf/allocateBlock
i32.const 16
i32.add
local.tee $1
local.get $0
i32.const 1232
i32.gt_u
if
local.get $1
local.get $0
i32.const 16
i32.sub
local.tee $0
local.tee $1
i32.load offset=4
local.tee $2
i32.const -268435456
Expand All @@ -925,14 +920,14 @@
call $~lib/builtins/abort
unreachable
end
local.get $0
local.get $1
local.get $2
i32.const 1
i32.add
i32.store offset=4
local.get $0
local.get $1
call $~lib/rt/rtrace/onincrement
local.get $0
local.get $1
i32.load
i32.const 1
i32.and
Expand All @@ -945,7 +940,14 @@
unreachable
end
end
local.get $1
local.get $0
)
(func $logical/Obj#constructor (result i32)
call $~lib/rt/tlsf/maybeInitialize
call $~lib/rt/tlsf/allocateBlock
i32.const 16
i32.add
call $~lib/rt/pure/__retain
)
(func $~lib/rt/pure/__release (param $0 i32)
local.get $0
Expand All @@ -958,16 +960,24 @@
call $~lib/rt/pure/decrement
end
)
(func $~start
(local $0 i32)
(func $start:logical
(local $0 f64)
(local $1 i32)
(local $2 i32)
(local $3 f32)
(local $4 i32)
(local $5 i32)
call $logical/Obj#constructor
local.tee $0
if (result i32)
local.tee $4
call $~lib/rt/pure/__retain
local.tee $2
if
i32.const 1
else
i32.const 0
local.set $1
end
local.get $2
call $~lib/rt/pure/__release
local.get $1
i32.eqz
if
i32.const 0
Expand All @@ -978,12 +988,16 @@
unreachable
end
call $logical/Obj#constructor
local.tee $1
local.tee $2
call $~lib/rt/pure/__retain
local.tee $5
if (result i32)
i32.const 1
else
i32.const 0
end
local.get $5
call $~lib/rt/pure/__release
i32.eqz
if
i32.const 0
Expand All @@ -993,11 +1007,14 @@
call $~lib/builtins/abort
unreachable
end
local.get $0
local.get $4
call $~lib/rt/pure/__release
local.get $1
local.get $2
call $~lib/rt/pure/__release
)
(func $~start
call $start:logical
)
(func $~lib/rt/pure/decrement (param $0 i32)
(local $1 i32)
(local $2 i32)
Expand Down
Loading