!6994 modify code alarms

Merge pull request !6994 from 韩靖/master
This commit is contained in:
openharmony_ci 2024-04-22 03:55:51 +00:00 committed by Gitee
commit 0cd6e4212d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
35 changed files with 116 additions and 92 deletions

View File

@ -69,7 +69,7 @@ inline constexpr uint32_t CountLeadingZeros(T value)
static_assert(std::numeric_limits<T>::radix == RADIX, "Unexpected radix!");
static_assert(sizeof(T) == sizeof(uint64_t) || sizeof(T) <= sizeof(uint32_t), "Unsupported sizeof(T)");
if (value == 0) {
return sizeof(T) * 8;
return sizeof(T) * 8; // 8: Each byte has 8 bits
}
if (sizeof(T) == sizeof(uint64_t)) {
return __builtin_clzll(static_cast<uint64_t>(value));
@ -107,7 +107,7 @@ inline constexpr uint32_t CountTrailingZeros(T value)
static_assert(std::numeric_limits<T>::radix == RADIX, "Unexpected radix!");
static_assert(sizeof(T) == sizeof(uint64_t) || sizeof(T) <= sizeof(uint32_t), "Unsupported sizeof(T)");
if (value == 0) {
return sizeof(T) * 8;
return sizeof(T) * 8; // 8: Each byte has 8 bits
}
if (sizeof(T) == sizeof(uint64_t)) {
return __builtin_ctzll(static_cast<uint64_t>(value));

View File

@ -407,7 +407,7 @@ JSTaggedValue NumberHelper::DoubleToExponential(JSThread *thread, double number,
}
CString result = ss.str();
size_t found = result.find_last_of('e');
if (found != CString::npos && found < result.size() - 2 && result[found + 2] == '0') {
if (found != CString::npos && found < result.size() - 2 && result[found + 2] == '0') { // 2:offset of e
result.erase(found + 2, 1); // 2:offset of e
}
if (digit < 0) {
@ -1150,7 +1150,7 @@ int NumberHelper::GetMinmumDigits(double d, int *decimalPoint, char *buf)
int MinDigits = 1;
int MaxDigits = DOUBLE_MAX_PRECISION;
while (MinDigits < MaxDigits) {
digits = (MinDigits + MaxDigits) / 2;
digits = (MinDigits + MaxDigits) / 2; // 2 : Divide by 2
GetBase(d, digits, decimalPoint, buf, bufTmp, sizeof(bufTmp));
if (strtod(bufTmp, NULL) == d) {
// no need to keep the trailing zeros

View File

@ -908,6 +908,7 @@ void Builtins::InitializeBoolean(const JSHandle<GlobalEnv> &env, const JSHandle<
void Builtins::InitializeProxy(const JSHandle<GlobalEnv> &env)
{
// 2: The number of parameters is 2
JSHandle<JSObject> proxyFunction(InitializeExoticConstructor(env, Proxy::ProxyConstructor, "Proxy", 2));
// Proxy method
@ -3710,7 +3711,7 @@ void Builtins::InitializeCjsModule(const JSHandle<GlobalEnv> &env) const
JSHandle<JSTaggedValue> loaded(factory_->NewEmptyJSObject());
JSHandle<JSTaggedValue> children(factory_->NewEmptyJSObject());
JSHandle<JSTaggedValue> cache = JSHandle<JSTaggedValue>::Cast(CjsModuleCache::Create(thread_,
CjsModuleCache::DEAULT_DICTIONART_CAPACITY));
CjsModuleCache::DEAULT_DICTIONART_CAPACITY));
// CjsModule.prototype members
SetNonConstantObject(cjsModulePrototype, "id", id);

View File

@ -230,7 +230,7 @@ void Builtins::InitializeSSet(const JSHandle<GlobalEnv> &env, const JSHandle<JSO
// SharedSet.prototype functions, excluding keys()
for (const base::BuiltinFunctionEntry &entry: BuiltinsSharedSet::GetSetPrototypeFunctions()) {
SetSFunction(env, setPrototype, entry.GetName(), entry.GetEntrypoint(), fieldIndex++,
entry.GetLength(), entry.GetBuiltinStubId());
entry.GetLength(), entry.GetBuiltinStubId());
}
// SharedSet.prototype.keys, which is strictly equal to Set.prototype.values
JSHandle<JSTaggedValue> keys(factory_->NewFromASCII("keys"));

View File

@ -35,14 +35,14 @@ LogicalImmediate LogicalImmediate::Create(uint64_t imm, int width)
// First, determine the element size.
unsigned int size = static_cast<uint32_t>(width);
do {
size /= 2;
size /= 2; // 2: Divide by 2
uint64_t mask = (1ULL << size) - 1;
if ((imm & mask) != ((imm >> size) & mask)) {
size *= 2;
size *= 2; // 2: Multiply by 2
break;
}
} while (size > 2);
} while (size > 2); // 2: Greater than 2
// Second, determine the rotation to make the element be: 0^m 1^n.
unsigned int cto = 0;
@ -407,7 +407,7 @@ void AssemblerAarch64::Mov(const Register &rd, const Immediate &imm)
Orr(rd, Register(Zero), orrImm);
return;
}
// One to up three instruction sequence.
// 2: One to up three instruction sequence.
if (allOneHalfWords >= (halfWords - 2) || allZeroHalfWords >= (halfWords - 2)) {
EmitMovInstruct(rd, immValue, allOneHalfWords, allZeroHalfWords);
return;

View File

@ -96,15 +96,15 @@ public:
inline int GetRegSize() const
{
if (scale_ == B) {
return 8;
return 8; // 8:Register size
} else if (scale_ == H) {
return 16;
return 16; // 16:Register size
} else if (scale_ == S) {
return 32;
return 32; // 32:Register size
} else if (scale_ == D) {
return 64;
return 64; // 64:Register size
} else if (scale_ == Q) {
return 128;
return 128; // 128:Register size
}
LOG_ECMA(FATAL) << "this branch is unreachable";
UNREACHABLE();

View File

@ -171,7 +171,8 @@ struct BytecodeRegion {
{
}
BytecodeIterator &GetBytecodeIterator() {
BytecodeIterator &GetBytecodeIterator()
{
return bytecodeIterator_;
}

View File

@ -357,7 +357,7 @@ void InterpreterStubBuilder::SetHomeObjectToFunction(GateRef glue, GateRef funct
}
void InterpreterStubBuilder::SetFrameState(GateRef glue, GateRef sp, GateRef function, GateRef acc,
GateRef env, GateRef pc, GateRef prev, GateRef type)
GateRef env, GateRef pc, GateRef prev, GateRef type)
{
GateRef state = GetFrame(sp);
SetFunctionToFrame(glue, state, function);
@ -584,7 +584,7 @@ void InterpreterStubBuilder::DispatchBase(GateRef target, GateRef glue, Args...
}
void InterpreterStubBuilder::Dispatch(GateRef glue, GateRef sp, GateRef pc, GateRef constpool, GateRef profileTypeInfo,
GateRef acc, GateRef hotnessCounter, GateRef format)
GateRef acc, GateRef hotnessCounter, GateRef format)
{
GateRef newPc = PtrAdd(pc, format);
GateRef opcode = Load(VariableType::INT8(), newPc);
@ -594,7 +594,7 @@ void InterpreterStubBuilder::Dispatch(GateRef glue, GateRef sp, GateRef pc, Gate
}
void InterpreterStubBuilder::DispatchLast(GateRef glue, GateRef sp, GateRef pc, GateRef constpool,
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
{
GateRef target = PtrMul(IntPtr(BytecodeStubCSigns::ID_ExceptionHandler), IntPtrSize());
DispatchBase(target, glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter);
@ -602,7 +602,7 @@ void InterpreterStubBuilder::DispatchLast(GateRef glue, GateRef sp, GateRef pc,
}
void InterpreterStubBuilder::DispatchDebugger(GateRef glue, GateRef sp, GateRef pc, GateRef constpool,
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
{
GateRef opcode = Load(VariableType::INT8(), pc);
GateRef target = PtrMul(ZExtInt32ToPtr(ZExtInt8ToInt32(opcode)), IntPtrSize());
@ -612,7 +612,7 @@ void InterpreterStubBuilder::DispatchDebugger(GateRef glue, GateRef sp, GateRef
}
void InterpreterStubBuilder::DispatchDebuggerLast(GateRef glue, GateRef sp, GateRef pc, GateRef constpool,
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
GateRef profileTypeInfo, GateRef acc, GateRef hotnessCounter)
{
GateRef target = PtrMul(IntPtr(BytecodeStubCSigns::ID_ExceptionHandler), IntPtrSize());
auto args = { glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter };

View File

@ -2671,8 +2671,8 @@ DECLARE_ASM_HANDLER(HandleReturn)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}
@ -2743,8 +2743,8 @@ DECLARE_ASM_HANDLER(HandleReturnundefined)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}
@ -2825,8 +2825,8 @@ DECLARE_ASM_HANDLER(HandleSuspendgeneratorV8)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}
@ -2906,8 +2906,8 @@ DECLARE_ASM_HANDLER(HandleDeprecatedSuspendgeneratorPrefV8V8)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}
@ -3250,8 +3250,8 @@ DECLARE_ASM_HANDLER(HandleAsyncgeneratorresolveV8V8V8)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}
@ -5063,8 +5063,8 @@ DECLARE_ASM_HANDLER(BCDebuggerEntry)
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = IntPtr(0);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndRollback),
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
{ glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
*varAcc, *varHotnessCounter, jumpSize });
Return();
}
}

View File

@ -1909,7 +1909,7 @@ void SlowPathLowering::LowerCopyDataProperties(GateRef gate)
void SlowPathLowering::LowerCreateObjectWithExcludedKeys(GateRef gate)
{
const int id = RTSTUB_ID(OptCreateObjectWithExcludedKeys);
// 3: number of value inputs
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) >= 2);
size_t numIn = acc_.GetNumValueIn(gate);
std::vector<GateRef> args;

View File

@ -1324,8 +1324,8 @@ inline GateRef StubBuilder::ObjIsSpecialContainer(GateRef obj)
{
GateRef objectType = GetObjectType(LoadHClass(obj));
return BoolAnd(
Int32GreaterThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST))),
Int32LessThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_QUEUE))));
Int32GreaterThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST))),
Int32LessThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_QUEUE))));
}
inline GateRef StubBuilder::IsJSPrimitiveRef(GateRef obj)
@ -1935,7 +1935,8 @@ inline void StubBuilder::SetPrototypeToHClass(VariableType type, GateRef glue, G
Store(type, glue, hClass, offset, proto);
}
inline void StubBuilder::SetProtoChangeDetailsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef protoChange)
inline void StubBuilder::SetProtoChangeDetailsToHClass(VariableType type,
GateRef glue, GateRef hClass, GateRef protoChange)
{
GateRef offset = IntPtr(JSHClass::PROTO_CHANGE_DETAILS_OFFSET);
Store(type, glue, hClass, offset, protoChange);

View File

@ -634,13 +634,15 @@ void AsmInterpreterCall::PushBuiltinFrame(ExtendedAssembler *assembler, Register
if (type == FrameType::BUILTIN_FRAME) {
// push stack args
__ Add(next, sp, Immediate(BuiltinFrame::GetStackArgsToFpDelta(false)));
// 16: type & next
// 2: -2 * FRAME_SLOT_SIZE means type & next
__ Stp(next, op, MemoryOperand(sp, -2 * FRAME_SLOT_SIZE, AddrMode::PREINDEX));
__ Add(Register(FP), sp, Immediate(2 * FRAME_SLOT_SIZE)); // 16: skip next and frame type
// 2: 2 * FRAME_SLOT_SIZE means skip next and frame type
__ Add(Register(FP), sp, Immediate(2 * FRAME_SLOT_SIZE));
} else {
// 16: type & next
// 2: -2 * FRAME_SLOT_SIZE means type & next
__ Stp(next, op, MemoryOperand(sp, -2 * FRAME_SLOT_SIZE, AddrMode::PREINDEX));
__ Add(Register(FP), sp, Immediate(2 * FRAME_SLOT_SIZE)); // 16: skip next and frame type
// 2: 2 * FRAME_SLOT_SIZE means skip next and frame type
__ Add(Register(FP), sp, Immediate(2 * FRAME_SLOT_SIZE));
}
}
@ -1259,7 +1261,7 @@ void AsmInterpreterCall::PushAsmInterpEntryFrame(ExtendedAssembler *assembler)
<< "This frame has been modified, and the offset CppToAsmInterp should be updated too.";
}
}
__ Add(fp, sp, Immediate(4 * FRAME_SLOT_SIZE)); // 32: skip frame type, prevSp, pc and glue
__ Add(fp, sp, Immediate(4 * FRAME_SLOT_SIZE)); // 4: 32 means skip frame type, prevSp, pc and glue
}
void AsmInterpreterCall::PopAsmInterpEntryFrame(ExtendedAssembler *assembler)

