diff --git a/ecmascript/builtins/builtins_json.h b/ecmascript/builtins/builtins_json.h index fa01eb6737..a80ebab7bb 100644 --- a/ecmascript/builtins/builtins_json.h +++ b/ecmascript/builtins/builtins_json.h @@ -20,7 +20,6 @@ #include "ecmascript/ecma_runtime_call_info.h" namespace panda::ecmascript::builtins { -using JSTaggedValue = JSTaggedValue; class BuiltinsJson : public base::BuiltinsBase { public: diff --git a/ecmascript/builtins/builtins_string.cpp b/ecmascript/builtins/builtins_string.cpp index f8a61226c3..09e822daf6 100644 --- a/ecmascript/builtins/builtins_string.cpp +++ b/ecmascript/builtins/builtins_string.cpp @@ -469,7 +469,7 @@ JSTaggedValue BuiltinsString::Includes(EcmaRuntimeCallInfo *argv) u16strSearch = base::StringHelper::Utf8ToU16String(uint8Search, searchLen); } uint32_t idx = base::StringHelper::Find(u16strThis, u16strSearch, start); - if (idx < 0 || idx > thisLen) { + if (idx > thisLen) { return BuiltinsString::GetTaggedBoolean(false); } return BuiltinsString::GetTaggedBoolean(true); @@ -552,7 +552,7 @@ JSTaggedValue BuiltinsString::LastIndexOf(EcmaRuntimeCallInfo *argv) u16strSearch = base::StringHelper::Utf8ToU16String(uint8Search, searchLen); } uint32_t res = base::StringHelper::RFind(u16strThis, u16strSearch, pos); - if (res >= 0 && res < thisLen) { + if (res < thisLen) { return GetTaggedInt(res); } res = -1; diff --git a/ecmascript/builtins/builtins_typedarray.cpp b/ecmascript/builtins/builtins_typedarray.cpp index 2910cb10f7..7d64e3f0b6 100644 --- a/ecmascript/builtins/builtins_typedarray.cpp +++ b/ecmascript/builtins/builtins_typedarray.cpp @@ -1378,7 +1378,7 @@ JSTaggedValue BuiltinsTypedArray::Sort(EcmaRuntimeCallInfo *argv) compareResult > 0 ? (endIndex = middleIndex) : (beginIndex = middleIndex + 1); } - if (endIndex >= 0 && endIndex < i) { + if (endIndex < i) { for (uint32_t j = i; j > endIndex; j--) { key2.Update(JSTaggedValue(j - 1)); previousValue.Update( diff --git a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp index 3f065476b7..beba6b6df8 100644 --- a/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp +++ b/ecmascript/compiler/assembler/aarch64/assembler_aarch64.cpp @@ -248,7 +248,7 @@ uint32_t AssemblerAarch64::GetOpcFromScale(Scale scale, bool ispair) opc = ispair ? 0 : 1; break; case Scale::D: - opc = ispair ? 1 : 1; + opc = 1; break; case Scale::Q: // 3 : means opc bit is 11 diff --git a/ecmascript/compiler/circuit_builder-inl.h b/ecmascript/compiler/circuit_builder-inl.h index 1fa83980ba..ae8cc18be0 100644 --- a/ecmascript/compiler/circuit_builder-inl.h +++ b/ecmascript/compiler/circuit_builder-inl.h @@ -791,13 +791,15 @@ void Environment::SubCfgEntry(Label *entry) void Environment::SubCfgExit() { - GateRef control = currentLabel_->GetControl(); - GateRef depend = currentLabel_->GetDepend(); - if (!stack_.empty()) { - currentLabel_ = stack_.top(); - currentLabel_->SetControl(control); - currentLabel_->SetDepend(depend); - stack_.pop(); + if (currentLabel_ != nullptr) { + GateRef control = currentLabel_->GetControl(); + GateRef depend = currentLabel_->GetDepend(); + if (!stack_.empty()) { + currentLabel_ = stack_.top(); + currentLabel_->SetControl(control); + currentLabel_->SetDepend(depend); + stack_.pop(); + } } } diff --git a/ecmascript/compiler/gate_accessor.h b/ecmascript/compiler/gate_accessor.h index fe81245278..205a853cd0 100644 --- a/ecmascript/compiler/gate_accessor.h +++ b/ecmascript/compiler/gate_accessor.h @@ -29,7 +29,10 @@ public: GateRef operator*() const { - return circuit_->GetGateRef(out_->GetGateConst()); + if (out_ != nullptr) { + return circuit_->GetGateRef(out_->GetGateConst()); + } + return 0; } const ConstUseIterator operator++() @@ -82,7 +85,10 @@ public: GateRef operator*() const { - return circuit_->GetGateRef(out_->GetGate()); + if (out_ != nullptr) { + return circuit_->GetGateRef(out_->GetGate()); + } + return 0; } const UseIterator& operator++() diff --git a/ecmascript/compiler/scheduler.cpp b/ecmascript/compiler/scheduler.cpp index d74eb18e77..f2cdaa12a3 100644 --- a/ecmascript/compiler/scheduler.cpp +++ b/ecmascript/compiler/scheduler.cpp @@ -325,7 +325,6 @@ std::optional> Scheduler::CalculateSchedulin GateAccessor acc(const_cast(circuit)); std::unordered_map lowerBound; std::unordered_map useCount; - std::deque pendingList; std::vector bbAndFixedGatesList; for (const auto &item : bbGatesAddrToIdx) { bbAndFixedGatesList.push_back(item.first); diff --git a/ecmascript/compiler/slowpath_lowering.cpp b/ecmascript/compiler/slowpath_lowering.cpp index b78a6959b0..8ac23ca38d 100644 --- a/ecmascript/compiler/slowpath_lowering.cpp +++ b/ecmascript/compiler/slowpath_lowering.cpp @@ -1855,11 +1855,7 @@ void SlowPathLowering::LowerSuperCallSpread(GateRef gate, GateRef glue, GateRef void SlowPathLowering::LowerIsTrueOrFalse(GateRef gate, GateRef glue, bool flag) { - if (flag) { - DebugPrintBC(gate, glue); - } else { - DebugPrintBC(gate, glue); - } + DebugPrintBC(gate, glue); Label isTrue(&builder_); Label isFalse(&builder_); Label successExit(&builder_); diff --git a/ecmascript/containers/containers_vector.cpp b/ecmascript/containers/containers_vector.cpp index 110b102c76..1b71bffa75 100644 --- a/ecmascript/containers/containers_vector.cpp +++ b/ecmascript/containers/containers_vector.cpp @@ -648,7 +648,7 @@ JSTaggedValue ContainersVector::Sort(EcmaRuntimeCallInfo *argv) } } - if (endIndex >= 0 && endIndex < i) { + if (endIndex < i) { for (uint32_t j = i; j > endIndex; j--) { previousValue.Update(elements->Get(j - 1)); elements->Set(thread, j, previousValue.GetTaggedValue()); diff --git a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp index 9a803f99ed..4b80ca6903 100644 --- a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp +++ b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp @@ -316,7 +316,10 @@ bool CpuProfiler::ParseMethodInfo(Method *method, FrameHandler &frameHandler, bo if (!CheckAndCopy(codeEntry.codeType, sizeof(codeEntry.codeType), "JS")) { return false; } - const char *tempVariable = method->GetMethodName(); + const char *tempVariable = nullptr; + if (method != nullptr) { + tempVariable = method->GetMethodName(); + } uint8_t length = strlen(tempVariable); if (length != 0 && tempVariable[0] == '#') { uint8_t index = length - 1; diff --git a/ecmascript/file_loader.cpp b/ecmascript/file_loader.cpp index 6b8a5019e6..eaee488b1b 100644 --- a/ecmascript/file_loader.cpp +++ b/ecmascript/file_loader.cpp @@ -63,14 +63,14 @@ void ModuleSectionDes::SaveSectionsInfo(std::ofstream &file) void ModuleSectionDes::LoadStackMapSection(BinaryBufferParser &parser, uintptr_t secBegin, uint32_t &curUnitOffset) { - uint32_t size; + uint32_t size = 0; parser.ParseBuffer(&size, sizeof(size)); parser.ParseBuffer(reinterpret_cast(secBegin), size); SetArkStackMapSize(size); SetArkStackMapPtr(reinterpret_cast(secBegin)); curUnitOffset += size; - uint32_t index; - uint32_t cnt; + uint32_t index = 0; + uint32_t cnt = 0; parser.ParseBuffer(&index, sizeof(index)); parser.ParseBuffer(&cnt, sizeof(cnt)); SetStartIndex(index); @@ -80,14 +80,14 @@ void ModuleSectionDes::LoadStackMapSection(BinaryBufferParser &parser, uintptr_t void ModuleSectionDes::LoadSectionsInfo(BinaryBufferParser &parser, uint32_t &curUnitOffset, uint64_t codeAddress) { - uint32_t secInfoSize; + uint32_t secInfoSize = 0; parser.ParseBuffer(&secInfoSize, sizeof(secInfoSize)); auto secBegin = codeAddress + static_cast(curUnitOffset); for (uint8_t i = 0; i < secInfoSize; i++) { - uint8_t secName; + uint8_t secName = 0; parser.ParseBuffer(&secName, sizeof(secName)); auto secEnumName = static_cast(secName); - uint32_t secSize; + uint32_t secSize = 0; parser.ParseBuffer(&secSize, sizeof(secSize)); SetSecSize(secSize, secEnumName); parser.ParseBuffer(reinterpret_cast(secBegin), secSize); @@ -181,7 +181,7 @@ bool StubModulePackInfo::Load(EcmaVM *vm) vm->GetFileLoader()->SetStubmmap(pool.GetMem(), pool.GetSize()); uint64_t codeAddress = reinterpret_cast(pool.GetMem()); uint32_t curUnitOffset = 0; - uint32_t asmStubSize; + uint32_t asmStubSize = 0; binBufparser.ParseBuffer(&asmStubSize, sizeof(asmStubSize)); SetAsmStubSize(asmStubSize); binBufparser.ParseBuffer(reinterpret_cast(codeAddress), asmStubSize); diff --git a/ecmascript/frames.cpp b/ecmascript/frames.cpp index 609abf65fe..5f7e7f6d5a 100644 --- a/ecmascript/frames.cpp +++ b/ecmascript/frames.cpp @@ -430,7 +430,6 @@ ARK_INLINE void AsmInterpretedFrame::GCIterate(const FrameIterator &it, visitor(Root::ROOT_FRAME, ObjectSlot(ToUintPtr(&frame->env))); } - std::set slotAddrs; bool ret = it.IteratorStackMap(visitor, derivedVisitor); if (!ret) { #ifndef NDEBUG diff --git a/ecmascript/js_api/js_api_lightweightset.cpp b/ecmascript/js_api/js_api_lightweightset.cpp index 80006e23a4..9d2317a0fb 100644 --- a/ecmascript/js_api/js_api_lightweightset.cpp +++ b/ecmascript/js_api/js_api_lightweightset.cpp @@ -260,7 +260,7 @@ bool JSAPILightWeightSet::Equal(JSThread *thread, const JSHandle destHashes(thread, obj->GetHashes()); uint32_t destSize = obj->GetLength(); - uint32_t srcSize; + uint32_t srcSize = 0; JSMutableHandle srcHashes(thread, obj->GetHashes()); if (value.GetTaggedValue().IsJSAPILightWeightSet()) { JSAPILightWeightSet *srcLightWeightSet = JSAPILightWeightSet::Cast(value.GetTaggedValue().GetTaggedObject()); diff --git a/ecmascript/js_api/js_api_queue.cpp b/ecmascript/js_api/js_api_queue.cpp index 89ab904464..6da9840460 100644 --- a/ecmascript/js_api/js_api_queue.cpp +++ b/ecmascript/js_api/js_api_queue.cpp @@ -166,7 +166,7 @@ bool JSAPIQueue::GetOwnProperty(JSThread *thread, const JSHandle &ob } uint32_t length = obj->GetLength().GetArrayLength(); - if (index < 0 || index >= length) { + if (index >= length) { THROW_RANGE_ERROR_AND_RETURN(thread, "GetOwnProperty index out-of-bounds", false); } diff --git a/ecmascript/js_date_time_format.cpp b/ecmascript/js_date_time_format.cpp index c957558ab3..c88f0828d6 100644 --- a/ecmascript/js_date_time_format.cpp +++ b/ecmascript/js_date_time_format.cpp @@ -1106,7 +1106,7 @@ std::vector InitializePattern(const IcuPatternDesc &hourData) } else { result.emplace_back(hourData); } - item++; + ++item; } return result; } diff --git a/ecmascript/js_handle.h b/ecmascript/js_handle.h index a463e4dcb8..6ea5bfe672 100644 --- a/ecmascript/js_handle.h +++ b/ecmascript/js_handle.h @@ -225,6 +225,7 @@ public: void Update(JSTaggedValue value) { auto addr = reinterpret_cast(this->GetAddress()); + ASSERT(addr != nullptr); *addr = value; } diff --git a/ecmascript/js_object.cpp b/ecmascript/js_object.cpp index 1cd53fa72c..0f13a801f0 100644 --- a/ecmascript/js_object.cpp +++ b/ecmascript/js_object.cpp @@ -147,7 +147,6 @@ JSHandle JSObject::TransitionToDictionary(const JSThread *thread ASSERT(!jshclass->IsDictionaryMode()); uint32_t propNumber = jshclass->NumberOfProps(); - ASSERT(propNumber >= 0); ASSERT(!jshclass->GetLayout().IsNull()); JSHandle layoutInfoHandle(thread, jshclass->GetLayout()); ASSERT(layoutInfoHandle->GetLength() != 0); diff --git a/ecmascript/js_vm/main.cpp b/ecmascript/js_vm/main.cpp index fb19905f55..4ec2c21525 100644 --- a/ecmascript/js_vm/main.cpp +++ b/ecmascript/js_vm/main.cpp @@ -38,12 +38,6 @@ void BlockSignals() LOG_ECMA(ERROR) << "sigemptyset failed"; return; } - int rc = 0; - - if (rc < 0) { - LOG_ECMA(ERROR) << "sigaddset failed"; - return; - } #endif // PANDA_TARGET_UNIX } diff --git a/ecmascript/mem/heap-inl.h b/ecmascript/mem/heap-inl.h index 51021471c3..dc1c8b5208 100644 --- a/ecmascript/mem/heap-inl.h +++ b/ecmascript/mem/heap-inl.h @@ -240,6 +240,7 @@ TaggedObject *Heap::AllocateClassClass(JSHClass *hclass, size_t size) auto object = reinterpret_cast(nonMovableSpace_->Allocate(size)); if (UNLIKELY(object == nullptr)) { LOG_ECMA_MEM(FATAL) << "Heap::AllocateClassClass can not allocate any space"; + UNREACHABLE(); } *reinterpret_cast(ToUintPtr(object)) = reinterpret_cast(hclass); OnAllocateEvent(reinterpret_cast(object)); diff --git a/ecmascript/napi/jsnapi_helper.h b/ecmascript/napi/jsnapi_helper.h index f4a6309070..1cb297053d 100644 --- a/ecmascript/napi/jsnapi_helper.h +++ b/ecmascript/napi/jsnapi_helper.h @@ -120,7 +120,7 @@ private: class Callback { public: - static ecmascript::JSTaggedValue RegisterCallback(ecmascript::EcmaRuntimeCallInfo *info); + static ecmascript::JSTaggedValue RegisterCallback(ecmascript::EcmaRuntimeCallInfo *ecmaRuntimeCallInfo); }; } // namespace panda #endif // ECMASCRIPT_NAPI_JSNAPI_HELPER_H diff --git a/ecmascript/quick_fix/main.cpp b/ecmascript/quick_fix/main.cpp index cb7fea87cb..b427bac3fd 100644 --- a/ecmascript/quick_fix/main.cpp +++ b/ecmascript/quick_fix/main.cpp @@ -39,12 +39,6 @@ void BlockSignals() LOG_ECMA(ERROR) << "sigemptyset failed"; return; } - int rc = 0; - - if (rc < 0) { - LOG_ECMA(ERROR) << "sigaddset failed"; - return; - } #endif // PANDA_TARGET_UNIX } @@ -89,7 +83,6 @@ int Main(const int argc, const char **argv) std::cout << "\n" << "Startup start time: " << startTime << std::endl; } - bool ret = true; EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions); if (vm == nullptr) { std::cerr << "Cannot Create vm" << std::endl; @@ -172,7 +165,7 @@ int Main(const int argc, const char **argv) } JSNApi::DestroyJSVM(vm); - return ret ? 0 : -1; + return 0; } } // namespace panda::ecmascript diff --git a/ecmascript/regexp/regexp_executor.cpp b/ecmascript/regexp/regexp_executor.cpp index a9d30b382c..08023ad758 100644 --- a/ecmascript/regexp/regexp_executor.cpp +++ b/ecmascript/regexp/regexp_executor.cpp @@ -368,7 +368,7 @@ void RegExpExecutor::ReAllocStack(uint32_t stackLen) UNREACHABLE(); } if (stateStack_ != nullptr) { - size_t stackSize = stateStackSize_ * stateSize_; + auto stackSize = stateStackSize_ * stateSize_; if (memcpy_s(newStack, stackSize, stateStack_, stackSize) != EOK) { return; } diff --git a/ecmascript/snapshot/mem/snapshot_processor.cpp b/ecmascript/snapshot/mem/snapshot_processor.cpp index 1ea33e5aab..abdb87a95b 100644 --- a/ecmascript/snapshot/mem/snapshot_processor.cpp +++ b/ecmascript/snapshot/mem/snapshot_processor.cpp @@ -1235,6 +1235,7 @@ void SnapshotProcessor::DeserializeString(uintptr_t stringBegin, uintptr_t strin } if (newObj == 0) { LOG_ECMA_MEM(FATAL) << "Snapshot Allocate OldLocalSpace OOM"; + UNREACHABLE(); } if (memcpy_s(ToVoidPtr(newObj), strSize, str, strSize) != EOK) { LOG_FULL(FATAL) << "memcpy_s failed"; diff --git a/ecmascript/ts_types/ts_obj_layout_info.h b/ecmascript/ts_types/ts_obj_layout_info.h index 3f530534fe..f847db3b11 100644 --- a/ecmascript/ts_types/ts_obj_layout_info.h +++ b/ecmascript/ts_types/ts_obj_layout_info.h @@ -73,7 +73,7 @@ public: return TaggedArray::Get(idxInArray); } - void SetKey(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &typeId); + void SetKey(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &typeIdVal); inline uint32_t GetLength() const {