[Fuzz] NewNumber/retype fuzz bugfix

Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAHZ1E
Description:1.phi的输入存在CHAR时,需要判断constant输入;2.new
Number时输入两个以上参数导致错误的ASSERT

Signed-off-by: zhangyinlu <zhangyinlu@huawei.com>
Change-Id: Ibfc5e2b481628db2514d0c5276ac61525dd463b9
This commit is contained in:
zhangyinlu 2024-08-05 17:48:23 +08:00
parent 45abcf3683
commit 6e7e95c0b3
7 changed files with 32 additions and 9 deletions

View File

@ -491,7 +491,7 @@ GateRef NumberSpeculativeRetype::VisitStringAdd(GateRef gate)
return Circuit::NullGate();
}
TypeInfo NumberSpeculativeRetype::GetOuputForPhi(GateRef gate, bool ignoreConstant)
TypeInfo NumberSpeculativeRetype::GetOutputForPhi(GateRef gate, bool ignoreConstant)
{
size_t valueNum = acc_.GetNumValueIn(gate);
bool hasConstantInput = false;
@ -515,8 +515,8 @@ TypeInfo NumberSpeculativeRetype::GetOuputForPhi(GateRef gate, bool ignoreConsta
}
}
if (hasConstantInput && ignoreConstant && tempType == TypeInfo::NONE) {
return GetOuputForPhi(gate, false);
if (hasConstantInput && ignoreConstant && (tempType == TypeInfo::NONE || tempType == TypeInfo::CHAR)) {
return GetOutputForPhi(gate, false);
}
return tempType;
}
@ -524,7 +524,7 @@ TypeInfo NumberSpeculativeRetype::GetOuputForPhi(GateRef gate, bool ignoreConsta
GateRef NumberSpeculativeRetype::VisitPhi(GateRef gate)
{
if (IsRetype()) {
auto tempType = GetOuputForPhi(gate, true);
auto tempType = GetOutputForPhi(gate, true);
TypeInfo typeInfo = GetOutputTypeInfo(gate);
if (typeInfo != tempType) {
SetOutputTypeInfo(gate, tempType);

View File

@ -159,7 +159,7 @@ private:
GateRef TryConvertConstant(GateRef gate, bool needInt32);
GateRef TryConvertConstantToInt32(GateRef gate);
GateRef ConvertTaggedToNJSValue(GateRef gate, TypeInfo output);
TypeInfo GetOuputForPhi(GateRef gate, bool ignoreConstant);
TypeInfo GetOutputForPhi(GateRef gate, bool ignoreConstant);
TypeInfo GetOutputTypeInfo(GateRef gate) const
{

View File

@ -1482,8 +1482,7 @@ bool TryLowerNewNumber(CircuitBuilder *builder, GateAccessor acc, GateRef gate)
if ((acc.GetOpCode(loadBuiltin) == OpCode::LOAD_BUILTIN_OBJECT) &&
(acc.GetIndex(loadBuiltin) == static_cast<size_t>(BuiltinType::BT_NUMBER))) {
auto arg = builder->ToTaggedIntPtr(builder->Int32(0));
if (acc.GetNumValueIn(gate) != 1) {
ASSERT(acc.GetNumValueIn(gate) == 2U);
if (acc.GetNumValueIn(gate) > 1) {
arg = acc.GetValueIn(gate, 1);
}

View File

@ -12,3 +12,5 @@
# limitations under the License.
[object Object]
7
true

View File

@ -18,3 +18,10 @@ declare function print(arg:any):string;
let a = new EventInfo()
print(a)
function foo() {
let c = new Number(7, Number)
print(c)
}
foo()
print(ArkTools.isAOTCompiled(foo))

View File

@ -13,3 +13,5 @@
true
97
true
9,[object Object]

View File

@ -25,7 +25,20 @@ for (let i = 0; i < 20; i++) {
}
ArkTools.jitCompileAsync(f);
let res = ArkTools.waitJitCompileFinish(f);
print(res)
print(ArkTools.waitJitCompileFinish(f))
print(f(ss))
function f2() {
let v1 = 0, v18 = 0, v28 = 1;
for (; v28--;) {
({ "length": v18, ...v1 } = "123456789");
}
return [v18, v1];
}
f2();
ArkTools.jitCompileAsync(f2);
print(ArkTools.waitJitCompileFinish(f2))
print(f2())