mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
!3987 Fix FrameState ComputeLiveOut
Merge pull request !3987 from dingding/fix_compute_live_out
This commit is contained in:
commit
a1b7168e4d
@ -1390,7 +1390,8 @@ void BytecodeCircuitBuilder::BuildCircuit()
|
||||
auto valueCount = gateAcc_.GetInValueCount(gate);
|
||||
[[maybe_unused]] size_t numValueInputs = bytecodeInfo.ComputeValueInputCount();
|
||||
[[maybe_unused]] size_t numValueOutputs = bytecodeInfo.ComputeOutCount();
|
||||
ASSERT(numValueInputs == valueCount);
|
||||
// RETURNUNDEFINED has value input, but not from acc
|
||||
ASSERT(numValueInputs == valueCount || bytecodeInfo.GetOpcode() == EcmaOpcode::RETURNUNDEFINED);
|
||||
ASSERT(numValueOutputs <= 1 + (bytecodeInfo.EnvOut() ? 1 : 0));
|
||||
auto valueStarts = gateAcc_.GetInValueStarts(gate);
|
||||
for (size_t valueIdx = 0; valueIdx < valueCount; valueIdx++) {
|
||||
|
@ -284,6 +284,7 @@ public:
|
||||
void PUBLIC_API BytecodeToCircuit();
|
||||
int32_t GetJumpOffset(uint32_t bcIndex) const;
|
||||
void CollectRegionInfo(uint32_t bcIndex);
|
||||
GateRef ResolveDef(const size_t bbId, int32_t bcId, const uint16_t reg, const bool acc);
|
||||
|
||||
[[nodiscard]] Circuit* GetCircuit() const
|
||||
{
|
||||
@ -465,7 +466,6 @@ private:
|
||||
void NewPhi(BytecodeRegion &bb, uint16_t reg, bool acc, GateRef ¤tPhi);
|
||||
GateRef NewLoopBackPhi(BytecodeRegion &bb, uint16_t reg, bool acc);
|
||||
GateRef NewLoopForwardPhi(BytecodeRegion &bb, uint16_t reg, bool acc);
|
||||
GateRef ResolveDef(const size_t bbId, int32_t bcId, const uint16_t reg, const bool acc);
|
||||
void BuildCircuit();
|
||||
GateRef GetExistingRestore(GateRef resumeGate, uint16_t tmpReg) const;
|
||||
void SetExistingRestore(GateRef resumeGate, uint16_t tmpReg, GateRef restoreGate);
|
||||
|
@ -179,10 +179,10 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
|
||||
case EcmaOpcode::CALLTHISRANGE_IMM8_IMM8_V8:
|
||||
flags |= BytecodeFlags::SUPPORT_DEOPT;
|
||||
break;
|
||||
case EcmaOpcode::RETURNUNDEFINED:
|
||||
case EcmaOpcode::RETURN:
|
||||
flags |= BytecodeFlags::READ_ACC;
|
||||
[[fallthrough]];
|
||||
case EcmaOpcode::RETURN:
|
||||
case EcmaOpcode::RETURNUNDEFINED:
|
||||
kind = BytecodeKind::RETURN_BC;
|
||||
break;
|
||||
case EcmaOpcode::SUSPENDGENERATOR_V8:
|
||||
|
@ -257,7 +257,7 @@ bool FrameStateBuilder::ComputeLiveOut(size_t bbId)
|
||||
liveOutResult_->CopyFrom(liveout);
|
||||
while (true) {
|
||||
auto &bytecodeInfo = iterator.GetBytecodeInfo();
|
||||
ComputeLiveOutBC(iterator.Index(), bytecodeInfo);
|
||||
ComputeLiveOutBC(iterator.Index(), bytecodeInfo, bbId);
|
||||
--iterator;
|
||||
if (iterator.Done()) {
|
||||
break;
|
||||
@ -324,7 +324,7 @@ void FrameStateBuilder::BuildFrameState(GateRef frameArgs)
|
||||
BindStateSplit(size);
|
||||
}
|
||||
|
||||
void FrameStateBuilder::ComputeLiveOutBC(uint32_t index, const BytecodeInfo &bytecodeInfo)
|
||||
void FrameStateBuilder::ComputeLiveOutBC(uint32_t index, const BytecodeInfo &bytecodeInfo, size_t bbId)
|
||||
{
|
||||
if (bytecodeInfo.IsMov()) {
|
||||
auto gate = Circuit::NullGate();
|
||||
@ -338,10 +338,17 @@ void FrameStateBuilder::ComputeLiveOutBC(uint32_t index, const BytecodeInfo &byt
|
||||
UpdateVirtualRegister(out, Circuit::NullGate());
|
||||
}
|
||||
// variable use
|
||||
// when alive gate is null, find def
|
||||
if (bytecodeInfo.AccIn()) {
|
||||
if (gate == Circuit::NullGate()) {
|
||||
gate = builder_->ResolveDef(bbId, index, 0, true);
|
||||
}
|
||||
UpdateAccumulator(gate);
|
||||
} else if (bytecodeInfo.inputs.size() != 0) {
|
||||
auto vreg = std::get<VirtualRegister>(bytecodeInfo.inputs.at(0)).GetId();
|
||||
if (gate == Circuit::NullGate()) {
|
||||
gate = builder_->ResolveDef(bbId, index, vreg, false);
|
||||
}
|
||||
UpdateVirtualRegister(vreg, gate);
|
||||
}
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ private:
|
||||
void BuildPostOrderList(size_t size);
|
||||
bool ComputeLiveOut(size_t bbId);
|
||||
void ComputeLiveState();
|
||||
void ComputeLiveOutBC(uint32_t index, const BytecodeInfo &bytecodeInfo);
|
||||
void ComputeLiveOutBC(uint32_t index, const BytecodeInfo &bytecodeInfo, size_t bbId);
|
||||
bool IsAsyncResolveOrSusp(const BytecodeInfo &bytecodeInfo);
|
||||
bool MergeIntoPredBC(uint32_t predPc);
|
||||
bool MergeIntoPredBB(BytecodeRegion *bb, BytecodeRegion *predBb);
|
||||
|
@ -401,6 +401,10 @@ void NumberSpeculativeLowering::VisitPhi(GateRef gate)
|
||||
acc_.SetMachineType(gate, MachineType::F64);
|
||||
break;
|
||||
}
|
||||
case TypeInfo::NONE: { // retype not visit it, it's unused
|
||||
acc_.DeleteGate(gate);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ group("ark_deopt_test") {
|
||||
"dec",
|
||||
"div",
|
||||
"inc",
|
||||
"live_out",
|
||||
"mod",
|
||||
"newobjrange",
|
||||
"restore_vregs",
|
||||
|
19
test/deopttest/live_out/BUILD.gn
Normal file
19
test/deopttest/live_out/BUILD.gn
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("live_out") {
|
||||
deps = []
|
||||
is_debug_abc = true
|
||||
}
|
14
test/deopttest/live_out/expect_output.txt
Normal file
14
test/deopttest/live_out/expect_output.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
2
|
36
test/deopttest/live_out/live_out.ts
Normal file
36
test/deopttest/live_out/live_out.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// @ts-nocheck
|
||||
declare function print(a:any, b?:any):string;
|
||||
|
||||
class C {
|
||||
x:number = 1;
|
||||
y:number = 2;
|
||||
z:number = 3;
|
||||
|
||||
public update(d:number) {
|
||||
const x = this.x; // occur deopt
|
||||
const {
|
||||
y
|
||||
} = this;
|
||||
print(y);
|
||||
}
|
||||
}
|
||||
|
||||
let c = new C();
|
||||
C.prototype.foo = 123;
|
||||
c.update(123);
|
||||
|
@ -517,6 +517,10 @@ template("host_aot_test_action") {
|
||||
src_js = rebase_path(_test_ts_path_)
|
||||
}
|
||||
|
||||
if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
|
||||
extra_args += [ "--debug" ]
|
||||
}
|
||||
|
||||
in_puts = [
|
||||
_test_ts_path_,
|
||||
_test_expect_path_,
|
||||
@ -542,6 +546,10 @@ template("host_aot_test_action") {
|
||||
"--type-extractor",
|
||||
]
|
||||
|
||||
if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
|
||||
extra_args += [ "--debug" ]
|
||||
}
|
||||
|
||||
in_puts = [
|
||||
_test_ts_path_,
|
||||
_test_expect_path_,
|
||||
|
Loading…
Reference in New Issue
Block a user