View File

@ -73,7 +73,7 @@ void OptimizedCall::CallRuntime(ExtendedAssembler *assembler)
__ Mov(frameType, Immediate(static_cast<int64_t>(FrameType::LEAVE_FRAME)));
// 2 : 2 means pairs
__ Stp(tmp, frameType, MemoryOperand(sp, -FRAME_SLOT_SIZE * 2, AddrMode::PREINDEX));
__ Add(fp, sp, Immediate(2 * FRAME_SLOT_SIZE)); // 16: skip frame type and tmp
__ Add(fp, sp, Immediate(2 * FRAME_SLOT_SIZE)); // 2 : 2 means pairs
__ Str(fp, MemoryOperand(glue, JSThread::GlueData::GetLeaveFrameOffset(false)));
// load runtime trampoline address

View File

@ -244,7 +244,7 @@ void AsmInterpreterCall::PushAsmInterpEntryFrame(ExtendedAssembler *assembler)
<< "This frame has been modified, and the offset CppToAsmInterp should be updated too.";
}
}
__ Leaq(Operand(rsp, 3 * FRAME_SLOT_SIZE), rbp); // 24: skip frame type, prevSp and pc
__ Leaq(Operand(rsp, 3 * FRAME_SLOT_SIZE), rbp); // 3: 24 means skip frame type, prevSp and pc
}
void AsmInterpreterCall::PopAsmInterpEntryFrame(ExtendedAssembler *assembler)
@ -854,7 +854,7 @@ void AsmInterpreterCall::CallNativeWithArgv(ExtendedAssembler *assembler, bool c
__ Pushq(JSTaggedValue::Undefined().GetRawData());
}
__ Pushq(func);
// 40: skip frame type, numArgs, func, newTarget and this
// 5: 40 means skip frame type, numArgs, func, newTarget and this
__ Leaq(Operand(rsp, numArgs, Times8, 5 * FRAME_SLOT_SIZE), rbp);
__ Movq(rsp, stackArgs);
@ -913,19 +913,19 @@ void AsmInterpreterCall::CallNativeEntry(ExtendedAssembler *assembler)
__ PushAlignBytes();
__ Push(function);
// 24: skip thread & argc & returnAddr
// 3: 24 means skip thread & argc & returnAddr
__ Subq(3 * FRAME_SLOT_SIZE, rsp);
PushBuiltinFrame(assembler, glue, FrameType::BUILTIN_ENTRY_FRAME);
__ Movq(Operand(method, Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET), nativeCode); // get native pointer
__ Movq(argv, r11);
// 16: skip numArgs & thread
// 2: 16 means skip numArgs & thread
__ Subq(2 * FRAME_SLOT_SIZE, r11);
// EcmaRuntimeCallInfo
__ Movq(r11, rdi);
CallNativeInternal(assembler, nativeCode);
// 40: skip function
// 5: 40 means skip function
__ Addq(5 * FRAME_SLOT_SIZE, rsp);
__ Ret();
}
@ -970,7 +970,7 @@ void AsmInterpreterCall::PushCallArgsAndDispatchNative(ExtendedAssembler *assemb
__ Movq(Operand(rsp, FRAME_SLOT_SIZE), glue); // 8: glue
PushBuiltinFrame(assembler, glue, FrameType::BUILTIN_FRAME);
__ Leaq(Operand(rbp, 2 * FRAME_SLOT_SIZE), rdi); // 16: skip argc & thread
__ Leaq(Operand(rbp, 2 * FRAME_SLOT_SIZE), rdi); // 2: skip argc & thread
__ PushAlignBytes();
CallNativeInternal(assembler, nativeCode);
__ Ret();

View File

@ -430,7 +430,7 @@ void OptimizedCall::GenJSCall(ExtendedAssembler *assembler, bool isNew)
__ Movq(kungfu::RuntimeStubCSigns::ID_CallRuntime, r10);
__ Movq(Operand(rax, r10, Times8, JSThread::GlueData::GetRTStubEntriesOffset(false)), r10);
__ Callq(r10); // call CallRuntime
__ Addq(4 * FRAME_SLOT_SIZE, rsp);
__ Addq(4 * FRAME_SLOT_SIZE, rsp); // 4: sp + 32 argv
__ Pop(rbp);
__ Ret();
}
@ -616,7 +616,7 @@ void OptimizedCall::ThrowNonCallableInternal(ExtendedAssembler *assembler, Regis
__ Movq(Operand(rax, r10, Times8, JSThread::GlueData::GetRTStubEntriesOffset(false)), r10);
__ Callq(r10); // call CallRuntime
__ Movabs(JSTaggedValue::VALUE_EXCEPTION, rax); // return exception
__ Addq(4 * FRAME_SLOT_SIZE, rsp); // 32: sp + 32 argv
__ Addq(4 * FRAME_SLOT_SIZE, rsp); // 4: sp + 32 argv
__ Pop(rbp);
__ Ret();
}
@ -797,7 +797,7 @@ void OptimizedCall::CallRuntime(ExtendedAssembler *assembler)
__ Pushq(rax);
__ Movq(rbp, rdx);
// 16: rbp & return address
// 2: rbp & return address
__ Addq(2 * FRAME_SLOT_SIZE, rdx);
__ Movq(Operand(rdx, 0), r10);
@ -805,7 +805,7 @@ void OptimizedCall::CallRuntime(ExtendedAssembler *assembler)
__ Movq(rax, rdi);
// 8: argc
__ Movq(Operand(rdx, FRAME_SLOT_SIZE), rsi);
// 16: argv
// 2: argv
__ Addq(2 * FRAME_SLOT_SIZE, rdx);
__ Callq(r10);
@ -993,7 +993,7 @@ void OptimizedCall::PushOptimizedUnfoldArgVFrame(ExtendedAssembler *assembler, R
void OptimizedCall::PopOptimizedUnfoldArgVFrame(ExtendedAssembler *assembler)
{
Register sp(rsp);
// 16 : 16 means pop call site sp and type
// 2 : 2 means pop call site sp and type
__ Addq(Immediate(2 * FRAME_SLOT_SIZE), sp);
__ Popq(rbp);
}

View File

@ -82,6 +82,7 @@ void TypedBytecodeLowering::ParseOptBytecodeRange()
std::vector<std::string> splitStrs = base::StringHelper::SplitString(optBCRange_, ",");
for (const auto &optBCRange : splitStrs) {
std::vector<std::string> splitRange = base::StringHelper::SplitString(optBCRange, ":");
// 2:Used to determine whether the size of the split string array splitRange is as expected.
if (splitRange.size() == 2) {
std::vector<int32_t> range;
std::string start = splitRange[0];
@ -580,7 +581,6 @@ void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate)
AddProfiling(gate);
GateRef frameState = Circuit::NullGate();
auto opcode = acc_.GetByteCodeOpcode(gate);
// The framestate of Call and Accessor related instructions directives is placed on IR. Using the depend edge to
// climb up and find the nearest framestate for other instructions
if (opcode == EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8 ||
@ -595,7 +595,6 @@ void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate)
} else {
UNREACHABLE();
}
if (tacc.IsMono()) {
GateRef receiver = tacc.GetReceiver();
builder_.ObjectTypeCheck(true, receiver,
@ -623,7 +622,6 @@ void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate)
DeleteConstDataIfNoUser(tacc.GetKey());
return;
}
auto receiverHC = builder_.LoadConstOffset(VariableType::JS_POINTER(), tacc.GetReceiver(),
TaggedObject::HCLASS_OFFSET);
for (size_t i = 0; i < typeCount; ++i) {
@ -724,7 +722,6 @@ void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate)
builder_.Bind(&fails[i]);
}
}
builder_.Bind(&exit);
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), Circuit::NullGate());
DeleteConstDataIfNoUser(tacc.GetKey());

