diff --git a/bytecode_optimizer/templates/ecmascript_codegen_intrinsics_gen.inc.erb b/bytecode_optimizer/templates/ecmascript_codegen_intrinsics_gen.inc.erb index 0da5ef60e876ec98c81a71c335865b1fb50094c4..f5a97af4464556b141e08457c5fb7f30b3a3f9f2 100644 --- a/bytecode_optimizer/templates/ecmascript_codegen_intrinsics_gen.inc.erb +++ b/bytecode_optimizer/templates/ecmascript_codegen_intrinsics_gen.inc.erb @@ -46,17 +46,17 @@ % input_index = input_index + 1 % elsif param.id? % if inst.properties.include?("method_id") - ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) + ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINT(readability-container-size-empty) auto ir_id<%= id_index %> = static_cast(inst->GetImms()[<%= imm_index %>]); auto bc_id<%= id_index %> = enc->ir_interface_->GetMethodIdByOffset(ir_id<%= id_index %>); % params_str = params_str + "bc_id#{id_index}, " % elsif inst.properties.include?("string_id") - ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) + ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINT(readability-container-size-empty) auto ir_id<%= id_index %> = static_cast(inst->GetImms()[<%= imm_index %>]); auto bc_id<%= id_index %> = enc->ir_interface_->GetStringIdByOffset(ir_id<%= id_index %>); % params_str = params_str + "bc_id#{id_index}, " % elsif inst.properties.include?("literalarray_id") - ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) + ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINT(readability-container-size-empty) auto ir_id<%= id_index %> = static_cast(inst->GetImms()[<%= imm_index %>]); auto bc_id<%= id_index %> = std::to_string(ir_id<%= id_index %>); % params_str = params_str + "bc_id#{id_index}, " @@ -64,7 +64,7 @@ % id_index = id_index + 1 % imm_index = imm_index + 1 % elsif param.imm? - ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) + ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINT(readability-container-size-empty) % if inst.properties.include?("jump") % params_str += "LabelName(inst->GetBasicBlock()->GetTrueSuccessor()->GetId()), " % else diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 6f2aa79ab60a342d2ff7404c2ee93dbd484d2cec..30f32cee99fdde6981eaab72120ce2a521281be9 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -65,6 +65,7 @@ namespace panda::ecmascript { ASSERT(!this->GetJSThread()->HasPendingException()); \ } while (false) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define UPDATE_UNARY_ARITH_PROFILE(lhs) \ if constexpr (IS_PROFILE_ENABLED) { \ UpdateUnaryArithProfile(lhs); \ @@ -72,6 +73,7 @@ namespace panda::ecmascript { UNUSED_VAR(lhs); \ } +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define UPDATE_BINARY_ARITH_PROFILE(lhs, rhs) \ if constexpr (IS_PROFILE_ENABLED) { \ UpdateBinaryArithProfile(lhs, rhs); \ @@ -80,6 +82,7 @@ namespace panda::ecmascript { UNUSED_VAR(rhs); \ } +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define UPDATE_OBJ_BY_INDEX_PROFILE(lhs) \ if constexpr (IS_PROFILE_ENABLED) { \ UpdateObjByIndexProfile(lhs); \ @@ -87,6 +90,7 @@ namespace panda::ecmascript { UNUSED_VAR(lhs); \ } +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define UPDATE_CALL_PROFILE(func) \ if constexpr (IS_PROFILE_ENABLED) { \ UpdateCallProfile(func); \ @@ -130,7 +134,7 @@ template class InstructionHandler : public interpreter::InstructionHandler { public: - ALWAYS_INLINE inline InstructionHandler(interpreter::InstructionHandlerState *state) + ALWAYS_INLINE inline explicit InstructionHandler(interpreter::InstructionHandlerState *state) : interpreter::InstructionHandler(state) { } @@ -402,7 +406,9 @@ public: // acc: out, thus dead auto range_args = GetStkArgs(first_arg_reg_idx); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto ctor_handle = JSHandle(ToUintPtr(&range_args[0])); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto new_target_handle = JSHandle(ToUintPtr(&range_args[1])); auto ctor = ctor_handle.GetTaggedValue(); @@ -927,7 +933,6 @@ public: SlowRuntimeStub::ThrowDyn(thread, acc); this->MoveToExceptionHandler(); - return; } template @@ -2796,6 +2801,7 @@ public: auto prof_data = method->GetProfilingVector(); auto prof_id = this->GetInst().GetProfileId(); ASSERT(prof_id >= 0); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto prof_value = reinterpret_cast(&prof_data[prof_id]); ASSERT(method->GetProfileSize() > helpers::ToUnsigned(prof_id)); ObjByIndexOperationProfile::Update(prof_value, JSTaggedValue(value)); @@ -2811,6 +2817,7 @@ public: auto prof_data = method->GetProfilingVector(); auto prof_id = this->GetInst().GetProfileId(); ASSERT(prof_id >= 0); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto prof_value = reinterpret_cast(&prof_data[prof_id]); ASSERT(method->GetProfileSize() > helpers::ToUnsigned(prof_id)); UnaryOperationProfile::Update(prof_value, JSTaggedValue(value)); @@ -2828,6 +2835,7 @@ public: auto prof_data = method->GetProfilingVector(); auto prof_id = this->GetInst().GetProfileId(); ASSERT(prof_id >= 0); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto prof_value = reinterpret_cast(&prof_data[prof_id]); ASSERT(method->GetProfileSize() > helpers::ToUnsigned(prof_id)); BinaryOperationProfile::Update(prof_value, left, right); @@ -2842,6 +2850,7 @@ public: auto prof_id = this->GetInst().GetProfileId(); ASSERT(prof_id != -1); ASSERT(static_cast(prof_id) < js_method->GetProfileSize()); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto profile = CallProfile::FromBuffer(js_method->GetProfilingVector() + prof_id); ASSERT(profile != nullptr); auto *profile_table = this->GetJSThread()->GetEcmaVM()->GetEcmaCallProfileTable(); diff --git a/runtime/interpreter/js_decode_call_instr.h b/runtime/interpreter/js_decode_call_instr.h index 6a9ed5303293fd189f9ec75858cbb2624cd5d4f7..b78da21b6c4306586f764ef5f9be5e7ce501937b 100644 --- a/runtime/interpreter/js_decode_call_instr.h +++ b/runtime/interpreter/js_decode_call_instr.h @@ -190,7 +190,7 @@ ALWAYS_INLINE inline static void JSCopyArgumets(JSThread *thread, Frame *prev_fr R::template Get()) { static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); - for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + for (size_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 1 + i); } } else if constexpr (OP == R::template Get()) { @@ -224,7 +224,7 @@ ALWAYS_INLINE inline static void JSCopyArgumets(JSThread *thread, Frame *prev_fr static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX) = prev_frame->GetVReg(prev_v0 + 1); - for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + for (size_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); } } else if constexpr (OP == @@ -232,7 +232,7 @@ ALWAYS_INLINE inline static void JSCopyArgumets(JSThread *thread, Frame *prev_fr static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); new_frame->GetVReg(num_vregs + js_method_args::NEW_TARGET_IDX) = prev_frame->GetVReg(prev_v0 + 1); - for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + for (size_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); } } else { diff --git a/tests/disassembler/disasm_test_lit_ecma.cpp.in b/tests/disassembler/disasm_test_lit_ecma.cpp.in index 6e6a51121ad6ac18b1bfd4d78569b9fde4b1ec09..53527b4eb475fffe11cca6a7b7141a4e4a303bbb 100644 --- a/tests/disassembler/disasm_test_lit_ecma.cpp.in +++ b/tests/disassembler/disasm_test_lit_ecma.cpp.in @@ -19,10 +19,9 @@ #include #include "disassembler.h" +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #cmakedefine DISASM_BIN_DIR "@DISASM_BIN_DIR@/" -using namespace panda::disasm; - static inline std::string ExtractArrayBody(const std::string &text, const std::string &header) { auto beg = text.find(header); @@ -34,9 +33,9 @@ static inline std::string ExtractArrayBody(const std::string &text, const std::s return text.substr(beg + header.length(), end - (beg + header.length())); } -TEST(instructions_test, test_lit_ecma) +TEST(InstructionsTest, TestLiteralArrayEcma) { - Disassembler d {}; + panda::disasm::Disassembler d {}; std::stringstream ss {}; d.Disassemble(std::string(DISASM_BIN_DIR) + "lit.bc");