View File

@ -236,6 +236,7 @@ bool Verifier::RunFixedGatesRelationsCheck(const Circuit *circuit, const std::ve
for (auto i = ins.begin(); i != ins.end(); i++) {
GateRef predGate = *i;
if (ac.IsFixed(predGate) &&
// 2: Judge equality
(circuit->GetOpCode(circuit->GetIn(fixedGate, 0)) == OpCode::LOOP_BEGIN && cnt == 2)) {
ASSERT(cnt > 0);
auto a = bbGatesAddrToIdx.at(circuit->GetIn(predGate, 0));

View File

@ -4300,7 +4300,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo*>(newSp);
newSp[index++] = ToUintPtr(thread);
newSp[index++] = numArgs + 2; // +1 for this
newSp[index++] = numArgs + 2; // 2: +1 for this
// func
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
newSp[index++] = ctor.GetRawData();

View File

@ -67,11 +67,11 @@ CString BigIntHelper::Conversion(const CString &num, uint32_t conversionToRadix,
JSHandle<BigInt> BigInt::GetUint64MaxBigint(JSThread *thread)
{
JSHandle<BigInt> bigint = CreateBigint(thread, 3);
JSHandle<BigInt> bigint = CreateBigint(thread, 3); // 3:The number of digits in an object of type BigInt
RETURN_HANDLE_IF_ABRUPT_COMPLETION(BigInt, thread);
bigint->SetDigit(0, 0);
bigint->SetDigit(1, 0);
bigint->SetDigit(2, 1);
bigint->SetDigit(2, 1); // 2:The number of digits in an object of type BigInt
return bigint;
}

View File

@ -110,7 +110,7 @@ void DateUtils::GetYearFromDays(std::array<int64_t, DATE_LENGTH> *date)
MONTH_TRANSFORM[0] : MONTH_TRANSFORM[2]); // transform month to civil system
int64_t year = y + (month <= MONTH_COEFFICIENT);
month -= 1;
realDay = doy - (COEFFICIENT_TO_CIVIL[1] * mp + 2) / COEFFICIENT_TO_CIVIL[0] + 1; // shift from 03-01 to 01-01
realDay = doy - (COEFFICIENT_TO_CIVIL[1] * mp + 2) / COEFFICIENT_TO_CIVIL[0] + 1; // 2: shift from 03-01 to 01-01
(*date)[YEAR] = year;
(*date)[MONTH] = month;
(*date)[DAYS] = realDay;

View File

@ -1235,7 +1235,7 @@ JSHandle<JSArray> JSDateTimeFormat::ConstructFDateIntervalToJSArray(JSThread *th
int32_t preEndPos = 0;
// 2: number of elements
std::array<int32_t, 2> begin {};
std::array<int32_t, 2> end {};
std::array<int32_t, 2> end {}; // 2: number of elements
begin[0] = begin[1] = end[0] = end[1] = 0;
std::vector<CommonDateFormatPart> parts;

View File

@ -173,7 +173,7 @@ private:
static HourCycleOption OptionToHourCycle(const std::string &hc);
// 2: number of elements
static Value TrackValue(int32_t beginning, int32_t ending, std::array<int32_t, 2> begin,
std::array<int32_t, 2> end);
std::array<int32_t, 2> end); // 2: number of elements
static HourCycleOption OptionToHourCycle(UDateFormatHourCycle hc);

View File

@ -258,6 +258,7 @@ class PropertyMetaData {
public:
using IsFoundField = BitField<bool, 0, 1>;
using IsInlinedPropsField = IsFoundField::NextFlag;
// 3: The bit field that represents the "Representation" of the property
using RepresentationField = IsInlinedPropsField::NextField<Representation, 3>;
using OffsetField = RepresentationField::NextField<uint32_t, PropertyAttributes::OFFSET_BITFIELD_NUM>;

View File

@ -1229,7 +1229,8 @@ public:
UNREACHABLE();
}
static constexpr bool HasId(Format format, size_t idx) {
static constexpr bool HasId(Format format, size_t idx)
{
switch (format) {
case Format::ID16:
return idx < 1;

View File

@ -1181,7 +1181,7 @@ void PandaFileTranslator::FixOpcode(MethodLiteral *method, const OldBytecodeInst
LOG_FULL(FATAL) << "FixOpcode memcpy_s fail";
UNREACHABLE();
}
*(pc + 4) = *(pc + 4) + 1;
*(pc + 4) = *(pc + 4) + 1; // 4: index of new opcode; 4: index of old opcode
break;
}
case OldBytecodeInst::Opcode::ECMA_LDLEXVARDYN_PREF_IMM4_IMM4: {
@ -1340,7 +1340,7 @@ void PandaFileTranslator::FixOpcode(MethodLiteral *method, const OldBytecodeInst
LOG_ECMA_IF(id > std::numeric_limits<uint16_t>::max(), FATAL) << "Cannot translate to 16 bits: " << id;
*pc = static_cast<uint8_t>(newOpcode);
*(pc + 1) = 0x00;
*(pc + 2) = 0x00;
*(pc + 2) = 0x00; // 2: offset of id
uint16_t newId = static_cast<uint16_t>(id);
if (memcpy_s(pc + 3, sizeof(uint16_t), &newId, sizeof(uint16_t)) != EOK) { // 3: offset of id
LOG_FULL(FATAL) << "FixOpcode memcpy_s fail";
@ -1354,7 +1354,7 @@ void PandaFileTranslator::FixOpcode(MethodLiteral *method, const OldBytecodeInst
LOG_ECMA_IF(id > std::numeric_limits<uint16_t>::max(), FATAL) << "Cannot translate to 16 bits: " << id;
*pc = static_cast<uint8_t>(newOpcode);
*(pc + 1) = 0x00;
*(pc + 2) = 0x00;
*(pc + 2) = 0x00; // 2: offset of id
uint16_t newId = static_cast<uint16_t>(id);
if (memcpy_s(pc + 3, sizeof(uint16_t), &newId, sizeof(uint16_t)) != EOK) { // 3: offset of id
LOG_FULL(FATAL) << "FixOpcode memcpy_s fail";

View File

@ -24,7 +24,7 @@ class ModuleManagerHelper {
public:
static JSTaggedValue PUBLIC_API GetModuleValue(JSThread *thread, JSHandle<SourceTextModule> module, int index);
static JSTaggedValue GetModuleValue(JSThread *thread, JSHandle<SourceTextModule> module,
static JSTaggedValue GetModuleValue(JSThread *thread, JSHandle<SourceTextModule> module,
JSTaggedValue bindingName);
static JSTaggedValue PUBLIC_API GetNativeModuleValue(JSThread *thread, JSTaggedValue resolvedModule,

View File

@ -423,6 +423,10 @@ public:
size += sizeof(PGOProfileType) * (count - 1) * 2; // 2 means mul by 2
}
auto result = reinterpret_cast<PGOProtoChainTemplate *>(malloc(size));
if (result == nullptr) {
LOG_ECMA_MEM(FATAL) << "malloc failed";
UNREACHABLE();
}
new (result) PGOProtoChainTemplate(size, count);
PGOProfileType *curPt = &(result->rootType_);
for (auto iter : protoChain) {
@ -448,6 +452,10 @@ public:
size += sizeof(PGOProfileType) * (static_cast<size_t>(count) - 1) * 2; // 2 means mul by 2
}
auto result = reinterpret_cast<PGOProtoChainTemplate *>(malloc(size));
if (result == nullptr) {
LOG_ECMA_MEM(FATAL) << "malloc failed";
UNREACHABLE();
}
new (result) PGOProtoChainTemplate(size, count);
PGOProfileType *curPt = &(result->rootType_);
from->IterateProtoChain([&context, &curPt] (auto rootType, auto childType) {

View File

@ -132,7 +132,6 @@ JSHandle<EcmaString> ResolveFilenameFromNative(JSThread *thread, JSTaggedValue d
CString resolvedFilename;
CString dirnameStr = ConvertToString(EcmaString::Cast(dirname.GetTaggedObject()));
CString requestStr = ConvertToString(EcmaString::Cast(request.GetTaggedObject()));
if (requestStr.find("./") == 0) {
requestStr = requestStr.substr(2); // 2 : delete './'
}

View File

@ -229,7 +229,7 @@ DEF_RUNTIME_STUBS(CallInternalSetter)
RUNTIME_STUBS_HEADER(CallInternalSetter);
JSHandle<JSObject> receiver = GetHArg<JSObject>(argv, argc, 0); // 0: means the zeroth parameter
JSTaggedType argSetter = GetTArg(argv, argc, 1); // 1: means the first parameter
JSHandle<JSTaggedValue> value = GetHArg<JSTaggedValue>(argv, argc, 2);
JSHandle<JSTaggedValue> value = GetHArg<JSTaggedValue>(argv, argc, 2); // 2: means the second parameter
auto setter = AccessorData::Cast((reinterpret_cast<TaggedObject *>(argSetter)));
auto result = setter->CallInternalSet(thread, receiver, value, true);
if (!result) {
@ -916,7 +916,6 @@ DEF_RUNTIME_STUBS(Exp)
RUNTIME_STUBS_HEADER(Exp);
JSTaggedValue baseValue = GetArg(argv, argc, 0); // 0: means the zeroth parameter
JSTaggedValue exponentValue = GetArg(argv, argc, 1); // 1: means the first parameter
if (baseValue.IsNumber() && exponentValue.IsNumber()) {
// fast path
double doubleBase = baseValue.IsInt() ? baseValue.GetInt() : baseValue.GetDouble();
@ -1096,9 +1095,9 @@ DEF_RUNTIME_STUBS(SuperCallSpread)
DEF_RUNTIME_STUBS(OptSuperCallSpread)
{
RUNTIME_STUBS_HEADER(OptSuperCallSpread);
JSHandle<JSTaggedValue> func = GetHArg<JSTaggedValue>(argv, argc, 0);
JSHandle<JSTaggedValue> newTarget = GetHArg<JSTaggedValue>(argv, argc, 1);
JSHandle<JSTaggedValue> array = GetHArg<JSTaggedValue>(argv, argc, 2);
JSHandle<JSTaggedValue> func = GetHArg<JSTaggedValue>(argv, argc, 0); // 0: means the zeroth parameter
JSHandle<JSTaggedValue> newTarget = GetHArg<JSTaggedValue>(argv, argc, 1); // 1: means the first parameter
JSHandle<JSTaggedValue> array = GetHArg<JSTaggedValue>(argv, argc, 2); // 2: means the second parameter
return RuntimeSuperCallSpread(thread, func, newTarget, array).GetRawData();
}

View File

@ -27,7 +27,7 @@ class MainEditor {
this.filePoint_ = '';
this.files_ = [];
this.viewer_ = {}
this.viewer_ = {};
LogParser.Load('test.txt', this.onLoad.bind(this));
this.selectFile_ = new XSelect(this.files_, this.filePoint_);

View File

@ -37,10 +37,10 @@ export class XTools {
try {
XTools.CONFIG = JSON.parse(xhr.responseText);
for (let k in XTools.CONFIG.NodeColor) {
XTools.CONFIG.NodeColor[k]=parseInt(XTools.CONFIG.NodeColor[k],16);
XTools.CONFIG.NodeColor[k] = parseInt(XTools.CONFIG.NodeColor[k],16);
}
for (let k in XTools.CONFIG.LineColor) {
XTools.CONFIG.LineColor[k]=parseInt(XTools.CONFIG.LineColor[k],16);
XTools.CONFIG.LineColor[k] = parseInt(XTools.CONFIG.LineColor[k],16);
}
} catch (e) {
alert('Config file error');

View File

@ -43,10 +43,18 @@ class XScroll {
}
}
isTouchIn(x, y) {
if (x < this.posX_) return false;
if (y < this.posY_) return false;
if (x > this.posX_ + this.posW_) return false;
if (y > this.posY_ + this.posH_) return false;
if (x < this.posX_) {
return false;
}
if (y < this.posY_) {
return false;
}
if (x > this.posX_ + this.posW_) {
return false;
}
if (y > this.posY_ + this.posH_) {
return false;
}
return true;
}
setBarOff(rate) {

View File

@ -121,7 +121,9 @@ class XSelect {
let isIn = this.isTouchIn(x, y);
switch (msg) {
case 1:
if (!isIn) break;
if (!isIn) {
break;
}
if (!this.open_) {
this.open_ = true;
break;

View File

@ -136,7 +136,10 @@ export class X2DFast {
this.drawCount = 0;
}
swapC(c) {
let r, g, b, a;
let r;
let g;
let b;
let a;
if (isNaN(c)) {
r = Math.floor(c[0] * 63 / 255);
g = Math.floor(c[1] * 63 / 255);

View File

@ -78,10 +78,10 @@ class LogParser {
}
isStart(l) {
//========= After bytecode2circuit lowering [func_main_0@484@arkcompiler/ets_runtime/sd_test/ttabs.abc] ========
const regexStart = /=+ *After ([a-zA-Z0-9_ ]+) \[([#a-zA-Z0-9_@/.-]+)\] *=+/g
const regexStart = /=+ *After ([a-zA-Z0-9_ ]+) \[([#a-zA-Z0-9_@/.-]+)\] *=+/g;
//========= After inlining [OthreMath@test@arkcompiler/ets_runtime/sd_test/test.abc] Caller
//method [func_main_0@641@arkcompiler/ets_runtime/sd_test/test.abc]====================
const regexStart2 = /=+ *After ([a-zA-Z0-9_ ]+) \[([a-zA-Z0-9_@/.-]+)\] *Caller method \[([#a-zA-Z0-9_@/.]+)\] *=+/g
const regexStart2 = /=+ *After ([a-zA-Z0-9_ ]+) \[([a-zA-Z0-9_@/.-]+)\] *Caller method \[([#a-zA-Z0-9_@/.]+)\] *=+/g;
if (l[11] !== '=') {
return;
@ -157,7 +157,7 @@ class LogParser {
cutResult.push(tmp);
p = i;
}
cutResult.push('inNum=[' + ir.in[0].length + ',' + ir.in[1].length + ',' + ir.in[2].length + ',' + ir.in[3].length + ',' + ir.in[4].length + ']')
cutResult.push('inNum=[' + ir.in[0].length + ',' + ir.in[1].length + ',' + ir.in[2].length + ',' + ir.in[3].length + ',' + ir.in[4].length + ']');
cutResult.push('outNum=' + ir.out.length);
ir.maxDetailWidth = 0;
for (let detail of cutResult) {
@ -172,7 +172,7 @@ class LogParser {
}
else {
//= End typeHitRate: 0.500000 =
let regexEnd = /=+ End[a-zA-Z:.0-9 ]* =+/g
let regexEnd = /=+ End[a-zA-Z:.0-9 ]* =+/g;
let tt = regexEnd.exec(l);
if (tt) { //收集结束入大表l.search('== End ==') > 0
if (this.procNormal_.irList.length > 0) {
@ -237,7 +237,7 @@ class LogParser {
}
NumberStringToArray(ss) {
let outs = ss.split(',');
let ret = []
let ret = [];
for (let s of outs) {
let ttt = parseInt(s);
if (!isNaN(ttt)) {
@ -252,7 +252,7 @@ class LogParser {
if (l.startsWith('[compiler] aot method')) {
//[compiler] aot method [func_main_0@b.abc] log:
const regexFuncName = /^\[compiler\] aot method \[([#a-zA-Z0-9_@/.]+)\] (recordName \[[a-zA-Z0-9_]*\] )*log:/g
const regexFuncName = /^\[compiler\] aot method \[([#a-zA-Z0-9_@/.]+)\] (recordName \[[a-zA-Z0-9_]*\] )*log:/g;
ret = regexFuncName.exec(l);
if (ret) {
[ib.funcPoint, ib.filePoint] = this.splitLast(ret[1]);
@ -261,7 +261,7 @@ class LogParser {
}
}
if (l.startsWith('[compiler] ==================== Before state split')) {
const regexFuncName2 = /^\[compiler\] =+ Before state split linearizer \[([#a-zA-Z0-9_@/.]+)\] *=*/g
const regexFuncName2 = /^\[compiler\] =+ Before state split linearizer \[([#a-zA-Z0-9_@/.]+)\] *=*/g;
ret = regexFuncName2.exec(l);
if (ret) {
[ib.funcPoint, ib.filePoint] = this.splitLast(ret[1]);
@ -270,7 +270,7 @@ class LogParser {
}
}
if (l.startsWith('[compiler] ==================== After graph lineari')) {
const regexFuncName3 = /^\[compiler\] =+ After graph linearizer \[([#a-zA-Z0-9_@/.]+)\] *=*/g
const regexFuncName3 = /^\[compiler\] =+ After graph linearizer \[([#a-zA-Z0-9_@/.]+)\] *=*/g;
ret = regexFuncName3.exec(l);
if (ret) {
[ib.funcPoint, ib.filePoint] = this.splitLast(ret[1]);