diff --git a/BUILD.gn b/BUILD.gn index ac2e7b2b..f6ce59f9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -598,6 +598,11 @@ source_set("libark_jsruntime_set") { defines += [ "ENABLE_DUMP_IN_FAULTLOG" ] include_dirs += [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client" ] } + if (enable_hilog) { + defines += [ "ENABLE_HILOG" ] + include_dirs += + [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ] + } } } @@ -664,7 +669,8 @@ ohos_shared_library("libark_jsruntime") { } if (is_ohos && is_standard_system) { - if (enable_dump_in_faultlog || enable_bytrace || enable_hitrace) { + if (enable_dump_in_faultlog || enable_bytrace || enable_hitrace || + enable_hilog) { external_deps = [] } if (enable_dump_in_faultlog) { @@ -676,6 +682,9 @@ ohos_shared_library("libark_jsruntime") { if (enable_hitrace) { external_deps += [ "hitrace_native:libhitrace" ] } + if (enable_hilog) { + external_deps += [ "hiviewdfx_hilog_native:libhilog" ] + } } install_enable = true diff --git a/ecmascript/base/error_helper.cpp b/ecmascript/base/error_helper.cpp index 09adc3e1..fa6e785c 100644 --- a/ecmascript/base/error_helper.cpp +++ b/ecmascript/base/error_helper.cpp @@ -157,7 +157,7 @@ JSTaggedValue ErrorHelper::ErrorCommonConstructor(EcmaRuntimeCallInfo *argv, auto globalConst = thread->GlobalConstants(); if (!message->IsUndefined()) { JSHandle handleStr = JSTaggedValue::ToString(thread, message); - LOG(DEBUG, ECMASCRIPT) << "Ark throw error: " << utf::Mutf8AsCString(handleStr->GetDataUtf8()); + LOG_ECMA(DEBUG) << "Ark throw error: " << utf::Mutf8AsCString(handleStr->GetDataUtf8()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); JSHandle msgKey = globalConst->GetHandledMessageString(); PropertyDescriptor msgDesc(thread, JSHandle::Cast(handleStr), true, false, true); @@ -187,7 +187,7 @@ JSHandle ErrorHelper::BuildEcmaStackTrace(JSThread *thread) { std::string data = BuildJsStackTrace(thread, false); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - LOG(DEBUG, ECMASCRIPT) << data; + LOG_ECMA(DEBUG) << data; return factory->NewFromStdString(data); } diff --git a/ecmascript/base/number_helper.cpp b/ecmascript/base/number_helper.cpp index ec5ac64e..bd23527d 100644 --- a/ecmascript/base/number_helper.cpp +++ b/ecmascript/base/number_helper.cpp @@ -749,14 +749,14 @@ void NumberHelper::GetBase(double d, int digits, int *decpt, char *buf, char *bu { int result = snprintf_s(bufTmp, size, size - 1, "%+.*e", digits - 1, d); if (result == -1) { - LOG_ECMA(FATAL) << "snprintf_s failed"; + LOG_FULL(FATAL) << "snprintf_s failed"; UNREACHABLE(); } // mantissa buf[0] = bufTmp[1]; if (digits > 1) { if (memcpy_s(buf + 1, digits, bufTmp + 2, digits) != EOK) { // 2 means add the point char to buf - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } diff --git a/ecmascript/builtins/builtins_ark_tools.cpp b/ecmascript/builtins/builtins_ark_tools.cpp index 4ea6583b..efd394c8 100644 --- a/ecmascript/builtins/builtins_ark_tools.cpp +++ b/ecmascript/builtins/builtins_ark_tools.cpp @@ -27,7 +27,7 @@ JSTaggedValue BuiltinsArkTools::ObjectDump(EcmaRuntimeCallInfo *info) JSHandle str = JSTaggedValue::ToString(thread, GetCallArg(info, 0)); // The default log level of ace_engine and js_runtime is error - LOG(ERROR, RUNTIME) << ": " << base::StringHelper::ToStdString(*str); + LOG_ECMA(ERROR) << ": " << base::StringHelper::ToStdString(*str); uint32_t numArgs = info->GetArgsNumber(); for (uint32_t i = 1; i < numArgs; i++) { @@ -36,7 +36,7 @@ JSTaggedValue BuiltinsArkTools::ObjectDump(EcmaRuntimeCallInfo *info) obj->Dump(oss); // The default log level of ace_engine and js_runtime is error - LOG(ERROR, RUNTIME) << ": " << oss.str(); + LOG_ECMA(ERROR) << ": " << oss.str(); } return JSTaggedValue::Undefined(); @@ -56,7 +56,7 @@ JSTaggedValue BuiltinsArkTools::CompareHClass(EcmaRuntimeCallInfo *info) obj1Hclass->Dump(oss); bool res = (obj1Hclass == obj2Hclass); if (!res) { - LOG(ERROR, RUNTIME) << "These two object don't share the same hclass:" << oss.str(); + LOG_ECMA(ERROR) << "These two object don't share the same hclass:" << oss.str(); } return JSTaggedValue(res); } @@ -72,7 +72,7 @@ JSTaggedValue BuiltinsArkTools::DumpHClass(EcmaRuntimeCallInfo *info) std::ostringstream oss; objHclass->Dump(oss); - LOG(ERROR, RUNTIME) << "hclass:" << oss.str(); + LOG_ECMA(ERROR) << "hclass:" << oss.str(); return JSTaggedValue::Undefined(); } diff --git a/ecmascript/compiler/aot_compiler.cpp b/ecmascript/compiler/aot_compiler.cpp index 78522434..157deeed 100644 --- a/ecmascript/compiler/aot_compiler.cpp +++ b/ecmascript/compiler/aot_compiler.cpp @@ -36,18 +36,18 @@ void BlockSignals() #if defined(PANDA_TARGET_UNIX) sigset_t set; if (sigemptyset(&set) == -1) { - COMPILER_LOG(ERROR) << "sigemptyset failed"; + LOG_COMPILER(ERROR) << "sigemptyset failed"; return; } int rc = 0; if (rc < 0) { - COMPILER_LOG(ERROR) << "sigaddset failed"; + LOG_COMPILER(ERROR) << "sigaddset failed"; return; } if (panda::os::native_stack::g_PandaThreadSigmask(SIG_BLOCK, &set, nullptr) != 0) { - COMPILER_LOG(ERROR) << "g_PandaThreadSigmask failed"; + LOG_COMPILER(ERROR) << "g_PandaThreadSigmask failed"; } #endif // PANDA_TARGET_UNIX } @@ -99,13 +99,13 @@ int Main(const int argc, const char **argv) arg_list_t arguments = paParser.GetRemainder(); if (runtimeOptions.IsStartupTime()) { - COMPILER_LOG(DEBUG) << "Startup start time: " << startTime; + LOG_COMPILER(DEBUG) << "Startup start time: " << startTime; } bool ret = true; EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions); if (vm == nullptr) { - COMPILER_LOG(ERROR) << "Cannot Create vm"; + LOG_COMPILER(ERROR) << "Cannot Create vm"; return -1; } @@ -125,7 +125,7 @@ int Main(const int argc, const char **argv) AOTFileGenerator generator(&log, vm); PassManager passManager(vm, entry, triple, optLevel, &log); for (const auto &fileName : pandaFileNames) { - COMPILER_LOG(INFO) << "AOT start to execute ark file: " << fileName; + LOG_COMPILER(INFO) << "AOT start to execute ark file: " << fileName; if (passManager.Compile(fileName, generator) == false) { ret = false; break; @@ -144,6 +144,6 @@ int Main(const int argc, const char **argv) int main(const int argc, const char **argv) { auto result = panda::ecmascript::kungfu::Main(argc, argv); - COMPILER_LOG(INFO) << (result == 0 ? "ts aot compile success" : "ts aot compile failed"); + LOG_COMPILER(INFO) << (result == 0 ? "ts aot compile success" : "ts aot compile failed"); return result; } diff --git a/ecmascript/compiler/assembler/aarch64/extend_assembler.h b/ecmascript/compiler/assembler/aarch64/extend_assembler.h index e4095e83..4bf1df66 100644 --- a/ecmascript/compiler/assembler/aarch64/extend_assembler.h +++ b/ecmascript/compiler/assembler/aarch64/extend_assembler.h @@ -47,7 +47,7 @@ public: Register TempRegister1() { if (temp1InUse_) { - COMPILER_LOG(ERROR) << "temp register1 inuse."; + LOG_COMPILER(ERROR) << "temp register1 inuse."; UNREACHABLE(); } temp1InUse_ = true; @@ -56,7 +56,7 @@ public: Register TempRegister2() { if (temp2InUse_) { - COMPILER_LOG(ERROR) << "temp register2 inuse."; + LOG_COMPILER(ERROR) << "temp register2 inuse."; UNREACHABLE(); } temp2InUse_ = true; diff --git a/ecmascript/compiler/assembler/x64/extended_assembler_x64.h b/ecmascript/compiler/assembler/x64/extended_assembler_x64.h index 53cc3c12..5dc16e69 100644 --- a/ecmascript/compiler/assembler/x64/extended_assembler_x64.h +++ b/ecmascript/compiler/assembler/x64/extended_assembler_x64.h @@ -42,7 +42,7 @@ public: Register TempRegister() { if (tempInUse_) { - COMPILER_LOG(ERROR) << "temp register inuse."; + LOG_COMPILER(ERROR) << "temp register inuse."; UNREACHABLE(); } tempInUse_ = true; diff --git a/ecmascript/compiler/assembler_module.cpp b/ecmascript/compiler/assembler_module.cpp index 5b356a46..15b98e36 100644 --- a/ecmascript/compiler/assembler_module.cpp +++ b/ecmascript/compiler/assembler_module.cpp @@ -39,11 +39,11 @@ void AssemblerModule::Run(const CompilationConfig *cfg, Chunk* chunk) void AssemblerModule::GenerateStubsX64(Chunk* chunk) { x64::ExtendedAssembler assembler(chunk, this); - COMPILER_LOG(INFO) << "compiling asm stubs"; + LOG_COMPILER(INFO) << "compiling asm stubs"; for (size_t i = 0; i < asmCallSigns_.size(); i++) { auto cs = asmCallSigns_[i]; ASSERT(cs->HasConstructor()); - COMPILER_LOG(INFO) << "Stub Name: " << cs->GetName(); + LOG_COMPILER(INFO) << "Stub Name: " << cs->GetName(); AssemblerStub *stub = static_cast( cs->GetConstructor()(nullptr)); stub->GenerateX64(&assembler); @@ -56,11 +56,11 @@ void AssemblerModule::GenerateStubsX64(Chunk* chunk) void AssemblerModule::GenerateStubsAarch64(Chunk* chunk) { aarch64::ExtendedAssembler assembler(chunk, this); - COMPILER_LOG(INFO) << "compiling asm stubs"; + LOG_COMPILER(INFO) << "compiling asm stubs"; for (size_t i = 0; i < asmCallSigns_.size(); i++) { auto cs = asmCallSigns_[i]; ASSERT(cs->HasConstructor()); - COMPILER_LOG(INFO) << "Stub Name: " << cs->GetName(); + LOG_COMPILER(INFO) << "Stub Name: " << cs->GetName(); AssemblerStub *stub = static_cast( cs->GetConstructor()(nullptr)); stub->GenerateAarch64(&assembler); diff --git a/ecmascript/compiler/bytecode_circuit_builder.cpp b/ecmascript/compiler/bytecode_circuit_builder.cpp index c4702a30..93916a6b 100644 --- a/ecmascript/compiler/bytecode_circuit_builder.cpp +++ b/ecmascript/compiler/bytecode_circuit_builder.cpp @@ -402,7 +402,7 @@ void BytecodeCircuitBuilder::ComputeDominatorTree() if (IsLogEnabled()) { // print cfg order for (auto iter : bbIdToDfsTimestamp) { - COMPILER_LOG(INFO) << "BB_" << iter.first << " dfs timestamp is : " << iter.second; + LOG_COMPILER(INFO) << "BB_" << iter.first << " dfs timestamp is : " << iter.second; } } @@ -452,7 +452,7 @@ void BytecodeCircuitBuilder::ComputeDominatorTree() for (auto j: doms[i]) { log += std::to_string(j) + " , "; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; } } @@ -477,7 +477,7 @@ void BytecodeCircuitBuilder::ComputeDominatorTree() if (IsLogEnabled()) { // print immediate dominator for (size_t i = 0; i < immDom.size(); i++) { - COMPILER_LOG(INFO) << i << " immediate dominator: " << immDom[i]; + LOG_COMPILER(INFO) << i << " immediate dominator: " << immDom[i]; } PrintGraph(); } @@ -502,7 +502,7 @@ void BytecodeCircuitBuilder::BuildImmediateDominator(const std::vector & if (block.isDead) { continue; } - COMPILER_LOG(INFO) << "current block " << block.id + LOG_COMPILER(INFO) << "current block " << block.id << " immediate dominator block id: " << block.iDominator->id; } } @@ -525,7 +525,7 @@ void BytecodeCircuitBuilder::BuildImmediateDominator(const std::vector & for (size_t i = 0; i < block.immDomBlocks.size(); i++) { log += std::to_string(block.immDomBlocks[i]->id) + ","; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; } } @@ -566,7 +566,7 @@ void BytecodeCircuitBuilder::ComputeDomFrontiers(const std::vector &immD for (auto iter = domFrontiers[i].cbegin(); iter != domFrontiers[i].cend(); iter++) { log += std::to_string((*iter)->id) + ", "; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; } } } @@ -1748,7 +1748,7 @@ BytecodeInfo BytecodeCircuitBuilder::GetBytecodeInfo(const uint8_t *pc) break; } default: { - COMPILER_LOG(ERROR) << "Error bytecode: " << opcode << ", pls check bytecode offset."; + LOG_COMPILER(ERROR) << "Error bytecode: " << opcode << ", pls check bytecode offset."; UNREACHABLE(); break; } @@ -1779,7 +1779,7 @@ void BytecodeCircuitBuilder::InsertPhi() for (auto id : defsites) { log += std::to_string(id) + " , "; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; } } @@ -2491,17 +2491,17 @@ void BytecodeCircuitBuilder::PrintCollectBlockInfo(std::vector &bytecod for (size_t i = 0; i < vec.size(); i++) { log += std::to_string(reinterpret_cast(vec[i])) + " , "; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; } - COMPILER_LOG(INFO) << "-----------------------------------------------------------------------"; + LOG_COMPILER(INFO) << "-----------------------------------------------------------------------"; } void BytecodeCircuitBuilder::PrintGraph() { for (size_t i = 0; i < graph_.size(); i++) { if (graph_[i].isDead) { - COMPILER_LOG(INFO) << "BB_" << graph_[i].id << ": ;predsId= invalid BB"; - COMPILER_LOG(INFO) << "curStartPc: " << reinterpret_cast(graph_[i].start) << + LOG_COMPILER(INFO) << "BB_" << graph_[i].id << ": ;predsId= invalid BB"; + LOG_COMPILER(INFO) << "curStartPc: " << reinterpret_cast(graph_[i].start) << " curEndPc: " << reinterpret_cast(graph_[i].end); continue; } @@ -2509,17 +2509,17 @@ void BytecodeCircuitBuilder::PrintGraph() for (size_t k = 0; k < graph_[i].preds.size(); ++k) { log += std::to_string(graph_[i].preds[k]->id) + ", "; } - COMPILER_LOG(INFO) << log; - COMPILER_LOG(INFO) << "curStartPc: " << reinterpret_cast(graph_[i].start) << + LOG_COMPILER(INFO) << log; + LOG_COMPILER(INFO) << "curStartPc: " << reinterpret_cast(graph_[i].start) << " curEndPc: " << reinterpret_cast(graph_[i].end); for (size_t j = 0; j < graph_[i].preds.size(); j++) { - COMPILER_LOG(INFO) << "predsStartPc: " << reinterpret_cast(graph_[i].preds[j]->start) << + LOG_COMPILER(INFO) << "predsStartPc: " << reinterpret_cast(graph_[i].preds[j]->start) << " predsEndPc: " << reinterpret_cast(graph_[i].preds[j]->end); } for (size_t j = 0; j < graph_[i].succs.size(); j++) { - COMPILER_LOG(INFO) << "succesStartPc: " << reinterpret_cast(graph_[i].succs[j]->start) << + LOG_COMPILER(INFO) << "succesStartPc: " << reinterpret_cast(graph_[i].succs[j]->start) << " succesEndPc: " << reinterpret_cast(graph_[i].succs[j]->end); } @@ -2527,21 +2527,21 @@ void BytecodeCircuitBuilder::PrintGraph() for (size_t j = 0; j < graph_[i].succs.size(); j++) { log1 += std::to_string(graph_[i].succs[j]->id) + ", "; } - COMPILER_LOG(INFO) << log1; + LOG_COMPILER(INFO) << log1; for (size_t j = 0; j < graph_[i].catchs.size(); j++) { - COMPILER_LOG(INFO) << "catchStartPc: " << reinterpret_cast(graph_[i].catchs[j]->start) << + LOG_COMPILER(INFO) << "catchStartPc: " << reinterpret_cast(graph_[i].catchs[j]->start) << " catchEndPc: " << reinterpret_cast(graph_[i].catchs[j]->end); } for (size_t j = 0; j < graph_[i].immDomBlocks.size(); j++) { - COMPILER_LOG(INFO) << "dominate block id: " << graph_[i].immDomBlocks[j]->id << " startPc: " << + LOG_COMPILER(INFO) << "dominate block id: " << graph_[i].immDomBlocks[j]->id << " startPc: " << reinterpret_cast(graph_[i].immDomBlocks[j]->start) << " endPc: " << reinterpret_cast(graph_[i].immDomBlocks[j]->end); } if (graph_[i].iDominator) { - COMPILER_LOG(INFO) << "current block " << graph_[i].id << + LOG_COMPILER(INFO) << "current block " << graph_[i].id << " immediate dominator is " << graph_[i].iDominator->id; } @@ -2549,14 +2549,14 @@ void BytecodeCircuitBuilder::PrintGraph() for (const auto &frontier: graph_[i].domFrontiers) { log2 += std::to_string(frontier->id) + " , "; } - COMPILER_LOG(INFO) << log2; + LOG_COMPILER(INFO) << log2; std::string log3("current block " + std::to_string(graph_[i].id) + " phi variable: "); for (auto variable: graph_[i].phi) { log3 += std::to_string(variable) + " , "; } - COMPILER_LOG(INFO) << log3; - COMPILER_LOG(INFO) << "-------------------------------------------------------"; + LOG_COMPILER(INFO) << log3; + LOG_COMPILER(INFO) << "-------------------------------------------------------"; } } @@ -2567,7 +2567,7 @@ void BytecodeCircuitBuilder::PrintBytecodeInfo() continue; } auto pc = bb.start; - COMPILER_LOG(INFO) << "BB_" << bb.id << ": "; + LOG_COMPILER(INFO) << "BB_" << bb.id << ": "; while (pc <= bb.end) { std::string log; auto curInfo = GetBytecodeInfo(pc); @@ -2588,7 +2588,7 @@ void BytecodeCircuitBuilder::PrintBytecodeInfo() log += std::to_string(out) + ","; } log += "]"; - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; pc += curInfo.offset; } } @@ -2600,28 +2600,28 @@ void BytecodeCircuitBuilder::PrintBBInfo() if (bb.isDead) { continue; } - COMPILER_LOG(INFO) << "------------------------"; - COMPILER_LOG(INFO) << "block: " << bb.id; + LOG_COMPILER(INFO) << "------------------------"; + LOG_COMPILER(INFO) << "block: " << bb.id; std::string log("preds: "); for (auto pred: bb.preds) { log += std::to_string(pred->id) + " , "; } - COMPILER_LOG(INFO) << log; + LOG_COMPILER(INFO) << log; std::string log1("succs: "); for (auto succ: bb.succs) { log1 += std::to_string(succ->id) + " , "; } - COMPILER_LOG(INFO) << log1; + LOG_COMPILER(INFO) << log1; std::string log2("catchs: "); for (auto catchBlock: bb.catchs) { log2 += std::to_string(catchBlock->id) + " , "; } - COMPILER_LOG(INFO) << log2; + LOG_COMPILER(INFO) << log2; std::string log3("trys: "); for (auto tryBlock: bb.trys) { log3 += std::to_string(tryBlock->id) + " , "; } - COMPILER_LOG(INFO) << log3; + LOG_COMPILER(INFO) << log3; } } } // namespace panda::ecmascript::kungfu diff --git a/ecmascript/compiler/circuit.cpp b/ecmascript/compiler/circuit.cpp index a4147a4f..2c84c167 100644 --- a/ecmascript/compiler/circuit.cpp +++ b/ecmascript/compiler/circuit.cpp @@ -62,7 +62,7 @@ GateRef Circuit::NewGate(OpCode opcode, MachineType bitValue, BitField bitfield, { #ifndef NDEBUG if (numIns != opcode.GetOpCodeNumIns(bitfield)) { - COMPILER_LOG(ERROR) << "Invalid input list!" + LOG_COMPILER(ERROR) << "Invalid input list!" << " op=" << opcode.Str() << " bitfield=" << bitfield << " expected_num_in=" << opcode.GetOpCodeNumIns(bitfield) << " actual_num_in=" << numIns; UNREACHABLE(); @@ -92,7 +92,7 @@ GateRef Circuit::NewGate(OpCode opcode, BitField bitfield, size_t numIns, const { #ifndef NDEBUG if (numIns != opcode.GetOpCodeNumIns(bitfield)) { - COMPILER_LOG(ERROR) << "Invalid input list!" + LOG_COMPILER(ERROR) << "Invalid input list!" << " op=" << opcode.Str() << " bitfield=" << bitfield << " expected_num_in=" << opcode.GetOpCodeNumIns(bitfield) << " actual_num_in=" << numIns; UNREACHABLE(); diff --git a/ecmascript/compiler/file_generators.cpp b/ecmascript/compiler/file_generators.cpp index ac390e04..0539a145 100644 --- a/ecmascript/compiler/file_generators.cpp +++ b/ecmascript/compiler/file_generators.cpp @@ -82,11 +82,11 @@ void StubFileGenerator::RunAsmAssembler() auto currentOffset = modulePackage_[0].GetCodeSize(); auto codeBuffer = modulePackage_[0].AllocaCodeSection(bufferSize, "asm code"); if (codeBuffer == nullptr) { - LOG_ECMA(FATAL) << "AllocaCodeSection failed"; + LOG_FULL(FATAL) << "AllocaCodeSection failed"; return; } if (memcpy_s(codeBuffer, bufferSize, buffer, bufferSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; return; } asmModule_.SetCodeBufferOffset(currentOffset); diff --git a/ecmascript/compiler/file_generators.h b/ecmascript/compiler/file_generators.h index 2dffe7fc..dedf6687 100644 --- a/ecmascript/compiler/file_generators.h +++ b/ecmascript/compiler/file_generators.h @@ -77,7 +77,7 @@ public: uint64_t length = 0; std::string funcName(LLVMGetValueName2(func, &length)); assert(length != 0); - COMPILER_LOG(INFO) << "CollectCodeInfo for AOT func: " << funcName.c_str(); + LOG_COMPILER(INFO) << "CollectCodeInfo for AOT func: " << funcName.c_str(); addr2name[funcEntry] = funcName; int delta = assembler_->GetFpDeltaPrevFramSp(func, log); ASSERT(delta >= 0 && (delta % sizeof(uintptr_t) == 0)); diff --git a/ecmascript/compiler/gate.cpp b/ecmascript/compiler/gate.cpp index 1383a8e6..b9137e55 100644 --- a/ecmascript/compiler/gate.cpp +++ b/ecmascript/compiler/gate.cpp @@ -185,7 +185,7 @@ Properties OpCode::GetProperties() const case BITCAST: return {FLEX, NO_STATE, NO_DEPEND, VALUE(ANYVALUE), NO_ROOT}; default: - COMPILER_LOG(ERROR) << "Please complete OpCode properties (OpCode=" << op_ << ")"; + LOG_COMPILER(ERROR) << "Please complete OpCode properties (OpCode=" << op_ << ")"; UNREACHABLE(); } #undef STATE @@ -654,9 +654,9 @@ bool Gate::Verify() const } } if (failed) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Gate level input list schema verify failed"; + LOG_COMPILER(ERROR) << "[Verifier][Error] Gate level input list schema verify failed"; Print("", true, highlightIdx); - COMPILER_LOG(ERROR) << "Note: " << errorString; + LOG_COMPILER(ERROR) << "Note: " << errorString; } return !failed; } @@ -936,7 +936,7 @@ In *Gate::GetIn(size_t idx) { #ifndef NDEBUG if (idx >= GetNumIns()) { - COMPILER_LOG(INFO) << std::dec << "Gate In access out-of-bound! (idx=" << idx << ")"; + LOG_COMPILER(INFO) << std::dec << "Gate In access out-of-bound! (idx=" << idx << ")"; Print(); ASSERT(false); } @@ -949,7 +949,7 @@ const In *Gate::GetInConst(size_t idx) const { #ifndef NDEBUG if (idx >= GetNumIns()) { - COMPILER_LOG(INFO) << std::dec << "Gate In access out-of-bound! (idx=" << idx << ")"; + LOG_COMPILER(INFO) << std::dec << "Gate In access out-of-bound! (idx=" << idx << ")"; Print(); ASSERT(false); } @@ -1117,7 +1117,7 @@ void Gate::Print(std::string bytecode, bool inListPreview, size_t highlightIdx) } log += "])"; log += "\n"; - COMPILER_LOG(INFO) << std::dec << log; + LOG_COMPILER(INFO) << std::dec << log; } } diff --git a/ecmascript/compiler/llvm_codegen.cpp b/ecmascript/compiler/llvm_codegen.cpp index ab75c63a..fe38ed5b 100644 --- a/ecmascript/compiler/llvm_codegen.cpp +++ b/ecmascript/compiler/llvm_codegen.cpp @@ -131,7 +131,7 @@ bool LLVMAssembler::BuildMCJITEngine() { LLVMBool ret = LLVMCreateMCJITCompilerForModule(&engine_, module_, &options_, sizeof(options_), &error_); if (ret) { - COMPILER_LOG(FATAL) << "error_ : " << error_; + LOG_COMPILER(FATAL) << "error_ : " << error_; return false; } return true; @@ -261,7 +261,7 @@ int LLVMAssembler::GetFpDeltaPrevFramSp(LLVMValueRef fn, const CompilerLog &log) fpToCallerSpDelta = atoi(value); if (log.IsAlwaysEnabled()) { size_t length; - COMPILER_LOG(INFO) << " funcName: " << LLVMGetValueName2(fn, &length) << " fpToCallerSpDelta:" + LOG_COMPILER(INFO) << " funcName: " << LLVMGetValueName2(fn, &length) << " fpToCallerSpDelta:" << fpToCallerSpDelta; } } @@ -288,8 +288,8 @@ void LLVMAssembler::Disassemble(const std::map &addr2nam if (addr2name.find(addr) != addr2name.end()) { methodName = addr2name.at(addr); if (logFlag) { - COMPILER_LOG(INFO) << "======================================================================="; - COMPILER_LOG(INFO) << methodName.c_str() << " disassemble:"; + LOG_COMPILER(INFO) << "======================================================================="; + LOG_COMPILER(INFO) << methodName.c_str() << " disassemble:"; } } logFlag = log.IsDisassembleEnabled() ? true : log.IncludesMethod(methodName); @@ -297,7 +297,7 @@ void LLVMAssembler::Disassemble(const std::map &addr2nam size_t InstSize = LLVMDisasmInstruction(dcr, byteSp, numBytes, pc, outString, outStringSize); if (InstSize == 0) { if (logFlag) { - COMPILER_LOG(INFO) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) + LOG_COMPILER(INFO) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) << *reinterpret_cast(byteSp) << "maybe constant"; } pc += 4; // 4 pc length @@ -305,7 +305,7 @@ void LLVMAssembler::Disassemble(const std::map &addr2nam numBytes -= 4; // 4 num bytes } if (logFlag) { - COMPILER_LOG(INFO) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) + LOG_COMPILER(INFO) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) << *reinterpret_cast(byteSp) << " " << outString; } pc += InstSize; @@ -330,7 +330,7 @@ void LLVMAssembler::Disassemble(uint8_t *buf, size_t size) LLVMInitializeX86Target(); LLVMDisasmContextRef dcr = LLVMCreateDisasm(LLVMGetTarget(module), nullptr, 0, nullptr, SymbolLookupCallback); if (!dcr) { - COMPILER_LOG(ERROR) << "ERROR: Couldn't create disassembler for triple!"; + LOG_COMPILER(ERROR) << "ERROR: Couldn't create disassembler for triple!"; return; } uint8_t *byteSp; @@ -343,13 +343,13 @@ void LLVMAssembler::Disassemble(uint8_t *buf, size_t size) while (numBytes > 0) { size_t InstSize = LLVMDisasmInstruction(dcr, byteSp, numBytes, pc, outString, outStringSize); if (InstSize == 0) { - COMPILER_LOG(ERROR) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) + LOG_COMPILER(ERROR) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) << *reinterpret_cast(byteSp) << "maybe constant"; pc += 4; // 4 pc length byteSp += 4; // 4 sp offset numBytes -= 4; // 4 num bytes } - COMPILER_LOG(ERROR) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) + LOG_COMPILER(ERROR) << std::setw(8) << std::setfill('0') << std::hex << pc << ":" << std::setw(8) << *reinterpret_cast(byteSp) << " " << outString; pc += InstSize; byteSp += InstSize; diff --git a/ecmascript/compiler/llvm_codegen.h b/ecmascript/compiler/llvm_codegen.h index def798f6..6bf71d8b 100644 --- a/ecmascript/compiler/llvm_codegen.h +++ b/ecmascript/compiler/llvm_codegen.h @@ -94,7 +94,7 @@ struct CodeInfo { size = AlignUp(size, static_cast(MemAlignment::MEM_ALIGN_REGION)); uint8_t *addr = nullptr; if (codeBufferPos_ + size > MAX_MACHINE_CODE_SIZE) { - COMPILER_LOG(ERROR) << std::hex << "AllocaCodeSection failed alloc codeBufferPos_:" << codeBufferPos_ + LOG_COMPILER(ERROR) << std::hex << "AllocaCodeSection failed alloc codeBufferPos_:" << codeBufferPos_ << " size:" << size << " larger MAX_MACHINE_CODE_SIZE:" << MAX_MACHINE_CODE_SIZE; return nullptr; } diff --git a/ecmascript/compiler/llvm_ir_builder.cpp b/ecmascript/compiler/llvm_ir_builder.cpp index 6dd4102d..bca3111a 100644 --- a/ecmascript/compiler/llvm_ir_builder.cpp +++ b/ecmascript/compiler/llvm_ir_builder.cpp @@ -50,7 +50,6 @@ #include "llvm/Support/Host.h" #include "securec.h" -#include "utils/logger.h" namespace panda::ecmascript::kungfu { LLVMIRBuilder::LLVMIRBuilder(const std::vector> *schedule, const Circuit *circuit, @@ -245,7 +244,7 @@ void LLVMIRBuilder::Build() continue; } if (illegalOpHandlers_.find(circuit_->GetOpCode(gate)) == illegalOpHandlers_.end()) { - COMPILER_OPTIONAL_LOG(ERROR) << "The gate below need to be translated "; + LOG_COMPILER(ERROR) << "The gate below need to be translated "; circuit_->Print(gate); UNREACHABLE(); } @@ -272,7 +271,7 @@ void LLVMIRBuilder::SetToCfg(BasicBlock *bb) const EnsureLBB(bb); BasicBlockImpl *impl = bb->GetImpl(); if ((impl == nullptr) || (impl->lBB_ == nullptr)) { - COMPILER_OPTIONAL_LOG(ERROR) << "SetToCfg failed "; + LOG_COMPILER(ERROR) << "SetToCfg failed "; return; } impl->started = true; @@ -287,12 +286,12 @@ void LLVMIRBuilder::ProcessPhiWorkList() for (auto &e : impl->unmergedPhis_) { BasicBlock *pred = e.pred; if (impl->started == 0) { - COMPILER_OPTIONAL_LOG(ERROR) << " ProcessPhiWorkList error hav't start "; + OPTIONAL_LOG_COMPILER(ERROR) << " ProcessPhiWorkList error hav't start "; return; } LLVMValueRef value = gate2LValue_[e.operand]; if (LLVMTypeOf(value) != LLVMTypeOf(e.phi)) { - COMPILER_OPTIONAL_LOG(ERROR) << " ProcessPhiWorkList LLVMTypeOf don't match error "; + OPTIONAL_LOG_COMPILER(ERROR) << " ProcessPhiWorkList LLVMTypeOf don't match error "; } LLVMBasicBlockRef llvmBB = EnsureLBB(pred); LLVMAddIncoming(e.phi, &value, &llvmBB, 1); @@ -380,7 +379,7 @@ void LLVMIRBuilder::GenPrologue([[maybe_unused]] LLVMModuleRef &module, LLVMBuil LLVMAddTargetDependentFunctionAttr(function_, "frame-reserved-slots", std::to_string(reservedSlotsSize).c_str()); } else { - COMPILER_OPTIONAL_LOG(FATAL) << "frameType interpret type error !"; + LOG_COMPILER(FATAL) << "frameType interpret type error !"; ASSERT_PRINT(static_cast(frameType), "is not support !"); } @@ -487,7 +486,7 @@ void LLVMIRBuilder::HandleCall(GateRef gate) if (callOp == OpCode::CALL || callOp == OpCode::NOGC_RUNTIME_CALL) { VisitCall(gate, ins, callOp); } else { - abort(); + UNREACHABLE(); } } @@ -857,12 +856,12 @@ void LLVMIRBuilder::VisitPhi(GateRef gate, const std::vector &srcGates) if (cnt > 0) { BasicBlock *bb = bbID2BB_[bbIdx].get(); if (bb == nullptr) { - COMPILER_OPTIONAL_LOG(ERROR) << "VisitPhi failed BasicBlock nullptr"; + OPTIONAL_LOG_COMPILER(ERROR) << "VisitPhi failed BasicBlock nullptr"; return; } BasicBlockImpl *impl = bb->GetImpl(); if (impl == nullptr) { - COMPILER_OPTIONAL_LOG(ERROR) << "VisitPhi failed impl nullptr"; + OPTIONAL_LOG_COMPILER(ERROR) << "VisitPhi failed impl nullptr"; return; } LLVMBasicBlockRef llvmBB = EnsureLBB(bb); // The llvm bb @@ -919,7 +918,7 @@ void LLVMIRBuilder::LinkToLLVMCfg(int bbId, const OperandsVector &predecessors) { BasicBlock *bb = EnsureBB(bbId); if (bb == nullptr) { - COMPILER_OPTIONAL_LOG(ERROR) << " block create failed "; + OPTIONAL_LOG_COMPILER(ERROR) << " block create failed "; return; } currentBb_ = bb; @@ -928,7 +927,7 @@ void LLVMIRBuilder::LinkToLLVMCfg(int bbId, const OperandsVector &predecessors) for (int predecessor : predecessors) { BasicBlock *pre = EnsureBB(predecessor); if (pre == nullptr) { - COMPILER_OPTIONAL_LOG(ERROR) << " block setup failed, predecessor:%d nullptr" << predecessor; + OPTIONAL_LOG_COMPILER(ERROR) << " block setup failed, predecessor:%d nullptr" << predecessor; return; } LLVMBasicBlockRef preLBB = EnsureLBB(pre); @@ -967,7 +966,7 @@ void LLVMIRBuilder::VisitGoto(int block, int bbOut) } BasicBlock *bb = EnsureBB(bbOut); if (bb == nullptr) { - COMPILER_OPTIONAL_LOG(ERROR) << " block is nullptr "; + OPTIONAL_LOG_COMPILER(ERROR) << " block is nullptr "; return; } llvm::BasicBlock *self = llvm::unwrap(EnsureLBB(bbID2BB_[block].get())); @@ -1013,7 +1012,7 @@ void LLVMIRBuilder::VisitConstant(GateRef gate, std::bitset<64> value) // 64: bi } else if (LLVMGetTypeKind(type) == LLVMIntegerTypeKind) { // do nothing } else { - abort(); + UNREACHABLE(); } } else if (machineType == MachineType::F64) { auto doubleValue = bit_cast(value.to_ullong()); // actual double value @@ -1025,7 +1024,7 @@ void LLVMIRBuilder::VisitConstant(GateRef gate, std::bitset<64> value) // 64: bi } else if (machineType == MachineType::I1) { llvmValue = LLVMConstInt(LLVMInt1Type(), value.to_ulong(), 0); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = llvmValue; } @@ -1126,7 +1125,7 @@ void LLVMIRBuilder::VisitMod(GateRef gate, GateRef e1, GateRef e2) } else if (machineType == MachineType::F64) { result = LLVMBuildFRem(builder_, e1Value, e2Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } @@ -1134,7 +1133,7 @@ void LLVMIRBuilder::VisitMod(GateRef gate, GateRef e1, GateRef e2) void LLVMIRBuilder::VisitBranch(GateRef gate, GateRef cmp, int btrue, int bfalse) { if (gate2LValue_.count(cmp) == 0) { - COMPILER_OPTIONAL_LOG(ERROR) << "Branch condition gate is nullptr!"; + OPTIONAL_LOG_COMPILER(ERROR) << "Branch condition gate is nullptr!"; return; } LLVMValueRef cond = gate2LValue_[cmp]; @@ -1225,8 +1224,8 @@ LLVMValueRef LLVMIRBuilder::CanonicalizeToInt(LLVMValueRef value) } else if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMIntegerTypeKind) { return value; } else { - COMPILER_OPTIONAL_LOG(ERROR) << "can't Canonicalize to Int64: "; - abort(); + LOG_COMPILER(ERROR) << "can't Canonicalize to Int64: "; + UNREACHABLE(); } } @@ -1242,8 +1241,8 @@ LLVMValueRef LLVMIRBuilder::CanonicalizeToPtr(LLVMValueRef value) LLVMValueRef tmp = LLVMBuildIntToPtr(builder_, value, LLVMPointerType(LLVMInt64Type(), 0), ""); return LLVMBuildPointerCast(builder_, tmp, LLVMPointerType(LLVMInt8Type(), 0), ""); } else { - COMPILER_OPTIONAL_LOG(ERROR) << "can't Canonicalize to Ptr: "; - abort(); + LOG_COMPILER(ERROR) << "can't Canonicalize to Ptr: "; + UNREACHABLE(); } } @@ -1262,7 +1261,7 @@ void LLVMIRBuilder::VisitIntRev(GateRef gate, GateRef e1) if (machineType <= MachineType::I64 && machineType >= MachineType::I1) { result = LLVMBuildNot(builder_, e1Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } @@ -1325,7 +1324,7 @@ LLVMTypeRef LLVMIRBuilder::ConvertLLVMTypeFromGate(GateRef gate) const } } default: - abort(); + UNREACHABLE(); } } @@ -1352,9 +1351,9 @@ int64_t LLVMIRBuilder::GetBitWidthFromMachineType(MachineType machineType) const return 64; // 64: bit width case FLEX: case ANYVALUE: - abort(); + UNREACHABLE(); default: - abort(); + UNREACHABLE(); } } @@ -1407,7 +1406,7 @@ void LLVMIRBuilder::VisitAdd(GateRef gate, GateRef e1, GateRef e2) } else if (machineType == MachineType::F64) { result = LLVMBuildFAdd(builder_, e1Value, e2Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } @@ -1431,7 +1430,7 @@ void LLVMIRBuilder::VisitSub(GateRef gate, GateRef e1, GateRef e2) } else if (machineType == MachineType::F64) { result = LLVMBuildFSub(builder_, e1Value, e2Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } @@ -1466,7 +1465,7 @@ void LLVMIRBuilder::VisitMul(GateRef gate, GateRef e1, GateRef e2) } else if (machineType == MachineType::F64) { result = LLVMBuildFMul(builder_, e1Value, e2Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } @@ -1593,7 +1592,7 @@ void LLVMIRBuilder::VisitCmp(GateRef gate, GateRef e1, GateRef e2) break; } default: { - abort(); + UNREACHABLE(); break; } } @@ -1604,7 +1603,7 @@ void LLVMIRBuilder::VisitCmp(GateRef gate, GateRef e1, GateRef e2) } else if (e1ValCode == MachineType::F64) { result = LLVMBuildFCmp(builder_, realOpcode, e1Value, e2Value, ""); } else { - abort(); + UNREACHABLE(); } gate2LValue_[gate] = result; } diff --git a/ecmascript/compiler/pass_manager.cpp b/ecmascript/compiler/pass_manager.cpp index be98b03e..fc383a04 100644 --- a/ecmascript/compiler/pass_manager.cpp +++ b/ecmascript/compiler/pass_manager.cpp @@ -30,7 +30,7 @@ bool PassManager::Compile(const std::string &fileName, AOTFileGenerator &generat [[maybe_unused]] EcmaHandleScope handleScope(vm_->GetJSThread()); bool res = CollectInfoOfPandaFile(fileName, entry_, &translationInfo); if (!res) { - COMPILER_LOG(ERROR) << "Cannot execute panda file '" << fileName << "'"; + LOG_COMPILER(ERROR) << "Cannot execute panda file '" << fileName << "'"; return false; } auto aotModule = new LLVMModule("aot_" + fileName, triple_); @@ -48,7 +48,7 @@ bool PassManager::Compile(const std::string &fileName, AOTFileGenerator &generat } if (enableLog) { - COMPILER_LOG(INFO) << "\033[34m" << "aot method [" << fileName << ":" + LOG_COMPILER(INFO) << "\033[34m" << "aot method [" << fileName << ":" << methodName << "] log:" << "\033[0m"; } @@ -86,7 +86,7 @@ bool PassManager::CollectInfoOfPandaFile(const std::string &fileName, std::strin TSLoader *tsLoader = vm_->GetTSLoader(); tsLoader->DecodeTSTypes(jsPandaFile); } else { - COMPILER_LOG(INFO) << fileName << " has no type info"; + LOG_COMPILER(INFO) << fileName << " has no type info"; } auto program = PandaFileTranslator::GenerateProgram(vm_, jsPandaFile); diff --git a/ecmascript/compiler/scheduler.cpp b/ecmascript/compiler/scheduler.cpp index 030cdda7..7a4fde7b 100644 --- a/ecmascript/compiler/scheduler.cpp +++ b/ecmascript/compiler/scheduler.cpp @@ -214,7 +214,7 @@ std::optional> Scheduler::CalculateSchedulin } auto predUpperBound = predResult.value(); if (!isAncestor(curUpperBound, predUpperBound) && !isAncestor(predUpperBound, curUpperBound)) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Scheduling upper bound of gate (id=" + LOG_COMPILER(ERROR) << "[Verifier][Error] Scheduling upper bound of gate (id=" << circuit->LoadGatePtrConst(curGate)->GetId() << ") does not exist"; return std::nullopt; } @@ -304,31 +304,31 @@ void Scheduler::Print(const std::vector> *cfg, const Circui std::unordered_map bbGatesAddrToIdx; std::vector immDom; std::tie(bbGatesList, bbGatesAddrToIdx, immDom) = Scheduler::CalculateDominatorTree(circuit); - COMPILER_LOG(INFO) << "=========================================================================="; + LOG_COMPILER(INFO) << "=========================================================================="; for (size_t bbIdx = 0; bbIdx < cfg->size(); bbIdx++) { - COMPILER_LOG(INFO) << "BB_" << bbIdx << "_" << circuit->GetOpCode((*cfg)[bbIdx].front()).Str() << ":" + LOG_COMPILER(INFO) << "BB_" << bbIdx << "_" << circuit->GetOpCode((*cfg)[bbIdx].front()).Str() << ":" << " immDom=" << immDom[bbIdx]; - COMPILER_LOG(INFO) << " pred=["; + LOG_COMPILER(INFO) << " pred=["; bool isFirst = true; for (const auto &predStates : circuit->GetInVector((*cfg)[bbIdx].front())) { if (circuit->GetOpCode(predStates).IsState() || circuit->GetOpCode(predStates) == OpCode::STATE_ENTRY) { - COMPILER_LOG(INFO) << (isFirst ? "" : " ") << bbGatesAddrToIdx.at(predStates); + LOG_COMPILER(INFO) << (isFirst ? "" : " ") << bbGatesAddrToIdx.at(predStates); isFirst = false; } } - COMPILER_LOG(INFO) << "] succ=["; + LOG_COMPILER(INFO) << "] succ=["; isFirst = true; for (const auto &succStates : circuit->GetOutVector((*cfg)[bbIdx].front())) { if (circuit->GetOpCode(succStates).IsState() || circuit->GetOpCode(succStates) == OpCode::STATE_ENTRY) { - COMPILER_LOG(INFO) << (isFirst ? "" : " ") << bbGatesAddrToIdx.at(succStates); + LOG_COMPILER(INFO) << (isFirst ? "" : " ") << bbGatesAddrToIdx.at(succStates); isFirst = false; } } - COMPILER_LOG(INFO) << "]"; + LOG_COMPILER(INFO) << "]"; for (size_t instIdx = (*cfg)[bbIdx].size(); instIdx > 0; instIdx--) { circuit->Print((*cfg)[bbIdx][instIdx - 1]); } } - COMPILER_LOG(INFO) << "=========================================================================="; + LOG_COMPILER(INFO) << "=========================================================================="; } } // namespace panda::ecmascript::kungfu \ No newline at end of file diff --git a/ecmascript/compiler/slowpath_lowering.cpp b/ecmascript/compiler/slowpath_lowering.cpp index 80897cda..f7d55a1f 100644 --- a/ecmascript/compiler/slowpath_lowering.cpp +++ b/ecmascript/compiler/slowpath_lowering.cpp @@ -43,7 +43,7 @@ void SlowPathLowering::CallRuntimeLowering() } if (IsLogEnabled()) { - COMPILER_LOG(INFO) << "========================================================="; + LOG_COMPILER(INFO) << "========================================================="; circuit_->PrintAllGates(*bcBuilder_); } } diff --git a/ecmascript/compiler/stub_compiler.cpp b/ecmascript/compiler/stub_compiler.cpp index 0a35290a..0a4c1169 100644 --- a/ecmascript/compiler/stub_compiler.cpp +++ b/ecmascript/compiler/stub_compiler.cpp @@ -71,7 +71,7 @@ public: bool Run(StubPassData *data, [[maybe_unused]] bool enableLog) { auto stub = data->GetStub(); - COMPILER_LOG(INFO) << "Stub Name: " << stub->GetMethodName(); + LOG_COMPILER(INFO) << "Stub Name: " << stub->GetMethodName(); stub->GenerateCircuit(data->GetCompilationConfig()); return true; } @@ -129,14 +129,14 @@ bool StubCompiler::BuildStubModuleAndSave(const std::string &triple, const std:: const CompilerLog *log = GetLog(); StubFileGenerator generator(log); if (!stubFile.empty()) { - COMPILER_LOG(INFO) << "compiling bytecode handler stubs"; + LOG_COMPILER(INFO) << "compiling bytecode handler stubs"; LLVMModule bcStubModule("bc_stub", triple); LLVMAssembler bcStubAssembler(bcStubModule.GetModule(), LOptions(optLevel, false)); bcStubModule.SetUpForBytecodeHandlerStubs(); RunPipeline(&bcStubModule); generator.AddModule(&bcStubModule, &bcStubAssembler); res++; - COMPILER_LOG(INFO) << "compiling common stubs"; + LOG_COMPILER(INFO) << "compiling common stubs"; LLVMModule comStubModule("com_stub", triple); LLVMAssembler comStubAssembler(comStubModule.GetModule(), LOptions(optLevel, true)); comStubModule.SetUpForCommonStubs(); @@ -181,7 +181,7 @@ int main(const int argc, const char **argv) panda::ecmascript::EcmaVM *vm = panda::JSNApi::CreateEcmaVM(runtimeOptions); if (vm == nullptr) { - COMPILER_LOG(INFO) << "Can't Create EcmaVM"; + LOG_COMPILER(INFO) << "Can't Create EcmaVM"; return -1; } std::string tripleString = runtimeOptions.GetTargetTriple(); @@ -192,7 +192,7 @@ int main(const int argc, const char **argv) panda::ecmascript::kungfu::StubCompiler compiler(&log); bool res = compiler.BuildStubModuleAndSave(tripleString, stubFile, optLevel); - COMPILER_LOG(INFO) << "stub compiler run finish, result condition(T/F):" << std::boolalpha << res; + LOG_COMPILER(INFO) << "stub compiler run finish, result condition(T/F):" << std::boolalpha << res; panda::JSNApi::DestroyJSVM(vm); return res ? 0 : -1; } diff --git a/ecmascript/compiler/tests/stub_tests.cpp b/ecmascript/compiler/tests/stub_tests.cpp index 864c9070..5fdfd2ce 100644 --- a/ecmascript/compiler/tests/stub_tests.cpp +++ b/ecmascript/compiler/tests/stub_tests.cpp @@ -64,7 +64,7 @@ public: { if (thread->GetEcmaVM()->GetJSOptions().WasSetlogCompiledMethods()) { for (size_t bbIdx = 0; bbIdx < cfg.size(); bbIdx++) { - COMPILER_LOG(INFO) << (netOfGates.GetOpCode(cfg[bbIdx].front()).IsCFGMerge() ? "MERGE_" : "BB_") + LOG_COMPILER(INFO) << (netOfGates.GetOpCode(cfg[bbIdx].front()).IsCFGMerge() ? "MERGE_" : "BB_") << bbIdx << ":"; for (size_t instIdx = cfg[bbIdx].size(); instIdx > 0; instIdx--) { netOfGates.Print(cfg[bbIdx][instIdx - 1]); @@ -117,9 +117,9 @@ HWTEST_F_L0(StubTest, FastAddTest) JSTaggedValue(2).GetRawData()); // 2 : test case auto resC = fn(thread->GetGlueAddr(), JSTaggedValue(11).GetRawData(), JSTaggedValue(11).GetRawData()); // 11 : test case - COMPILER_LOG(INFO) << "res for FastAdd(1, 1) = " << resA.GetNumber(); - COMPILER_LOG(INFO) << "res for FastAdd(2, 2) = " << resB.GetNumber(); - COMPILER_LOG(INFO) << "res for FastAdd(11, 11) = " << resC.GetNumber(); + LOG_COMPILER(INFO) << "res for FastAdd(1, 1) = " << resA.GetNumber(); + LOG_COMPILER(INFO) << "res for FastAdd(2, 2) = " << resB.GetNumber(); + LOG_COMPILER(INFO) << "res for FastAdd(11, 11) = " << resC.GetNumber(); EXPECT_EQ(resA.GetNumber(), JSTaggedValue(2).GetNumber()); EXPECT_EQ(resB.GetNumber(), JSTaggedValue(4).GetNumber()); EXPECT_EQ(resC.GetNumber(), JSTaggedValue(22).GetNumber()); @@ -154,9 +154,9 @@ HWTEST_F_L0(StubTest, FastSubTest) JSTaggedValue(2).GetRawData()); // 7, 2 : test cases auto resC = fn(thread->GetGlueAddr(), JSTaggedValue(11).GetRawData(), JSTaggedValue(11).GetRawData()); // 11 : test case - COMPILER_LOG(INFO) << "res for FastSub(2, 1) = " << resA.GetNumber(); - COMPILER_LOG(INFO) << "res for FastSub(7, 2) = " << resB.GetNumber(); - COMPILER_LOG(INFO) << "res for FastSub(11, 11) = " << resC.GetNumber(); + LOG_COMPILER(INFO) << "res for FastSub(2, 1) = " << resA.GetNumber(); + LOG_COMPILER(INFO) << "res for FastSub(7, 2) = " << resB.GetNumber(); + LOG_COMPILER(INFO) << "res for FastSub(11, 11) = " << resC.GetNumber(); EXPECT_EQ(resA, JSTaggedValue(1)); EXPECT_EQ(resB, JSTaggedValue(5)); EXPECT_EQ(resC, JSTaggedValue(0)); @@ -187,9 +187,9 @@ HWTEST_F_L0(StubTest, FastMulTest) JSTaggedValue(-2).GetRawData()); // -7, -2 : test case auto resC = fn(thread->GetGlueAddr(), JSTaggedValue(11).GetRawData(), JSTaggedValue(11).GetRawData()); // 11 : test case - COMPILER_LOG(INFO) << "res for FastMul(-2, 1) = " << std::dec << resA.GetNumber(); - COMPILER_LOG(INFO) << "res for FastMul(-7, -2) = " << std::dec << resB.GetNumber(); - COMPILER_LOG(INFO) << "res for FastMul(11, 11) = " << std::dec << resC.GetNumber(); + LOG_COMPILER(INFO) << "res for FastMul(-2, 1) = " << std::dec << resA.GetNumber(); + LOG_COMPILER(INFO) << "res for FastMul(-7, -2) = " << std::dec << resB.GetNumber(); + LOG_COMPILER(INFO) << "res for FastMul(11, 11) = " << std::dec << resC.GetNumber(); EXPECT_EQ(resA.GetNumber(), -2); // -2: test case EXPECT_EQ(resB.GetNumber(), 14); // 14: test case EXPECT_EQ(resC.GetNumber(), 121); // 121: test case @@ -235,27 +235,27 @@ HWTEST_F_L0(StubTest, FastDivTest) // test normal Division operation uint64_t x1 = JSTaggedValue(50).GetRawData(); uint64_t y1 = JSTaggedValue(25).GetRawData(); - COMPILER_LOG(INFO) << "x1 = " << x1 << " y1 = " << y1; + LOG_COMPILER(INFO) << "x1 = " << x1 << " y1 = " << y1; auto res1 = fn(thread->GetGlueAddr(), x1, y1); - COMPILER_LOG(INFO) << "res for FastDiv(50, 25) = " << res1.GetRawData(); + LOG_COMPILER(INFO) << "res for FastDiv(50, 25) = " << res1.GetRawData(); auto expectedG1 = FastRuntimeStub::FastDiv(JSTaggedValue(x1), JSTaggedValue(y1)); EXPECT_EQ(res1, expectedG1); // test x == 0.0 or std::isnan(x) uint64_t x2 = JSTaggedValue(base::NAN_VALUE).GetRawData(); uint64_t y2 = JSTaggedValue(0).GetRawData(); - COMPILER_LOG(INFO) << "x2 = " << x1 << " y2 = " << y2; + LOG_COMPILER(INFO) << "x2 = " << x1 << " y2 = " << y2; auto res2 = fn(thread->GetGlueAddr(), x2, y2); - COMPILER_LOG(INFO) << "res for FastDiv(base::NAN_VALUE, 0) = " << res2.GetRawData(); + LOG_COMPILER(INFO) << "res for FastDiv(base::NAN_VALUE, 0) = " << res2.GetRawData(); auto expectedG2 = FastRuntimeStub::FastDiv(JSTaggedValue(x2), JSTaggedValue(y2)); EXPECT_EQ(res2, expectedG2); // test other uint64_t x3 = JSTaggedValue(7).GetRawData(); uint64_t y3 = JSTaggedValue(0).GetRawData(); - COMPILER_LOG(INFO) << "x2 = " << x3 << " y2 = " << y3; + LOG_COMPILER(INFO) << "x2 = " << x3 << " y2 = " << y3; auto res3 = fn(thread->GetGlueAddr(), x3, y3); - COMPILER_LOG(INFO) << "res for FastDiv(7, 0) = " << res3.GetRawData(); + LOG_COMPILER(INFO) << "res for FastDiv(7, 0) = " << res3.GetRawData(); auto expectedG3 = FastRuntimeStub::FastDiv(JSTaggedValue(x3), JSTaggedValue(y3)); EXPECT_EQ(res3, expectedG3); } @@ -290,8 +290,8 @@ HWTEST_F_L0(StubTest, FastModTest) auto result2 = fn(thread->GetGlueAddr(), JSTaggedValue(x2).GetRawData(), JSTaggedValue(y2).GetRawData()); auto expectRes2 = FastRuntimeStub::FastMod(JSTaggedValue(x2), JSTaggedValue(y2)); EXPECT_EQ(result2, expectRes2); - COMPILER_LOG(INFO) << "result2 for FastMod(7, 'helloworld') = " << result2.GetRawData(); - COMPILER_LOG(INFO) << "expectRes2 for FastMod(7, 'helloworld') = " << expectRes2.GetRawData(); + LOG_COMPILER(INFO) << "result2 for FastMod(7, 'helloworld') = " << result2.GetRawData(); + LOG_COMPILER(INFO) << "expectRes2 for FastMod(7, 'helloworld') = " << expectRes2.GetRawData(); // // test modular operation under normal conditions auto sp = const_cast(thread->GetCurrentSPFrame()); @@ -308,8 +308,8 @@ HWTEST_F_L0(StubTest, FastModTest) auto result4 = fn(thread->GetGlueAddr(), JSTaggedValue(x4).GetRawData(), JSTaggedValue(y4).GetRawData()); auto expectRes4 = FastRuntimeStub::FastMod(JSTaggedValue(x4), JSTaggedValue(y4)); - COMPILER_LOG(INFO) << "result4 for FastMod(base::NAN_VALUE, 7) = " << result4.GetRawData(); - COMPILER_LOG(INFO) << "expectRes4 for FastMod(base::NAN_VALUE, 7) = " << expectRes4.GetRawData(); + LOG_COMPILER(INFO) << "result4 for FastMod(base::NAN_VALUE, 7) = " << result4.GetRawData(); + LOG_COMPILER(INFO) << "expectRes4 for FastMod(base::NAN_VALUE, 7) = " << expectRes4.GetRawData(); EXPECT_EQ(result4, expectRes4); // test all non-conforming conditions @@ -320,7 +320,7 @@ HWTEST_F_L0(StubTest, FastModTest) auto result5 = fn(thread->GetGlueAddr(), JSTaggedValue(x5).GetRawData(), y5.GetTaggedValue().GetRawData()); EXPECT_EQ(result5, JSTaggedValue::Hole()); auto expectRes5 = FastRuntimeStub::FastMod(JSTaggedValue(x5), y5.GetTaggedValue()); - COMPILER_LOG(INFO) << "result1 for FastMod(7, 'helloworld') = " << result5.GetRawData(); + LOG_COMPILER(INFO) << "result1 for FastMod(7, 'helloworld') = " << result5.GetRawData(); EXPECT_EQ(result5, expectRes5); } @@ -401,12 +401,12 @@ public: StubCallRunTimeThreadFpLock(struct ThreadTy *thread, intptr_t newFp) : oldRbp_(thread->fp), thread_(thread) { thread_->fp = *(reinterpret_cast(newFp)); - COMPILER_LOG(INFO) << "StubCallRunTimeThreadFpLock newFp: " << newFp << " oldRbp_ : " << oldRbp_ + LOG_COMPILER(INFO) << "StubCallRunTimeThreadFpLock newFp: " << newFp << " oldRbp_ : " << oldRbp_ << " thread_->fp:" << thread_->fp; } ~StubCallRunTimeThreadFpLock() { - COMPILER_LOG(INFO) << "~StubCallRunTimeThreadFpLock oldRbp_: " << oldRbp_ << " thread_->fp:" << thread_->fp; + LOG_COMPILER(INFO) << "~StubCallRunTimeThreadFpLock oldRbp_: " << oldRbp_ << " thread_->fp:" << thread_->fp; thread_->fp = oldRbp_; } @@ -430,31 +430,31 @@ int64_t (*g_stub2Func)(struct ThreadTy *) = nullptr; int RuntimeFunc1(struct ThreadTy *fpInfo) { - COMPILER_LOG(INFO) << "RuntimeFunc1 -"; + LOG_COMPILER(INFO) << "RuntimeFunc1 -"; int64_t newRbp; asm("mov %%rbp, %0" : "=rm"(newRbp)); StubCallRunTimeThreadFpLock lock(fpInfo, newRbp); - COMPILER_LOG(INFO) << std::hex << "g_stub2Func " << reinterpret_cast(g_stub2Func); + LOG_COMPILER(INFO) << std::hex << "g_stub2Func " << reinterpret_cast(g_stub2Func); if (g_stub2Func != nullptr) { g_stub2Func(fpInfo); } - COMPILER_LOG(INFO) << "RuntimeFunc1 +"; + LOG_COMPILER(INFO) << "RuntimeFunc1 +"; return 0; } int RuntimeFunc2(struct ThreadTy *fpInfo) { - COMPILER_LOG(INFO) << "RuntimeFunc2 -"; + LOG_COMPILER(INFO) << "RuntimeFunc2 -"; // update thread.fp int64_t newRbp; asm("mov %%rbp, %0" : "=rm"(newRbp)); StubCallRunTimeThreadFpLock lock(fpInfo, newRbp); auto rbp = reinterpret_cast(fpInfo->fp); - COMPILER_LOG(INFO) << " RuntimeFunc2 rbp:" << rbp; + LOG_COMPILER(INFO) << " RuntimeFunc2 rbp:" << rbp; for (int i = 0; i < 40; i++) { // print 40 ptr value for debug - COMPILER_LOG(INFO) << std::hex << &(rbp[i]) << " :" << rbp[i]; + LOG_COMPILER(INFO) << std::hex << &(rbp[i]) << " :" << rbp[i]; } /* walk back stack frame: 0 pre rbp <-- rbp @@ -463,7 +463,7 @@ int RuntimeFunc2(struct ThreadTy *fpInfo) */ int64_t *frameType = nullptr; int64_t *gcFp = nullptr; - COMPILER_LOG(INFO) << "-----------------walkback----------------"; + LOG_COMPILER(INFO) << "-----------------walkback----------------"; do { frameType = rbp - 1; if (*frameType == 1) { @@ -472,11 +472,11 @@ int RuntimeFunc2(struct ThreadTy *fpInfo) gcFp = rbp; } rbp = reinterpret_cast(*gcFp); - COMPILER_LOG(INFO) << std::hex << "frameType :" << *frameType << " gcFp:" << *gcFp; + LOG_COMPILER(INFO) << std::hex << "frameType :" << *frameType << " gcFp:" << *gcFp; } while (*gcFp != 0); - COMPILER_LOG(INFO) << "+++++++++++++++++walkback++++++++++++++++"; - COMPILER_LOG(INFO) << "call RuntimeFunc2 func ThreadTy fp: " << fpInfo->fp << " magic:" << fpInfo->magic; - COMPILER_LOG(INFO) << "RuntimeFunc2 +"; + LOG_COMPILER(INFO) << "+++++++++++++++++walkback++++++++++++++++"; + LOG_COMPILER(INFO) << "call RuntimeFunc2 func ThreadTy fp: " << fpInfo->fp << " magic:" << fpInfo->magic; + LOG_COMPILER(INFO) << "RuntimeFunc2 +"; return 0; } } @@ -519,7 +519,7 @@ LLVMValueRef CallingFp(LLVMModuleRef &module, LLVMBuilderRef &builder) std::vector args = {LLVMConstInt(LLVMInt32Type(), 0, false)}; auto fn = LLVMGetNamedFunction(module, "llvm.frameaddress.p0i8"); if (!fn) { - COMPILER_LOG(INFO) << "Could not find function "; + LOG_COMPILER(INFO) << "Could not find function "; return LLVMConstInt(LLVMInt64Type(), 0, false); } LLVMValueRef fAddrRet = LLVMBuildCall(builder, fn, args.data(), 1, ""); @@ -530,7 +530,7 @@ LLVMValueRef CallingFp(LLVMModuleRef &module, LLVMBuilderRef &builder) #ifdef ARK_GC_SUPPORT HWTEST_F_L0(StubTest, JSEntryTest) { - COMPILER_LOG(INFO) << " ---------- JSEntryTest ------------- "; + LOG_COMPILER(INFO) << " ---------- JSEntryTest ------------- "; LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); LLVMSetTarget(module, "x86_64-unknown-linux-gnu"); LLVMBuilderRef builder = LLVMCreateBuilder(); @@ -657,10 +657,10 @@ HWTEST_F_L0(StubTest, JSEntryTest) auto stub1Func = reinterpret_cast(stub1Code); g_stub2Func = reinterpret_cast(stub2Code); int64_t result = stub1Func(¶meters); - COMPILER_LOG(INFO) << "parameters magic:" << parameters.magic << " parameters.fp " << parameters.fp; + LOG_COMPILER(INFO) << "parameters magic:" << parameters.magic << " parameters.fp " << parameters.fp; EXPECT_EQ(parameters.fp, 0x0); EXPECT_EQ(result, 1); - COMPILER_LOG(INFO) << " ++++++++++ JSEntryTest +++++++++++++ "; + LOG_COMPILER(INFO) << " ++++++++++ JSEntryTest +++++++++++++ "; } /* @@ -675,7 +675,7 @@ main push rbp */ HWTEST_F_L0(StubTest, Prologue) { - COMPILER_LOG(INFO) << " ---------- Prologue ------------- "; + LOG_COMPILER(INFO) << " ---------- Prologue ------------- "; LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); LLVMSetTarget(module); LLVMBuilderRef builder = LLVMCreateBuilder(); @@ -722,7 +722,7 @@ HWTEST_F_L0(StubTest, Prologue) auto mainFunc = reinterpret_cast(mainCode); int64_t result = mainFunc(1, 2); EXPECT_EQ(result, 3); - COMPILER_LOG(INFO) << " ++++++++++ Prologue +++++++++++++ "; + LOG_COMPILER(INFO) << " ++++++++++ Prologue +++++++++++++ "; } /* @@ -733,7 +733,7 @@ test: */ HWTEST_F_L0(StubTest, CEntryFp) { - COMPILER_LOG(INFO) << " ---------- CEntryFp ------------- "; + LOG_COMPILER(INFO) << " ---------- CEntryFp ------------- "; LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); LLVMSetTarget(module); LLVMBuilderRef builder = LLVMCreateBuilder(); @@ -781,7 +781,7 @@ HWTEST_F_L0(StubTest, CEntryFp) LLVMValueRef runTimeFunc = LLVMAddFunction(module, "RuntimeFunc", funcType); std::vector argValue = {value}; - COMPILER_LOG(INFO); + LOG_COMPILER(INFO); LLVMValueRef retVal = LLVMBuildCall(builder, runTimeFunc, argValue.data(), 1, ""); LLVMBuildRet(builder, retVal); char *error = nullptr; @@ -791,25 +791,25 @@ HWTEST_F_L0(StubTest, CEntryFp) assembler.Run(); auto engine = assembler.GetEngine(); uint64_t nativeCode = LLVMGetFunctionAddress(engine, "main"); - COMPILER_LOG(INFO) << " nativeCode : " << nativeCode; + LOG_COMPILER(INFO) << " nativeCode : " << nativeCode; struct ThreadTy parameters = {0x0, 0x0}; auto mainFunc = reinterpret_cast(nativeCode); int64_t result = mainFunc(¶meters); EXPECT_EQ(result, 1); - COMPILER_LOG(INFO) << " ++++++++++ CEntryFp +++++++++++++ "; + LOG_COMPILER(INFO) << " ++++++++++ CEntryFp +++++++++++++ "; } HWTEST_F_L0(StubTest, LoadGCIRTest) { - COMPILER_LOG(INFO) << "--------------LoadGCIRTest--------------------"; + LOG_COMPILER(INFO) << "--------------LoadGCIRTest--------------------"; char *path = get_current_dir_name(); std::string filePath = std::string(path) + "/ark/js_runtime/ecmascript/compiler/tests/satepoint_GC_0.ll"; char resolvedPath[PATH_MAX]; char *res = realpath(filePath.c_str(), resolvedPath); if (res == nullptr) { - COMPILER_LOG(ERROR) << "filePath :" << filePath.c_str() << " is not exist !"; + LOG_COMPILER(ERROR) << "filePath :" << filePath.c_str() << " is not exist !"; return; } @@ -819,7 +819,7 @@ HWTEST_F_L0(StubTest, LoadGCIRTest) // Load the input module... std::unique_ptr rawModule = parseIRFile(inputFilename, err, context); if (!rawModule) { - COMPILER_LOG(INFO) << "parseIRFile :" << inputFilename.data() << " failed !"; + LOG_COMPILER(INFO) << "parseIRFile :" << inputFilename.data() << " failed !"; err.print("parseIRFile ", llvm::errs()); return; } @@ -834,7 +834,7 @@ HWTEST_F_L0(StubTest, LoadGCIRTest) LLVMStackMapParser::GetInstance().CalculateStackMap(ptr); int value = reinterpret_cast(mainPtr)(); - COMPILER_LOG(INFO) << " value:" << value; + LOG_COMPILER(INFO) << " value:" << value; } #endif diff --git a/ecmascript/compiler/type_inference/type_infer.cpp b/ecmascript/compiler/type_inference/type_infer.cpp index aa58ed9b..72e08ff1 100644 --- a/ecmascript/compiler/type_inference/type_infer.cpp +++ b/ecmascript/compiler/type_inference/type_infer.cpp @@ -51,7 +51,7 @@ void TypeInfer::TraverseCircuit() } if (IsLogEnabled()) { - COMPILER_LOG(INFO) << "TypeInfer:======================================================"; + LOG_COMPILER(INFO) << "TypeInfer:======================================================"; circuit_->PrintAllGates(*builder_); } @@ -76,7 +76,7 @@ void TypeInfer::TypeInferPrint() const log += type.GetTypeStr(); } } - COMPILER_LOG(INFO) << std::dec << log; + LOG_COMPILER(INFO) << std::dec << log; } bool TypeInfer::UpdateType(GateRef gate, const GateType type) diff --git a/ecmascript/compiler/type_lowering.cpp b/ecmascript/compiler/type_lowering.cpp index 6bc9c4c2..238a9c66 100644 --- a/ecmascript/compiler/type_lowering.cpp +++ b/ecmascript/compiler/type_lowering.cpp @@ -27,7 +27,7 @@ void TypeLowering::RunTypeLowering() } if (IsLogEnabled()) { - COMPILER_LOG(INFO) << "================== type lowering print all gates =================="; + LOG_COMPILER(INFO) << "================== type lowering print all gates =================="; circuit_->PrintAllGates(*bcBuilder_); } } diff --git a/ecmascript/compiler/verifier.cpp b/ecmascript/compiler/verifier.cpp index b4c5a4ab..367b2a32 100644 --- a/ecmascript/compiler/verifier.cpp +++ b/ecmascript/compiler/verifier.cpp @@ -37,8 +37,8 @@ bool Verifier::RunDataIntegrityCheck(const Circuit *circuit) reinterpret_cast(circuit->LoadGatePtrConst(GateRef(out)))->GetGateConst()); if (gate < prevGate + static_cast(sizeof(Gate)) || gate >= static_cast(circuit->GetCircuitDataSize())) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (bad next gate)"; - COMPILER_LOG(ERROR) << "at: " << std::dec << gate; + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (bad next gate)"; + LOG_COMPILER(ERROR) << "at: " << std::dec << gate; return false; } gatesList.push_back(gate); @@ -51,8 +51,8 @@ bool Verifier::RunDataIntegrityCheck(const Circuit *circuit) break; } if (out > circuit->GetCircuitDataSize() || out < 0) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (out of bound access)"; - COMPILER_LOG(ERROR) << "at: " << std::dec << out; + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (out of bound access)"; + LOG_COMPILER(ERROR) << "at: " << std::dec << out; return false; } } @@ -60,13 +60,13 @@ bool Verifier::RunDataIntegrityCheck(const Circuit *circuit) for (size_t idx = 0; idx < circuit->LoadGatePtrConst(gate)->GetNumIns(); idx++) { const In *curIn = circuit->LoadGatePtrConst(gate)->GetInConst(idx); if (!(circuit->GetSpaceDataStartPtrConst() < curIn && curIn < circuit->GetSpaceDataEndPtrConst())) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted in list)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted in list)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } if (gatesSet.count(circuit->SaveGatePtr(curIn->GetGateConst())) == 0) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid in address)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid in address)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } } @@ -75,26 +75,26 @@ bool Verifier::RunDataIntegrityCheck(const Circuit *circuit) if (!curGate->IsFirstOutNull()) { const Out *curOut = curGate->GetFirstOutConst(); if (!(circuit->GetSpaceDataStartPtrConst() < curOut && curOut < circuit->GetSpaceDataEndPtrConst())) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted out list)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted out list)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } if (gatesSet.count(circuit->SaveGatePtr(curOut->GetGateConst())) == 0) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid out address)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid out address)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } while (!curOut->IsNextOutNull()) { curOut = curOut->GetNextOutConst(); if (!(circuit->GetSpaceDataStartPtrConst() < curOut && curOut < circuit->GetSpaceDataEndPtrConst())) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted out list)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (corrupted out list)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } if (gatesSet.count(circuit->SaveGatePtr(curOut->GetGateConst())) == 0) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid out address)"; - COMPILER_LOG(ERROR) << "id: " << std::dec << circuit->GetId(gate); + LOG_COMPILER(ERROR) << "[Verifier][Error] Circuit data is corrupted (invalid out address)"; + LOG_COMPILER(ERROR) << "id: " << std::dec << circuit->GetId(gate); return false; } } @@ -122,12 +122,12 @@ bool Verifier::RunCFGSoundnessCheck(const Circuit *circuit, const std::vectorGetOpCode(predGate).IsState() || circuit->GetOpCode(predGate) == OpCode::STATE_ENTRY) { if (bbGatesAddrToIdx.count(predGate) == 0) { - COMPILER_LOG(ERROR) << "[Verifier][Error] CFG is not sound"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(predGate) << ") is pred of " + LOG_COMPILER(ERROR) << "[Verifier][Error] CFG is not sound"; + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(predGate) << ") is pred of " << "(id=" << circuit->GetId(bbGate) << ")"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(bbGate) << ") is reachable from entry"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(predGate) << ") is unreachable from entry"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(bbGate) << ") is reachable from entry"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(predGate) << ") is unreachable from entry"; return false; } } @@ -150,12 +150,12 @@ bool Verifier::RunCFGIsDAGCheck(const Circuit *circuit) if (circuit->GetOpCode(*use).IsState() && use.GetIndex() < circuit->GetOpCode(*use).GetStateCount( circuit->LoadGatePtrConst(*use)->GetBitField())) { if (circuit->GetMark(*use) == MarkCode::VISITED) { - COMPILER_LOG(ERROR) << + LOG_COMPILER(ERROR) << "[Verifier][Error] CFG without loop back edges is not a directed acyclic graph"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(*use) << ") is succ of " + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(*use) << ") is succ of " << "(id=" << circuit->GetId(cur) << ")"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(cur) << ") is reachable from " + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(cur) << ") is reachable from " << "(id=" << circuit->GetId(*use) << ") without loop back edges"; return false; } @@ -192,11 +192,11 @@ bool Verifier::RunCFGReducibilityCheck(const Circuit *circuit, const std::vector ASSERT(circuit->LoadGatePtrConst(*use)->GetOpCode().IsState()); bool isDom = isAncestor(bbGatesAddrToIdx.at(*use), bbGatesAddrToIdx.at(curGate)); if (!isDom) { - COMPILER_LOG(ERROR) << "[Verifier][Error] CFG is not reducible"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(*use) << ") is loop back succ of " + LOG_COMPILER(ERROR) << "[Verifier][Error] CFG is not reducible"; + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(*use) << ") is loop back succ of " << "(id=" << circuit->GetId(curGate) << ")"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(*use) << ") does not dominate " + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(*use) << ") does not dominate " << "(id=" << circuit->GetId(curGate) << ")"; return false; } @@ -230,13 +230,13 @@ bool Verifier::RunFixedGatesRelationsCheck(const Circuit *circuit, const std::ve auto b = bbGatesAddrToIdx.at(circuit->GetIn(circuit->GetIn(fixedGate, 0), static_cast(cnt - 1))); if (!isAncestor(a, b)) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Fixed gates relationship is not consistent"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "Fixed gate (id=" + LOG_COMPILER(ERROR) << "[Verifier][Error] Fixed gates relationship is not consistent"; + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "Fixed gate (id=" << circuit->GetId(predGate) << ") is pred of fixed gate (id=" << circuit->GetId(fixedGate) << ")"; - COMPILER_LOG(ERROR) << "BB_" << bbGatesAddrToIdx.at(circuit->GetIn(predGate, 0)) + LOG_COMPILER(ERROR) << "BB_" << bbGatesAddrToIdx.at(circuit->GetIn(predGate, 0)) << " does not dominate BB_" << bbGatesAddrToIdx.at(circuit->GetIn(circuit->GetIn(fixedGate, 0), static_cast(cnt - 1))); @@ -285,12 +285,12 @@ bool Verifier::RunFlowCyclesFind(const Circuit *circuit, std::vector *s const auto prev = circuit->GetIn(cur, idx); if (circuit->GetOpCode(prev).IsSchedulable()) { if (circuit->GetMark(prev) == MarkCode::VISITED) { - COMPILER_LOG(ERROR) << + LOG_COMPILER(ERROR) << "[Verifier][Error] Found a data or depend flow cycle without passing selectors"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(prev) << ") is prev of " + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(prev) << ") is prev of " << "(id=" << circuit->GetId(cur) << ")"; - COMPILER_LOG(ERROR) << "(id=" << circuit->GetId(prev) << ") is reachable from " + LOG_COMPILER(ERROR) << "(id=" << circuit->GetId(prev) << ") is reachable from " << "(id=" << circuit->GetId(cur) << ") without passing selectors"; meet = prev; cycleGatesList.push_back(cur); @@ -315,7 +315,7 @@ bool Verifier::RunFlowCyclesFind(const Circuit *circuit, std::vector *s for (const auto &startGate : startGateList) { if (circuit->GetMark(startGate) == MarkCode::NO_MARK) { if (!dfs(startGate)) { - COMPILER_LOG(ERROR) << "Path:"; + LOG_COMPILER(ERROR) << "Path:"; for (const auto &cycleGate : cycleGatesList) { circuit->Print(cycleGate); } @@ -376,10 +376,10 @@ bool Verifier::RunSchedulingBoundsCheck(const Circuit *circuit, const std::vecto ASSERT(upperBound.size() == lowerBound.size()); for (const auto &item : lowerBound) { if (!isAncestor(upperBound.at(item.first), lowerBound.at(item.first))) { - COMPILER_LOG(ERROR) << "[Verifier][Error] Bounds of gate (id=" << item.first << ") is not consistent"; - COMPILER_LOG(ERROR) << "Proof:"; - COMPILER_LOG(ERROR) << "Upper bound is BB_" << upperBound.at(item.first); - COMPILER_LOG(ERROR) << "Lower bound is BB_" << lowerBound.at(item.first); + LOG_COMPILER(ERROR) << "[Verifier][Error] Bounds of gate (id=" << item.first << ") is not consistent"; + LOG_COMPILER(ERROR) << "Proof:"; + LOG_COMPILER(ERROR) << "Upper bound is BB_" << upperBound.at(item.first); + LOG_COMPILER(ERROR) << "Lower bound is BB_" << lowerBound.at(item.first); } } } @@ -403,7 +403,7 @@ bool Verifier::Run(const Circuit *circuit, bool enableLog) { if (!RunDataIntegrityCheck(circuit)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] Circuit data integrity verifier failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] Circuit data integrity verifier failed"; } return false; } @@ -413,19 +413,19 @@ bool Verifier::Run(const Circuit *circuit, bool enableLog) std::tie(bbGatesList, bbGatesAddrToIdx, immDom) = Scheduler::CalculateDominatorTree(circuit); if (!RunStateGatesCheck(circuit, bbGatesList)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunStateGatesCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunStateGatesCheck failed"; } return false; } if (!RunCFGSoundnessCheck(circuit, bbGatesList, bbGatesAddrToIdx)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunCFGSoundnessCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunCFGSoundnessCheck failed"; } return false; } if (!RunCFGIsDAGCheck(circuit)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunCFGIsDAGCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunCFGIsDAGCheck failed"; } return false; } @@ -473,51 +473,51 @@ bool Verifier::Run(const Circuit *circuit, bool enableLog) }; if (!RunCFGReducibilityCheck(circuit, bbGatesList, bbGatesAddrToIdx, isAncestor)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunCFGReducibilityCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunCFGReducibilityCheck failed"; } return false; } std::vector fixedGatesList = FindFixedGates(circuit, bbGatesList); if (!RunFixedGatesCheck(circuit, fixedGatesList)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunFixedGatesCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunFixedGatesCheck failed"; } return false; } if (!RunFixedGatesRelationsCheck(circuit, fixedGatesList, bbGatesAddrToIdx, isAncestor)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunFixedGatesRelationsCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunFixedGatesRelationsCheck failed"; } return false; } std::vector schedulableGatesList; if (!RunFlowCyclesFind(circuit, &schedulableGatesList, bbGatesList, fixedGatesList)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunFlowCyclesFind failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunFlowCyclesFind failed"; } return false; } if (!RunSchedulableGatesCheck(circuit, fixedGatesList)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunSchedulableGatesCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunSchedulableGatesCheck failed"; } return false; } if (!RunPrologGatesCheck(circuit, fixedGatesList)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunPrologGatesCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunPrologGatesCheck failed"; } return false; } if (!RunSchedulingBoundsCheck(circuit, schedulableGatesList, bbGatesAddrToIdx, isAncestor, lowestCommonAncestor)) { if (enableLog) { - COMPILER_LOG(ERROR) << "[Verifier][Fail] RunSchedulingBoundsCheck failed"; + LOG_COMPILER(ERROR) << "[Verifier][Fail] RunSchedulingBoundsCheck failed"; } return false; } if (enableLog) { - COMPILER_LOG(INFO) << "[Verifier][Pass] Verifier success"; + LOG_COMPILER(INFO) << "[Verifier][Pass] Verifier success"; } return true; diff --git a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp index 59cdc9a3..043d395b 100644 --- a/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp +++ b/ecmascript/dfx/cpu_profiler/cpu_profiler.cpp @@ -35,10 +35,10 @@ CpuProfiler::CpuProfiler() { generator_ = new SamplesRecord(); if (sem_init(&sem_[0], 0, 0) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] init failed"; + LOG_ECMA(ERROR) << "sem_[0] init failed"; } if (sem_init(&sem_[1], 0, 0) != 0) { - LOG(ERROR, RUNTIME) << "sem_[1] init failed"; + LOG_ECMA(ERROR) << "sem_[1] init failed"; } } @@ -65,13 +65,13 @@ void CpuProfiler::StartCpuProfilerForInfo(const EcmaVM *vm) struct sigaction sa; sa.sa_handler = &GetStackSignalHandler; if (sigemptyset(&sa.sa_mask) != 0) { - LOG(ERROR, RUNTIME) << "Parameter set signal set initialization and emptying failed"; + LOG_ECMA(ERROR) << "Parameter set signal set initialization and emptying failed"; isProfiling_ = false; return; } sa.sa_flags = SA_RESTART; if (sigaction(SIGINT, &sa, nullptr) != 0) { - LOG(ERROR, RUNTIME) << "sigaction failed to set signal"; + LOG_ECMA(ERROR) << "sigaction failed to set signal"; isProfiling_ = false; return; } @@ -90,7 +90,7 @@ void CpuProfiler::StartCpuProfilerForFile(const EcmaVM *vm, const std::string &f isProfiling_ = true; std::string absoluteFilePath(""); if (!CheckFileName(fileName, absoluteFilePath)) { - LOG(ERROR, RUNTIME) << "The fileName contains illegal characters"; + LOG_ECMA(ERROR) << "The fileName contains illegal characters"; isProfiling_ = false; return; } @@ -101,7 +101,7 @@ void CpuProfiler::StartCpuProfilerForFile(const EcmaVM *vm, const std::string &f generator_->SetFileName(fileName_); generator_->fileHandle_.open(fileName_.c_str()); if (generator_->fileHandle_.fail()) { - LOG(ERROR, RUNTIME) << "File open failed"; + LOG_ECMA(ERROR) << "File open failed"; isProfiling_ = false; return; } @@ -110,13 +110,13 @@ void CpuProfiler::StartCpuProfilerForFile(const EcmaVM *vm, const std::string &f struct sigaction sa; sa.sa_handler = &GetStackSignalHandler; if (sigemptyset(&sa.sa_mask) != 0) { - LOG(ERROR, RUNTIME) << "Parameter set signal set initialization and emptying failed"; + LOG_ECMA(ERROR) << "Parameter set signal set initialization and emptying failed"; isProfiling_ = false; return; } sa.sa_flags = SA_RESTART; if (sigaction(SIGINT, &sa, nullptr) != 0) { - LOG(ERROR, RUNTIME) << "sigaction failed to set signal"; + LOG_ECMA(ERROR) << "sigaction failed to set signal"; isProfiling_ = false; return; } @@ -134,27 +134,27 @@ std::unique_ptr CpuProfiler::StopCpuProfilerForInfo() { std::unique_ptr profileInfo; if (!isProfiling_) { - LOG(ERROR, RUNTIME) << "Do not execute stop cpuprofiler twice in a row or didn't execute the start\ + LOG_ECMA(ERROR) << "Do not execute stop cpuprofiler twice in a row or didn't execute the start\ or the sampling thread is not started"; return profileInfo; } if (outToFile_) { - LOG(ERROR, RUNTIME) << "Can not Stop a CpuProfiler sampling which is for file output by this stop method"; + LOG_ECMA(ERROR) << "Can not Stop a CpuProfiler sampling which is for file output by this stop method"; return profileInfo; } if (static_cast(tid_) != syscall(SYS_gettid)) { - LOG(ERROR, RUNTIME) << "Thread attempted to close other sampling threads"; + LOG_ECMA(ERROR) << "Thread attempted to close other sampling threads"; return profileInfo; } isProfiling_ = false; SamplingProcessor::SetIsStart(false); generator_->SetLastSampleFlag(); if (sem_post(&sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] post failed"; + LOG_ECMA(ERROR) << "sem_[0] post failed"; return profileInfo; } if (sem_wait(&sem_[1]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[1] wait failed"; + LOG_ECMA(ERROR) << "sem_[1] wait failed"; return profileInfo; } @@ -174,30 +174,30 @@ void CpuProfiler::SetCpuSamplingInterval(int interval) void CpuProfiler::StopCpuProfilerForFile() { if (!isProfiling_) { - LOG(ERROR, RUNTIME) << "Do not execute stop cpuprofiler twice in a row or didn't execute the start\ + LOG_ECMA(ERROR) << "Do not execute stop cpuprofiler twice in a row or didn't execute the start\ or the sampling thread is not started"; return; } if (!outToFile_) { - LOG(ERROR, RUNTIME) << "Can not Stop a CpuProfiler sampling which is for return profile info by\ + LOG_ECMA(ERROR) << "Can not Stop a CpuProfiler sampling which is for return profile info by\ this stop method"; return; } if (static_cast(tid_) != syscall(SYS_gettid)) { - LOG(ERROR, RUNTIME) << "Thread attempted to close other sampling threads"; + LOG_ECMA(ERROR) << "Thread attempted to close other sampling threads"; return; } isProfiling_ = false; SamplingProcessor::SetIsStart(false); generator_->SetLastSampleFlag(); if (sem_post(&sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] post failed"; + LOG_ECMA(ERROR) << "sem_[0] post failed"; return; } if (sem_wait(&sem_[1]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[1] wait failed"; + LOG_ECMA(ERROR) << "sem_[1] wait failed"; return; } generator_->WriteMethodsAndSampleInfo(true); @@ -213,10 +213,10 @@ void CpuProfiler::StopCpuProfilerForFile() CpuProfiler::~CpuProfiler() { if (sem_destroy(&sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] destroy failed"; + LOG_ECMA(ERROR) << "sem_[0] destroy failed"; } if (sem_destroy(&sem_[1]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[1] destroy failed"; + LOG_ECMA(ERROR) << "sem_[1] destroy failed"; } if (generator_ != nullptr) { delete generator_; @@ -254,7 +254,7 @@ void CpuProfiler::GetCurrentProcessInfo(struct CurrentProcessInfo ¤tProces currentProcessInfo.nowTimeStamp = SamplingProcessor::GetMicrosecondsTimeStamp() % TIME_CHANGE; currentProcessInfo.pid = getpid(); if (syscall(SYS_gettid) == -1) { - LOG_ECMA(FATAL) << "syscall failed"; + LOG_FULL(FATAL) << "syscall failed"; UNREACHABLE(); } tid_ = currentProcessInfo.tid = static_cast(syscall(SYS_gettid)); @@ -346,7 +346,7 @@ void CpuProfiler::IsNeedAndGetStack(JSThread *thread) if (thread->GetStackSignal()) { GetFrameStack(thread); if (sem_post(&sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] post failed"; + LOG_ECMA(ERROR) << "sem_[0] post failed"; return; } thread->SetGetStackSignal(false); @@ -358,7 +358,7 @@ void CpuProfiler::GetStackSignalHandler([[maybe_unused]] int signal) JSThread *thread = SamplingProcessor::GetJSThread(); GetFrameStack(thread); if (sem_post(&sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] post failed"; + LOG_ECMA(ERROR) << "sem_[0] post failed"; return; } } @@ -373,12 +373,12 @@ std::string CpuProfiler::GetProfileName() const size_t result = 0; result = strftime(time1, sizeof(time1), "%Y%m%d", &nowTime1); if (result == 0) { - LOG(ERROR, RUNTIME) << "get time failed"; + LOG_ECMA(ERROR) << "get time failed"; return ""; } result = strftime(time2, sizeof(time2), "%H%M%S", &nowTime1); if (result == 0) { - LOG(ERROR, RUNTIME) << "get time failed"; + LOG_ECMA(ERROR) << "get time failed"; return ""; } std::string profileName = "cpuprofile-"; @@ -402,7 +402,7 @@ bool CpuProfiler::CheckFileName(const std::string &fileName, std::string &absolu CVector resolvedPath(PATH_MAX); auto result = realpath(fileName.c_str(), resolvedPath.data()); if (result == nullptr) { - LOG(INFO, RUNTIME) << "The file path does not exist"; + LOG_ECMA(INFO) << "The file path does not exist"; } std::ofstream file(resolvedPath.data()); if (!file.good()) { diff --git a/ecmascript/dfx/cpu_profiler/sampling_processor.cpp b/ecmascript/dfx/cpu_profiler/sampling_processor.cpp index c90ad1fb..cb7c5938 100644 --- a/ecmascript/dfx/cpu_profiler/sampling_processor.cpp +++ b/ecmascript/dfx/cpu_profiler/sampling_processor.cpp @@ -46,16 +46,16 @@ bool SamplingProcessor::Run([[maybe_unused]] uint32_t threadIndex) if (!SamplesRecord::staticGcState_) { thread->SetGetStackSignal(true); if (sem_wait(&CpuProfiler::sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] wait failed"; + LOG_ECMA(ERROR) << "sem_[0] wait failed"; } } #else if (pthread_kill(pid_, SIGINT) != 0) { - LOG(ERROR, RUNTIME) << "pthread_kill signal failed"; + LOG_ECMA(ERROR) << "pthread_kill signal failed"; return false; } if (sem_wait(&CpuProfiler::sem_[0]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[0] wait failed"; + LOG_ECMA(ERROR) << "sem_[0] wait failed"; return false; } #endif @@ -82,7 +82,7 @@ bool SamplingProcessor::Run([[maybe_unused]] uint32_t threadIndex) uint64_t stopTime = GetMicrosecondsTimeStamp(); generator_->SetThreadStopTime(stopTime); if (sem_post(&CpuProfiler::sem_[1]) != 0) { - LOG(ERROR, RUNTIME) << "sem_[1] post failed"; + LOG_ECMA(ERROR) << "sem_[1] post failed"; return false; } return true; diff --git a/ecmascript/dfx/hprof/heap_profiler.cpp b/ecmascript/dfx/hprof/heap_profiler.cpp index de401ead..f23afbc7 100644 --- a/ecmascript/dfx/hprof/heap_profiler.cpp +++ b/ecmascript/dfx/hprof/heap_profiler.cpp @@ -36,9 +36,9 @@ bool HeapProfiler::DumpHeapSnapshot(DumpFormat dumpFormat, Stream *stream, Progr { [[maybe_unused]] bool heapClean = ForceFullGC(vm_); ASSERT(heapClean); - LOG(INFO, RUNTIME) << "HeapProfiler DumpSnapshot start"; + LOG_ECMA(INFO) << "HeapProfiler DumpSnapshot start"; size_t heapSize = vm_->GetHeap()->GetHeapObjectSize(); - LOG(ERROR, RUNTIME) << "HeapProfiler DumpSnapshot heap size " << heapSize; + LOG_ECMA(ERROR) << "HeapProfiler DumpSnapshot heap size " << heapSize; int32_t heapCount = vm_->GetHeap()->GetHeapObjectCount(); if (progress != nullptr) { progress->ReportProgress(0, heapCount); @@ -121,7 +121,7 @@ CString HeapProfiler::GetTimeStamp() }; struct tm *timeData = localtime_r(&timeSource, &tm); if (timeData == nullptr) { - LOG_ECMA(FATAL) << "localtime_r failed"; + LOG_FULL(FATAL) << "localtime_r failed"; UNREACHABLE(); } CString stamp; @@ -152,7 +152,7 @@ bool HeapProfiler::ForceFullGC(const EcmaVM *vm) HeapSnapshot *HeapProfiler::MakeHeapSnapshot(SampleType sampleType, bool isVmMode, bool isPrivate) { - LOG(ERROR, RUNTIME) << "HeapProfiler::MakeHeapSnapshot"; + LOG_ECMA(ERROR) << "HeapProfiler::MakeHeapSnapshot"; DISALLOW_GARBAGE_COLLECTION; const_cast(vm_->GetHeap())->Prepare(); switch (sampleType) { @@ -160,7 +160,7 @@ HeapSnapshot *HeapProfiler::MakeHeapSnapshot(SampleType sampleType, bool isVmMod auto *snapshot = const_cast(vm_->GetNativeAreaAllocator()) ->New(vm_, isVmMode, isPrivate); if (snapshot == nullptr) { - LOG_ECMA(FATAL) << "alloc snapshot failed"; + LOG_FULL(FATAL) << "alloc snapshot failed"; UNREACHABLE(); } snapshot->BuildUp(); @@ -171,7 +171,7 @@ HeapSnapshot *HeapProfiler::MakeHeapSnapshot(SampleType sampleType, bool isVmMod auto *snapshot = const_cast(vm_->GetNativeAreaAllocator()) ->New(vm_, isVmMode, isPrivate); if (snapshot == nullptr) { - LOG_ECMA(FATAL) << "alloc snapshot failed"; + LOG_FULL(FATAL) << "alloc snapshot failed"; UNREACHABLE(); } AddSnapshot(snapshot); diff --git a/ecmascript/dfx/hprof/heap_profiler.h b/ecmascript/dfx/hprof/heap_profiler.h index bb017708..859b807d 100644 --- a/ecmascript/dfx/hprof/heap_profiler.h +++ b/ecmascript/dfx/hprof/heap_profiler.h @@ -38,7 +38,7 @@ public: jsonSerializer_ = const_cast(vm->GetNativeAreaAllocator())->New(); if (UNLIKELY(jsonSerializer_ == nullptr)) { - LOG_ECMA(FATAL) << "alloc snapshot json serializer failed"; + LOG_FULL(FATAL) << "alloc snapshot json serializer failed"; UNREACHABLE(); } } diff --git a/ecmascript/dfx/hprof/heap_snapshot.cpp b/ecmascript/dfx/hprof/heap_snapshot.cpp index 4bbd797f..c80e59f0 100644 --- a/ecmascript/dfx/hprof/heap_snapshot.cpp +++ b/ecmascript/dfx/hprof/heap_snapshot.cpp @@ -46,7 +46,7 @@ Node *Node::NewNode(const EcmaVM *vm, size_t id, size_t index, CString *name, No auto node = const_cast(vm->GetNativeAreaAllocator()) ->New(id, index, name, type, size, 0, NewAddress(entry), isLive); if (UNLIKELY(node == nullptr)) { - LOG_ECMA(FATAL) << "internal allocator failed"; + LOG_FULL(FATAL) << "internal allocator failed"; UNREACHABLE(); } return node; @@ -56,7 +56,7 @@ Edge *Edge::NewEdge(const EcmaVM *vm, uint64_t id, EdgeType type, Node *from, No { auto edge = const_cast(vm->GetNativeAreaAllocator())->New(id, type, from, to, name); if (UNLIKELY(edge == nullptr)) { - LOG_ECMA(FATAL) << "internal allocator failed"; + LOG_FULL(FATAL) << "internal allocator failed"; UNREACHABLE(); } return edge; @@ -126,7 +126,7 @@ void HeapSnapshot::PushHeapStat(Stream* stream) { CVector statsBuffer; if (stream == nullptr) { - LOG(ERROR, DEBUGGER) << "HeapSnapshot::PushHeapStat::stream is nullptr"; + LOG_DEBUGGER(ERROR) << "HeapSnapshot::PushHeapStat::stream is nullptr"; return; } int32_t preChunkSize = stream->GetSize(); @@ -535,7 +535,7 @@ Node *HeapSnapshot::GenerateNode(JSTaggedValue entry, int sequenceId) node = GenerateStringNode(entry, sequenceId); } if (node == nullptr) { - LOG(DEBUG, RUNTIME) << "string node nullptr"; + LOG_ECMA(DEBUG) << "string node nullptr"; } return node; } diff --git a/ecmascript/dfx/hprof/heap_snapshot_json_serializer.cpp b/ecmascript/dfx/hprof/heap_snapshot_json_serializer.cpp index 8a3dc97b..40986ec1 100644 --- a/ecmascript/dfx/hprof/heap_snapshot_json_serializer.cpp +++ b/ecmascript/dfx/hprof/heap_snapshot_json_serializer.cpp @@ -22,7 +22,7 @@ namespace panda::ecmascript { bool HeapSnapshotJSONSerializer::Serialize(HeapSnapshot *snapshot, Stream *stream) { // Serialize Node/Edge/String-Table - LOG(ERROR, RUNTIME) << "HeapSnapshotJSONSerializer::Serialize begin"; + LOG_ECMA(ERROR) << "HeapSnapshotJSONSerializer::Serialize begin"; snapshot_ = snapshot; ASSERT(snapshot_->GetNodes() != nullptr && snapshot_->GetEdges() != nullptr && snapshot_->GetEcmaStringTable() != nullptr); @@ -41,7 +41,7 @@ bool HeapSnapshotJSONSerializer::Serialize(HeapSnapshot *snapshot, Stream *strea SerializerSnapshotClosure(); // 9. WriteChunk(); - LOG(ERROR, RUNTIME) << "HeapSnapshotJSONSerializer::Serialize exit"; + LOG_ECMA(ERROR) << "HeapSnapshotJSONSerializer::Serialize exit"; return true; } diff --git a/ecmascript/dfx/native_dfx/backtrace.cpp b/ecmascript/dfx/native_dfx/backtrace.cpp index ea5eb52d..8397aba5 100644 --- a/ecmascript/dfx/native_dfx/backtrace.cpp +++ b/ecmascript/dfx/native_dfx/backtrace.cpp @@ -21,7 +21,6 @@ #include #include -#include "libpandabase/utils/logger.h" #include "mem/mem.h" namespace panda::ecmascript { @@ -37,12 +36,12 @@ void PrintBacktrace(uintptr_t value) if (!unwBackTrace) { void *handle = dlopen(LIB_UNWIND_SO_NAME.c_str(), RTLD_NOW); if (handle == nullptr) { - LOG(ERROR, RUNTIME) << "dlopen libunwind.so failed"; + LOG_ECMA(ERROR) << "dlopen libunwind.so failed"; return; } unwBackTrace = reinterpret_cast(dlsym(handle, "unw_backtrace")); if (unwBackTrace == nullptr) { - LOG(ERROR, RUNTIME) << "dlsym unw_backtrace failed"; + LOG_ECMA(ERROR) << "dlsym unw_backtrace failed"; return; } } @@ -69,8 +68,8 @@ void PrintBacktrace(uintptr_t value) stack << "#" << std::setw(ALIGN_WIDTH) << std::dec << i << ": " << file << "(" << "+" << std::hex << offset << ")" << std::endl; } - LOG(INFO, RUNTIME) << "=====================Backtrace(" << std::hex << value <<")========================"; - LOG(INFO, RUNTIME) << stack.str(); + LOG_ECMA(INFO) << "=====================Backtrace(" << std::hex << value <<")========================"; + LOG_ECMA(INFO) << stack.str(); stack.clear(); } } // namespace panda::ecmascript diff --git a/ecmascript/dfx/vmstat/runtime_stat.cpp b/ecmascript/dfx/vmstat/runtime_stat.cpp index bdfc2791..1527a4ed 100644 --- a/ecmascript/dfx/vmstat/runtime_stat.cpp +++ b/ecmascript/dfx/vmstat/runtime_stat.cpp @@ -68,14 +68,14 @@ void EcmaRuntimeStat::ResetAllCount() void EcmaRuntimeStat::PrintAllStats() const { - LOG(INFO, RUNTIME) << "panda runtime stat:"; + LOG_ECMA(INFO) << "panda runtime stat:"; static constexpr int nameRightAdjustment = 45; static constexpr int numberRightAdjustment = 12; - LOG(INFO, RUNTIME) << std::right << std::setw(nameRightAdjustment) << "InterPreter && GC && C++ Builtin Function" + LOG_ECMA(INFO) << std::right << std::setw(nameRightAdjustment) << "InterPreter && GC && C++ Builtin Function" << std::setw(numberRightAdjustment) << "Time(ns)" << std::setw(numberRightAdjustment) << "Count" << std::setw(numberRightAdjustment) << "MaxTime(ns)" << std::setw(numberRightAdjustment) << "AvgTime(ns)"; - LOG(INFO, RUNTIME) << "============================================================" + LOG_ECMA(INFO) << "============================================================" << "========================================================="; CVector callerStat; @@ -92,7 +92,7 @@ void EcmaRuntimeStat::PrintAllStats() const for (auto &runCallerStat : callerStat) { if (runCallerStat.TotalCount() != 0) { totalTime += runCallerStat.TotalTime(); - LOG(INFO, RUNTIME) << std::right << std::setw(nameRightAdjustment) << runCallerStat.Name() + LOG_ECMA(INFO) << std::right << std::setw(nameRightAdjustment) << runCallerStat.Name() << std::setw(numberRightAdjustment) << runCallerStat.TotalTime() << std::setw(numberRightAdjustment) << runCallerStat.TotalCount() << std::setw(numberRightAdjustment) << runCallerStat.MaxTime() @@ -100,9 +100,9 @@ void EcmaRuntimeStat::PrintAllStats() const << runCallerStat.TotalTime() / runCallerStat.TotalCount(); } } - LOG(INFO, RUNTIME) << "------------------------------------------------------------" + LOG_ECMA(INFO) << "------------------------------------------------------------" << "---------------------------------------------------------"; - LOG(INFO, RUNTIME) << std::right << std::setw(nameRightAdjustment) << "Total Time(ns)" + LOG_ECMA(INFO) << std::right << std::setw(nameRightAdjustment) << "Total Time(ns)" << std::setw(numberRightAdjustment) << totalTime; } diff --git a/ecmascript/ecma_macros.h b/ecmascript/ecma_macros.h index cc96695b..951171cd 100644 --- a/ecmascript/ecma_macros.h +++ b/ecmascript/ecma_macros.h @@ -17,6 +17,7 @@ #define ECMASCRIPT_ECMA_MACROS_H #include "ecmascript/common.h" +#include "ecmascript/log_wrapper.h" #include "libpandabase/trace/trace.h" #if defined(ENABLE_BYTRACE) @@ -25,16 +26,9 @@ #if defined(__cplusplus) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define LOG_ECMA(type) \ - LOG(type, ECMASCRIPT) << __func__ << " Line:" << __LINE__ << " " // NOLINT(bugprone-lambda-function-name) -#define ECMA_GC_LOG() LOG(DEBUG, ECMASCRIPT) << " ecmascript gc log: " - -#define OPTIONAL_LOG(ecmaVM, level, component) \ - LOG_IF(ecmaVM->IsOptionalLogEnabled(), level, component) - -#define COMPILER_LOG(level) LOG(level, ECMASCRIPT) -#define COMPILER_OPTIONAL_LOG(level) LOG_IF(IsLogEnabled(), level, ECMASCRIPT) +#define OPTIONAL_LOG(vm, level) LOG_ECMA_IF(vm->IsOptionalLogEnabled(), level) +#define OPTIONAL_LOG_COMPILER(level) LOG_ECMA_IF(IsLogEnabled(), level) #if !defined(ENABLE_BYTRACE) #define ECMA_BYTRACE_NAME(tag, name) trace::ScopedTrace scopedTrace(name) @@ -523,19 +517,14 @@ } #endif -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define CHECK_DUMP_FIELDS(begin, end, num) \ - LOG_IF((num) != ((end) - (begin)) / JSTaggedValue::TaggedTypeSize(), FATAL, RUNTIME) \ - << "Fields in obj are not in dump list. "; - -#define CHECK_OBJECT_SIZE(size) \ - if ((size) == 0) { \ - LOG(FATAL, ECMASCRIPT) << __func__ << " Line: " << __LINE__ << " objectSize is " << (size); \ +#define CHECK_OBJECT_SIZE(size) \ + if ((size) == 0) { \ + LOG_FULL(FATAL) << __func__ << ":" << __LINE__ << " objectSize is " << (size); \ } -#define CHECK_REGION_END(begin, end) \ - if ((begin) > (end)) { \ - LOG(FATAL, ECMASCRIPT) << __func__ << " Line: " << __LINE__ << " begin: " << (begin) << " end: " << (end); \ +#define CHECK_REGION_END(begin, end) \ + if ((begin) > (end)) { \ + LOG_FULL(FATAL) << __func__ << ":" << __LINE__ << " begin: " << (begin) << " end: " << (end); \ } #define CHECK_JS_THREAD(vm) ASSERT(vm->GetJSThread()->GetThreadId() == JSThread::GetCurrentThreadId()) diff --git a/ecmascript/ecma_string-inl.h b/ecmascript/ecma_string-inl.h index 82a5623e..fe591101 100644 --- a/ecmascript/ecma_string-inl.h +++ b/ecmascript/ecma_string-inl.h @@ -59,7 +59,7 @@ inline EcmaString *EcmaString::CreateFromUtf8(const uint8_t *utf8Data, uint32_t ASSERT(string != nullptr); if (memcpy_s(string->GetDataUtf8Writable(), utf8Len, utf8Data, utf8Len) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } else { @@ -85,7 +85,7 @@ inline EcmaString *EcmaString::CreateFromUtf8NonMovable(const EcmaVM *vm, const EcmaString *string = AllocStringObjectNonMovable(vm, utf8Len); ASSERT(string != nullptr); if (memcpy_s(string->GetDataUtf8Writable(), utf8Len, utf8Data, utf8Len) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } ASSERT_PRINT(CanBeCompressed(string) == true, "Bad input canBeCompress!"); @@ -106,7 +106,7 @@ inline EcmaString *EcmaString::CreateFromUtf16(const uint16_t *utf16Data, uint32 } else { uint32_t len = utf16Len * (sizeof(uint16_t) / sizeof(uint8_t)); if (memcpy_s(string->GetDataUtf16Writable(), len, utf16Data, len) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -159,7 +159,7 @@ void EcmaString::WriteData(EcmaString *src, uint32_t start, uint32_t destSize, u ASSERT(src->IsUtf8()); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (length != 0 && memcpy_s(GetDataUtf8Writable() + start, destSize, src->GetDataUtf8(), length) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } else if (src->IsUtf8()) { @@ -173,7 +173,7 @@ void EcmaString::WriteData(EcmaString *src, uint32_t start, uint32_t destSize, u // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (length != 0 && memcpy_s(GetDataUtf16Writable() + start, ComputeDataSizeUtf16(destSize), src->GetDataUtf16(), ComputeDataSizeUtf16(length)) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } diff --git a/ecmascript/ecma_string.cpp b/ecmascript/ecma_string.cpp index 7fb6ccbf..713c56b8 100644 --- a/ecmascript/ecma_string.cpp +++ b/ecmascript/ecma_string.cpp @@ -383,7 +383,7 @@ bool EcmaString::StringCopy(Span &dst, size_t dstMax, Span &src, siz ASSERT(dstMax >= count); ASSERT(dst.Size() >= src.Size()); if (memcpy_s(dst.data(), dstMax, src.data(), count) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } return true; diff --git a/ecmascript/ecma_string.h b/ecmascript/ecma_string.h index 760a3140..b915b47b 100644 --- a/ecmascript/ecma_string.h +++ b/ecmascript/ecma_string.h @@ -91,7 +91,7 @@ public: const uint16_t *GetDataUtf16() const { - LOG_IF(!IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf16 for utf8 string"; + LOG_ECMA_IF(!IsUtf16(), FATAL) << "EcmaString: Read data as utf16 for utf8 string"; return GetData(); } @@ -159,20 +159,20 @@ public: } if (!IsUtf16()) { if (length > std::numeric_limits::max() / 2 - 1) { // 2: half - LOG(FATAL, RUNTIME) << " length is higher than half of size_t::max"; + LOG_FULL(FATAL) << " length is higher than half of size_t::max"; UNREACHABLE(); } // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) // Only memcpy_s maxLength number of chars into buffer if length > maxLength if (length > maxLength) { if (memcpy_s(buf, maxLength, GetDataUtf8() + start, maxLength) != EOK) { - LOG(FATAL, RUNTIME) << "memcpy_s failed when length > maxlength"; + LOG_FULL(FATAL) << "memcpy_s failed when length > maxlength"; UNREACHABLE(); } return maxLength; } if (memcpy_s(buf, maxLength, GetDataUtf8() + start, length) != EOK) { - LOG(FATAL, RUNTIME) << "memcpy_s failed when length <= maxlength"; + LOG_FULL(FATAL) << "memcpy_s failed when length <= maxlength"; UNREACHABLE(); } return length; @@ -201,7 +201,7 @@ public: // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(buf, ComputeDataSizeUtf16(maxLength), GetDataUtf16() + start, ComputeDataSizeUtf16(length)) != EOK) { - LOG(FATAL, RUNTIME) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } return length; @@ -330,7 +330,7 @@ private: uint16_t *GetDataUtf16Writable() { - LOG_IF(!IsUtf16(), FATAL, RUNTIME) << "EcmaString: Read data as utf16 for utf8 string"; + LOG_ECMA_IF(!IsUtf16(), FATAL) << "EcmaString: Read data as utf16 for utf8 string"; return GetData(); } diff --git a/ecmascript/ecma_string_table.cpp b/ecmascript/ecma_string_table.cpp index fbc09f55..cd4dbcb5 100644 --- a/ecmascript/ecma_string_table.cpp +++ b/ecmascript/ecma_string_table.cpp @@ -163,13 +163,13 @@ void EcmaStringTable::SweepWeakReference(const WeakRootVisitor &visitor) auto *object = it->second; auto fwd = visitor(object); if (fwd == nullptr) { - LOG(DEBUG, GC) << "StringTable: delete string " << std::hex << object + LOG_ECMA(DEBUG) << "StringTable: delete string " << std::hex << object << ", val = " << ConvertToString(object); table_.erase(it++); } else if (fwd != object) { it->second = static_cast(fwd); ++it; - LOG(DEBUG, GC) << "StringTable: forward " << std::hex << object << " -> " << fwd; + LOG_ECMA(DEBUG) << "StringTable: forward " << std::hex << object << " -> " << fwd; } else { ++it; } diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index 91e4b67e..a0d05cce 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -126,7 +126,7 @@ EcmaVM::EcmaVM(JSRuntimeOptions options, EcmaParamConfiguration config) bool EcmaVM::Initialize() { - LOG(INFO, RUNTIME) << "EcmaVM Initialize"; + LOG_ECMA(INFO) << "EcmaVM Initialize"; ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "EcmaVM::Initialize"); Taskpool::GetCurrentTaskpool()->Initialize(); #ifndef PANDA_TARGET_WINDOWS @@ -139,7 +139,7 @@ bool EcmaVM::Initialize() gcStats_ = chunk_.New(heap_, options_.GetLongPauseTime()); factory_ = chunk_.New(thread_, heap_, &chunk_); if (UNLIKELY(factory_ == nullptr)) { - LOG_ECMA(FATAL) << "alloc factory_ failed"; + LOG_FULL(FATAL) << "alloc factory_ failed"; UNREACHABLE(); } [[maybe_unused]] EcmaHandleScope scope(thread_); @@ -223,7 +223,7 @@ void EcmaVM::InitializeEcmaScriptRunStat() "Invalid runtime caller number"); runtimeStat_ = chunk_.New(runtimeCallerNames, ecmascript::RUNTIME_CALLER_NUMBER); if (UNLIKELY(runtimeStat_ == nullptr)) { - LOG_ECMA(FATAL) << "alloc runtimeStat_ failed"; + LOG_FULL(FATAL) << "alloc runtimeStat_ failed"; UNREACHABLE(); } } @@ -237,7 +237,7 @@ void EcmaVM::SetRuntimeStatEnable(bool flag) InitializeEcmaScriptRunStat(); } } else { - LOG(INFO, RUNTIME) << "Runtime State duration:" << PandaRuntimeTimer::Now() - start << "(ns)"; + LOG_ECMA(INFO) << "Runtime State duration:" << PandaRuntimeTimer::Now() - start << "(ns)"; if (runtimeStat_->IsRuntimeStatEnabled()) { runtimeStat_->Print(); runtimeStat_->ResetAllCount(); @@ -254,7 +254,7 @@ bool EcmaVM::InitializeFinish() EcmaVM::~EcmaVM() { - LOG(INFO, RUNTIME) << "Destruct ecma_vm, vm address is: " << this; + LOG_ECMA(INFO) << "Destruct ecma_vm, vm address is: " << this; vmInitialized_ = false; Taskpool::GetCurrentTaskpool()->Destroy(); @@ -459,7 +459,7 @@ void EcmaVM::CJSExecution(JSHandle &func, const JSPandaFile *jsPanda JSHandle(func), global, undefined, 5); // 5 : argument numbers if (info == nullptr) { - LOG(ERROR, RUNTIME) << "CJSExecution Stack overflow!"; + LOG_ECMA(ERROR) << "CJSExecution Stack overflow!"; return; } info->SetCallArg(cjsInfo.exportsHdl.GetTaggedValue(), @@ -518,14 +518,14 @@ void EcmaVM::HandleUncaughtException(TaggedObject *exception) PrintJSErrorInfo(exceptionHandle); if (thread_->IsPrintBCOffset() && exceptionBCList_.size() != 0) { for (auto info : exceptionBCList_) { - LOG(ERROR, RUNTIME) << "Exception at function " << info.first << ": " << info.second; + LOG_ECMA(ERROR) << "Exception at function " << info.first << ": " << info.second; } } return; } JSHandle result = JSTaggedValue::ToString(thread_, exceptionHandle); CString string = ConvertToString(*result); - LOG(ERROR, RUNTIME) << string; + LOG_ECMA(ERROR) << string; } void EcmaVM::PrintJSErrorInfo(const JSHandle &exceptionInfo) @@ -540,7 +540,7 @@ void EcmaVM::PrintJSErrorInfo(const JSHandle &exceptionInfo) CString nameBuffer = ConvertToString(*name); CString msgBuffer = ConvertToString(*msg); CString stackBuffer = ConvertToString(*stack); - LOG(ERROR, RUNTIME) << nameBuffer << ": " << msgBuffer << "\n" << stackBuffer; + LOG_ECMA(ERROR) << nameBuffer << ": " << msgBuffer << "\n" << stackBuffer; } void EcmaVM::ProcessNativeDelete(const WeakRootVisitor &v0) @@ -623,7 +623,7 @@ void EcmaVM::ClearBufferData() bool EcmaVM::ExecutePromisePendingJob() { if (isProcessingPendingJob_) { - LOG(ERROR, RUNTIME) << "EcmaVM::ExecutePromisePendingJob can not reentrant"; + LOG_ECMA(ERROR) << "EcmaVM::ExecutePromisePendingJob can not reentrant"; return false; } if (!thread_->HasPendingException()) { @@ -689,7 +689,7 @@ void EcmaVM::LoadStubFile() void EcmaVM::LoadAOTFiles() { std::string file = options_.GetAOTOutputFile(); - LOG(INFO, RUNTIME) << "Try to load aot file" << file.c_str(); + LOG_ECMA(INFO) << "Try to load aot file" << file.c_str(); fileLoader_->LoadAOTFile(file); fileLoader_->TryLoadSnapshotFile(); } diff --git a/ecmascript/ecma_vm.h b/ecmascript/ecma_vm.h index df1f014f..fe77d329 100644 --- a/ecmascript/ecma_vm.h +++ b/ecmascript/ecma_vm.h @@ -165,11 +165,11 @@ public: // Exclude GC thread if (options_.EnableThreadCheck()) { if (thread_ == nullptr) { - LOG(FATAL, RUNTIME) << "Fatal: ecma_vm has been destructed! vm address is: " << this; + LOG_FULL(FATAL) << "Fatal: ecma_vm has been destructed! vm address is: " << this; } if (!Taskpool::GetCurrentTaskpool()->IsInThreadPool(std::this_thread::get_id()) && thread_->GetThreadId() != JSThread::GetCurrentThreadId()) { - LOG(FATAL, RUNTIME) << "Fatal: ecma_vm cannot run in multi-thread!" + LOG_FULL(FATAL) << "Fatal: ecma_vm cannot run in multi-thread!" << " thread:" << thread_->GetThreadId() << " currentThread:" << JSThread::GetCurrentThreadId(); } diff --git a/ecmascript/file_loader.cpp b/ecmascript/file_loader.cpp index d9ccb200..98299d91 100644 --- a/ecmascript/file_loader.cpp +++ b/ecmascript/file_loader.cpp @@ -70,7 +70,7 @@ bool StubModulePackInfo::Load(EcmaVM *vm) // then MachineCode will support movable, code is saved to MachineCode and stackmap is saved // to different heap which will be freed when stackmap is parsed by EcmaVM is started. if (_binary_stub_m_length <= 1) { - LOG_ECMA(FATAL) << "stub.m length <= 1, is default and invalid."; + LOG_FULL(FATAL) << "stub.m length <= 1, is default and invalid."; return false; } BinaryBufferParser binBufparser((uint8_t *)_binary_stub_m_start, _binary_stub_m_length); @@ -121,7 +121,7 @@ bool StubModulePackInfo::Load(EcmaVM *vm) auto des = des_[entries_[i].moduleIndex_]; entries_[i].codeAddr_ += des.GetDeviceCodeSecAddr(); } - COMPILER_LOG(INFO) << "Load stub file success"; + LOG_COMPILER(INFO) << "Load stub file success"; return true; } @@ -156,7 +156,7 @@ void AOTModulePackInfo::Save(const std::string &filename) bool AOTModulePackInfo::Load(EcmaVM *vm, const std::string &filename) { if (!VerifyFilePath(filename)) { - COMPILER_LOG(ERROR) << "Can not load aot file from path [ " << filename << " ], " + LOG_COMPILER(ERROR) << "Can not load aot file from path [ " << filename << " ], " << "please execute ark_aot_compiler with options --aot-file."; return false; } @@ -217,7 +217,7 @@ bool AOTModulePackInfo::Load(EcmaVM *vm, const std::string &filename) vm->SaveAOTFuncEntry(curFileHash, curMethodId, entries_[i].codeAddr_); } moduleFile.close(); - COMPILER_LOG(INFO) << "Load aot file success"; + LOG_COMPILER(INFO) << "Load aot file success"; return true; } @@ -411,12 +411,12 @@ void BinaryBufferParser::ParseBuffer(void *dst, uint32_t count) { if (count > 0 && count + offset_ <= length_) { if (memcpy_s(dst, count, buffer_ + offset_, count) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; return; }; offset_ = offset_ + count; } else { - LOG_ECMA(FATAL) << "parse buffer error, length is 0 or overflow"; + LOG_FULL(FATAL) << "parse buffer error, length is 0 or overflow"; } } } \ No newline at end of file diff --git a/ecmascript/ic/ic_runtime.cpp b/ecmascript/ic/ic_runtime.cpp index 85380786..8bc27d14 100644 --- a/ecmascript/ic/ic_runtime.cpp +++ b/ecmascript/ic/ic_runtime.cpp @@ -122,11 +122,11 @@ void ICRuntime::TraceIC([[maybe_unused]] JSHandle receiver, auto kind = ICKindToString(GetICKind()); auto state = ProfileTypeAccessor::ICStateToString(icAccessor_.GetICState()); if (key->IsString()) { - LOG(ERROR, RUNTIME) << kind << " miss key is: " << JSHandle::Cast(key)->GetCString().get() + LOG_ECMA(ERROR) << kind << " miss key is: " << JSHandle::Cast(key)->GetCString().get() << ", receiver is " << receiver->GetTaggedObject()->GetClass()->IsDictionaryMode() << ", state is " << state; } else { - LOG(ERROR, RUNTIME) << kind << " miss " << ", state is " + LOG_ECMA(ERROR) << kind << " miss " << ", state is " << ", receiver is " << receiver->GetTaggedObject()->GetClass()->IsDictionaryMode() << state; } diff --git a/ecmascript/interpreter/frame_handler.cpp b/ecmascript/interpreter/frame_handler.cpp index d74d2070..51b845ff 100644 --- a/ecmascript/interpreter/frame_handler.cpp +++ b/ecmascript/interpreter/frame_handler.cpp @@ -178,7 +178,7 @@ JSTaggedValue FrameHandler::GetFunction() const case FrameType::BUILTIN_CALL_LEAVE_FRAME: case FrameType::OPTIMIZED_ENTRY_FRAME: default: { - LOG_ECMA(FATAL) << "frame type error!"; + LOG_FULL(FATAL) << "frame type error!"; UNREACHABLE(); } } @@ -287,7 +287,7 @@ ARK_INLINE uintptr_t FrameHandler::GetInterpretedFrameEnd(JSTaggedType *prevSp) case FrameType::ASM_INTERPRETER_ENTRY_FRAME: case FrameType::ASM_INTERPRETER_BRIDGE_FRAME: default: { - LOG_ECMA(FATAL) << "frame type error!"; + LOG_FULL(FATAL) << "frame type error!"; UNREACHABLE(); } } @@ -406,7 +406,7 @@ void FrameHandler::IterateFrameChain(JSTaggedType *start, const RootVisitor &v0, break; } default: { - LOG_ECMA(FATAL) << "frame type error!"; + LOG_FULL(FATAL) << "frame type error!"; UNREACHABLE(); } } @@ -466,7 +466,7 @@ void FrameHandler::CollectBCOffsetInfo() break; } default: { - LOG_ECMA(FATAL) << "frame type error!"; + LOG_FULL(FATAL) << "frame type error!"; UNREACHABLE(); } } diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index 4720323a..f982890c 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -53,7 +53,7 @@ using CommonStubCSigns = kungfu::CommonStubCSigns; #endif // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define LOG_INST() LOG(DEBUG, INTERPRETER) << ": " +#define LOG_INST() LOG_INTERPRETER(DEBUG) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define HANDLE_OPCODE(handle_opcode) \ @@ -421,10 +421,10 @@ JSTaggedValue EcmaInterpreter::ExecuteNative(EcmaRuntimeCallInfo *info) thread->CheckSafepoint(); ECMAObject *callTarget = reinterpret_cast(info->GetFunctionValue().GetTaggedObject()); JSMethod *method = callTarget->GetCallTarget(); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime Call."; + LOG_INST() << "Entry: Runtime Call."; JSTaggedValue tagged = reinterpret_cast(const_cast(method->GetNativePointer()))(info); - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call."; + LOG_INST() << "Exit: Runtime Call."; InterpretedEntryFrame *entryState = GET_ENTRY_FRAME(sp); JSTaggedType *prevSp = entryState->base.prev; @@ -536,7 +536,7 @@ JSTaggedValue EcmaInterpreter::Execute(EcmaRuntimeCallInfo *info) CpuProfiler::IsNeedAndGetStack(thread); #endif thread->CheckSafepoint(); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime Call " << std::hex << reinterpret_cast(newSp) << " " + LOG_INST() << "Entry: Runtime Call " << std::hex << reinterpret_cast(newSp) << " " << std::hex << reinterpret_cast(pc); EcmaInterpreter::RunInternal(thread, ConstantPool::Cast(constpool.GetTaggedObject()), pc, newSp); @@ -901,7 +901,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool state->pc = nullptr; state->function = JSTaggedValue(funcTagged); thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime Call."; + LOG_INST() << "Entry: Runtime Call."; SAVE_PC(); JSTaggedValue retValue = reinterpret_cast( const_cast(method->GetNativePointer()))(ecmaRuntimeCallInfo); @@ -909,7 +909,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool if (UNLIKELY(thread->HasPendingException())) { INTERPRETER_GOTO_EXCEPTION_HANDLER(); } - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call."; + LOG_INST() << "Exit: Runtime Call."; SET_ACC(retValue); INTERPRETER_HANDLE_RETURN(); } @@ -960,7 +960,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSTaggedValue env = JSFunction::Cast(funcObject)->GetLexicalEnv(); state->env = env; thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime Call " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Entry: Runtime Call " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(pc); DISPATCH_OFFSET(0); } @@ -968,7 +968,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool HANDLE_OPCODE(HANDLE_RETURN_DYN) { LOG_INST() << "return.dyn"; InterpretedFrame *state = GET_FRAME(sp); - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); JSMethod *method = JSFunction::Cast(state->function.GetTaggedObject())->GetMethod(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); @@ -1020,7 +1020,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool HANDLE_OPCODE(HANDLE_RETURNUNDEFINED_PREF) { LOG_INST() << "return.undefined"; InterpretedFrame *state = GET_FRAME(sp); - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); JSMethod *method = JSFunction::Cast(state->function.GetTaggedObject())->GetMethod(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); @@ -1970,7 +1970,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool state->function = ctor; thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime New."; + LOG_INST() << "Entry: Runtime New."; SAVE_PC(); JSTaggedValue retValue = reinterpret_cast( const_cast(ctorMethod->GetNativePointer()))(ecmaRuntimeCallInfo); @@ -1978,7 +1978,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool if (UNLIKELY(thread->HasPendingException())) { INTERPRETER_GOTO_EXCEPTION_HANDLER(); } - LOG(DEBUG, INTERPRETER) << "Exit: Runtime New."; + LOG_INST() << "Exit: Runtime New."; SET_ACC(retValue); DISPATCH(BytecodeInstruction::Format::PREF_IMM16_V8); } @@ -2050,7 +2050,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool constpool = ConstantPool::Cast(state->constpool.GetTaggedObject()); thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime New " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Entry: Runtime New " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(pc); DISPATCH_OFFSET(0); } @@ -2323,7 +2323,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSMethod *method = JSFunction::Cast(state->function.GetTaggedObject())->GetMethod(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); - LOG(DEBUG, INTERPRETER) << "Exit: SuspendGenerator " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: SuspendGenerator " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); sp = state->base.prev; ASSERT(sp != nullptr); @@ -3514,7 +3514,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool state->pc = nullptr; state->function = superCtor; thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime SuperCall "; + LOG_INST() << "Entry: Runtime SuperCall "; JSTaggedValue retValue = reinterpret_cast( const_cast(superCtorMethod->GetNativePointer()))(ecmaRuntimeCallInfo); thread->SetCurrentSPFrame(sp); @@ -3522,7 +3522,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool if (UNLIKELY(thread->HasPendingException())) { INTERPRETER_GOTO_EXCEPTION_HANDLER(); } - LOG(DEBUG, INTERPRETER) << "Exit: Runtime SuperCall "; + LOG_INST() << "Exit: Runtime SuperCall "; SET_ACC(retValue); DISPATCH(BytecodeInstruction::Format::PREF_IMM16_V8); } @@ -3592,7 +3592,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool constpool = ConstantPool::Cast(state->constpool.GetTaggedObject()); thread->SetCurrentSPFrame(newSp); - LOG(DEBUG, INTERPRETER) << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast(sp) + LOG_INST() << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(pc); DISPATCH_OFFSET(0); } @@ -3708,7 +3708,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool DISPATCH_OFFSET(0); } HANDLE_OPCODE(HANDLE_OVERFLOW) { - LOG(FATAL, INTERPRETER) << "opcode overflow"; + LOG_INTERPRETER(FATAL) << "opcode overflow"; } #include "templates/debugger_instruction_handler.inl" } diff --git a/ecmascript/interpreter/interpreter_assembly.cpp b/ecmascript/interpreter/interpreter_assembly.cpp index 0199762d..e0eb52f0 100644 --- a/ecmascript/interpreter/interpreter_assembly.cpp +++ b/ecmascript/interpreter/interpreter_assembly.cpp @@ -48,7 +48,7 @@ using panda::ecmascript::kungfu::CommonStubCSigns; #endif // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define LOG_INST() LOG(DEBUG, INTERPRETER) << ": " +#define LOG_INST() LOG_INTERPRETER(DEBUG) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ADVANCE_PC(offset) \ @@ -563,7 +563,7 @@ void InterpreterAssembly::HandleReturnDyn( { LOG_INST() << "returnla "; AsmInterpretedFrame *state = GET_ASM_FRAME(sp); - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); JSMethod *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); @@ -591,7 +591,7 @@ void InterpreterAssembly::HandleReturnUndefinedPref( { LOG_INST() << "return.undefined"; AsmInterpretedFrame *state = GET_ASM_FRAME(sp); - LOG(DEBUG, INTERPRETER) << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); JSMethod *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); @@ -1999,7 +1999,7 @@ void InterpreterAssembly::HandleSuspendGeneratorPrefV8V8( JSMethod *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); - LOG(DEBUG, INTERPRETER) << "Exit: SuspendGenerator " << std::hex << reinterpret_cast(sp) << " " + LOG_INST() << "Exit: SuspendGenerator " << std::hex << reinterpret_cast(sp) << " " << std::hex << reinterpret_cast(state->pc); sp = state->base.prev; ASSERT(sp != nullptr); @@ -3499,7 +3499,7 @@ void InterpreterAssembly::HandleOverflow( JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, JSTaggedValue acc, int32_t hotnessCounter) { - LOG(FATAL, INTERPRETER) << "opcode overflow"; + LOG_INTERPRETER(FATAL) << "opcode overflow"; } uint32_t InterpreterAssembly::FindCatchBlock(JSMethod *caller, uint32_t pc) diff --git a/ecmascript/js_arraybuffer.cpp b/ecmascript/js_arraybuffer.cpp index 3f7999f0..b6c0eb73 100644 --- a/ecmascript/js_arraybuffer.cpp +++ b/ecmascript/js_arraybuffer.cpp @@ -30,7 +30,7 @@ void JSArrayBuffer::CopyDataBlockBytes(JSTaggedValue toBlock, JSTaggedValue from auto *from = static_cast(fromBuf); auto *to = static_cast(toBuf); if (memcpy_s(to, count, from + fromIndex, count) != EOK) { // NOLINT - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } diff --git a/ecmascript/js_bigint.cpp b/ecmascript/js_bigint.cpp index 4f84e0fd..770217f5 100644 --- a/ecmascript/js_bigint.cpp +++ b/ecmascript/js_bigint.cpp @@ -456,7 +456,7 @@ JSTaggedValue BigInt::NumberToBigInt(JSThread *thread, JSHandle n // Bit operations must be of integer type uint64_t bits = 0; if (memcpy_s(&bits, sizeof(bits), &num, sizeof(num)) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } // Take out bits 62-52 (11 bits in total) and subtract 1023 @@ -1122,7 +1122,7 @@ static JSTaggedNumber CalculateNumber(const uint64_t &sign, const uint64_t &mant uint64_t doubleBit = sign | exponent | mantissa; double res = 0; if (memcpy_s(&res, sizeof(res), &doubleBit, sizeof(doubleBit)) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } return JSTaggedNumber(res); @@ -1255,7 +1255,7 @@ ComparisonResult BigInt::CompareWithNumber(JSHandle bigint, JSHandle> base::DOUBLE_SIGNIFICAND_SIZE) & 0x7FF; diff --git a/ecmascript/js_bigint.h b/ecmascript/js_bigint.h index 2baa00d2..def5fe81 100644 --- a/ecmascript/js_bigint.h +++ b/ecmascript/js_bigint.h @@ -105,7 +105,7 @@ public: { uint32_t size = GetLength() * sizeof(uint32_t); if (memset_s(GetData(), size, 0, size) != EOK) { - LOG_ECMA(FATAL) << "memset failed"; + LOG_FULL(FATAL) << "memset failed"; UNREACHABLE(); } } diff --git a/ecmascript/js_runtime_options.h b/ecmascript/js_runtime_options.h index 12a0f653..f4afde5c 100644 --- a/ecmascript/js_runtime_options.h +++ b/ecmascript/js_runtime_options.h @@ -17,7 +17,6 @@ #define ECMASCRIPT_JS_RUNTIME_OPTIONS_H_ #include "libpandabase/utils/pandargs.h" -#include "utils/logger.h" // namespace panda { namespace panda::ecmascript { diff --git a/ecmascript/js_serializer.cpp b/ecmascript/js_serializer.cpp index b18e2ed9..ac72f269 100644 --- a/ecmascript/js_serializer.cpp +++ b/ecmascript/js_serializer.cpp @@ -135,7 +135,7 @@ bool JSSerializer::WriteRawData(const void *data, size_t length) errno_t rc; rc = memcpy_s(buffer_ + bufferSize_, bufferCapacity_ - bufferSize_, data, length); if (rc != EOK) { - LOG(ERROR, RUNTIME) << "Failed to memcpy_s Data"; + LOG_FULL(ERROR) << "Failed to memcpy_s Data"; return false; } bufferSize_ += length; @@ -195,7 +195,7 @@ bool JSSerializer::ExpandBuffer(size_t requestedSize) errno_t rc; rc = memcpy_s(newBuffer, newCapacity, buffer_, bufferSize_); if (rc != EOK) { - LOG(ERROR, RUNTIME) << "Failed to memcpy_s Data"; + LOG_FULL(ERROR) << "Failed to memcpy_s Data"; free(newBuffer); return false; } @@ -1167,7 +1167,7 @@ JSHandle JSDeserializer::ReadNativeBindingObject() Local attachVal = attachFunc( engine_, reinterpret_cast(bufferPointer), reinterpret_cast(hint)); if (attachVal.IsEmpty()) { - LOG(ERROR, RUNTIME) << "NativeBindingObject is empty"; + LOG_ECMA(ERROR) << "NativeBindingObject is empty"; attachVal = JSValueRef::Undefined(thread_->GetEcmaVM()); } return JSNApiHelper::ToJSHandle(attachVal); diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index e3c6bf01..5bba9167 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -163,7 +163,7 @@ void JSThread::Iterate(const RootVisitor &v0, const RootRangeVisitor &v1) #endif }); #if ECMASCRIPT_ENABLE_HANDLE_LEAK_CHECK - LOG(INFO, RUNTIME) << "Iterate root handle count:" << handleCount << ", global handle count:" << globalCount; + LOG_ECMA(INFO) << "Iterate root handle count:" << handleCount << ", global handle count:" << globalCount; #endif } @@ -228,7 +228,7 @@ void JSThread::ShrinkHandleStorage(int prevIndex) #if ECMASCRIPT_ENABLE_ZAP_MEM uintptr_t size = ToUintPtr(handleScopeStorageEnd_) - ToUintPtr(handleScopeStorageNext_); if (memset_s(handleScopeStorageNext_, size, 0, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } for (int32_t i = currentHandleStorageIndex_ + 1; i < lastIndex; i++) { @@ -236,7 +236,7 @@ void JSThread::ShrinkHandleStorage(int prevIndex) NODE_BLOCK_SIZE * sizeof(JSTaggedType), 0, NODE_BLOCK_SIZE * sizeof(JSTaggedType)) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -314,7 +314,7 @@ void JSThread::CheckJSTaggedType(JSTaggedType value) const { if (JSTaggedValue(value).IsHeapObject() && !GetEcmaVM()->GetHeap()->IsAlive(reinterpret_cast(value))) { - LOG(FATAL, RUNTIME) << "value:" << value << " is invalid!"; + LOG_FULL(FATAL) << "value:" << value << " is invalid!"; } } diff --git a/ecmascript/js_vm/main.cpp b/ecmascript/js_vm/main.cpp index cc263851..dd0d8639 100644 --- a/ecmascript/js_vm/main.cpp +++ b/ecmascript/js_vm/main.cpp @@ -37,18 +37,18 @@ void BlockSignals() #if defined(PANDA_TARGET_UNIX) sigset_t set; if (sigemptyset(&set) == -1) { - LOG(ERROR, RUNTIME) << "sigemptyset failed"; + LOG_ECMA(ERROR) << "sigemptyset failed"; return; } int rc = 0; if (rc < 0) { - LOG(ERROR, RUNTIME) << "sigaddset failed"; + LOG_ECMA(ERROR) << "sigaddset failed"; return; } if (panda::os::native_stack::g_PandaThreadSigmask(SIG_BLOCK, &set, nullptr) != 0) { - LOG(ERROR, RUNTIME) << "g_PandaThreadSigmask failed"; + LOG_ECMA(ERROR) << "g_PandaThreadSigmask failed"; } #endif // PANDA_TARGET_UNIX } diff --git a/ecmascript/jspandafile/debug_info_extractor.cpp b/ecmascript/jspandafile/debug_info_extractor.cpp index edf18e93..927fec44 100644 --- a/ecmascript/jspandafile/debug_info_extractor.cpp +++ b/ecmascript/jspandafile/debug_info_extractor.cpp @@ -243,7 +243,7 @@ const std::string &DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId { auto iter = methods_.find(methodId.GetOffset()); if (iter == methods_.end()) { - LOG(FATAL, DEBUGGER) << "Get source file of unknown method id: " << methodId.GetOffset(); + LOG_DEBUGGER(FATAL) << "Get source file of unknown method id: " << methodId.GetOffset(); } return iter->second.sourceFile; } @@ -252,7 +252,7 @@ const std::string &DebugInfoExtractor::GetSourceCode(panda_file::File::EntityId { auto iter = methods_.find(methodId.GetOffset()); if (iter == methods_.end()) { - LOG(FATAL, DEBUGGER) << "Get source code of unknown method id: " << methodId.GetOffset(); + LOG_DEBUGGER(FATAL) << "Get source code of unknown method id: " << methodId.GetOffset(); } return iter->second.sourceCode; } diff --git a/ecmascript/jspandafile/js_pandafile.h b/ecmascript/jspandafile/js_pandafile.h index 9cea6594..f449c668 100644 --- a/ecmascript/jspandafile/js_pandafile.h +++ b/ecmascript/jspandafile/js_pandafile.h @@ -22,7 +22,6 @@ #include "ecmascript/jspandafile/constpool_value.h" #include "ecmascript/mem/c_containers.h" #include "libpandafile/file.h" -#include "libpandabase/utils/logger.h" namespace panda { namespace panda_file { diff --git a/ecmascript/jspandafile/js_pandafile_manager.cpp b/ecmascript/jspandafile/js_pandafile_manager.cpp index 0ca7ae93..0e7b5291 100644 --- a/ecmascript/jspandafile/js_pandafile_manager.cpp +++ b/ecmascript/jspandafile/js_pandafile_manager.cpp @@ -208,7 +208,7 @@ void JSPandaFileManager::ReleaseJSPandaFile(const JSPandaFile *jsPandaFile) tooling::JSPtExtractor *JSPandaFileManager::GetJSPtExtractor(const JSPandaFile *jsPandaFile) { - LOG_IF(jsPandaFile == nullptr, FATAL, ECMASCRIPT) << "GetJSPtExtractor error, js pandafile is nullptr"; + LOG_ECMA_IF(jsPandaFile == nullptr, FATAL) << "GetJSPtExtractor error, js pandafile is nullptr"; os::memory::LockHolder lock(jsPandaFileLock_); ASSERT(loadedJSPandaFiles_.find(jsPandaFile) != loadedJSPandaFiles_.end()); diff --git a/ecmascript/jspandafile/js_pandafile_manager.h b/ecmascript/jspandafile/js_pandafile_manager.h index dc817f14..65deb8d4 100644 --- a/ecmascript/jspandafile/js_pandafile_manager.h +++ b/ecmascript/jspandafile/js_pandafile_manager.h @@ -21,7 +21,6 @@ #include "ecmascript/jspandafile/panda_file_translator.h" #include "ecmascript/tooling/backend/js_pt_extractor.h" #include "libpandafile/file.h" -#include "libpandabase/utils/logger.h" namespace panda { namespace panda_file { diff --git a/ecmascript/jspandafile/panda_file_translator.cpp b/ecmascript/jspandafile/panda_file_translator.cpp index 39470ae7..f8067a7c 100644 --- a/ecmascript/jspandafile/panda_file_translator.cpp +++ b/ecmascript/jspandafile/panda_file_translator.cpp @@ -30,7 +30,6 @@ #include "ecmascript/ts_types/ts_type_table.h" #include "ecmascript/ts_types/ts_loader.h" #include "libpandabase/mem/mem.h" -#include "libpandabase/utils/logger.h" #include "libpandabase/utils/utf.h" #include "libpandafile/bytecode_instruction-inl.h" #include "libpandafile/class_data_accessor-inl.h" @@ -332,7 +331,7 @@ void PandaFileTranslator::FixOpcode(uint8_t *pc) break; default: if (*pc != static_cast(BytecodeInstruction::Opcode::ECMA_LDNAN_PREF_NONE)) { - LOG_ECMA(FATAL) << "Is not an Ecma Opcode opcode: " << static_cast(opcode); + LOG_FULL(FATAL) << "Is not an Ecma Opcode opcode: " << static_cast(opcode); UNREACHABLE(); } *pc = *(pc + 1); @@ -404,7 +403,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui uint8_t size = sizeof(uint32_t); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_ONE, size, &index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; @@ -414,7 +413,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui uint8_t size = sizeof(uint16_t); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_TWO, size, &u16Index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; @@ -425,7 +424,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui uint8_t size = sizeof(uint32_t); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_TWO, size, &index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; @@ -436,7 +435,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui uint8_t size = sizeof(uint16_t); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_TWO, size, &u16Index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; @@ -449,7 +448,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui ASSERT(static_cast(index) == index); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_TWO, size, &index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; @@ -460,7 +459,7 @@ void PandaFileTranslator::FixInstructionId32(const BytecodeInstruction &inst, ui uint8_t size = sizeof(uint16_t); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(pc + FixInstructionIndex::FIX_FOUR, size, &u16Index, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } break; diff --git a/ecmascript/llvm_stackmap_parser.cpp b/ecmascript/llvm_stackmap_parser.cpp index 3ff1d51d..794076e0 100644 --- a/ecmascript/llvm_stackmap_parser.cpp +++ b/ecmascript/llvm_stackmap_parser.cpp @@ -59,13 +59,13 @@ void LLVMStackMapParser::PrintCallSiteSlotAddr(const CallSiteInfo& callsiteInfo, for (; j < callsiteInfo.size(); j += 2) { // 2: base and derived const DwarfRegAndOffsetType baseInfo = callsiteInfo[j]; const DwarfRegAndOffsetType derivedInfo = callsiteInfo[j + 1]; - COMPILER_LOG(DEBUG) << std::hex << " callSiteSp:0x" << callSiteSp << " callsiteFp:" << callsiteFp; - COMPILER_LOG(DEBUG) << std::dec << "base DWARF_REG:" << baseInfo.first + LOG_COMPILER(DEBUG) << std::hex << " callSiteSp:0x" << callSiteSp << " callsiteFp:" << callsiteFp; + LOG_COMPILER(DEBUG) << std::dec << "base DWARF_REG:" << baseInfo.first << " OFFSET:" << baseInfo.second; uintptr_t base = GetStackSlotAddress(baseInfo, callSiteSp, callsiteFp); uintptr_t derived = GetStackSlotAddress(derivedInfo, callSiteSp, callsiteFp); if (base != derived) { - COMPILER_LOG(DEBUG) << std::dec << "derived DWARF_REG:" << derivedInfo.first + LOG_COMPILER(DEBUG) << std::dec << "derived DWARF_REG:" << derivedInfo.first << " OFFSET:" << derivedInfo.second; } } @@ -157,7 +157,7 @@ void LLVMStackMapParser::CalcCallSite() uintptr_t callsite = address + instructionOffset; uint64_t patchPointID = recordHead.PatchPointID; if (loc.location == LocationTy::Kind::INDIRECT) { - COMPILER_OPTIONAL_LOG(DEBUG) << "DwarfRegNum:" << loc.DwarfRegNum << " loc.OffsetOrSmallConstant:" + OPTIONAL_LOG_COMPILER(DEBUG) << "DwarfRegNum:" << loc.DwarfRegNum << " loc.OffsetOrSmallConstant:" << loc.OffsetOrSmallConstant << "address:" << address << " instructionOffset:" << instructionOffset << " callsite:" << " patchPointID :" << std::hex << patchPointID << callsite; @@ -190,7 +190,7 @@ void LLVMStackMapParser::CalcCallSite() bool LLVMStackMapParser::CalculateStackMap(std::unique_ptr stackMapAddr) { if (!stackMapAddr) { - COMPILER_LOG(ERROR) << "stackMapAddr nullptr error ! "; + LOG_COMPILER(ERROR) << "stackMapAddr nullptr error ! "; return false; } dataInfo_ = std::make_unique(std::move(stackMapAddr)); @@ -244,13 +244,13 @@ bool LLVMStackMapParser::CalculateStackMap(std::unique_ptr stackMapA } // update functionAddress from host side to device side - COMPILER_OPTIONAL_LOG(DEBUG) << "stackmap calculate update funcitonaddress "; + OPTIONAL_LOG_COMPILER(DEBUG) << "stackmap calculate update funcitonaddress "; for (size_t i = 0; i < llvmStackMap_.StkSizeRecords.size(); i++) { uintptr_t hostAddr = llvmStackMap_.StkSizeRecords[i].functionAddress; uintptr_t deviceAddr = hostAddr - hostCodeSectionAddr + deviceCodeSectionAddr; llvmStackMap_.StkSizeRecords[i].functionAddress = deviceAddr; - COMPILER_OPTIONAL_LOG(DEBUG) << std::dec << i << "th function " << std::hex << hostAddr << " ---> " + OPTIONAL_LOG_COMPILER(DEBUG) << std::dec << i << "th function " << std::hex << hostAddr << " ---> " << deviceAddr; } CalcCallSite(); diff --git a/ecmascript/llvm_stackmap_parser.h b/ecmascript/llvm_stackmap_parser.h index 79f2d511..89a9fbd7 100644 --- a/ecmascript/llvm_stackmap_parser.h +++ b/ecmascript/llvm_stackmap_parser.h @@ -43,9 +43,9 @@ struct Header { uint16_t Reserved1; // Reserved (expected to be 0) void Print() const { - COMPILER_LOG(DEBUG) << "----- head ----"; - COMPILER_LOG(DEBUG) << " version:" << static_cast(stackmapversion); - COMPILER_LOG(DEBUG) << "+++++ head ++++"; + LOG_COMPILER(DEBUG) << "----- head ----"; + LOG_COMPILER(DEBUG) << " version:" << static_cast(stackmapversion); + LOG_COMPILER(DEBUG) << "+++++ head ++++"; } }; @@ -56,9 +56,9 @@ struct StkSizeRecordTy { uint64_t recordCount; void Print() const { - COMPILER_LOG(DEBUG) << " functionAddress:0x" << std::hex << functionAddress; - COMPILER_LOG(DEBUG) << " stackSize:0x" << std::hex << stackSize; - COMPILER_LOG(DEBUG) << " recordCount:" << std::hex << recordCount; + LOG_COMPILER(DEBUG) << " functionAddress:0x" << std::hex << functionAddress; + LOG_COMPILER(DEBUG) << " stackSize:0x" << std::hex << stackSize; + LOG_COMPILER(DEBUG) << " recordCount:" << std::hex << recordCount; } }; #pragma pack() @@ -67,7 +67,7 @@ struct ConstantsTy { uintptr_t LargeConstant; void Print() const { - COMPILER_LOG(DEBUG) << " LargeConstant:0x" << std::hex << LargeConstant; + LOG_COMPILER(DEBUG) << " LargeConstant:0x" << std::hex << LargeConstant; } }; @@ -78,10 +78,10 @@ struct StkMapRecordHeadTy { uint16_t NumLocations; void Print() const { - COMPILER_LOG(DEBUG) << " PatchPointID:0x" << std::hex << PatchPointID; - COMPILER_LOG(DEBUG) << " instructionOffset:0x" << std::hex << InstructionOffset; - COMPILER_LOG(DEBUG) << " Reserved:0x" << std::hex << Reserved; - COMPILER_LOG(DEBUG) << " NumLocations:0x" << std::hex << NumLocations; + LOG_COMPILER(DEBUG) << " PatchPointID:0x" << std::hex << PatchPointID; + LOG_COMPILER(DEBUG) << " instructionOffset:0x" << std::hex << InstructionOffset; + LOG_COMPILER(DEBUG) << " Reserved:0x" << std::hex << Reserved; + LOG_COMPILER(DEBUG) << " NumLocations:0x" << std::hex << NumLocations; } }; @@ -105,10 +105,10 @@ struct LocationTy { void Print() const { - COMPILER_LOG(DEBUG) << TypeToString(location); - COMPILER_LOG(DEBUG) << ", size:" << std::dec << LocationSize; - COMPILER_LOG(DEBUG) << "\tDwarfRegNum:" << DwarfRegNum; - COMPILER_LOG(DEBUG) << "\t OffsetOrSmallConstant:" << OffsetOrSmallConstant; + LOG_COMPILER(DEBUG) << TypeToString(location); + LOG_COMPILER(DEBUG) << ", size:" << std::dec << LocationSize; + LOG_COMPILER(DEBUG) << "\tDwarfRegNum:" << DwarfRegNum; + LOG_COMPILER(DEBUG) << "\t OffsetOrSmallConstant:" << OffsetOrSmallConstant; } }; @@ -118,9 +118,9 @@ struct LiveOutsTy { uint8_t SizeinBytes; void Print() const { - COMPILER_LOG(DEBUG) << " Dwarf RegNum:" << DwarfRegNum; - COMPILER_LOG(DEBUG) << " Reserved:" << Reserved; - COMPILER_LOG(DEBUG) << " SizeinBytes:" << SizeinBytes; + LOG_COMPILER(DEBUG) << " Dwarf RegNum:" << DwarfRegNum; + LOG_COMPILER(DEBUG) << " Reserved:" << Reserved; + LOG_COMPILER(DEBUG) << " SizeinBytes:" << SizeinBytes; } }; @@ -133,12 +133,12 @@ struct StkMapRecordTy { head.Print(); auto size = Locations.size(); for (size_t i = 0; i < size; i++) { - COMPILER_LOG(DEBUG) << " #" << std::dec << i << ":"; + LOG_COMPILER(DEBUG) << " #" << std::dec << i << ":"; Locations[i].Print(); } size = LiveOuts.size(); for (size_t i = 0; i < size; i++) { - COMPILER_LOG(DEBUG) << " liveOuts[" << i << "] info:"; + LOG_COMPILER(DEBUG) << " liveOuts[" << i << "] info:"; } } }; @@ -176,15 +176,15 @@ struct LLVMStackMap { { head.Print(); for (size_t i = 0; i < StkSizeRecords.size(); i++) { - COMPILER_LOG(DEBUG) << "stkSizeRecord[" << i << "] info:"; + LOG_COMPILER(DEBUG) << "stkSizeRecord[" << i << "] info:"; StkSizeRecords[i].Print(); } for (size_t i = 0; i < Constants.size(); i++) { - COMPILER_LOG(DEBUG) << "constants[" << i << "] info:"; + LOG_COMPILER(DEBUG) << "constants[" << i << "] info:"; Constants[i].Print(); } for (size_t i = 0; i < StkMapRecord.size(); i++) { - COMPILER_LOG(DEBUG) << "StkMapRecord[" << i << "] info:"; + LOG_COMPILER(DEBUG) << "StkMapRecord[" << i << "] info:"; StkMapRecord[i].Print(); } } diff --git a/ecmascript/log.h b/ecmascript/log.h new file mode 100644 index 00000000..b05c0937 --- /dev/null +++ b/ecmascript/log.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef ECMASCRIPT_LOG_H +#define ECMASCRIPT_LOG_H + +#include + +#include "hilog/log.h" + +constexpr static unsigned int DOMAIN = 0xD003F00; +constexpr static auto TAG = "ArkCompiler"; +constexpr static OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, DOMAIN, TAG}; + +namespace panda::ecmascript { +template +class Log { +public: + Log() = default; + ~Log() + { + if constexpr (level == LOG_DEBUG) { + OHOS::HiviewDFX::HiLog::Debug(LABEL, "%{public}s", stream_.str().c_str()); + } else if constexpr (level == LOG_INFO) { + OHOS::HiviewDFX::HiLog::Info(LABEL, "%{public}s", stream_.str().c_str()); + } else if constexpr (level == LOG_WARN) { + OHOS::HiviewDFX::HiLog::Warn(LABEL, "%{public}s", stream_.str().c_str()); + } else if constexpr (level == LOG_ERROR) { + OHOS::HiviewDFX::HiLog::Error(LABEL, "%{public}s", stream_.str().c_str()); + } else { + OHOS::HiviewDFX::HiLog::Fatal(LABEL, "%{public}s", stream_.str().c_str()); + } + } + template + std::ostream &operator <<(type input) + { + stream_ << input; + return stream_; + } + +private: + std::ostringstream stream_; +}; +} // namespace panda::ecmascript + +#define HILOG(level) HiLogIsLoggable(DOMAIN, TAG, LOG_##level) && panda::ecmascript::Log() + +#endif // ECMASCRIPT_LOG_H diff --git a/ecmascript/log_wrapper.h b/ecmascript/log_wrapper.h new file mode 100644 index 00000000..a31d23be --- /dev/null +++ b/ecmascript/log_wrapper.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef ECMASCRIPT_LOG_WRAPPER_H +#define ECMASCRIPT_LOG_WRAPPER_H + +#ifdef ENABLE_HILOG + +#include "ecmascript/log.h" + +#define LOG_ECMA(level) HILOG(level) + +#else // ENABLE_HILOG + +#include "libpandabase/utils/logger.h" + +// HILOG use WARN, but panda use WARNING +#define _LOG_WARN(component, p) _LOG_WARNING(component, p) + +#define LOG_ECMA(level) LOG(level, ECMASCRIPT) + +#endif // ENABLE_HILOG + +#define LOG_FULL(level) LOG_ECMA(level) << __func__ << ":" << __LINE__ << " " +#define LOG_GC(level) LOG_ECMA(level) << " gc: " +#define LOG_INTERPRETER(level) LOG_ECMA(level) << " interpreter: " +#define LOG_COMPILER(level) LOG_ECMA(level) << " compiler: " +#define LOG_DEBUGGER(level) LOG_ECMA(level) << " debugger: " +#define LOG_ECMA_IF(cond, level) (cond) && LOG_ECMA(level) + +#endif // ECMASCRIPT_LOG_WRAPPER_H diff --git a/ecmascript/mem/chunk.h b/ecmascript/mem/chunk.h index e79c0764..a3d4e2d3 100644 --- a/ecmascript/mem/chunk.h +++ b/ecmascript/mem/chunk.h @@ -17,6 +17,7 @@ #define ECMASCRIPT_MEM_CHUNK_H #include "ecmascript/common.h" +#include "ecmascript/log_wrapper.h" #include "ecmascript/mem/ecma_list.h" #include "ecmascript/mem/area.h" diff --git a/ecmascript/mem/clock_scope.h b/ecmascript/mem/clock_scope.h index 73c4a368..e0ef998a 100644 --- a/ecmascript/mem/clock_scope.h +++ b/ecmascript/mem/clock_scope.h @@ -18,7 +18,6 @@ #include "time.h" #include "chrono" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { class ClockScope { diff --git a/ecmascript/mem/concurrent_marker.cpp b/ecmascript/mem/concurrent_marker.cpp index 0794788b..532433f6 100644 --- a/ecmascript/mem/concurrent_marker.cpp +++ b/ecmascript/mem/concurrent_marker.cpp @@ -54,7 +54,7 @@ void ConcurrentMarker::EnableConcurrentMarking(EnableConcurrentMarkType type) void ConcurrentMarker::Mark() { - ECMA_GC_LOG() << "ConcurrentMarker: Concurrent Marking Begin"; + LOG_GC(DEBUG) << "ConcurrentMarker: Concurrent Marking Begin"; ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "ConcurrentMarker::Mark"); MEM_ALLOCATE_AND_GC_TRACE(vm_, ConcurrentMarking); ClockScope scope; @@ -73,7 +73,7 @@ void ConcurrentMarker::Finish() void ConcurrentMarker::ReMark() { - ECMA_GC_LOG() << "ConcurrentMarker: Remarking Begin"; + LOG_GC(DEBUG) << "ConcurrentMarker: Remarking Begin"; MEM_ALLOCATE_AND_GC_TRACE(vm_, ReMarking); ClockScope scope; Marker *nonMovableMarker = heap_->GetNonMovableMarker(); diff --git a/ecmascript/mem/free_object_list.cpp b/ecmascript/mem/free_object_list.cpp index 711238a6..fb48ef7f 100644 --- a/ecmascript/mem/free_object_list.cpp +++ b/ecmascript/mem/free_object_list.cpp @@ -136,7 +136,7 @@ void FreeObjectList::Free(uintptr_t start, size_t size, bool isAdd) Region *region = Region::ObjectAddressToRange(reinterpret_cast(start)); auto set = region->GetFreeObjectSet(type); if (set == nullptr) { - LOG_ECMA(FATAL) << "The set of region is nullptr"; + LOG_FULL(FATAL) << "The set of region is nullptr"; return; } set->Free(start, size); diff --git a/ecmascript/mem/full_gc.cpp b/ecmascript/mem/full_gc.cpp index 019fd837..5a67a682 100644 --- a/ecmascript/mem/full_gc.cpp +++ b/ecmascript/mem/full_gc.cpp @@ -37,7 +37,7 @@ void FullGC::RunPhases() ClockScope clockScope; if (heap_->CheckOngoingConcurrentMarking()) { - ECMA_GC_LOG() << "FullGC after ConcurrentMarking"; + LOG_GC(DEBUG) << "FullGC after ConcurrentMarking"; heap_->GetConcurrentMarker()->Reset(); // HPPGC use mark result to move TaggedObject. } Initialize(); @@ -47,7 +47,7 @@ void FullGC::RunPhases() heap_->GetEcmaVM()->GetEcmaGCStats()->StatisticFullGC(clockScope.GetPauseTime(), youngAndOldAliveSize_, youngSpaceCommitSize_, oldSpaceCommitSize_, nonMoveSpaceFreeSize_, nonMoveSpaceCommitSize_); - ECMA_GC_LOG() << "FullGC::RunPhases " << clockScope.TotalSpentTime(); + LOG_GC(DEBUG) << "FullGC::RunPhases " << clockScope.TotalSpentTime(); } void FullGC::RunPhasesForAppSpawn() diff --git a/ecmascript/mem/gc_stats.cpp b/ecmascript/mem/gc_stats.cpp index 8067e9a2..bdfdad1e 100644 --- a/ecmascript/mem/gc_stats.cpp +++ b/ecmascript/mem/gc_stats.cpp @@ -21,7 +21,7 @@ namespace panda::ecmascript { void GCStats::PrintStatisticResult(bool force) { - LOG(INFO, RUNTIME) << "/******************* GCStats statistic: *******************/"; + LOG_GC(INFO) << "/******************* GCStats statistic: *******************/"; PrintSemiStatisticResult(force); PrintPartialStatisticResult(force); PrintCompressStatisticResult(force); @@ -32,8 +32,8 @@ void GCStats::PrintSemiStatisticResult(bool force) { if ((force && semiGCCount_ != 0) || (!force && semiGCCount_ != lastSemiGCCount_)) { lastSemiGCCount_ = semiGCCount_; - LOG(INFO, RUNTIME) << " STWYoungGC statistic: total semi gc count " << semiGCCount_; - LOG(INFO, RUNTIME) << " MIN pause time: " << PrintTimeMilliseconds(semiGCMinPause_) << "ms" + LOG_GC(INFO) << " STWYoungGC statistic: total semi gc count " << semiGCCount_; + LOG_GC(INFO) << " MIN pause time: " << PrintTimeMilliseconds(semiGCMinPause_) << "ms" << " MAX pause time: " << PrintTimeMilliseconds(semiGCMaxPause_) << "ms" << " total pause time: " << PrintTimeMilliseconds(semiGCTotalPause_) << "ms" << " average pause time: " << PrintTimeMilliseconds(semiGCTotalPause_ / semiGCCount_) @@ -52,8 +52,8 @@ void GCStats::PrintPartialStatisticResult(bool force) { if ((force && partialGCCount_ != 0) || (!force && lastOldGCCount_ != partialGCCount_)) { lastOldGCCount_ = partialGCCount_; - LOG(INFO, RUNTIME) << " PartialGC with non-concurrent mark statistic: total old gc count " << partialGCCount_; - LOG(INFO, RUNTIME) << " Pause time statistic:: MIN pause time: " << PrintTimeMilliseconds(partialGCMinPause_) + LOG_GC(INFO) << " PartialGC with non-concurrent mark statistic: total old gc count " << partialGCCount_; + LOG_GC(INFO) << " Pause time statistic:: MIN pause time: " << PrintTimeMilliseconds(partialGCMinPause_) << "ms" << " MAX pause time: " << PrintTimeMilliseconds(partialGCMaxPause_) << "ms" << " total pause time: " << PrintTimeMilliseconds(partialGCTotalPause_) << "ms" @@ -67,9 +67,9 @@ void GCStats::PrintPartialStatisticResult(bool force) if ((force && partialConcurrentMarkGCCount_ != 0) || (!force && lastOldConcurrentMarkGCCount_ != partialConcurrentMarkGCCount_)) { lastOldConcurrentMarkGCCount_ = partialConcurrentMarkGCCount_; - LOG(INFO, RUNTIME) << " PartialCollector with concurrent mark statistic: total old gc count " + LOG_GC(INFO) << " PartialCollector with concurrent mark statistic: total old gc count " << partialConcurrentMarkGCCount_; - LOG(INFO, RUNTIME) << " Pause time statistic:: Current GC pause time: " + LOG_GC(INFO) << " Pause time statistic:: Current GC pause time: " << PrintTimeMilliseconds(partialConcurrentMarkGCPauseTime_) << "ms" << " Concurrent mark pause time: " << PrintTimeMilliseconds(partialConcurrentMarkMarkPause_) << "ms" @@ -96,8 +96,8 @@ void GCStats::PrintCompressStatisticResult(bool force) { if ((force && fullGCCount_ != 0) || (!force && fullGCCount_ != lastFullGCCount_)) { lastFullGCCount_ = fullGCCount_; - LOG(INFO, RUNTIME) << " FullGC statistic: total compress gc count " << fullGCCount_; - LOG(INFO, RUNTIME) + LOG_GC(INFO) << " FullGC statistic: total compress gc count " << fullGCCount_; + LOG_GC(INFO) << " MIN pause time: " << PrintTimeMilliseconds(fullGCMinPause_) << "ms" << " MAX pause time: " << PrintTimeMilliseconds(fullGCMaxPause_) << "ms" << " total pause time: " << PrintTimeMilliseconds(fullGCTotalPause_) << "ms" @@ -122,8 +122,8 @@ void GCStats::PrintHeapStatisticResult(bool force) if (force && heap_ != nullptr) { NativeAreaAllocator *nativeAreaAllocator = heap_->GetNativeAreaAllocator(); HeapRegionAllocator *heapRegionAllocator = heap_->GetHeapRegionAllocator(); - LOG(INFO, RUNTIME) << "/******************* Memory statistic: *******************/"; - LOG(INFO, RUNTIME) << " Anno memory usage size: " << sizeToMB(heapRegionAllocator->GetAnnoMemoryUsage()) + LOG_GC(INFO) << "/******************* Memory statistic: *******************/"; + LOG_GC(INFO) << " Anno memory usage size: " << sizeToMB(heapRegionAllocator->GetAnnoMemoryUsage()) << "MB" << " anno memory max usage size: " << sizeToMB(heapRegionAllocator->GetMaxAnnoMemoryUsage()) << "MB" @@ -131,7 +131,7 @@ void GCStats::PrintHeapStatisticResult(bool force) << "MB" << " native memory max usage size: " << sizeToMB(nativeAreaAllocator->GetMaxNativeMemoryUsage()) << "MB"; - LOG(INFO, RUNTIME) << " Semi space commit size: " << sizeToMB(heap_->GetNewSpace()->GetCommittedSize()) << "MB" + LOG_GC(INFO) << " Semi space commit size: " << sizeToMB(heap_->GetNewSpace()->GetCommittedSize()) << "MB" << " semi space heap object size: " << sizeToMB(heap_->GetNewSpace()->GetHeapObjectSize()) << "MB" << " old space commit size: " @@ -223,9 +223,9 @@ void GCStats::StatisticFullGC(Duration time, size_t youngAndOldAliveSize, size_t void GCStats::CheckIfLongTimePause() { if (currentPauseTime_ > longPauseTime_) { - LOG(INFO, RUNTIME) << "Has checked a long time gc; gc type = " << currentGcType_ << "; pause time = " + LOG_GC(INFO) << "Has checked a long time gc; gc type = " << currentGcType_ << "; pause time = " << currentPauseTime_ << "ms"; - LOG(INFO, RUNTIME) << "/******************* GCStats statistic: *******************/"; + LOG_GC(INFO) << "/******************* GCStats statistic: *******************/"; PrintSemiStatisticResult(true); PrintPartialStatisticResult(true); PrintCompressStatisticResult(true); diff --git a/ecmascript/mem/gc_stats.h b/ecmascript/mem/gc_stats.h index 5c988fa1..79d545dd 100644 --- a/ecmascript/mem/gc_stats.h +++ b/ecmascript/mem/gc_stats.h @@ -16,9 +16,10 @@ #ifndef ECMASCRIPT_MEM_GC_STATS_H #define ECMASCRIPT_MEM_GC_STATS_H +#include +#include #include "time.h" -#include "chrono" -#include "libpandabase/utils/logger.h" +#include "libpandabase/macros.h" namespace panda::ecmascript { class Heap; diff --git a/ecmascript/mem/heap.cpp b/ecmascript/mem/heap.cpp index 34023f91..226de134 100644 --- a/ecmascript/mem/heap.cpp +++ b/ecmascript/mem/heap.cpp @@ -96,7 +96,7 @@ void Heap::Initialize() maxMarkTaskCount_ = std::min(ecmaVm_->GetJSOptions().GetGcThreadNum(), maxEvacuateTaskCount_ - 1); - LOG(INFO, RUNTIME) << "heap initialize: heap size = " << maxHeapSize + LOG_GC(INFO) << "heap initialize: heap size = " << maxHeapSize << ", semispace capacity = " << minSemiSpaceCapacity << ", nonmovablespace capacity = " << nonmovableSpaceCapacity << ", snapshotspace capacity = " << snapshotSpaceCapacity @@ -305,7 +305,7 @@ void Heap::CollectGarbage(TriggerGCType gcType) sweeper_->EnsureAllTaskFinished(); auto failCount = Verification(this).VerifyAll(); if (failCount > 0) { - LOG(FATAL, GC) << "Before gc heap corrupted and " << failCount << " corruptions"; + LOG_GC(FATAL) << "Before gc heap corrupted and " << failCount << " corruptions"; } isVerifying_ = false; #endif @@ -318,8 +318,8 @@ void Heap::CollectGarbage(TriggerGCType gcType) } size_t originalNewSpaceSize = activeSemiSpace_->GetHeapObjectSize(); memController_->StartCalculationBeforeGC(); - LOG(INFO, ECMASCRIPT) << "Heap::CollectGarbage, gcType = " << gcType; - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << " global CommittedSize " << GetCommittedSize() + LOG_GC(INFO) << "Heap::CollectGarbage, gcType = " << gcType; + OPTIONAL_LOG(ecmaVm_, ERROR) << " global CommittedSize " << GetCommittedSize() << " global limit " << globalSpaceAllocLimit_; switch (gcType) { case TriggerGCType::YOUNG_GC: @@ -367,7 +367,7 @@ void Heap::CollectGarbage(TriggerGCType gcType) // Only when the gc type is not semiGC and after the old space sweeping has been finished, // the limits of old space and global space can be recomputed. RecomputeLimits(); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << " GC after: is full mark" << IsFullMark() + OPTIONAL_LOG(ecmaVm_, ERROR) << " GC after: is full mark" << IsFullMark() << " global CommittedSize " << GetCommittedSize() << " global limit " << globalSpaceAllocLimit_; markType_ = MarkType::MARK_YOUNG; @@ -386,7 +386,7 @@ void Heap::CollectGarbage(TriggerGCType gcType) sweeper_->EnsureAllTaskFinished(); failCount = Verification(this).VerifyAll(); if (failCount > 0) { - LOG(FATAL, GC) << "After gc heap corrupted and " << failCount << " corruptions"; + LOG_GC(FATAL) << "After gc heap corrupted and " << failCount << " corruptions"; } isVerifying_ = false; #endif @@ -453,7 +453,7 @@ void Heap::AdjustOldSpaceLimit() if (newGlobalSpaceAllocLimit < globalSpaceAllocLimit_) { globalSpaceAllocLimit_ = newGlobalSpaceAllocLimit; } - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "AdjustOldSpaceLimit oldSpaceAllocLimit_" << oldSpaceAllocLimit + OPTIONAL_LOG(ecmaVm_, ERROR) << "AdjustOldSpaceLimit oldSpaceAllocLimit_" << oldSpaceAllocLimit << " globalSpaceAllocLimit_" << globalSpaceAllocLimit_; } @@ -493,7 +493,7 @@ void Heap::RecomputeLimits() maxGlobalSize, newSpaceCapacity, growingFactor); globalSpaceAllocLimit_ = newGlobalSpaceLimit; oldSpace_->SetInitialCapacity(newOldSpaceLimit); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "RecomputeLimits oldSpaceAllocLimit_" << newOldSpaceLimit + OPTIONAL_LOG(ecmaVm_, ERROR) << "RecomputeLimits oldSpaceAllocLimit_" << newOldSpaceLimit << " globalSpaceAllocLimit_" << globalSpaceAllocLimit_; } @@ -514,7 +514,7 @@ bool Heap::CheckOngoingConcurrentMarking() GetNonMovableMarker()->ProcessMarkStack(MAIN_THREAD_INDEX); WaitConcurrentMarkingFinished(); ecmaVm_->GetEcmaGCStats()->StatisticConcurrentMarkWait(clockScope.GetPauseTime()); - ECMA_GC_LOG() << "wait concurrent marking finish pause time " << clockScope.TotalSpentTime(); + LOG_GC(DEBUG) << "wait concurrent marking finish pause time " << clockScope.TotalSpentTime(); } memController_->RecordAfterConcurrentMark(IsFullMark(), concurrentMarker_); return true; @@ -546,7 +546,7 @@ void Heap::TryTriggerConcurrentMarking() if (oldSpaceConcurrentMarkSpeed == 0 || oldSpaceAllocSpeed == 0) { if (oldSpaceHeapObjectSize >= oldSpaceAllocLimit || globalHeapObjectSize >= globalSpaceAllocLimit_) { markType_ = MarkType::MARK_FULL; - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Trigger the first full mark"; + OPTIONAL_LOG(ecmaVm_, ERROR) << "Trigger the first full mark"; TriggerConcurrentMarking(); return; } @@ -571,7 +571,7 @@ void Heap::TryTriggerConcurrentMarking() if (activeSemiSpace_->GetCommittedSize() >= config.GetSemiSpaceTriggerConcurrentMark()) { markType_ = MarkType::MARK_YOUNG; TriggerConcurrentMarking(); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Trigger the first semi mark" << fullGCRequested_; + OPTIONAL_LOG(ecmaVm_, ERROR) << "Trigger the first semi mark" << fullGCRequested_; } return; } @@ -586,18 +586,18 @@ void Heap::TryTriggerConcurrentMarking() && oldSpaceMarkDuration < oldSpaceAllocToLimitDuration) { markType_ = MarkType::MARK_FULL; TriggerConcurrentMarking(); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Trigger full mark by speed"; + OPTIONAL_LOG(ecmaVm_, ERROR) << "Trigger full mark by speed"; } else { if (oldSpaceHeapObjectSize >= oldSpaceAllocLimit || globalHeapObjectSize >= globalSpaceAllocLimit_) { markType_ = MarkType::MARK_FULL; TriggerConcurrentMarking(); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Trigger full mark by limit"; + OPTIONAL_LOG(ecmaVm_, ERROR) << "Trigger full mark by limit"; } } } else if (newSpaceRemainSize < DEFAULT_REGION_SIZE) { markType_ = MarkType::MARK_YOUNG; TriggerConcurrentMarking(); - OPTIONAL_LOG(ecmaVm_, ERROR, ECMASCRIPT) << "Trigger semi mark"; + OPTIONAL_LOG(ecmaVm_, ERROR) << "Trigger semi mark"; } } @@ -620,13 +620,13 @@ void Heap::UpdateDerivedObjectInStack() uintptr_t baseOldObject = derived.second; uintptr_t *derivedAddr = reinterpret_cast(derived.first.second); #ifndef NDEBUG - LOG_ECMA(DEBUG) << std::hex << "fix base before:" << baseAddr << " base old Value: " << baseOldObject << + LOG_GC(DEBUG) << std::hex << "fix base before:" << baseAddr << " base old Value: " << baseOldObject << " derived:" << derivedAddr << " old Value: " << *derivedAddr << std::endl; #endif // derived is always bigger than base *derivedAddr = reinterpret_cast(base.GetTaggedObject()) + (*derivedAddr - baseOldObject); #ifndef NDEBUG - LOG_ECMA(DEBUG) << std::hex << "fix base after:" << baseAddr << + LOG_GC(DEBUG) << std::hex << "fix base after:" << baseAddr << " base New Value: " << base.GetTaggedObject() << " derived:" << derivedAddr << " New Value: " << *derivedAddr << std::endl; #endif @@ -671,20 +671,20 @@ void Heap::IncreaseTaskCount() void Heap::ChangeGCParams(bool inBackground) { if (inBackground) { - LOG(INFO, RUNTIME) << "app is inBackground"; + LOG_GC(INFO) << "app is inBackground"; if (GetMemGrowingType() != MemGrowingType::PRESSURE) { SetMemGrowingType(MemGrowingType::CONSERVATIVE); - LOG(INFO, RUNTIME) << "Heap Growing Type CONSERVATIVE"; + LOG_GC(INFO) << "Heap Growing Type CONSERVATIVE"; } concurrentMarker_->EnableConcurrentMarking(EnableConcurrentMarkType::DISABLE); sweeper_->EnableConcurrentSweep(EnableConcurrentSweepType::DISABLE); maxMarkTaskCount_ = 1; maxEvacuateTaskCount_ = 1; } else { - LOG(INFO, RUNTIME) << "app is not inBackground"; + LOG_GC(INFO) << "app is not inBackground"; if (GetMemGrowingType() != MemGrowingType::PRESSURE) { SetMemGrowingType(MemGrowingType::HIGH_THROUGHPUT); - LOG(INFO, RUNTIME) << "Heap Growing Type HIGH_THROUGHPUT"; + LOG_GC(INFO) << "Heap Growing Type HIGH_THROUGHPUT"; } concurrentMarker_->EnableConcurrentMarking(EnableConcurrentMarkType::ENABLE); sweeper_->EnableConcurrentSweep(EnableConcurrentSweepType::ENABLE); @@ -697,10 +697,10 @@ void Heap::ChangeGCParams(bool inBackground) void Heap::NotifyMemoryPressure(bool inHighMemoryPressure) { if (inHighMemoryPressure) { - LOG(INFO, RUNTIME) << "app is inHighMemoryPressure"; + LOG_GC(INFO) << "app is inHighMemoryPressure"; SetMemGrowingType(MemGrowingType::PRESSURE); } else { - LOG(INFO, RUNTIME) << "app is not inHighMemoryPressure"; + LOG_GC(INFO) << "app is not inHighMemoryPressure"; SetMemGrowingType(MemGrowingType::CONSERVATIVE); } } @@ -771,14 +771,14 @@ size_t Heap::GetArrayBufferSize() const bool Heap::IsAlive(TaggedObject *object) const { if (!ContainObject(object)) { - LOG(ERROR, RUNTIME) << "The region is already free"; + LOG_GC(ERROR) << "The region is already free"; return false; } bool isFree = object->GetClass() != nullptr && FreeObject::Cast(ToUintPtr(object))->IsFreeObject(); if (isFree) { Region *region = Region::ObjectAddressToRange(object); - LOG(ERROR, RUNTIME) << "The object " << object << " in " + LOG_GC(ERROR) << "The object " << object << " in " << region->GetSpaceTypeName() << " already free"; } diff --git a/ecmascript/mem/heap_region_allocator.cpp b/ecmascript/mem/heap_region_allocator.cpp index b9c44647..74835f19 100644 --- a/ecmascript/mem/heap_region_allocator.cpp +++ b/ecmascript/mem/heap_region_allocator.cpp @@ -36,7 +36,7 @@ Region *HeapRegionAllocator::AllocateAlignedRegion(Space *space, size_t capacity } #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(mapMem, capacity, 0, capacity) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif @@ -44,7 +44,7 @@ Region *HeapRegionAllocator::AllocateAlignedRegion(Space *space, size_t capacity uintptr_t mem = ToUintPtr(mapMem); // Check that the address is 256K byte aligned - LOG_IF(AlignUp(mem, PANDA_POOL_ALIGNMENT_IN_BYTES) != mem, FATAL, RUNTIME) << "region not align by 256KB"; + LOG_ECMA_IF(AlignUp(mem, PANDA_POOL_ALIGNMENT_IN_BYTES) != mem, FATAL) << "region not align by 256KB"; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) uintptr_t begin = AlignUp(mem + sizeof(Region), static_cast(MemAlignment::MEM_ALIGN_REGION)); @@ -63,7 +63,7 @@ void HeapRegionAllocator::FreeRegion(Region *region) region->Invalidate(); #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(ToVoidPtr(allocateBase), size, INVALID_VALUE, size) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif diff --git a/ecmascript/mem/heap_region_allocator.h b/ecmascript/mem/heap_region_allocator.h index f3230c96..1925f8e9 100644 --- a/ecmascript/mem/heap_region_allocator.h +++ b/ecmascript/mem/heap_region_allocator.h @@ -19,7 +19,6 @@ #include #include "ecmascript/mem/mem.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { class JSThread; diff --git a/ecmascript/mem/mem.h b/ecmascript/mem/mem.h index 70f92a27..1b214cf7 100644 --- a/ecmascript/mem/mem.h +++ b/ecmascript/mem/mem.h @@ -25,10 +25,9 @@ #include "ecmascript/ecma_param_configuration.h" #include "ecmascript/mem/tagged_object.h" #include "libpandabase/mem/mem.h" -#include "libpandabase/utils/logger.h" // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, bugprone-lambda-function-name) -#define LOG_ECMA_MEM(type) LOG(type, ECMASCRIPT) << __func__ << " Line:" << __LINE__ << " " +#define LOG_ECMA_MEM(level) LOG_GC(level) << __func__ << ":" << __LINE__ << " " namespace panda::ecmascript { enum class MemAlignment : uint8_t { diff --git a/ecmascript/mem/mem_controller.cpp b/ecmascript/mem/mem_controller.cpp index 61027aa6..0f8d0e43 100644 --- a/ecmascript/mem/mem_controller.cpp +++ b/ecmascript/mem/mem_controller.cpp @@ -71,7 +71,7 @@ double MemController::CalculateGrowingFactor(double gcSpeed, double mutatorSpeed double factor = (a < b * maxGrowingFactor) ? a / b : maxGrowingFactor; factor = std::min(maxGrowingFactor, factor); factor = std::max(factor, minGrowingFactor); - OPTIONAL_LOG(heap_->GetEcmaVM(), ERROR, ECMASCRIPT) << "CalculateGrowingFactor gcSpeed" + OPTIONAL_LOG(heap_->GetEcmaVM(), ERROR) << "CalculateGrowingFactor gcSpeed" << gcSpeed << " mutatorSpeed" << mutatorSpeed << " factor" << factor; return factor; } diff --git a/ecmascript/mem/mem_map_allocator.cpp b/ecmascript/mem/mem_map_allocator.cpp index 871ffffd..384976d3 100644 --- a/ecmascript/mem/mem_map_allocator.cpp +++ b/ecmascript/mem/mem_map_allocator.cpp @@ -48,7 +48,7 @@ namespace panda::ecmascript { MemMap MemMapAllocator::Allocate(size_t size, size_t alignment, bool isRegular) { if (UNLIKELY(memMapTotalSize_ + size > capacity_)) { - LOG(ERROR, RUNTIME) << "memory map overflow"; + LOG_GC(ERROR) << "memory map overflow"; return MemMap(); } MemMap mem; @@ -91,7 +91,7 @@ MemMap MemMapAllocator::PageMap(size_t size, size_t alignment) #else void *result = mmap(allocSize, -1, 0); #endif - LOG_IF(result == nullptr, FATAL, ECMASCRIPT); + LOG_ECMA_IF(result == nullptr, FATAL) << "mmap fail"; auto alignResult = AlignUp(reinterpret_cast(result), alignment); #ifdef PANDA_TARGET_UNIX size_t leftSize = alignResult - reinterpret_cast(result); @@ -118,7 +118,7 @@ void MemMapAllocator::AdapterSuitablePoolCapacity() int64_t size = 0; size_t bufferLength = sizeof(size); if (sysctl(mib, MIB_LENGTH, &size, &bufferLength, NULL, 0) != 0) { - LOG(FATAL, RUNTIME) << "sysctl error"; + LOG_GC(FATAL) << "sysctl error"; } size_t physSize = static_cast(size); #else @@ -134,6 +134,6 @@ void MemMapAllocator::AdapterSuitablePoolCapacity() } else if (capacity_ >= LOW_POOL_SIZE) { capacity_ = std::max(capacity_, 128_MB); } - LOG(INFO, RUNTIME) << "Ark Auto adapter memory pool capacity:" << capacity_; + LOG_GC(INFO) << "Ark Auto adapter memory pool capacity:" << capacity_; } } // namespace panda::ecmascript diff --git a/ecmascript/mem/mem_map_allocator.h b/ecmascript/mem/mem_map_allocator.h index 520bc053..f3a4b00c 100644 --- a/ecmascript/mem/mem_map_allocator.h +++ b/ecmascript/mem/mem_map_allocator.h @@ -53,6 +53,8 @@ #endif #endif +#include "ecmascript/log_wrapper.h" + namespace panda::ecmascript { class MemMap { public: @@ -228,17 +230,17 @@ public: void IncreaseAndCheckReserved(size_t size) { if (reserved_ + size > capacity_) { - LOG(ERROR, RUNTIME) << "pool is empty, reserved = " << reserved_ << ", capacity_ = " + LOG_GC(ERROR) << "pool is empty, reserved = " << reserved_ << ", capacity_ = " << capacity_ << ", size = " << size; } reserved_ += size; - LOG(DEBUG, RUNTIME) << "Ark IncreaseAndCheckReserved reserved = " << reserved_ << ", capacity_ = " << capacity_; + LOG_GC(DEBUG) << "Ark IncreaseAndCheckReserved reserved = " << reserved_ << ", capacity_ = " << capacity_; } void DecreaseReserved(size_t size) { reserved_ -= size; - LOG(DEBUG, RUNTIME) << "Ark DecreaseReserved reserved = " << reserved_ << ", capacity_ = " << capacity_; + LOG_GC(DEBUG) << "Ark DecreaseReserved reserved = " << reserved_ << ", capacity_ = " << capacity_; } static MemMapAllocator *GetInstance() diff --git a/ecmascript/mem/native_area_allocator.cpp b/ecmascript/mem/native_area_allocator.cpp index 3eaed4bb..01adf373 100644 --- a/ecmascript/mem/native_area_allocator.cpp +++ b/ecmascript/mem/native_area_allocator.cpp @@ -44,7 +44,7 @@ Area *NativeAreaAllocator::AllocateArea(size_t capacity) } #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(mem, capacity, 0, capacity) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif @@ -68,7 +68,7 @@ void NativeAreaAllocator::FreeArea(Area *area) DecreaseNativeMemoryUsage(size); #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(area, size, INVALID_VALUE, size) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif @@ -84,7 +84,7 @@ void NativeAreaAllocator::Free(void *mem, size_t size) DecreaseNativeMemoryUsage(size); #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(mem, size, INVALID_VALUE, size) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif @@ -107,7 +107,7 @@ void *NativeAreaAllocator::AllocateBuffer(size_t size) } #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(ptr, size, INVALID_VALUE, size) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif @@ -130,7 +130,7 @@ void NativeAreaAllocator::FreeBuffer(void *mem) #if ECMASCRIPT_ENABLE_ZAP_MEM if (memset_s(mem, size, INVALID_VALUE, size) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } #endif diff --git a/ecmascript/mem/native_area_allocator.h b/ecmascript/mem/native_area_allocator.h index 180d6886..3b277e93 100644 --- a/ecmascript/mem/native_area_allocator.h +++ b/ecmascript/mem/native_area_allocator.h @@ -19,9 +19,9 @@ #include #include "ecmascript/common.h" +#include "ecmascript/log_wrapper.h" #include "ecmascript/mem/mem.h" #include "ecmascript/mem/area.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { class PUBLIC_API NativeAreaAllocator { diff --git a/ecmascript/mem/parallel_evacuator.cpp b/ecmascript/mem/parallel_evacuator.cpp index 6c4dc736..adaa14fa 100644 --- a/ecmascript/mem/parallel_evacuator.cpp +++ b/ecmascript/mem/parallel_evacuator.cpp @@ -129,10 +129,10 @@ void ParallelEvacuator::EvacuateRegion(TlabAllocator *allocator, Region *region) promotedSize += size; } } - LOG_IF(address == 0, FATAL, RUNTIME) << "Evacuate object failed:" << size; + LOG_ECMA_IF(address == 0, FATAL) << "Evacuate object failed:" << size; if (memcpy_s(ToVoidPtr(address), size, ToVoidPtr(ToUintPtr(mem)), size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; } Barriers::SetDynPrimitive(header, 0, MarkWord::FromForwardingAddress(address)); @@ -162,7 +162,7 @@ void ParallelEvacuator::VerifyHeapObject(TaggedObject *object) continue; } if (!objectRegion->Test(value.GetTaggedObject())) { - LOG(FATAL, RUNTIME) << "Miss mark value: " << value.GetTaggedObject() + LOG_GC(FATAL) << "Miss mark value: " << value.GetTaggedObject() << ", body address:" << slot.SlotAddress() << ", header address:" << object; } @@ -197,7 +197,7 @@ void ParallelEvacuator::UpdateReference() heap_->EnumerateSnapshotSpaceRegions([this] (Region *current) { AddWorkload(std::make_unique(this, current)); }); - LOG(DEBUG, RUNTIME) << "UpdatePointers statistic: younge space region compact moving count:" + LOG_GC(DEBUG) << "UpdatePointers statistic: younge space region compact moving count:" << youngeRegionMoveCount << "younge space region compact coping count:" << youngeRegionCopyCount << "old space region count:" << oldRegionCount; diff --git a/ecmascript/mem/parallel_marker-inl.h b/ecmascript/mem/parallel_marker-inl.h index b742e5a3..31016cf4 100644 --- a/ecmascript/mem/parallel_marker-inl.h +++ b/ecmascript/mem/parallel_marker-inl.h @@ -161,7 +161,7 @@ inline void MovableMarker::UpdateForwardAddressIfSuccess(uint32_t threadId, Tagg { if (memcpy_s(ToVoidPtr(toAddress + HEAD_SIZE), size - HEAD_SIZE, ToVoidPtr(ToUintPtr(object) + HEAD_SIZE), size - HEAD_SIZE) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; } workManager_->IncreaseAliveSize(threadId, size); if (isPromoted) { diff --git a/ecmascript/mem/parallel_marker.h b/ecmascript/mem/parallel_marker.h index 4f7a9c6e..ba8e73c0 100644 --- a/ecmascript/mem/parallel_marker.h +++ b/ecmascript/mem/parallel_marker.h @@ -21,7 +21,6 @@ #include "ecmascript/mem/object_xray.h" #include "ecmascript/mem/slots.h" #include "ecmascript/mem/work_manager.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { class Heap; @@ -37,7 +36,7 @@ public: virtual void Initialize() { - ECMA_GC_LOG() << "Marker::Initialize do nothing"; + LOG_GC(DEBUG) << "Marker::Initialize do nothing"; } void MarkRoots(uint32_t threadId); @@ -47,20 +46,20 @@ public: virtual void ProcessMarkStack([[maybe_unused]] uint32_t threadId) { - LOG(FATAL, ECMASCRIPT) << "can not call this method"; + LOG_GC(FATAL) << "can not call this method"; } protected: // non move virtual inline void MarkObject([[maybe_unused]] uint32_t threadId, [[maybe_unused]] TaggedObject *object) { - LOG(FATAL, ECMASCRIPT) << "can not call this method"; + LOG_GC(FATAL) << "can not call this method"; } virtual inline SlotStatus MarkObject([[maybe_unused]] uint32_t threadId, [[maybe_unused]] TaggedObject *object, [[maybe_unused]] ObjectSlot slot) // move { - LOG(FATAL, ECMASCRIPT) << "can not call this method"; + LOG_GC(FATAL) << "can not call this method"; return SlotStatus::KEEP_SLOT; } @@ -70,7 +69,7 @@ protected: ObjectSlot end) = 0; virtual inline void RecordWeakReference([[maybe_unused]] uint32_t threadId, [[maybe_unused]] JSTaggedType *ref) { - LOG(FATAL, ECMASCRIPT) << "can not call this method"; + LOG_GC(FATAL) << "can not call this method"; } Heap *heap_ {nullptr}; diff --git a/ecmascript/mem/partial_gc.cpp b/ecmascript/mem/partial_gc.cpp index 0361cbab..bf56d9c7 100644 --- a/ecmascript/mem/partial_gc.cpp +++ b/ecmascript/mem/partial_gc.cpp @@ -41,21 +41,21 @@ void PartialGC::RunPhases() markingInProgress_ = heap_->CheckOngoingConcurrentMarking(); - ECMA_GC_LOG() << "markingInProgress_" << markingInProgress_; + LOG_GC(DEBUG) << "markingInProgress_" << markingInProgress_; Initialize(); Mark(); Sweep(); Evacuate(); Finish(); heap_->GetEcmaVM()->GetEcmaGCStats()->StatisticPartialGC(markingInProgress_, clockScope.GetPauseTime(), freeSize_); - ECMA_GC_LOG() << "PartialGC::RunPhases " << clockScope.TotalSpentTime(); + LOG_GC(DEBUG) << "PartialGC::RunPhases " << clockScope.TotalSpentTime(); } void PartialGC::Initialize() { ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "PartialGC::Initialize"); if (!markingInProgress_) { - LOG(INFO, RUNTIME) << "No ongoing Concurrent marking. Initializing..."; + LOG_GC(INFO) << "No ongoing Concurrent marking. Initializing..."; heap_->Prepare(); if (heap_->IsFullMark()) { heap_->GetOldSpace()->SelectCSet(); diff --git a/ecmascript/mem/region.h b/ecmascript/mem/region.h index a62eced0..919e8cb7 100644 --- a/ecmascript/mem/region.h +++ b/ecmascript/mem/region.h @@ -16,11 +16,11 @@ #ifndef ECMASCRIPT_MEM_REGION_H #define ECMASCRIPT_MEM_REGION_H -#include "libpandabase/utils/aligned_storage.h" - #include "ecmascript/mem/free_object_list.h" #include "ecmascript/mem/gc_bitset.h" #include "ecmascript/mem/remembered_set.h" +#include "libpandabase/os/mutex.h" +#include "libpandabase/utils/aligned_storage.h" #include "securec.h" namespace panda { diff --git a/ecmascript/mem/sparse_space.cpp b/ecmascript/mem/sparse_space.cpp index 71dfafd6..3d834042 100644 --- a/ecmascript/mem/sparse_space.cpp +++ b/ecmascript/mem/sparse_space.cpp @@ -373,7 +373,7 @@ void OldSpace::CheckRegionSize() size_t available = allocator_->GetAvailableSize(); size_t wasted = allocator_->GetWastedSize(); if (GetHeapObjectSize() + wasted + available != objectSize_) { - LOG(DEBUG, RUNTIME) << "Actual live object size:" << GetHeapObjectSize() + LOG_GC(DEBUG) << "Actual live object size:" << GetHeapObjectSize() << ", free object size:" << available << ", wasted size:" << wasted << ", but exception totoal size:" << objectSize_; diff --git a/ecmascript/mem/stw_young_gc.cpp b/ecmascript/mem/stw_young_gc.cpp index 272befc0..3138a24c 100644 --- a/ecmascript/mem/stw_young_gc.cpp +++ b/ecmascript/mem/stw_young_gc.cpp @@ -42,7 +42,7 @@ void STWYoungGC::RunPhases() ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "STWYoungGC::RunPhases"); if (heap_->CheckOngoingConcurrentMarking()) { - ECMA_GC_LOG() << "STWYoungGC after ConcurrentMarking"; + LOG_GC(DEBUG) << "STWYoungGC after ConcurrentMarking"; heap_->GetConcurrentMarker()->Reset(); // HPPGC use mark result to move TaggedObject. } Initialize(); @@ -51,7 +51,7 @@ void STWYoungGC::RunPhases() Finish(); heap_->GetEcmaVM()->GetEcmaGCStats()->StatisticSTWYoungGC(clockScope.GetPauseTime(), semiCopiedSize_, promotedSize_, commitSize_); - ECMA_GC_LOG() << "STWYoungGC::RunPhases " << clockScope.TotalSpentTime(); + LOG_GC(DEBUG) << "STWYoungGC::RunPhases " << clockScope.TotalSpentTime(); } void STWYoungGC::Initialize() diff --git a/ecmascript/mem/verification.cpp b/ecmascript/mem/verification.cpp index 873924ee..a7813088 100644 --- a/ecmascript/mem/verification.cpp +++ b/ecmascript/mem/verification.cpp @@ -31,13 +31,13 @@ void VerifyObjectVisitor::VisitAllObjects(TaggedObject *obj) JSTaggedValue value(slot.GetTaggedType()); if (value.IsWeak()) { if (!heap_->IsAlive(value.GetTaggedWeakRef())) { - LOG(ERROR, RUNTIME) << "Heap verify detected a dead weak object " << value.GetTaggedObject() + LOG_GC(ERROR) << "Heap verify detected a dead weak object " << value.GetTaggedObject() << " at object:" << slot.SlotAddress(); ++(*failCount_); } } else if (value.IsHeapObject()) { if (!heap_->IsAlive(value.GetTaggedObject())) { - LOG(ERROR, RUNTIME) << "Heap verify detected a dead object at " << value.GetTaggedObject() + LOG_GC(ERROR) << "Heap verify detected a dead object at " << value.GetTaggedObject() << " at object:" << slot.SlotAddress(); ++(*failCount_); } @@ -69,7 +69,7 @@ size_t Verification::VerifyRoot() const }; objXRay_.VisitVMRoots(visit1, visit2); if (failCount > 0) { - LOG(ERROR, RUNTIME) << "VerifyRoot detects deadObject count is " << failCount; + LOG_GC(ERROR) << "VerifyRoot detects deadObject count is " << failCount; } return failCount; @@ -79,7 +79,7 @@ size_t Verification::VerifyHeap() const { size_t failCount = heap_->VerifyHeapObjects(); if (failCount > 0) { - LOG(ERROR, RUNTIME) << "VerifyHeap detects deadObject count is " << failCount; + LOG_GC(ERROR) << "VerifyHeap detects deadObject count is " << failCount; } return failCount; } diff --git a/ecmascript/module/js_module_manager.cpp b/ecmascript/module/js_module_manager.cpp index e0ca8843..fd65e897 100644 --- a/ecmascript/module/js_module_manager.cpp +++ b/ecmascript/module/js_module_manager.cpp @@ -43,7 +43,7 @@ JSTaggedValue ModuleManager::GetModuleValueInner(JSTaggedValue key) { JSTaggedValue currentModule = GetCurrentModule(); if (currentModule.IsUndefined()) { - LOG_ECMA(FATAL) << "GetModuleValueInner currentModule failed"; + LOG_FULL(FATAL) << "GetModuleValueInner currentModule failed"; } return SourceTextModule::Cast(currentModule.GetTaggedObject())->GetModuleValue(vm_->GetJSThread(), key, false); } @@ -53,7 +53,7 @@ JSTaggedValue ModuleManager::GetModuleValueOutter(JSTaggedValue key) JSThread *thread = vm_->GetJSThread(); JSTaggedValue currentModule = GetCurrentModule(); if (currentModule.IsUndefined()) { - LOG_ECMA(FATAL) << "GetModuleValueOutter currentModule failed"; + LOG_FULL(FATAL) << "GetModuleValueOutter currentModule failed"; } JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetTaggedObject())->GetEnvironment(); ASSERT(!moduleEnvironment.IsUndefined()); @@ -79,7 +79,7 @@ void ModuleManager::StoreModuleValue(JSTaggedValue key, JSTaggedValue value) JSThread *thread = vm_->GetJSThread(); JSHandle currentModule(thread, GetCurrentModule()); if (currentModule.GetTaggedValue().IsUndefined()) { - LOG_ECMA(FATAL) << "StoreModuleValue currentModule failed"; + LOG_FULL(FATAL) << "StoreModuleValue currentModule failed"; } JSHandle keyHandle(thread, key); JSHandle valueHandle(thread, value); @@ -93,7 +93,7 @@ JSHandle ModuleManager::HostGetImportedModule(const CString &r JSHandle::Cast(factory->NewFromUtf8(referencingModule)); int entry = NameDictionary::Cast(resolvedModules_.GetTaggedObject())->FindEntry(referencingHandle.GetTaggedValue()); - LOG_IF(entry == -1, FATAL, ECMASCRIPT) << "cannot get module: " << referencingModule; + LOG_ECMA_IF(entry == -1, FATAL) << "cannot get module: " << referencingModule; return JSHandle(vm_->GetJSThread(), NameDictionary::Cast(resolvedModules_.GetTaggedObject())->GetValue(entry)); @@ -164,7 +164,7 @@ JSTaggedValue ModuleManager::GetModuleNamespace(JSTaggedValue localName) { JSTaggedValue currentModule = GetCurrentModule(); if (currentModule.IsUndefined()) { - LOG_ECMA(FATAL) << "GetModuleNamespace currentModule failed"; + LOG_FULL(FATAL) << "GetModuleNamespace currentModule failed"; } JSTaggedValue moduleEnvironment = SourceTextModule::Cast(currentModule.GetTaggedObject())->GetEnvironment(); ASSERT(!moduleEnvironment.IsUndefined()); diff --git a/ecmascript/napi/dfx_jsnapi.cpp b/ecmascript/napi/dfx_jsnapi.cpp index 31efbb03..3ef52654 100644 --- a/ecmascript/napi/dfx_jsnapi.cpp +++ b/ecmascript/napi/dfx_jsnapi.cpp @@ -175,7 +175,7 @@ std::unique_ptr DFXJSNApi::StopCpuProfilerForInfo() CpuProfiler *singleton = CpuProfiler::GetInstance(); auto profile = singleton->StopCpuProfilerForInfo(); if (profile == nullptr) { - LOG(ERROR, DEBUGGER) << "Transfer CpuProfiler::StopCpuProfilerImpl is failure"; + LOG_DEBUGGER(ERROR) << "Transfer CpuProfiler::StopCpuProfilerImpl is failure"; } return profile; } diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index 9113ea64..51ea97c5 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -169,7 +169,7 @@ EcmaVM *JSNApi::CreateEcmaVM(const JSRuntimeOptions &options) } auto config = ecmascript::EcmaParamConfiguration(options.IsWorker(), MemMapAllocator::GetInstance()->GetCapacity()); - LOG(INFO, RUNTIME) << "CreateEcmaVM: isWorker = " << options.IsWorker() << ", vmCount = " << vmCount_; + LOG_ECMA(INFO) << "CreateEcmaVM: isWorker = " << options.IsWorker() << ", vmCount = " << vmCount_; MemMapAllocator::GetInstance()->IncreaseAndCheckReserved(config.GetMaxHeapSize()); return EcmaVM::Create(options, config); } @@ -233,7 +233,7 @@ bool JSNApi::StartDebugger(const char *libraryPath, EcmaVM *vm, bool isDebugMode auto sym = panda::os::library_loader::ResolveSymbol(handle.Value(), "StartDebug"); if (!sym) { - LOG(ERROR, RUNTIME) << sym.Error().ToString(); + LOG_ECMA(ERROR) << sym.Error().ToString(); return false; } @@ -257,7 +257,7 @@ bool JSNApi::StopDebugger(EcmaVM *vm) auto sym = panda::os::library_loader::ResolveSymbol(handle, "StopDebug"); if (!sym) { - LOG(ERROR, RUNTIME) << sym.Error().ToString(); + LOG_ECMA(ERROR) << sym.Error().ToString(); return false; } @@ -359,7 +359,7 @@ uintptr_t JSNApi::ClearWeak(const EcmaVM *vm, uintptr_t localAddress) } if (JSTaggedValue(reinterpret_cast(localAddress)->GetObject()) .IsUndefined()) { - LOG(ERROR, RUNTIME) << "The object of weak reference has been recycled!"; + LOG_ECMA(ERROR) << "The object of weak reference has been recycled!"; return 0; } return vm->GetJSThread()->GetEcmaGlobalStorage()->ClearWeak(localAddress); @@ -1514,7 +1514,7 @@ double DateRef::GetTime() { JSHandle date(JSNApiHelper::ToJSHandle(this)); if (!date->IsDate()) { - LOG(ERROR, RUNTIME) << "Not a Date Object"; + LOG_ECMA(ERROR) << "Not a Date Object"; } return date->GetTime().GetDouble(); } diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 6a8f872e..e7709b6f 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -293,7 +293,7 @@ void ObjectFactory::NewJSArrayBufferData(const JSHandle &array, i auto *pointer = JSNativePointer::Cast(data.GetTaggedObject()); auto newData = vm_->GetNativeAreaAllocator()->AllocateBuffer(length * sizeof(uint8_t)); if (memset_s(newData, length, 0, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } pointer->ResetExternalPointer(newData); @@ -302,7 +302,7 @@ void ObjectFactory::NewJSArrayBufferData(const JSHandle &array, i auto newData = vm_->GetNativeAreaAllocator()->AllocateBuffer(length * sizeof(uint8_t)); if (memset_s(newData, length, 0, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } JSHandle pointer = NewJSNativePointer(newData, NativeAreaAllocator::FreeBufferFunc, @@ -318,7 +318,7 @@ void ObjectFactory::NewJSSharedArrayBufferData(const JSHandle &ar void *newData = nullptr; JSSharedMemoryManager::GetInstance()->CreateOrLoad(&newData, length); if (memset_s(newData, length, 0, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } JSHandle pointer = NewJSNativePointer(newData, JSSharedMemoryManager::RemoveSharedMemory, @@ -337,7 +337,7 @@ JSHandle ObjectFactory::NewJSArrayBuffer(int32_t length) if (length > 0) { auto newData = vm_->GetNativeAreaAllocator()->AllocateBuffer(length); if (memset_s(newData, length, 0, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } JSHandle pointer = NewJSNativePointer(newData, NativeAreaAllocator::FreeBufferFunc, @@ -426,7 +426,7 @@ void ObjectFactory::NewJSRegExpByteCodeData(const JSHandle ®exp, vo auto newBuffer = vm_->GetNativeAreaAllocator()->AllocateBuffer(size); if (memcpy_s(newBuffer, size, buffer, size) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } JSTaggedValue data = regexp->GetByteCodeBuffer(); @@ -2772,7 +2772,7 @@ JSHandle ObjectFactory::NewMachineCodeObject(size_t length, const u thread_->GlobalConstants()->GetMachineCodeClass().GetTaggedObject()), length + MachineCode::SIZE); MachineCode *code = MachineCode::Cast(obj); if (code == nullptr) { - LOG_ECMA(FATAL) << "machine code cast failed"; + LOG_FULL(FATAL) << "machine code cast failed"; UNREACHABLE(); } code->SetInstructionSizeInBytes(static_cast(length)); diff --git a/ecmascript/regexp/regexp_executor.cpp b/ecmascript/regexp/regexp_executor.cpp index aec901aa..a681a6fd 100644 --- a/ecmascript/regexp/regexp_executor.cpp +++ b/ecmascript/regexp/regexp_executor.cpp @@ -43,14 +43,14 @@ bool RegExpExecutor::Execute(const uint8_t *input, uint32_t lastIndex, uint32_t if (captureResultSize != 0) { captureResultList_ = chunk_->NewArray(nCapture_); if (memset_s(captureResultList_, captureResultSize, 0, captureResultSize) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } } if (stackSize != 0) { stack_ = chunk_->NewArray(nStack_); if (memset_s(stack_, stackSize, 0, stackSize) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } } @@ -264,7 +264,7 @@ MatchResult RegExpExecutor::GetResult(const JSThread *thread, bool isSuccess) co uint8_t *dest = buffer.data(); if (memcpy_s(dest, len + 1, reinterpret_cast(captureState->captureStart), len) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } dest[len] = '\0'; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) @@ -298,7 +298,7 @@ void RegExpExecutor::PushRegExpState(StateType type, uint32_t pc) state->currentPtr_ = GetCurrentPtr(); size_t listSize = sizeof(CaptureState) * nCapture_; if (memcpy_s(state->captureResultList_, listSize, GetCaptureResultList(), listSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } uint8_t *stackStart = @@ -307,7 +307,7 @@ void RegExpExecutor::PushRegExpState(StateType type, uint32_t pc) if (stack_ != nullptr) { size_t stackSize = sizeof(uintptr_t) * nStack_; if (memcpy_s(stackStart, stackSize, stack_, stackSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -321,7 +321,7 @@ RegExpState *RegExpExecutor::PopRegExpState(bool copyCaptrue) size_t listSize = sizeof(CaptureState) * nCapture_; if (copyCaptrue) { if (memcpy_s(GetCaptureResultList(), listSize, state->captureResultList_, listSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -333,7 +333,7 @@ RegExpState *RegExpExecutor::PopRegExpState(bool copyCaptrue) if (stack_ != nullptr) { size_t stackSize = sizeof(uintptr_t) * nStack_; if (memcpy_s(stack_, stackSize, stackStart, stackSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -350,7 +350,7 @@ void RegExpExecutor::ReAllocStack(uint32_t stackLen) uint32_t stackByteSize = newStackSize * stateSize_; auto newStack = chunk_->NewArray(stackByteSize); if (memset_s(newStack, stackByteSize, 0, stackByteSize) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; + LOG_FULL(FATAL) << "memset_s failed"; UNREACHABLE(); } if (stateStack_ != nullptr) { diff --git a/ecmascript/regexp/regexp_parser.cpp b/ecmascript/regexp/regexp_parser.cpp index 82305693..e6a3cbb0 100644 --- a/ecmascript/regexp/regexp_parser.cpp +++ b/ecmascript/regexp/regexp_parser.cpp @@ -156,7 +156,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(uint32_t maxValue, uint32_t *va } while (d >= 0) { if (UNLIKELY(x > (std::numeric_limits::max() - static_cast(d)) / HEX_VALUE)) { - LOG_ECMA(FATAL) << "value overflow"; + LOG_FULL(FATAL) << "value overflow"; return false; } x = x * HEX_VALUE + static_cast(d); @@ -441,12 +441,12 @@ void RegExpParser::ParseAlternative(bool isBackward) moveSize, buffer_.buf_ + start, // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) moveSize) != EOK) { - LOG_ECMA(FATAL) << "memmove_s failed"; + LOG_FULL(FATAL) << "memmove_s failed"; UNREACHABLE(); } // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (memcpy_s(buffer_.buf_ + start, termSize, buffer_.buf_ + end, termSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -1398,7 +1398,7 @@ void RegExpParser::ParseError(const char *errorMessage) SetIsError(); size_t length = strlen(errorMessage) + 1; if (memcpy_s(errorMsg_, length, errorMessage, length) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } diff --git a/ecmascript/shared_mm/shared_mm.h b/ecmascript/shared_mm/shared_mm.h index 0479e9c9..1cb62148 100644 --- a/ecmascript/shared_mm/shared_mm.h +++ b/ecmascript/shared_mm/shared_mm.h @@ -17,7 +17,6 @@ #define ECMASCRIPT_SHARED_MEMORY_MANAGER_MANAGER_H #include "ecmascript/mem/c_containers.h" -#include "libpandabase/utils/logger.h" #include "os/mutex.h" namespace panda { diff --git a/ecmascript/snapshot/mem/snapshot.cpp b/ecmascript/snapshot/mem/snapshot.cpp index 479189ba..056a74b3 100644 --- a/ecmascript/snapshot/mem/snapshot.cpp +++ b/ecmascript/snapshot/mem/snapshot.cpp @@ -39,12 +39,12 @@ void Snapshot::Serialize(TaggedObject *objectHeader, const panda_file::File *pf, { std::pair filePath = VerifyFilePath(fileName, true); if (!filePath.first) { - LOG_ECMA(FATAL) << "snapshot file path error"; + LOG_FULL(FATAL) << "snapshot file path error"; } std::fstream writer(fileName.c_str(), std::ios::out | std::ios::binary | std::ios::trunc); if (!writer.good()) { writer.close(); - LOG_ECMA(FATAL) << "snapshot open file failed"; + LOG_FULL(FATAL) << "snapshot open file failed"; } SnapshotProcessor processor(vm_); @@ -67,12 +67,12 @@ void Snapshot::Serialize(uintptr_t startAddr, size_t size, const CString &fileNa { std::pair filePath = VerifyFilePath(fileName, true); if (!filePath.first) { - LOG_ECMA(FATAL) << "snapshot file path error"; + LOG_FULL(FATAL) << "snapshot file path error"; } std::fstream writer(fileName.c_str(), std::ios::out | std::ios::binary | std::ios::trunc); if (!writer.good()) { writer.close(); - LOG_ECMA(FATAL) << "snapshot open file failed"; + LOG_FULL(FATAL) << "snapshot open file failed"; } SnapshotProcessor processor(vm_); @@ -94,7 +94,7 @@ void Snapshot::SerializeBuiltins(const CString &fileName) { std::pair filePath = VerifyFilePath(fileName, true); if (!filePath.first) { - LOG_ECMA(FATAL) << "snapshot file path error"; + LOG_FULL(FATAL) << "snapshot file path error"; } // if builtins.snapshot file has exist, return directly if (!filePath.second.empty()) { @@ -103,7 +103,7 @@ void Snapshot::SerializeBuiltins(const CString &fileName) std::fstream write(fileName.c_str(), std::ios::out | std::ios::binary | std::ios::trunc); if (!write.good()) { write.close(); - LOG_ECMA(FATAL) << "snapshot open file failed"; + LOG_FULL(FATAL) << "snapshot open file failed"; } SnapshotProcessor processor(vm_); @@ -129,17 +129,17 @@ const JSPandaFile *Snapshot::Deserialize(SnapshotType type, const CString &snaps { std::pair filePath = VerifyFilePath(snapshotFile, false); if (!filePath.first) { - LOG_ECMA(FATAL) << "snapshot file path error"; + LOG_FULL(FATAL) << "snapshot file path error"; UNREACHABLE(); } int fd = open(filePath.second.c_str(), O_CLOEXEC); // NOLINT(cppcoreguidelines-pro-type-vararg) if (UNLIKELY(fd == -1)) { - LOG_ECMA(FATAL) << "open file failed"; + LOG_FULL(FATAL) << "open file failed"; UNREACHABLE(); } int32_t file_size = lseek(fd, 0, SEEK_END); if (file_size == -1) { - LOG_ECMA(FATAL) << "lseek failed"; + LOG_FULL(FATAL) << "lseek failed"; UNREACHABLE(); } diff --git a/ecmascript/snapshot/mem/snapshot_processor.cpp b/ecmascript/snapshot/mem/snapshot_processor.cpp index 74baf11d..a1ddf0f9 100644 --- a/ecmascript/snapshot/mem/snapshot_processor.cpp +++ b/ecmascript/snapshot/mem/snapshot_processor.cpp @@ -1107,7 +1107,7 @@ void SnapshotProcessor::DeserializeSpaceObject(uintptr_t beginAddr, Space* space copyBytes, ToVoidPtr(copyFrom), copyBytes) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } @@ -1154,7 +1154,7 @@ void SnapshotProcessor::DeserializeString(uintptr_t stringBegin, uintptr_t strin LOG_ECMA_MEM(FATAL) << "Snapshot Allocate OldLocalSpace OOM"; } if (memcpy_s(ToVoidPtr(newObj), strSize, str, strSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } str = reinterpret_cast(newObj); @@ -1174,7 +1174,7 @@ void SnapshotProcessor::DeserializePandaMethod(uintptr_t begin, uintptr_t end, J pandaMethod_.emplace_back(begin); auto method = reinterpret_cast(begin); if (memcpy_s(methods + (--methodNums), METHOD_SIZE, method, METHOD_SIZE) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } begin += METHOD_SIZE; @@ -1230,7 +1230,7 @@ void SnapshotProcessor::SerializeObject(TaggedObject *objectHeader, CQueueGetObjectType(); uintptr_t snapshotObj = 0; if (UNLIKELY(data->find(ToUintPtr(objectHeader)) == data->end())) { - LOG_ECMA(FATAL) << "Data map can not find object"; + LOG_FULL(FATAL) << "Data map can not find object"; UNREACHABLE(); } else { snapshotObj = data->find(ToUintPtr(objectHeader))->second.first; @@ -1443,7 +1443,7 @@ EncodeBit SnapshotProcessor::NativePointerToEncodeBit(void *nativePointer) index = SearchNativeMethodIndex(nativePointer); } - LOG_IF(index > Constants::MAX_C_POINTER_INDEX, FATAL, RUNTIME) << "MAX_C_POINTER_INDEX: " + ToCString(index); + LOG_ECMA_IF(index > Constants::MAX_C_POINTER_INDEX, FATAL) << "MAX_C_POINTER_INDEX: " << index; native.SetNativePointerOrObjectIndex(index); } return native; @@ -1481,7 +1481,7 @@ size_t SnapshotProcessor::SearchNativeMethodIndex(void *nativePointer) } } - LOG_ECMA(FATAL) << "native method did not register in g_table, please register it first"; + LOG_FULL(FATAL) << "native method did not register in g_table, please register it first"; UNREACHABLE(); } @@ -1494,7 +1494,7 @@ uintptr_t SnapshotProcessor::TaggedObjectEncodeBitToAddr(EncodeBit taggedBit) } size_t regionIndex = taggedBit.GetRegionIndex(); if (UNLIKELY(regionIndexMap_.find(regionIndex) == regionIndexMap_.end())) { - LOG_ECMA(FATAL) << "Snapshot deserialize can not find region by index"; + LOG_FULL(FATAL) << "Snapshot deserialize can not find region by index"; } Region *region = regionIndexMap_.find(regionIndex)->second; size_t objectOffset = taggedBit.GetObjectOffsetInRegion(); @@ -1526,7 +1526,7 @@ void SnapshotProcessor::SerializePandaFileMethod() // panda method space begin uintptr_t snapshotObj = factory->NewSpaceBySnapshotAllocator(sizeof(uint64_t)); if (snapshotObj == 0) { - LOG(ERROR, RUNTIME) << "SnapshotAllocator OOM"; + LOG_ECMA(ERROR) << "SnapshotAllocator OOM"; return; } SetObjectEncodeField(snapshotObj, 0, encodeBit.GetValue()); // methods @@ -1537,11 +1537,11 @@ void SnapshotProcessor::SerializePandaFileMethod() size_t methodObjSize = METHOD_SIZE; uintptr_t methodObj = factory->NewSpaceBySnapshotAllocator(methodObjSize); if (methodObj == 0) { - LOG(ERROR, RUNTIME) << "SnapshotAllocator OOM"; + LOG_ECMA(ERROR) << "SnapshotAllocator OOM"; return; } if (memcpy_s(ToVoidPtr(methodObj), methodObjSize, ToVoidPtr(it), METHOD_SIZE) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } } @@ -1600,7 +1600,7 @@ EncodeBit SnapshotProcessor::EncodeTaggedObject(TaggedObject *objectHeader, CQue LOG_ECMA_MEM(FATAL) << "Snapshot Allocate OOM"; } if (memcpy_s(ToVoidPtr(newObj), objectSize, objectHeader, objectSize) != EOK) { - LOG_ECMA(FATAL) << "memcpy_s failed"; + LOG_FULL(FATAL) << "memcpy_s failed"; UNREACHABLE(); } auto currentRegion = Region::ObjectAddressToRange(newObj); diff --git a/ecmascript/tests/dump_test.cpp b/ecmascript/tests/dump_test.cpp index 1b7babdb..0be27c16 100644 --- a/ecmascript/tests/dump_test.cpp +++ b/ecmascript/tests/dump_test.cpp @@ -116,6 +116,11 @@ using namespace panda::ecmascript; using namespace panda::ecmascript::base; +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define CHECK_DUMP_FIELDS(begin, end, num); \ + LOG_ECMA_IF((num) != ((end) - (begin)) / JSTaggedValue::TaggedTypeSize(), FATAL) \ + << "Fields in obj are not in dump list. " + namespace panda::test { class EcmaDumpTest : public testing::Test { public: @@ -384,33 +389,33 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) case JSType::JS_ARGUMENTS: case JSType::JS_SYNTAX_ERROR: case JSType::JS_OBJECT: { - CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U) + CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U); JSHandle jsObj = NewJSObject(thread, factory, globalEnv); DUMP_FOR_HANDLE(jsObj) break; } case JSType::JS_REALM: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSRealm::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSRealm::SIZE, 2U); JSHandle jsRealm = factory->NewJSRealm(); DUMP_FOR_HANDLE(jsRealm) break; } case JSType::JS_FUNCTION_BASE: { #ifdef PANDA_TARGET_64 - CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 2U); #else - CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 1U); #endif break; } case JSType::JS_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 8U) + CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 8U); JSHandle jsFunc = globalEnv->GetFunctionFunction(); DUMP_FOR_HANDLE(jsFunc) break; } case JSType::JS_PROXY_REVOC_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSProxyRevocFunction::SIZE, 1U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSProxyRevocFunction::SIZE, 1U); JSHandle proxyRevocClass = JSHandle::Cast(globalEnv->GetProxyRevocFunctionClass()); JSHandle proxyRevocFunc = factory->NewJSObjectWithInit(proxyRevocClass); @@ -418,7 +423,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_REACTIONS_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseReactionsFunction::SIZE, 2U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseReactionsFunction::SIZE, 2U); JSHandle promiseReactClass = JSHandle::Cast(globalEnv->GetPromiseReactionFunctionClass()); JSHandle promiseReactFunc = factory->NewJSObjectWithInit(promiseReactClass); @@ -426,7 +431,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_EXECUTOR_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseExecutorFunction::SIZE, 1U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseExecutorFunction::SIZE, 1U); JSHandle promiseExeClass = JSHandle::Cast(globalEnv->GetPromiseExecutorFunctionClass()); JSHandle promiseExeFunc = factory->NewJSObjectWithInit(promiseExeClass); @@ -434,7 +439,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllResolveElementFunction::SIZE, 5U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllResolveElementFunction::SIZE, 5U); JSHandle promiseAllClass = JSHandle::Cast(globalEnv->GetPromiseAllResolveElementFunctionClass()); JSHandle promiseAllFunc = factory->NewJSObjectWithInit(promiseAllClass); @@ -442,7 +447,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAnyRejectElementFunction::SIZE, 5U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAnyRejectElementFunction::SIZE, 5U); JSHandle promiseAnyClass = JSHandle::Cast(globalEnv->GetPromiseAnyRejectElementFunctionClass()); JSHandle promiseAnyFunc = factory->NewJSObjectWithInit(promiseAnyClass); @@ -450,7 +455,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllSettledElementFunction::SIZE, 5U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllSettledElementFunction::SIZE, 5U); JSHandle promiseAllSettledClass = JSHandle::Cast(globalEnv->GetPromiseAllSettledElementFunctionClass()); JSHandle promiseAllSettledFunc = factory->NewJSObjectWithInit(promiseAllSettledClass); @@ -458,7 +463,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_FINALLY_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseFinallyFunction::SIZE, 2U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseFinallyFunction::SIZE, 2U); JSHandle promiseFinallyClass = JSHandle::Cast(globalEnv->GetPromiseFinallyFunctionClass()); JSHandle promiseFinallyFunc = factory->NewJSObjectWithInit(promiseFinallyClass); @@ -466,7 +471,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseValueThunkOrThrowerFunction::SIZE, 1U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseValueThunkOrThrowerFunction::SIZE, 1U); JSHandle promiseValueClass = JSHandle::Cast(globalEnv->GetPromiseValueThunkOrThrowerFunctionClass()); JSHandle promiseValueFunc = factory->NewJSObjectWithInit(promiseValueClass); @@ -474,51 +479,51 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_GENERATOR_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSGeneratorFunction::SIZE, 0U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSGeneratorFunction::SIZE, 0U); break; } case JSType::JS_ASYNC_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFunction::SIZE, 0U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFunction::SIZE, 0U); break; } case JSType::JS_INTL_BOUND_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSIntlBoundFunction::SIZE, 3U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSIntlBoundFunction::SIZE, 3U); JSHandle intlBoundFunc = factory->NewJSIntlBoundFunction( MethodIndex::BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER); DUMP_FOR_HANDLE(intlBoundFunc) break; } case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncAwaitStatusFunction::SIZE, 1U) + CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncAwaitStatusFunction::SIZE, 1U); JSHandle asyncAwaitFunc = factory->NewJSAsyncAwaitStatusFunction( MethodIndex::BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED); DUMP_FOR_HANDLE(asyncAwaitFunc) break; } case JSType::JS_BOUND_FUNCTION: { - CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSBoundFunction::SIZE, 3U) + CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSBoundFunction::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSBoundFunction, JS_BOUND_FUNCTION) break; } case JSType::JS_REG_EXP: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExp::SIZE, 5U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExp::SIZE, 5U); NEW_OBJECT_AND_DUMP(JSRegExp, JS_REG_EXP) break; } case JSType::JS_SET: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSSet::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSSet::SIZE, 1U); JSHandle jsSet = NewJSSet(thread, factory, proto); DUMP_FOR_HANDLE(jsSet) break; } case JSType::JS_MAP: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSMap::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSMap::SIZE, 1U); JSHandle jsMap = NewJSMap(thread, factory, proto); DUMP_FOR_HANDLE(jsMap) break; } case JSType::JS_WEAK_MAP: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakMap::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakMap::SIZE, 1U); JSHandle weakMapClass = factory->NewEcmaDynClass(JSWeakMap::SIZE, JSType::JS_WEAK_MAP, proto); JSHandle jsWeakMap = JSHandle::Cast(factory->NewJSObjectWithInit(weakMapClass)); JSHandle weakLinkedMap(LinkedHashMap::Create(thread)); @@ -527,7 +532,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_WEAK_SET: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakSet::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakSet::SIZE, 1U); JSHandle weakSetClass = factory->NewEcmaDynClass(JSWeakSet::SIZE, JSType::JS_WEAK_SET, proto); JSHandle jsWeakSet = JSHandle::Cast(factory->NewJSObjectWithInit(weakSetClass)); JSHandle weakLinkedSet(LinkedHashSet::Create(thread)); @@ -536,7 +541,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_WEAK_REF: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakRef::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakRef::SIZE, 1U); JSHandle weakRefClass = factory->NewEcmaDynClass(JSWeakRef::SIZE, JSType::JS_WEAK_REF, proto); JSHandle jsWeakRef = JSHandle::Cast(factory->NewJSObjectWithInit(weakRefClass)); jsWeakRef->SetWeakObject(thread, JSTaggedValue::Undefined()); @@ -544,7 +549,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_FINALIZATION_REGISTRY: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSFinalizationRegistry::SIZE, 5U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSFinalizationRegistry::SIZE, 5U); JSHandle finalizationRegistryClass = factory->NewEcmaDynClass(JSFinalizationRegistry::SIZE, JSType::JS_FINALIZATION_REGISTRY, proto); JSHandle jsFinalizationRegistry = @@ -555,13 +560,13 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::CELL_RECORD: { - CHECK_DUMP_FIELDS(Record::SIZE, CellRecord::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, CellRecord::SIZE, 2U); JSHandle cellRecord = factory->NewCellRecord(); DUMP_FOR_HANDLE(cellRecord) break; } case JSType::JS_DATE: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSDate::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSDate::SIZE, 2U); JSHandle dateClass = factory->NewEcmaDynClass(JSDate::SIZE, JSType::JS_DATE, proto); JSHandle date = JSHandle::Cast(factory->NewJSObjectWithInit(dateClass)); date->SetTimeValue(thread, JSTaggedValue(0.0)); @@ -570,28 +575,28 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_FORIN_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 4U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 4U); JSHandle array(thread, factory->NewJSArray().GetTaggedValue()); JSHandle forInIter = factory->NewJSForinIterator(array); DUMP_FOR_HANDLE(forInIter) break; } case JSType::JS_MAP_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSMapIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSMapIterator::SIZE, 2U); JSHandle jsMapIter = factory->NewJSMapIterator(NewJSMap(thread, factory, proto), IterationKind::KEY); DUMP_FOR_HANDLE(jsMapIter) break; } case JSType::JS_SET_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSSetIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSSetIterator::SIZE, 2U); JSHandle jsSetIter = factory->NewJSSetIterator(NewJSSet(thread, factory, proto), IterationKind::KEY); DUMP_FOR_HANDLE(jsSetIter) break; } case JSType::JS_REG_EXP_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExpIterator::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExpIterator::SIZE, 3U); JSHandle emptyString(thread->GlobalConstants()->GetHandledEmptyString()); JSHandle jsRegExp(NewJSRegExp(thread, factory, proto)); JSHandle jsRegExpIter = @@ -600,92 +605,92 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_ARRAY_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U); JSHandle arrayIter = factory->NewJSArrayIterator(JSHandle::Cast(factory->NewJSArray()), IterationKind::KEY); DUMP_FOR_HANDLE(arrayIter) break; } case JSType::JS_STRING_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSStringIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSStringIterator::SIZE, 2U); JSHandle stringIter = globalEnv->GetStringIterator(); DUMP_FOR_HANDLE(stringIter) break; } case JSType::JS_INTL: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSIntl::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSIntl::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSIntl, JS_INTL) break; } case JSType::JS_LOCALE: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSLocale::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSLocale::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSLocale, JS_LOCALE) break; } case JSType::JS_DATE_TIME_FORMAT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSDateTimeFormat::SIZE, 9U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSDateTimeFormat::SIZE, 9U); NEW_OBJECT_AND_DUMP(JSDateTimeFormat, JS_DATE_TIME_FORMAT) break; } case JSType::JS_RELATIVE_TIME_FORMAT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSRelativeTimeFormat::SIZE, 6U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSRelativeTimeFormat::SIZE, 6U); NEW_OBJECT_AND_DUMP(JSRelativeTimeFormat, JS_RELATIVE_TIME_FORMAT) break; } case JSType::JS_NUMBER_FORMAT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSNumberFormat::SIZE, 13U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSNumberFormat::SIZE, 13U); NEW_OBJECT_AND_DUMP(JSNumberFormat, JS_NUMBER_FORMAT) break; } case JSType::JS_COLLATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSCollator::SIZE, 5U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSCollator::SIZE, 5U); NEW_OBJECT_AND_DUMP(JSCollator, JS_COLLATOR) break; } case JSType::JS_PLURAL_RULES: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSPluralRules::SIZE, 10U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSPluralRules::SIZE, 10U); NEW_OBJECT_AND_DUMP(JSPluralRules, JS_PLURAL_RULES) break; } case JSType::JS_DISPLAYNAMES: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSDisplayNames::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSDisplayNames::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSDisplayNames, JS_DISPLAYNAMES) break; } case JSType::JS_LIST_FORMAT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSListFormat::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSListFormat::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSListFormat, JS_LIST_FORMAT) break; } case JSType::JS_SHARED_ARRAY_BUFFER: case JSType::JS_ARRAY_BUFFER: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayBuffer::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayBuffer::SIZE, 2U); NEW_OBJECT_AND_DUMP(JSArrayBuffer, JS_ARRAY_BUFFER) break; } case JSType::JS_PROMISE: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSPromise::SIZE, 4U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSPromise::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSPromise, JS_PROMISE) break; } case JSType::JS_DATA_VIEW: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSDataView::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSDataView::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSDataView, JS_DATA_VIEW) break; } case JSType::JS_GENERATOR_OBJECT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSGeneratorObject, JS_GENERATOR_OBJECT) break; } case JSType::JS_ASYNC_FUNC_OBJECT: { - CHECK_DUMP_FIELDS(JSGeneratorObject::SIZE, JSAsyncFuncObject::SIZE, 1U) + CHECK_DUMP_FIELDS(JSGeneratorObject::SIZE, JSAsyncFuncObject::SIZE, 1U); JSHandle asyncFuncObject = factory->NewJSAsyncFuncObject(); DUMP_FOR_HANDLE(asyncFuncObject) break; } case JSType::JS_ARRAY: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 1U); JSHandle jsArray = factory->NewJSArray(); DUMP_FOR_HANDLE(jsArray) break; @@ -702,30 +707,30 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) case JSType::JS_FLOAT64_ARRAY: case JSType::JS_BIGINT64_ARRAY: case JSType::JS_BIGUINT64_ARRAY: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSTypedArray::SIZE, 4U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSTypedArray::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSTypedArray, JS_TYPED_ARRAY) break; } case JSType::JS_PRIMITIVE_REF: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSPrimitiveRef::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSPrimitiveRef::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSPrimitiveRef, JS_PRIMITIVE_REF) break; } case JSType::JS_GLOBAL_OBJECT: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSGlobalObject::SIZE, 0U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSGlobalObject::SIZE, 0U); JSHandle globalObject = globalEnv->GetJSGlobalObject(); DUMP_FOR_HANDLE(globalObject) break; } case JSType::JS_PROXY: { - CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSProxy::SIZE, 3U) + CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSProxy::SIZE, 3U); JSHandle emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle proxy = factory->NewJSProxy(emptyObj, emptyObj); DUMP_FOR_HANDLE(proxy) break; } case JSType::HCLASS: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSHClass::SIZE, 7U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSHClass::SIZE, 7U); JSHandle hclass = factory->NewEcmaDynClass(JSHClass::SIZE, JSType::HCLASS, proto); DUMP_FOR_HANDLE(hclass) break; @@ -754,49 +759,49 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::ACCESSOR_DATA: case JSType::INTERNAL_ACCESSOR: { - CHECK_DUMP_FIELDS(Record::SIZE, AccessorData::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, AccessorData::SIZE, 2U); JSHandle accessor = factory->NewAccessorData(); DUMP_FOR_HANDLE(accessor) break; } case JSType::SYMBOL: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSSymbol::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSSymbol::SIZE, 2U); JSHandle symbol = factory->NewJSSymbol(); DUMP_FOR_HANDLE(symbol) break; } case JSType::JS_GENERATOR_CONTEXT: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), GeneratorContext::SIZE, 6U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), GeneratorContext::SIZE, 6U); JSHandle genContext = factory->NewGeneratorContext(); DUMP_FOR_HANDLE(genContext) break; } case JSType::PROTOTYPE_HANDLER: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PrototypeHandler::SIZE, 3U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PrototypeHandler::SIZE, 3U); JSHandle protoHandler = factory->NewPrototypeHandler(); DUMP_FOR_HANDLE(protoHandler) break; } case JSType::TRANSITION_HANDLER: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransitionHandler::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransitionHandler::SIZE, 2U); JSHandle transitionHandler = factory->NewTransitionHandler(); DUMP_FOR_HANDLE(transitionHandler) break; } case JSType::PROPERTY_BOX: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PropertyBox::SIZE, 1U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PropertyBox::SIZE, 1U); JSHandle PropertyBox = factory->NewPropertyBox(globalConst->GetHandledEmptyArray()); DUMP_FOR_HANDLE(PropertyBox) break; } case JSType::PROTO_CHANGE_MARKER: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeMarker::SIZE, 1U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeMarker::SIZE, 1U); JSHandle protoMaker = factory->NewProtoChangeMarker(); DUMP_FOR_HANDLE(protoMaker) break; } case JSType::PROTOTYPE_INFO: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeDetails::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeDetails::SIZE, 2U); JSHandle protoDetails = factory->NewProtoChangeDetails(); DUMP_FOR_HANDLE(protoDetails) break; @@ -807,53 +812,53 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::PROGRAM: { - CHECK_DUMP_FIELDS(ECMAObject::SIZE, Program::SIZE, 1U) + CHECK_DUMP_FIELDS(ECMAObject::SIZE, Program::SIZE, 1U); JSHandle program = factory->NewProgram(); DUMP_FOR_HANDLE(program) break; } case JSType::PROMISE_CAPABILITY: { - CHECK_DUMP_FIELDS(Record::SIZE, PromiseCapability::SIZE, 3U) + CHECK_DUMP_FIELDS(Record::SIZE, PromiseCapability::SIZE, 3U); JSHandle promiseCapa = factory->NewPromiseCapability(); DUMP_FOR_HANDLE(promiseCapa) break; } case JSType::PROMISE_RECORD: { - CHECK_DUMP_FIELDS(Record::SIZE, PromiseRecord::SIZE, 1U) + CHECK_DUMP_FIELDS(Record::SIZE, PromiseRecord::SIZE, 1U); JSHandle promiseRecord = factory->NewPromiseRecord(); DUMP_FOR_HANDLE(promiseRecord) break; } case JSType::RESOLVING_FUNCTIONS_RECORD: { - CHECK_DUMP_FIELDS(Record::SIZE, ResolvingFunctionsRecord::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, ResolvingFunctionsRecord::SIZE, 2U); JSHandle ResolvingFunc = factory->NewResolvingFunctionsRecord(); DUMP_FOR_HANDLE(ResolvingFunc) break; } case JSType::PROMISE_REACTIONS: { - CHECK_DUMP_FIELDS(Record::SIZE, PromiseReaction::SIZE, 3U) + CHECK_DUMP_FIELDS(Record::SIZE, PromiseReaction::SIZE, 3U); JSHandle promiseReact = factory->NewPromiseReaction(); DUMP_FOR_HANDLE(promiseReact) break; } case JSType::PROMISE_ITERATOR_RECORD: { - CHECK_DUMP_FIELDS(Record::SIZE, PromiseIteratorRecord::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, PromiseIteratorRecord::SIZE, 2U); JSHandle emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle promiseIter = factory->NewPromiseIteratorRecord(emptyObj, false); DUMP_FOR_HANDLE(promiseIter) break; } case JSType::MICRO_JOB_QUEUE: { - CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::MicroJobQueue::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::MicroJobQueue::SIZE, 2U); JSHandle microJob = factory->NewMicroJobQueue(); DUMP_FOR_HANDLE(microJob) break; } case JSType::PENDING_JOB: { #if defined(ENABLE_HITRACE) - CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 6U) + CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 6U); #else - CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 2U); #endif JSHandle pendingClass(thread, JSHClass::Cast(globalConst->GetPendingJobClass().GetTaggedObject())); @@ -864,99 +869,99 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::COMPLETION_RECORD: { - CHECK_DUMP_FIELDS(Record::SIZE, CompletionRecord::SIZE, 2U) + CHECK_DUMP_FIELDS(Record::SIZE, CompletionRecord::SIZE, 2U); JSHandle comRecord = factory->NewCompletionRecord(CompletionRecordType::NORMAL, globalConst->GetHandledEmptyArray()); DUMP_FOR_HANDLE(comRecord) break; } case JSType::MACHINE_CODE_OBJECT: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MachineCode::DATA_OFFSET, 1U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MachineCode::DATA_OFFSET, 1U); JSHandle machineCode = factory->NewMachineCodeObject(16, nullptr); DUMP_FOR_HANDLE(machineCode) break; } case JSType::CLASS_INFO_EXTRACTOR: { #ifdef PANDA_TARGET_64 - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 10U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 10U); #else - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 9U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 9U); #endif JSHandle classInfoExtractor = factory->NewClassInfoExtractor(nullptr); DUMP_FOR_HANDLE(classInfoExtractor) break; } case JSType::TS_OBJECT_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSObjectType::SIZE, 3U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSObjectType::SIZE, 3U); JSHandle objectType = factory->NewTSObjectType(0); DUMP_FOR_HANDLE(objectType) break; } case JSType::TS_CLASS_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSClassType::SIZE, 5U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSClassType::SIZE, 5U); JSHandle classType = factory->NewTSClassType(); DUMP_FOR_HANDLE(classType) break; } case JSType::TS_INTERFACE_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSInterfaceType::SIZE, 3U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSInterfaceType::SIZE, 3U); JSHandle interfaceType = factory->NewTSInterfaceType(); DUMP_FOR_HANDLE(interfaceType) break; } case JSType::TS_IMPORT_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSImportType::SIZE, 3U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSImportType::SIZE, 3U); JSHandle importType = factory->NewTSImportType(); DUMP_FOR_HANDLE(importType) break; } case JSType::TS_CLASS_INSTANCE_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSClassInstanceType::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSClassInstanceType::SIZE, 2U); JSHandle classInstanceType = factory->NewTSClassInstanceType(); DUMP_FOR_HANDLE(classInstanceType) break; } case JSType::TS_UNION_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSUnionType::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSUnionType::SIZE, 2U); JSHandle unionType = factory->NewTSUnionType(1); DUMP_FOR_HANDLE(unionType) break; } case JSType::TS_FUNCTION_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSFunctionType::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSFunctionType::SIZE, 2U); JSHandle functionType = factory->NewTSFunctionType(1); DUMP_FOR_HANDLE(functionType) break; } case JSType::TS_ARRAY_TYPE: { - CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSArrayType::SIZE, 2U) + CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TSArrayType::SIZE, 2U); JSHandle arrayType = factory->NewTSArrayType(); DUMP_FOR_HANDLE(arrayType) break; } case JSType::JS_API_ARRAY_LIST: { // 1 : 1 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayList::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayList::SIZE, 1U); JSHandle jsArrayList = NewJSAPIArrayList(thread, factory, proto); DUMP_FOR_HANDLE(jsArrayList) break; } case JSType::JS_API_ARRAYLIST_ITERATOR: { // 2 : 2 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayListIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayListIterator::SIZE, 2U); JSHandle jsArrayList = NewJSAPIArrayList(thread, factory, proto); JSHandle jsArrayListIter = factory->NewJSAPIArrayListIterator(jsArrayList); DUMP_FOR_HANDLE(jsArrayListIter) break; } case JSType::JS_API_LIGHT_WEIGHT_MAP: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMap::SIZE, 4U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMap::SIZE, 4U); JSHandle jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory); DUMP_FOR_HANDLE(jSAPILightWeightMap) break; } case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMapIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMapIterator::SIZE, 2U); JSHandle jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory); JSHandle jSAPILightWeightMapIterator = factory->NewJSAPILightWeightMapIterator(jSAPILightWeightMap, IterationKind::KEY); @@ -964,13 +969,13 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_API_LIGHT_WEIGHT_SET: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSet::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSet::SIZE, 3U); JSHandle jSAPILightWeightSet = NewJSAPILightWeightSet(thread, factory); DUMP_FOR_HANDLE(jSAPILightWeightSet) break; } case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSetIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSetIterator::SIZE, 2U); JSHandle jSAPILightWeightSetIter = factory->NewJSAPILightWeightSetIterator(NewJSAPILightWeightSet(thread, factory), IterationKind::KEY); @@ -979,14 +984,14 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::JS_API_QUEUE: { // 2 : 2 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueue::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueue::SIZE, 2U); JSHandle jsQueue = NewJSAPIQueue(thread, factory, proto); DUMP_FOR_HANDLE(jsQueue) break; } case JSType::JS_API_QUEUE_ITERATOR: { // 2 : 2 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueueIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueueIterator::SIZE, 2U); JSHandle jsQueue = NewJSAPIQueue(thread, factory, proto); JSHandle jsQueueIter = factory->NewJSAPIQueueIterator(jsQueue); @@ -994,13 +999,13 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_API_PLAIN_ARRAY: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArray::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArray::SIZE, 3U); JSHandle jSAPIPlainArray = NewJSAPIPlainArray(thread, factory); DUMP_FOR_HANDLE(jSAPIPlainArray) break; } case JSType::JS_API_PLAIN_ARRAY_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArrayIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArrayIterator::SIZE, 2U); JSHandle jSAPIPlainArray = NewJSAPIPlainArray(thread, factory); JSHandle jSAPIPlainArrayIter = factory->NewJSAPIPlainArrayIterator(jSAPIPlainArray, IterationKind::KEY); @@ -1009,21 +1014,21 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::JS_API_TREE_MAP: { // 1 : 1 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMap::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMap::SIZE, 1U); JSHandle jsTreeMap = NewJSAPITreeMap(thread, factory); DUMP_FOR_HANDLE(jsTreeMap) break; } case JSType::JS_API_TREE_SET: { // 1 : 1 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSet::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSet::SIZE, 1U); JSHandle jsTreeSet = NewJSAPITreeSet(thread, factory); DUMP_FOR_HANDLE(jsTreeSet) break; } case JSType::JS_API_TREEMAP_ITERATOR: { // 3 : 3 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMapIterator::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMapIterator::SIZE, 3U); JSHandle jsTreeMap = NewJSAPITreeMap(thread, factory); JSHandle jsTreeMapIter = factory->NewJSAPITreeMapIterator(jsTreeMap, IterationKind::KEY); @@ -1032,7 +1037,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::JS_API_TREESET_ITERATOR: { // 3 : 3 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSetIterator::SIZE, 3U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSetIterator::SIZE, 3U); JSHandle jsTreeSet = NewJSAPITreeSet(thread, factory); JSHandle jsTreeSetIter = factory->NewJSAPITreeSetIterator(jsTreeSet, IterationKind::KEY); @@ -1040,39 +1045,39 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) break; } case JSType::JS_API_DEQUE: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDeque::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDeque::SIZE, 1U); JSHandle jsDeque = NewJSAPIDeque(thread, factory, proto); DUMP_FOR_HANDLE(jsDeque) break; } case JSType::JS_API_DEQUE_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDequeIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDequeIterator::SIZE, 2U); JSHandle jsDequeIter = factory->NewJSAPIDequeIterator(NewJSAPIDeque(thread, factory, proto)); DUMP_FOR_HANDLE(jsDequeIter) break; } case JSType::JS_API_STACK: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStack::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStack::SIZE, 1U); JSHandle jsStack = NewJSAPIStack(factory, proto); DUMP_FOR_HANDLE(jsStack) break; } case JSType::JS_API_STACK_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStackIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStackIterator::SIZE, 2U); JSHandle jsStackIter = factory->NewJSAPIStackIterator(NewJSAPIStack(factory, proto)); DUMP_FOR_HANDLE(jsStackIter) break; } case JSType::JS_API_VECTOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVector::SIZE, 1) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVector::SIZE, 1); JSHandle jsVector = NewJSAPIVector(factory, proto); DUMP_FOR_HANDLE(jsVector) break; } case JSType::JS_API_VECTOR_ITERATOR: { - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVectorIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVectorIterator::SIZE, 2U); JSHandle jsVectorIter = factory->NewJSAPIVectorIterator(NewJSAPIVector(factory, proto)); DUMP_FOR_HANDLE(jsVectorIter) @@ -1080,21 +1085,21 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::JS_API_LIST: { // 1 : 1 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIList::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIList::SIZE, 1U); JSHandle jsAPIList = NewJSAPIList(thread, factory); DUMP_FOR_HANDLE(jsAPIList) break; } case JSType::JS_API_LINKED_LIST: { // 1 : 1 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedList::SIZE, 1U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedList::SIZE, 1U); JSHandle jsAPILinkedList = NewJSAPILinkedList(thread, factory); DUMP_FOR_HANDLE(jsAPILinkedList) break; } case JSType::JS_API_LIST_ITERATOR: { // 2 : 2 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U); JSHandle jsAPIList = NewJSAPIList(thread, factory); JSHandle jsAPIListIter = factory->NewJSAPIListIterator(jsAPIList); DUMP_FOR_HANDLE(jsAPIListIter) @@ -1102,7 +1107,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) } case JSType::JS_API_LINKED_LIST_ITERATOR: { // 2 : 2 dump fileds number - CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U) + CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U); JSHandle jsAPILinkedList = NewJSAPILinkedList(thread, factory); JSHandle jsAPILinkedListIter = factory->NewJSAPILinkedListIterator(jsAPILinkedList); diff --git a/ecmascript/tests/js_api_lightweightset_test.cpp b/ecmascript/tests/js_api_lightweightset_test.cpp index 5ef578c4..27729a3d 100644 --- a/ecmascript/tests/js_api_lightweightset_test.cpp +++ b/ecmascript/tests/js_api_lightweightset_test.cpp @@ -168,7 +168,7 @@ HWTEST_F_L0(JSAPILightWeightSetTest, EqualClearNotEqual) for (uint32_t i = 0; i < NODE_NUMBERS; i++) { std::string iValue = myValue2 + std::to_string(i); if (i == 2) { - LOG(ERROR, RUNTIME) << " {} " << iValue; + LOG_ECMA(ERROR) << " {} " << iValue; } else { value2.Update(factory->NewFromStdString(iValue).GetTaggedValue()); result = JSAPILightWeightSet::Add(thread, equalLws, value2); diff --git a/ecmascript/tests/js_array_buffer_test.cpp b/ecmascript/tests/js_array_buffer_test.cpp index 96361e87..bcf8e76f 100644 --- a/ecmascript/tests/js_array_buffer_test.cpp +++ b/ecmascript/tests/js_array_buffer_test.cpp @@ -64,7 +64,6 @@ HWTEST_F_L0(JsArrayBufferTest, CopyDataBlockBytes) JSHandle toNativePointer = factory->NewJSNativePointer(toBuffer, nullptr, nullptr); uint8_t *data = static_cast(vm->GetNativeAreaAllocator()->AllocateBuffer(length)); if (memset_s(data, length, value, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; UNREACHABLE(); } void *formBuffer = vm->GetNativeAreaAllocator()->AllocateBuffer(length); @@ -98,7 +97,6 @@ HWTEST_F_L0(JsArrayBufferTest, Attach_Detach_IsDetach) void *buffer = vm->GetNativeAreaAllocator()->AllocateBuffer(100); uint8_t *data = static_cast(vm->GetNativeAreaAllocator()->AllocateBuffer(length)); if (memset_s(data, length, value, length) != EOK) { - LOG_ECMA(FATAL) << "memset_s failed"; UNREACHABLE(); } JSHandle nativePointer = diff --git a/ecmascript/tooling/BUILD.gn b/ecmascript/tooling/BUILD.gn index 675e67fb..23411433 100644 --- a/ecmascript/tooling/BUILD.gn +++ b/ecmascript/tooling/BUILD.gn @@ -58,6 +58,14 @@ source_set("libark_ecma_debugger_set") { "//third_party/cJSON:cjson_static", ] + if (is_ohos && is_standard_system) { + if (enable_hilog) { + defines = [ "ENABLE_HILOG" ] + include_dirs = + [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ] + } + } + cflags_cc = [ "-fvisibility=hidden" ] } @@ -69,6 +77,12 @@ ohos_shared_library("libark_ecma_debugger") { install_enable = true + if (is_ohos && is_standard_system) { + if (enable_hilog) { + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + } + } + output_extension = "so" if (!is_standard_system) { relative_install_dir = "ark" @@ -84,6 +98,14 @@ source_set("libark_ecma_debugger_test_set") { defines = [ "DEBUGGER_TEST" ] + if (is_ohos && is_standard_system) { + if (enable_hilog) { + defines += [ "ENABLE_HILOG" ] + include_dirs = + [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ] + } + } + deps = [ "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", @@ -98,11 +120,8 @@ ohos_shared_library("libark_ecma_debugger_test") { ] if (is_ohos && is_standard_system) { - if (build_public_version) { - external_deps = [ - "hitrace_native:hitrace_meter", - "hitrace_native:libhitrace", - ] + if (enable_hilog) { + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] } } diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index 7c8f4a77..171f73a5 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -26,7 +26,6 @@ #include "ecmascript/tooling/backend/debugger_executor.h" #include "ecmascript/tooling/dispatcher.h" #include "ecmascript/tooling/protocol_handler.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript::tooling { using namespace boost::beast::detail; @@ -63,7 +62,7 @@ DebuggerImpl::~DebuggerImpl() bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &fileName) { if (fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) { - LOG(WARNING, DEBUGGER) << "NotifyScriptParsed: unsupport file: " << fileName; + LOG_DEBUGGER(WARN) << "NotifyScriptParsed: unsupport file: " << fileName; return false; } @@ -71,7 +70,7 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file return true; }; if (MatchScripts(scriptFunc, fileName, ScriptMatchType::FILE_NAME)) { - LOG(WARNING, DEBUGGER) << "NotifyScriptParsed: already loaded: " << fileName; + LOG_DEBUGGER(WARN) << "NotifyScriptParsed: already loaded: " << fileName; return false; } const JSPandaFile *jsPandaFile = nullptr; @@ -84,13 +83,13 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file return true; }); if (jsPandaFile == nullptr) { - LOG(ERROR, DEBUGGER) << "NotifyScriptParsed: unknown file: " << fileName; + LOG_DEBUGGER(ERROR) << "NotifyScriptParsed: unknown file: " << fileName; return false; } JSPtExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "NotifyScriptParsed: Unsupported file: " << fileName; + LOG_DEBUGGER(ERROR) << "NotifyScriptParsed: Unsupported file: " << fileName; return false; } @@ -99,7 +98,7 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file const std::string &url = extractor->GetSourceFile(mainMethodIndex); const uint32_t MIN_SOURCE_CODE_LENGTH = 5; // maybe return 'ANDA' when source code is empty if (source.size() < MIN_SOURCE_CODE_LENGTH) { - LOG(ERROR, DEBUGGER) << "NotifyScriptParsed: invalid file: " << fileName; + LOG_DEBUGGER(ERROR) << "NotifyScriptParsed: invalid file: " << fileName; return false; } // store here for performance of get extractor from url @@ -122,7 +121,7 @@ bool DebuggerImpl::NotifySingleStep(const JSPtLocation &location) return false; } pauseOnNextByteCode_ = false; - LOG(INFO, DEBUGGER) << "StepComplete: pause on next bytecode"; + LOG_DEBUGGER(INFO) << "StepComplete: pause on next bytecode"; return true; } @@ -141,7 +140,7 @@ bool DebuggerImpl::NotifySingleStep(const JSPtLocation &location) } singleStepper_.reset(); - LOG(INFO, DEBUGGER) << "StepComplete: pause on current byte_code"; + LOG_DEBUGGER(INFO) << "StepComplete: pause on current byte_code"; return true; } @@ -153,7 +152,7 @@ bool DebuggerImpl::IsSkipLine(const JSPtLocation &location) return true; }; if (!MatchScripts(scriptFunc, location.GetPandaFile(), ScriptMatchType::FILE_NAME) || extractor == nullptr) { - LOG(INFO, DEBUGGER) << "StepComplete: skip unknown file"; + LOG_DEBUGGER(INFO) << "StepComplete: skip unknown file"; return true; } @@ -163,7 +162,7 @@ bool DebuggerImpl::IsSkipLine(const JSPtLocation &location) File::EntityId methodId = location.GetMethodId(); uint32_t offset = location.GetBytecodeOffset(); if (extractor->MatchLineWithOffset(callbackFunc, methodId, offset)) { - LOG(INFO, DEBUGGER) << "StepComplete: skip -1"; + LOG_DEBUGGER(INFO) << "StepComplete: skip -1"; return true; } @@ -199,7 +198,7 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso if (!MatchScripts(scriptFunc, location->GetPandaFile(), ScriptMatchType::FILE_NAME) || extractor == nullptr || !extractor->MatchLineWithOffset(callbackLineFunc, methodId, offset) || !extractor->MatchColumnWithOffset(callbackColumnFunc, methodId, offset)) { - LOG(ERROR, DEBUGGER) << "NotifyPaused: unknown " << location->GetPandaFile(); + LOG_DEBUGGER(ERROR) << "NotifyPaused: unknown " << location->GetPandaFile(); return; } hitBreakpoints.emplace_back(BreakpointDetails::ToString(detail)); @@ -211,7 +210,7 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso // Notify paused event std::vector> callFrames; if (!GenerateCallFrames(&callFrames)) { - LOG(ERROR, DEBUGGER) << "NotifyPaused: GenerateCallFrames failed"; + LOG_DEBUGGER(ERROR) << "NotifyPaused: GenerateCallFrames failed"; return; } tooling::Paused paused; @@ -261,7 +260,7 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) }; const std::string &method = request.GetMethod(); - LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to DebuggerImpl"; + LOG_DEBUGGER(DEBUG) << "dispatch [" << method << "] to DebuggerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { (this->*(entry->second))(request); @@ -531,10 +530,10 @@ DispatchResponse DebuggerImpl::EvaluateOnCallFrame(const EvaluateOnCallFramePara std::string dest; if (!DecodeAndCheckBase64(expression, dest)) { - LOG(ERROR, DEBUGGER) << "EvaluateValue: base64 decode failed"; + LOG_DEBUGGER(ERROR) << "EvaluateValue: base64 decode failed"; auto ret = CmptEvaluateValue(callFrameId, expression, result); if (ret.has_value()) { - LOG(ERROR, DEBUGGER) << "Evaluate fail, expression: " << expression; + LOG_DEBUGGER(ERROR) << "Evaluate fail, expression: " << expression; } return DispatchResponse::Create(ret); } @@ -544,7 +543,7 @@ DispatchResponse DebuggerImpl::EvaluateOnCallFrame(const EvaluateOnCallFramePara auto res = DebuggerApi::EvaluateViaFuncCall(const_cast(vm_), funcRef, callFrameHandlers_[callFrameId]); if (vm_->GetJSThread()->HasPendingException()) { - LOG(ERROR, DEBUGGER) << "EvaluateValue: has pending exception"; + LOG_DEBUGGER(ERROR) << "EvaluateValue: has pending exception"; std::string msg; DebuggerApi::HandleUncaughtException(vm_, msg); *result = RemoteObject::FromTagged(vm_, @@ -567,7 +566,7 @@ DispatchResponse DebuggerImpl::GetPossibleBreakpoints(const GetPossibleBreakpoin } JSPtExtractor *extractor = GetExtractor(iter->second->GetUrl()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "GetPossibleBreakpoints: extractor is null"; + LOG_DEBUGGER(ERROR) << "GetPossibleBreakpoints: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } @@ -606,14 +605,14 @@ DispatchResponse DebuggerImpl::Pause() DispatchResponse DebuggerImpl::RemoveBreakpoint(const RemoveBreakpointParams ¶ms) { std::string id = params.GetBreakpointId(); - LOG(INFO, DEBUGGER) << "RemoveBreakpoint: " << id; + LOG_DEBUGGER(INFO) << "RemoveBreakpoint: " << id; BreakpointDetails metaData{}; if (!BreakpointDetails::ParseBreakpointId(id, &metaData)) { return DispatchResponse::Fail("Parse breakpoint id failed"); } JSPtExtractor *extractor = GetExtractor(metaData.url_); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "RemoveBreakpoint: extractor is null"; + LOG_DEBUGGER(ERROR) << "RemoveBreakpoint: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } @@ -623,7 +622,7 @@ DispatchResponse DebuggerImpl::RemoveBreakpoint(const RemoveBreakpointParams &pa return true; }; if (!MatchScripts(scriptFunc, metaData.url_, ScriptMatchType::URL)) { - LOG(ERROR, DEBUGGER) << "RemoveBreakpoint: Unknown url: " << metaData.url_; + LOG_DEBUGGER(ERROR) << "RemoveBreakpoint: Unknown url: " << metaData.url_; return DispatchResponse::Fail("Unknown file name."); } @@ -632,12 +631,12 @@ DispatchResponse DebuggerImpl::RemoveBreakpoint(const RemoveBreakpointParams &pa return DebuggerApi::RemoveBreakpoint(jsDebugger_, location); }; if (!extractor->MatchWithLocation(callbackFunc, metaData.line_, metaData.column_)) { - LOG(ERROR, DEBUGGER) << "failed to set breakpoint location number: " + LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << metaData.line_ << ":" << metaData.column_; return DispatchResponse::Fail("Breakpoint not found."); } - LOG(INFO, DEBUGGER) << "remove breakpoint line number:" << metaData.line_; + LOG_DEBUGGER(INFO) << "remove breakpoint line number:" << metaData.line_; return DispatchResponse::Ok(); } @@ -664,7 +663,7 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams JSPtExtractor *extractor = GetExtractor(url); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "SetBreakpointByUrl: extractor is null"; + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrl: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } @@ -676,7 +675,7 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams return true; }; if (!MatchScripts(scriptFunc, url, ScriptMatchType::URL)) { - LOG(ERROR, DEBUGGER) << "SetBreakpointByUrl: Unknown url: " << url; + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrl: Unknown url: " << url; return DispatchResponse::Fail("Unknown file name."); } @@ -686,20 +685,20 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams if (condition.has_value() && !condition.value().empty()) { std::string dest; if (!DecodeAndCheckBase64(condition.value(), dest)) { - LOG(ERROR, DEBUGGER) << "SetBreakpointByUrl: base64 decode failed"; + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrl: base64 decode failed"; return false; } condFuncRef = DebuggerApi::GenerateFuncFromBuffer(vm_, dest.data(), dest.size(), JSPandaFile::ENTRY_MAIN_FUNCTION); if (condFuncRef->IsUndefined()) { - LOG(ERROR, DEBUGGER) << "SetBreakpointByUrl: generate function failed"; + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrl: generate function failed"; return false; } } return DebuggerApi::SetBreakpoint(jsDebugger_, location, condFuncRef); }; if (!extractor->MatchWithLocation(callbackFunc, lineNumber, columnNumber)) { - LOG(ERROR, DEBUGGER) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber; + LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber; return DispatchResponse::Fail("Breakpoint not found."); } @@ -726,7 +725,7 @@ DispatchResponse DebuggerImpl::StepInto([[maybe_unused]] const StepIntoParams &p JSMethod *method = DebuggerApi::GetMethod(vm_); JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "StepOver: extractor is null"; + LOG_DEBUGGER(ERROR) << "StepOver: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } singleStepper_ = extractor->GetStepIntoStepper(vm_); @@ -740,7 +739,7 @@ DispatchResponse DebuggerImpl::StepOut() JSMethod *method = DebuggerApi::GetMethod(vm_); JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "StepOut: extractor is null"; + LOG_DEBUGGER(ERROR) << "StepOut: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } singleStepper_ = extractor->GetStepOutStepper(vm_); @@ -754,7 +753,7 @@ DispatchResponse DebuggerImpl::StepOver([[maybe_unused]] const StepOverParams &p JSMethod *method = DebuggerApi::GetMethod(vm_); JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "StepOver: extractor is null"; + LOG_DEBUGGER(ERROR) << "StepOver: extractor is null"; return DispatchResponse::Fail("Unknown file name."); } singleStepper_ = extractor->GetStepOverStepper(vm_); @@ -808,7 +807,7 @@ bool DebuggerImpl::GenerateCallFrames(std::vector> *c auto walkerFunc = [this, &callFrameId, &callFrames](const FrameHandler *frameHandler) -> StackState { JSMethod *method = DebuggerApi::GetMethod(frameHandler); if (method->IsNativeWithCallField()) { - LOG(INFO, DEBUGGER) << "GenerateCallFrames: Skip CFrame and Native method"; + LOG_DEBUGGER(INFO) << "GenerateCallFrames: Skip CFrame and Native method"; return StackState::CONTINUE; } std::unique_ptr callFrame = std::make_unique(); @@ -839,7 +838,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, JSMethod *method = DebuggerApi::GetMethod(frameHandler); JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "GenerateCallFrame: extractor is null"; + LOG_DEBUGGER(ERROR) << "GenerateCallFrame: extractor is null"; return false; } @@ -851,7 +850,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, return true; }; if (!MatchScripts(scriptFunc, url, ScriptMatchType::URL)) { - LOG(ERROR, DEBUGGER) << "GenerateCallFrame: Unknown url: " << url; + LOG_DEBUGGER(ERROR) << "GenerateCallFrame: Unknown url: " << url; return false; } auto callbackLineFunc = [&location](int32_t line) -> bool { @@ -865,7 +864,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, File::EntityId methodId = method->GetMethodId(); if (!extractor->MatchLineWithOffset(callbackLineFunc, methodId, DebuggerApi::GetBytecodeOffset(frameHandler)) || !extractor->MatchColumnWithOffset(callbackColumnFunc, methodId, DebuggerApi::GetBytecodeOffset(frameHandler))) { - LOG(ERROR, DEBUGGER) << "GenerateCallFrame: unknown offset: " << DebuggerApi::GetBytecodeOffset(frameHandler); + LOG_DEBUGGER(ERROR) << "GenerateCallFrame: unknown offset: " << DebuggerApi::GetBytecodeOffset(frameHandler); return false; } @@ -897,7 +896,7 @@ std::unique_ptr DebuggerImpl::GetLocalScopeChain(const FrameHandler *fram JSMethod *method = DebuggerApi::GetMethod(frameHandler); JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "GetScopeChain: extractor is null"; + LOG_DEBUGGER(ERROR) << "GetScopeChain: extractor is null"; return localScope; } @@ -1023,7 +1022,7 @@ void DebuggerImpl::UpdateScopeObject(const FrameHandler *frameHandler, auto *sp = DebuggerApi::GetSp(frameHandler); auto iter = scopeObjects_.find(sp); if (iter == scopeObjects_.end()) { - LOG(ERROR, DEBUGGER) << "UpdateScopeObject: object not found"; + LOG_DEBUGGER(ERROR) << "UpdateScopeObject: object not found"; return; } @@ -1031,11 +1030,11 @@ void DebuggerImpl::UpdateScopeObject(const FrameHandler *frameHandler, Local localObj = runtime_->properties_[objectId].ToLocal(vm_); Local name = StringRef::NewFromUtf8(vm_, varName.data()); if (localObj->Has(vm_, name)) { - LOG(DEBUG, DEBUGGER) << "UpdateScopeObject: set new value"; + LOG_DEBUGGER(DEBUG) << "UpdateScopeObject: set new value"; PropertyAttribute descriptor(newVal, true, true, true); localObj->DefineProperty(vm_, name, descriptor); } else { - LOG(ERROR, DEBUGGER) << "UpdateScopeObject: not found " << varName; + LOG_DEBUGGER(ERROR) << "UpdateScopeObject: not found " << varName; } } diff --git a/ecmascript/tooling/agent/heapprofiler_impl.cpp b/ecmascript/tooling/agent/heapprofiler_impl.cpp index bba61f3d..28a07f80 100644 --- a/ecmascript/tooling/agent/heapprofiler_impl.cpp +++ b/ecmascript/tooling/agent/heapprofiler_impl.cpp @@ -34,7 +34,7 @@ void HeapProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) }; const std::string &method = request.GetMethod(); - LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to HeapProfilerImpl"; + LOG_DEBUGGER(DEBUG) << "dispatch [" << method << "] to HeapProfilerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { (this->*(entry->second))(request); diff --git a/ecmascript/tooling/agent/heapprofiler_impl.h b/ecmascript/tooling/agent/heapprofiler_impl.h index e74e6241..266a7487 100644 --- a/ecmascript/tooling/agent/heapprofiler_impl.h +++ b/ecmascript/tooling/agent/heapprofiler_impl.h @@ -27,7 +27,6 @@ #include "ecmascript/tooling/protocol_handler.h" #include "ecmascript/tooling/protocol_channel.h" #include "ecmascript/napi/include/dfx_jsnapi.h" -#include "libpandabase/utils/logger.h" static const double INTERVAL = 0.05; diff --git a/ecmascript/tooling/agent/profiler_impl.cpp b/ecmascript/tooling/agent/profiler_impl.cpp index fc1de36b..c76606e9 100644 --- a/ecmascript/tooling/agent/profiler_impl.cpp +++ b/ecmascript/tooling/agent/profiler_impl.cpp @@ -18,7 +18,6 @@ #include "ecmascript/napi/include/dfx_jsnapi.h" #include "ecmascript/tooling/base/pt_events.h" #include "ecmascript/tooling/protocol_channel.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript::tooling { void ProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) @@ -39,7 +38,7 @@ void ProfilerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) }; const std::string &method = request.GetMethod(); - LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to ProfilerImpl"; + LOG_DEBUGGER(DEBUG) << "dispatch [" << method << "] to ProfilerImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { (this->*(entry->second))(request); @@ -192,7 +191,7 @@ DispatchResponse ProfilerImpl::Stop(std::unique_ptr *profile) { auto profileInfo = panda::DFXJSNApi::StopCpuProfilerForInfo(); if (profileInfo == nullptr) { - LOG(ERROR, DEBUGGER) << "Transfer DFXJSNApi::StopCpuProfilerImpl is failure"; + LOG_DEBUGGER(ERROR) << "Transfer DFXJSNApi::StopCpuProfilerImpl is failure"; return DispatchResponse::Fail("Stop is failure"); } *profile = Profile::FromProfileInfo(*profileInfo); diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index 3779cc15..0c03ca91 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -20,7 +20,6 @@ #include "ecmascript/napi/include/dfx_jsnapi.h" #include "ecmascript/tooling/base/pt_returns.h" #include "ecmascript/tooling/protocol_channel.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript::tooling { void RuntimeImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) @@ -34,13 +33,13 @@ void RuntimeImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) }; const std::string &method = request.GetMethod(); - LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to RuntimeImpl"; + LOG_DEBUGGER(DEBUG) << "dispatch [" << method << "] to RuntimeImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end()) { (this->*(entry->second))(request); } else { - LOG(ERROR, DEBUGGER) << "unknown method: " << method; + LOG_DEBUGGER(ERROR) << "unknown method: " << method; SendResponse(request, DispatchResponse::Fail("unknown method: " + method)); } } @@ -79,7 +78,7 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) &outPrivateProperties, &outExceptionDetails); if (outExceptionDetails) { ASSERT(outExceptionDetails.value() != nullptr); - LOG(WARNING, DEBUGGER) << "GetProperties thrown an exception"; + LOG_DEBUGGER(WARN) << "GetProperties thrown an exception"; } GetPropertiesReturns result(std::move(outPropertyDesc), std::move(outInternalDescs), @@ -101,7 +100,7 @@ void RuntimeImpl::DispatcherImpl::CallFunctionOn(const DispatchRequest &request) DispatchResponse response = runtime_->CallFunctionOn(*params, &outRemoteObject, &outExceptionDetails); if (outExceptionDetails) { ASSERT(outExceptionDetails.value() != nullptr); - LOG(WARNING, DEBUGGER) << "CallFunctionOn thrown an exception"; + LOG_DEBUGGER(WARN) << "CallFunctionOn thrown an exception"; } if (outRemoteObject == nullptr) { SendResponse(request, response); @@ -179,12 +178,12 @@ DispatchResponse RuntimeImpl::GetProperties(const GetPropertiesParams ¶ms, bool isAccessorOnly = params.GetAccessPropertiesOnly(); auto iter = properties_.find(objectId); if (iter == properties_.end()) { - LOG(ERROR, DEBUGGER) << "RuntimeImpl::GetProperties Unknown object id: " << objectId; + LOG_DEBUGGER(ERROR) << "RuntimeImpl::GetProperties Unknown object id: " << objectId; return DispatchResponse::Fail("Unknown object id"); } Local value = Local(vm_, iter->second); if (value.IsEmpty() || !value->IsObject()) { - LOG(ERROR, DEBUGGER) << "RuntimeImpl::GetProperties should a js object"; + LOG_DEBUGGER(ERROR) << "RuntimeImpl::GetProperties should a js object"; return DispatchResponse::Fail("Not a object"); } if (value->IsArrayBuffer()) { @@ -347,7 +346,7 @@ void RuntimeImpl::GetAdditionalProperties(Local value, Local localTypedArrayRef(value); uint32_t lengthTypedArray = localTypedArrayRef->ArrayLength(vm_); if (lengthTypedArray > lengthTypedArrayLimit) { - LOG(ERROR, DEBUGGER) << "The length of the TypedArray is non-compliant or unsupported."; + LOG_DEBUGGER(ERROR) << "The length of the TypedArray is non-compliant or unsupported."; return; } for (uint32_t i = 0; i < lengthTypedArray; i++) { diff --git a/ecmascript/tooling/agent/tracing_impl.cpp b/ecmascript/tooling/agent/tracing_impl.cpp index bf8fdc88..8de90cc4 100644 --- a/ecmascript/tooling/agent/tracing_impl.cpp +++ b/ecmascript/tooling/agent/tracing_impl.cpp @@ -18,7 +18,6 @@ #include "ecmascript/napi/include/dfx_jsnapi.h" #include "ecmascript/tooling/base/pt_events.h" #include "ecmascript/tooling/protocol_channel.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript::tooling { void TracingImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) @@ -32,7 +31,7 @@ void TracingImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) }; const std::string &method = request.GetMethod(); - LOG(DEBUG, DEBUGGER) << "dispatch [" << method << "] to TracingImpl"; + LOG_DEBUGGER(DEBUG) << "dispatch [" << method << "] to TracingImpl"; auto entry = dispatcherTable.find(method); if (entry != dispatcherTable.end() && entry->second != nullptr) { (this->*(entry->second))(request); @@ -116,32 +115,27 @@ void TracingImpl::Frontend::TracingComplete() DispatchResponse TracingImpl::End() { - LOG(ERROR, DEBUGGER) << "End not support now."; - return DispatchResponse::Ok(); + return DispatchResponse::Fail("End not support now."); } DispatchResponse TracingImpl::GetCategories([[maybe_unused]] std::vector categories) { - LOG(ERROR, DEBUGGER) << "GetCategories not support now."; - return DispatchResponse::Ok(); + return DispatchResponse::Fail("GetCategories not support now."); } DispatchResponse TracingImpl::RecordClockSyncMarker([[maybe_unused]] std::string syncId) { - LOG(ERROR, DEBUGGER) << "RecordClockSyncMarker not support now."; - return DispatchResponse::Ok(); + return DispatchResponse::Fail("RecordClockSyncMarker not support now."); } DispatchResponse TracingImpl::RequestMemoryDump([[maybe_unused]] std::unique_ptr params, [[maybe_unused]] std::string dumpGuid, [[maybe_unused]] bool success) { - LOG(ERROR, DEBUGGER) << "RequestMemoryDump not support now."; - return DispatchResponse::Ok(); + return DispatchResponse::Fail("RequestMemoryDump not support now."); } DispatchResponse TracingImpl::Start([[maybe_unused]] std::unique_ptr params) { - LOG(ERROR, DEBUGGER) << "Start not support now."; - return DispatchResponse::Ok(); + return DispatchResponse::Fail("Start not support now."); } } // namespace panda::ecmascript::tooling \ No newline at end of file diff --git a/ecmascript/tooling/backend/debugger_api.cpp b/ecmascript/tooling/backend/debugger_api.cpp index 16b9074c..bef42e4c 100644 --- a/ecmascript/tooling/backend/debugger_api.cpp +++ b/ecmascript/tooling/backend/debugger_api.cpp @@ -110,12 +110,12 @@ int32_t DebuggerApi::GetVregIndex(const FrameHandler *frameHandler, std::string_ { JSMethod *method = frameHandler->GetMethod(); if (method->IsNativeWithCallField()) { - LOG(ERROR, DEBUGGER) << "GetVregIndex: native frame not support"; + LOG_DEBUGGER(ERROR) << "GetVregIndex: native frame not support"; return -1; } JSPtExtractor *extractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(method->GetJSPandaFile()); if (extractor == nullptr) { - LOG(ERROR, DEBUGGER) << "GetVregIndex: extractor is null"; + LOG_DEBUGGER(ERROR) << "GetVregIndex: extractor is null"; return -1; } auto table = extractor->GetLocalVariableTable(method->GetMethodId()); diff --git a/ecmascript/tooling/backend/debugger_executor.cpp b/ecmascript/tooling/backend/debugger_executor.cpp index e6c4459c..7a497aca 100644 --- a/ecmascript/tooling/backend/debugger_executor.cpp +++ b/ecmascript/tooling/backend/debugger_executor.cpp @@ -17,7 +17,6 @@ #include "ecmascript/tooling/backend/debugger_api.h" #include "ecmascript/tooling/interface/js_debugger_manager.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript::tooling { void DebuggerExecutor::Initialize(const EcmaVM *vm) diff --git a/ecmascript/tooling/backend/js_debugger.cpp b/ecmascript/tooling/backend/js_debugger.cpp index 659b93c8..ba744d02 100644 --- a/ecmascript/tooling/backend/js_debugger.cpp +++ b/ecmascript/tooling/backend/js_debugger.cpp @@ -29,12 +29,12 @@ bool JSDebugger::SetBreakpoint(const JSPtLocation &location, Local { JSMethod *method = FindMethod(location); if (method == nullptr) { - LOG(ERROR, DEBUGGER) << "SetBreakpoint: Cannot find JSMethod"; + LOG_DEBUGGER(ERROR) << "SetBreakpoint: Cannot find JSMethod"; return false; } if (location.GetBytecodeOffset() >= method->GetCodeSize()) { - LOG(ERROR, DEBUGGER) << "SetBreakpoint: Invalid breakpoint location"; + LOG_DEBUGGER(ERROR) << "SetBreakpoint: Invalid breakpoint location"; return false; } @@ -42,7 +42,7 @@ bool JSDebugger::SetBreakpoint(const JSPtLocation &location, Local Global(ecmaVm_, condFuncRef)); if (!success) { // also return true - LOG(WARNING, DEBUGGER) << "SetBreakpoint: Breakpoint already exists"; + LOG_DEBUGGER(WARN) << "SetBreakpoint: Breakpoint already exists"; } return true; @@ -52,12 +52,12 @@ bool JSDebugger::RemoveBreakpoint(const JSPtLocation &location) { JSMethod *method = FindMethod(location); if (method == nullptr) { - LOG(ERROR, DEBUGGER) << "RemoveBreakpoint: Cannot find JSMethod"; + LOG_DEBUGGER(ERROR) << "RemoveBreakpoint: Cannot find JSMethod"; return false; } if (!RemoveBreakpoint(method, location.GetBytecodeOffset())) { - LOG(ERROR, DEBUGGER) << "RemoveBreakpoint: Breakpoint not found"; + LOG_DEBUGGER(ERROR) << "RemoveBreakpoint: Breakpoint not found"; return false; } @@ -86,18 +86,18 @@ bool JSDebugger::HandleBreakpoint(const JSMethod *method, uint32_t bcOffset) JSThread *thread = ecmaVm_->GetJSThread(); auto condFuncRef = breakpoint.value().GetConditionFunction(); if (condFuncRef->IsFunction()) { - LOG(INFO, DEBUGGER) << "HandleBreakpoint: begin evaluate condition"; + LOG_DEBUGGER(INFO) << "HandleBreakpoint: begin evaluate condition"; auto handlerPtr = std::make_shared(ecmaVm_->GetJSThread()); auto res = DebuggerApi::EvaluateViaFuncCall(const_cast(ecmaVm_), condFuncRef.ToLocal(ecmaVm_), handlerPtr); if (thread->HasPendingException()) { - LOG(ERROR, DEBUGGER) << "HandleBreakpoint: has pending exception"; + LOG_DEBUGGER(ERROR) << "HandleBreakpoint: has pending exception"; thread->ClearException(); return false; } bool isMeet = res->ToBoolean(ecmaVm_)->Value(); if (!isMeet) { - LOG(ERROR, DEBUGGER) << "HandleBreakpoint: condition not meet"; + LOG_DEBUGGER(ERROR) << "HandleBreakpoint: condition not meet"; return false; } } diff --git a/ecmascript/tooling/backend/js_pt_hooks.cpp b/ecmascript/tooling/backend/js_pt_hooks.cpp index 1785e5b5..dbcbe5a6 100644 --- a/ecmascript/tooling/backend/js_pt_hooks.cpp +++ b/ecmascript/tooling/backend/js_pt_hooks.cpp @@ -20,7 +20,7 @@ namespace panda::ecmascript::tooling { void JSPtHooks::Breakpoint(const JSPtLocation &location) { - LOG(DEBUG, DEBUGGER) << "JSPtHooks: Breakpoint => " << location.GetMethodId() << ": " + LOG_DEBUGGER(DEBUG) << "JSPtHooks: Breakpoint => " << location.GetMethodId() << ": " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -29,7 +29,7 @@ void JSPtHooks::Breakpoint(const JSPtLocation &location) void JSPtHooks::Exception([[maybe_unused]] const JSPtLocation &location) { - LOG(DEBUG, DEBUGGER) << "JSPtHooks: Exception"; + LOG_DEBUGGER(DEBUG) << "JSPtHooks: Exception"; [[maybe_unused]] LocalScope scope(debugger_->vm_); debugger_->NotifyPaused({}, EXCEPTION); @@ -37,7 +37,7 @@ void JSPtHooks::Exception([[maybe_unused]] const JSPtLocation &location) bool JSPtHooks::SingleStep(const JSPtLocation &location) { - LOG(DEBUG, DEBUGGER) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); + LOG_DEBUGGER(DEBUG) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); if (UNLIKELY(firstTime_)) { @@ -61,7 +61,7 @@ bool JSPtHooks::SingleStep(const JSPtLocation &location) void JSPtHooks::LoadModule(std::string_view pandaFileName) { - LOG(INFO, DEBUGGER) << "JSPtHooks: LoadModule: " << pandaFileName; + LOG_DEBUGGER(INFO) << "JSPtHooks: LoadModule: " << pandaFileName; [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -73,7 +73,7 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName) void JSPtHooks::PendingJobEntry() { - LOG(DEBUG, DEBUGGER) << "JSPtHooks: PendingJobEntry"; + LOG_DEBUGGER(DEBUG) << "JSPtHooks: PendingJobEntry"; [[maybe_unused]] LocalScope scope(debugger_->vm_); diff --git a/ecmascript/tooling/base/pt_events.h b/ecmascript/tooling/base/pt_events.h index efbc3ac0..05b140b4 100644 --- a/ecmascript/tooling/base/pt_events.h +++ b/ecmascript/tooling/base/pt_events.h @@ -150,7 +150,7 @@ public: return "Break on start"; } default: { - LOG(ERROR, DEBUGGER) << "Unknown paused reason: " << reason; + LOG_DEBUGGER(ERROR) << "Unknown paused reason: " << reason; } } return ""; diff --git a/ecmascript/tooling/base/pt_params.cpp b/ecmascript/tooling/base/pt_params.cpp index 83903fcd..64bda897 100644 --- a/ecmascript/tooling/base/pt_params.cpp +++ b/ecmascript/tooling/base/pt_params.cpp @@ -31,7 +31,7 @@ std::unique_ptr EnableParams::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "EnableParams::Create " << error; + LOG_DEBUGGER(ERROR) << "EnableParams::Create " << error; return nullptr; } @@ -102,7 +102,7 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "EvaluateOnCallFrameParams::Create " << error; + LOG_DEBUGGER(ERROR) << "EvaluateOnCallFrameParams::Create " << error; return nullptr; } return paramsObject; @@ -147,7 +147,7 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "GetPossibleBreakpointsParams::Create " << error; + LOG_DEBUGGER(ERROR) << "GetPossibleBreakpointsParams::Create " << error; return nullptr; } @@ -169,7 +169,7 @@ std::unique_ptr GetScriptSourceParams::Create(const PtJso } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "GetScriptSourceParams::Create " << error; + LOG_DEBUGGER(ERROR) << "GetScriptSourceParams::Create " << error; return nullptr; } @@ -191,7 +191,7 @@ std::unique_ptr RemoveBreakpointParams::Create(const PtJ } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "RemoveBreakpointParams::Create " << error; + LOG_DEBUGGER(ERROR) << "RemoveBreakpointParams::Create " << error; return nullptr; } @@ -213,7 +213,7 @@ std::unique_ptr ResumeParams::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ResumeParams::Create " << error; + LOG_DEBUGGER(ERROR) << "ResumeParams::Create " << error; return nullptr; } @@ -235,7 +235,7 @@ std::unique_ptr SetAsyncCallStackDepthParams::Crea } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SetAsyncCallStackDepthParams::Create " << error; + LOG_DEBUGGER(ERROR) << "SetAsyncCallStackDepthParams::Create " << error; return nullptr; } @@ -265,7 +265,7 @@ std::unique_ptr SetBlackboxPatternsParams::Create(con } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SetBlackboxPatternsParams::Create " << error; + LOG_DEBUGGER(ERROR) << "SetBlackboxPatternsParams::Create " << error; return nullptr; } @@ -321,7 +321,7 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const error += "Unknown 'condition';"; } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SetBreakpointByUrlParams::Create " << error; + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrlParams::Create " << error; return nullptr; } @@ -343,7 +343,7 @@ std::unique_ptr SetPauseOnExceptionsParams::Create(c } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SetPauseOnExceptionsParams::Create " << error; + LOG_DEBUGGER(ERROR) << "SetPauseOnExceptionsParams::Create " << error; return nullptr; } @@ -380,7 +380,7 @@ std::unique_ptr StepIntoParams::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StepIntoParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StepIntoParams::Create " << error; return nullptr; } @@ -410,7 +410,7 @@ std::unique_ptr StepOverParams::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StepOverParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StepOverParams::Create " << error; return nullptr; } @@ -452,7 +452,7 @@ std::unique_ptr GetPropertiesParams::Create(const PtJson &p error += "Unknown 'generatePreview';"; } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "GetPropertiesParams::Create " << error; + LOG_DEBUGGER(ERROR) << "GetPropertiesParams::Create " << error; return nullptr; } @@ -564,7 +564,7 @@ std::unique_ptr CallFunctionOnParams::Create(const PtJson // Check whether the error is empty. if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "CallFunctionOnParams::Create " << error; + LOG_DEBUGGER(ERROR) << "CallFunctionOnParams::Create " << error; return nullptr; } @@ -586,7 +586,7 @@ std::unique_ptr StartSamplingParams::Create(const PtJson &p } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StartSamplingParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StartSamplingParams::Create " << error; return nullptr; } return paramsObject; @@ -607,7 +607,7 @@ std::unique_ptr StartTrackingHeapObjectsParams:: } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StartTrackingHeapObjectsParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StartTrackingHeapObjectsParams::Create " << error; return nullptr; } return paramsObject; @@ -644,7 +644,7 @@ std::unique_ptr StopTrackingHeapObjectsParams::Cr } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StopTrackingHeapObjectsParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StopTrackingHeapObjectsParams::Create " << error; return nullptr; } return paramsObject; @@ -665,7 +665,7 @@ std::unique_ptr AddInspectedHeapObjectParams::Crea } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "AddInspectedHeapObjectParams::Create " << error; + LOG_DEBUGGER(ERROR) << "AddInspectedHeapObjectParams::Create " << error; return nullptr; } return paramsObject; @@ -686,7 +686,7 @@ std::unique_ptr GetHeapObjectIdParams::Create(const PtJso } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "GetHeapObjectIdParams::Create " << error; + LOG_DEBUGGER(ERROR) << "GetHeapObjectIdParams::Create " << error; return nullptr; } return paramsObject; @@ -715,7 +715,7 @@ std::unique_ptr GetObjectByHeapObjectIdParams::Cr } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "GetObjectByHeapObjectIdParams::Create " << error; + LOG_DEBUGGER(ERROR) << "GetObjectByHeapObjectIdParams::Create " << error; return nullptr; } return paramsObject; @@ -752,7 +752,7 @@ std::unique_ptr StartPreciseCoverageParams::Create(c } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StartPreciseCoverageParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StartPreciseCoverageParams::Create " << error; return nullptr; } return paramsObject; @@ -773,7 +773,7 @@ std::unique_ptr SetSamplingIntervalParams::Create(con } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SetSamplingIntervalParams::Create " << error; + LOG_DEBUGGER(ERROR) << "SetSamplingIntervalParams::Create " << error; return nullptr; } return paramsObject; @@ -794,7 +794,7 @@ std::unique_ptr RecordClockSyncMarkerParams::Create } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "RecordClockSyncMarkerParams::Create " << error; + LOG_DEBUGGER(ERROR) << "RecordClockSyncMarkerParams::Create " << error; return nullptr; } @@ -828,7 +828,7 @@ std::unique_ptr RequestMemoryDumpParams::Create(const P } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "RequestMemoryDumpParams::Create " << error; + LOG_DEBUGGER(ERROR) << "RequestMemoryDumpParams::Create " << error; return nullptr; } @@ -935,7 +935,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "StartParams::Create " << error; + LOG_DEBUGGER(ERROR) << "StartParams::Create " << error; return nullptr; } diff --git a/ecmascript/tooling/base/pt_types.cpp b/ecmascript/tooling/base/pt_types.cpp index cc1252bd..4c28077b 100644 --- a/ecmascript/tooling/base/pt_types.cpp +++ b/ecmascript/tooling/base/pt_types.cpp @@ -481,7 +481,7 @@ std::unique_ptr RemoteObject::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "RemoteObject::Create " << error; + LOG_DEBUGGER(ERROR) << "RemoteObject::Create " << error; return nullptr; } @@ -588,7 +588,7 @@ std::unique_ptr ExceptionDetails::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ExceptionDetails::Create " << error; + LOG_DEBUGGER(ERROR) << "ExceptionDetails::Create " << error; return nullptr; } @@ -649,7 +649,7 @@ std::unique_ptr InternalPropertyDescriptor::Create(c } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "InternalPropertyDescriptor::Create " << error; + LOG_DEBUGGER(ERROR) << "InternalPropertyDescriptor::Create " << error; return nullptr; } @@ -724,7 +724,7 @@ std::unique_ptr PrivatePropertyDescriptor::Create(con } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "PrivatePropertyDescriptor::Create " << error; + LOG_DEBUGGER(ERROR) << "PrivatePropertyDescriptor::Create " << error; return nullptr; } @@ -894,7 +894,7 @@ std::unique_ptr PropertyDescriptor::Create(const PtJson &par } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "PropertyDescriptor::Create " << error; + LOG_DEBUGGER(ERROR) << "PropertyDescriptor::Create " << error; return nullptr; } @@ -959,7 +959,7 @@ std::unique_ptr CallArgument::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "CallArgument::Create " << error; + LOG_DEBUGGER(ERROR) << "CallArgument::Create " << error; return nullptr; } @@ -1009,7 +1009,7 @@ std::unique_ptr Location::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "Location::Create " << error; + LOG_DEBUGGER(ERROR) << "Location::Create " << error; return nullptr; } @@ -1051,7 +1051,7 @@ std::unique_ptr ScriptPosition::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ScriptPosition::Create " << error; + LOG_DEBUGGER(ERROR) << "ScriptPosition::Create " << error; return nullptr; } @@ -1091,7 +1091,7 @@ std::unique_ptr SearchMatch::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SearchMatch::Create " << error; + LOG_DEBUGGER(ERROR) << "SearchMatch::Create " << error; return nullptr; } @@ -1150,7 +1150,7 @@ std::unique_ptr LocationRange::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "LocationRange::Create " << error; + LOG_DEBUGGER(ERROR) << "LocationRange::Create " << error; return nullptr; } @@ -1213,7 +1213,7 @@ std::unique_ptr BreakLocation::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "Location::Create " << error; + LOG_DEBUGGER(ERROR) << "Location::Create " << error; return nullptr; } @@ -1304,7 +1304,7 @@ std::unique_ptr Scope::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "Location::Create " << error; + LOG_DEBUGGER(ERROR) << "Location::Create " << error; return nullptr; } @@ -1436,7 +1436,7 @@ std::unique_ptr CallFrame::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "CallFrame::Create " << error; + LOG_DEBUGGER(ERROR) << "CallFrame::Create " << error; return nullptr; } @@ -1505,7 +1505,7 @@ std::unique_ptr SamplingHeapProfileSample::Create(con error += "Unknown 'ordinal';"; } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SamplingHeapProfileSample::Create " << error; + LOG_DEBUGGER(ERROR) << "SamplingHeapProfileSample::Create " << error; return nullptr; } @@ -1569,7 +1569,7 @@ std::unique_ptr RuntimeCallFrame::Create(const PtJson ¶ms) error += "Unknown 'columnNumber';"; } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "RuntimeCallFrame::Create " << error; + LOG_DEBUGGER(ERROR) << "RuntimeCallFrame::Create " << error; return nullptr; } @@ -1654,7 +1654,7 @@ std::unique_ptr SamplingHeapProfileNode::Create(const P } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SamplingHeapProfileNode::Create " << error; + LOG_DEBUGGER(ERROR) << "SamplingHeapProfileNode::Create " << error; return nullptr; } @@ -1718,7 +1718,7 @@ std::unique_ptr SamplingHeapProfile::Create(const PtJson &p } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "SamplingHeapProfile::Create " << error; + LOG_DEBUGGER(ERROR) << "SamplingHeapProfile::Create " << error; return nullptr; } @@ -1765,7 +1765,7 @@ std::unique_ptr PositionTickInfo::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "PositionTickInfo::Create " << error; + LOG_DEBUGGER(ERROR) << "PositionTickInfo::Create " << error; return nullptr; } @@ -1856,7 +1856,7 @@ std::unique_ptr ProfileNode::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ProfileNode::Create " << error; + LOG_DEBUGGER(ERROR) << "ProfileNode::Create " << error; return nullptr; } @@ -1980,7 +1980,7 @@ std::unique_ptr Profile::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "Profile::Create " << error; + LOG_DEBUGGER(ERROR) << "Profile::Create " << error; return nullptr; } @@ -2085,7 +2085,7 @@ std::unique_ptr Coverage::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "Coverage::Create " << error; + LOG_DEBUGGER(ERROR) << "Coverage::Create " << error; return nullptr; } @@ -2144,7 +2144,7 @@ std::unique_ptr FunctionCoverage::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "FunctionCoverage::Create " << error; + LOG_DEBUGGER(ERROR) << "FunctionCoverage::Create " << error; return nullptr; } @@ -2211,7 +2211,7 @@ std::unique_ptr ScriptCoverage::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ScriptCoverage::Create " << error; + LOG_DEBUGGER(ERROR) << "ScriptCoverage::Create " << error; return nullptr; } @@ -2251,7 +2251,7 @@ std::unique_ptr TypeObject::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "TypeObject::Create " << error; + LOG_DEBUGGER(ERROR) << "TypeObject::Create " << error; return nullptr; } @@ -2300,7 +2300,7 @@ std::unique_ptr TypeProfileEntry::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "TypeProfileEntry::Create " << error; + LOG_DEBUGGER(ERROR) << "TypeProfileEntry::Create " << error; return nullptr; } @@ -2365,7 +2365,7 @@ std::unique_ptr ScriptTypeProfile::Create(const PtJson ¶m } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "ScriptTypeProfile::Create " << error; + LOG_DEBUGGER(ERROR) << "ScriptTypeProfile::Create " << error; return nullptr; } @@ -2482,7 +2482,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) } if (!error.empty()) { - LOG(ERROR, DEBUGGER) << "TraceConfig::Create " << error; + LOG_DEBUGGER(ERROR) << "TraceConfig::Create " << error; return nullptr; } diff --git a/ecmascript/tooling/debugger_service.cpp b/ecmascript/tooling/debugger_service.cpp index fa5acddd..1564f439 100644 --- a/ecmascript/tooling/debugger_service.cpp +++ b/ecmascript/tooling/debugger_service.cpp @@ -25,7 +25,7 @@ void InitializeDebugger(::panda::ecmascript::EcmaVM *vm, { ProtocolHandler *handler = vm->GetJsDebuggerManager()->GetDebuggerHandler(); if (handler != nullptr) { - LOG(ERROR, DEBUGGER) << "JS debugger was initialized"; + LOG_DEBUGGER(ERROR) << "JS debugger was initialized"; return; } vm->GetJsDebuggerManager()->SetDebuggerHandler(new ProtocolHandler(onResponse, vm)); diff --git a/ecmascript/tooling/dispatcher.cpp b/ecmascript/tooling/dispatcher.cpp index 33e55578..95856407 100644 --- a/ecmascript/tooling/dispatcher.cpp +++ b/ecmascript/tooling/dispatcher.cpp @@ -15,8 +15,6 @@ #include "ecmascript/tooling/dispatcher.h" -#include "libpandabase/utils/logger.h" - #include "ecmascript/tooling/agent/debugger_impl.h" #include "ecmascript/tooling/agent/runtime_impl.h" #include "ecmascript/tooling/agent/heapprofiler_impl.h" @@ -30,7 +28,7 @@ DispatchRequest::DispatchRequest(const std::string &message) std::unique_ptr json = PtJson::Parse(message); if (json == nullptr || !json->IsObject()) { code_ = RequestCode::JSON_PARSE_ERROR; - LOG(ERROR, DEBUGGER) << "json parse error"; + LOG_DEBUGGER(ERROR) << "json parse error"; return; } @@ -39,7 +37,7 @@ DispatchRequest::DispatchRequest(const std::string &message) ret = json->GetInt("id", &callId); if (ret != Result::SUCCESS) { code_ = RequestCode::PARSE_ID_ERROR; - LOG(ERROR, DEBUGGER) << "parse id error"; + LOG_DEBUGGER(ERROR) << "parse id error"; return; } callId_ = callId; @@ -48,7 +46,7 @@ DispatchRequest::DispatchRequest(const std::string &message) ret = json->GetString("method", &wholeMethod); if (ret != Result::SUCCESS) { code_ = RequestCode::PARSE_METHOD_ERROR; - LOG(ERROR, DEBUGGER) << "parse method error"; + LOG_DEBUGGER(ERROR) << "parse method error"; return; } std::string::size_type length = wholeMethod.length(); @@ -56,15 +54,15 @@ DispatchRequest::DispatchRequest(const std::string &message) indexPoint = wholeMethod.find_first_of('.', 0); if (indexPoint == std::string::npos || indexPoint == 0 || indexPoint == length - 1) { code_ = RequestCode::METHOD_FORMAT_ERROR; - LOG(ERROR, DEBUGGER) << "method format error: " << wholeMethod; + LOG_DEBUGGER(ERROR) << "method format error: " << wholeMethod; return; } domain_ = wholeMethod.substr(0, indexPoint); method_ = wholeMethod.substr(indexPoint + 1, length); - LOG(DEBUG, DEBUGGER) << "id: " << callId_; - LOG(DEBUG, DEBUGGER) << "domain: " << domain_; - LOG(DEBUG, DEBUGGER) << "method: " << method_; + LOG_DEBUGGER(DEBUG) << "id: " << callId_; + LOG_DEBUGGER(DEBUG) << "domain: " << domain_; + LOG_DEBUGGER(DEBUG) << "method: " << method_; std::unique_ptr params; ret = json->GetObject("params", ¶ms); @@ -73,7 +71,7 @@ DispatchRequest::DispatchRequest(const std::string &message) } if (ret == Result::TYPE_ERROR) { code_ = RequestCode::PARAMS_FORMAT_ERROR; - LOG(ERROR, DEBUGGER) << "params format error"; + LOG_DEBUGGER(ERROR) << "params format error"; return; } params_ = std::move(params); @@ -148,7 +146,7 @@ Dispatcher::Dispatcher(const EcmaVM *vm, ProtocolChannel *channel) void Dispatcher::Dispatch(const DispatchRequest &request) { if (!request.IsValid()) { - LOG(ERROR, DEBUGGER) << "Unknown request"; + LOG_DEBUGGER(ERROR) << "Unknown request"; return; } const std::string &domain = request.GetDomain(); @@ -156,7 +154,7 @@ void Dispatcher::Dispatch(const DispatchRequest &request) if (dispatcher != dispatchers_.end()) { dispatcher->second->Dispatch(request); } else { - LOG(ERROR, DEBUGGER) << "unknown domain: " << domain; + LOG_DEBUGGER(ERROR) << "unknown domain: " << domain; } } } // namespace panda::ecmascript::tooling diff --git a/ecmascript/tooling/interface/file_stream.cpp b/ecmascript/tooling/interface/file_stream.cpp index 48bc240f..7332a55c 100644 --- a/ecmascript/tooling/interface/file_stream.cpp +++ b/ecmascript/tooling/interface/file_stream.cpp @@ -15,11 +15,11 @@ #include "ecmascript/tooling/interface/file_stream.h" -#include #include +#include +#include #include "ecmascript/ecma_macros.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { FileStream::FileStream(const std::string &fileName) @@ -122,4 +122,4 @@ bool FileDescriptorStream::WriteChunk(char *data, int32_t size) } return true; } -} \ No newline at end of file +} diff --git a/ecmascript/tooling/protocol_handler.cpp b/ecmascript/tooling/protocol_handler.cpp index 0d07e037..281e055f 100644 --- a/ecmascript/tooling/protocol_handler.cpp +++ b/ecmascript/tooling/protocol_handler.cpp @@ -16,7 +16,6 @@ #include "ecmascript/tooling/protocol_handler.h" #include "ecmascript/tooling/agent/debugger_impl.h" -#include "utils/logger.h" namespace panda::ecmascript::tooling { void ProtocolHandler::WaitForDebugger() @@ -32,6 +31,7 @@ void ProtocolHandler::RunIfWaitingForDebugger() void ProtocolHandler::DispatchCommand(std::string &&msg) { + LOG_DEBUGGER(DEBUG) << "ProtocolHandler::DispatchCommand: " << msg; std::unique_lock queueLock(requestLock_); requestQueue_.push(std::move(msg)); requestQueueCond_.notify_one(); @@ -82,7 +82,7 @@ void ProtocolHandler::ProcessCommand() void ProtocolHandler::SendResponse(const DispatchRequest &request, const DispatchResponse &response, const PtBaseReturns &result) { - LOG(INFO, DEBUGGER) << "ProtocolHandler::SendResponse: " + LOG_DEBUGGER(INFO) << "ProtocolHandler::SendResponse: " << (response.IsOk() ? "success" : "failed: " + response.GetMessage()); std::unique_ptr reply = PtJson::CreateObject(); @@ -99,7 +99,7 @@ void ProtocolHandler::SendResponse(const DispatchRequest &request, const Dispatc void ProtocolHandler::SendNotification(const PtBaseEvents &events) { - LOG(DEBUG, DEBUGGER) << "ProtocolHandler::SendNotification: " << events.GetName(); + LOG_DEBUGGER(DEBUG) << "ProtocolHandler::SendNotification: " << events.GetName(); SendReply(*events.ToJson()); } @@ -107,7 +107,7 @@ void ProtocolHandler::SendReply(const PtJson &reply) { std::string str = reply.Stringify(); if (str.empty()) { - LOG(ERROR, DEBUGGER) << "ProtocolHandler::SendReply: json stringify error"; + LOG_DEBUGGER(ERROR) << "ProtocolHandler::SendReply: json stringify error"; return; } diff --git a/ecmascript/tooling/test/BUILD.gn b/ecmascript/tooling/test/BUILD.gn index 419a3d7e..a45b5eaf 100644 --- a/ecmascript/tooling/test/BUILD.gn +++ b/ecmascript/tooling/test/BUILD.gn @@ -177,6 +177,14 @@ source_set("jsdebugtest_set") { defines = [ "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"" ] + if (is_ohos && is_standard_system) { + if (enable_hilog) { + defines += [ "ENABLE_HILOG" ] + include_dirs = + [ "//base/hiviewdfx/hilog/interfaces/native/innerkits/include" ] + } + } + deps = [ "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", @@ -189,11 +197,8 @@ ohos_shared_library("jsdebugtest") { deps = [ ":jsdebugtest_set" ] if (is_ohos && is_standard_system) { - if (build_public_version) { - external_deps = [ - "hitrace_native:hitrace_meter", - "hitrace_native:libhitrace", - ] + if (enable_hilog) { + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] } } diff --git a/ecmascript/tooling/test/utils/test_hooks.h b/ecmascript/tooling/test/utils/test_hooks.h index e5fa79c7..e4edc324 100644 --- a/ecmascript/tooling/test/utils/test_hooks.h +++ b/ecmascript/tooling/test/utils/test_hooks.h @@ -103,7 +103,7 @@ public: if (TestUtil::IsTestFinished()) { return; } - LOG(FATAL, DEBUGGER) << "Test " << testName_ << " failed"; + LOG_DEBUGGER(FATAL) << "Test " << testName_ << " failed"; } ~TestHooks() = default; diff --git a/ecmascript/tooling/test/utils/test_util.h b/ecmascript/tooling/test/utils/test_util.h index 8596e30f..9304a47b 100644 --- a/ecmascript/tooling/test/utils/test_util.h +++ b/ecmascript/tooling/test/utils/test_util.h @@ -43,7 +43,7 @@ public: if (iter != testMap_.end()) { return iter->second.get(); } - LOG(FATAL, DEBUGGER) << "Test " << name << " not found"; + LOG_DEBUGGER(FATAL) << "Test " << name << " not found"; return nullptr; } @@ -88,7 +88,7 @@ public: static void Event(DebugEvent event, JSPtLocation location = JSPtLocation("", EntityId(0), 0)) { - LOG(DEBUG, DEBUGGER) << "Occurred event " << event; + LOG_DEBUGGER(DEBUG) << "Occurred event " << event; os::memory::LockHolder holder(eventMutex_); lastEvent_ = event; lastEventLocation_ = location; @@ -173,7 +173,7 @@ private: constexpr uint64_t TIMEOUT_MSEC = 10000U; bool timeExceeded = eventCv_.TimedWait(&eventMutex_, TIMEOUT_MSEC); if (timeExceeded) { - LOG(FATAL, DEBUGGER) << "Time limit exceeded while waiting " << event; + LOG_DEBUGGER(FATAL) << "Time limit exceeded while waiting " << event; return false; } } diff --git a/ecmascript/ts_types/global_ts_type_ref.h b/ecmascript/ts_types/global_ts_type_ref.h index 56f5f57c..77c9a2ee 100644 --- a/ecmascript/ts_types/global_ts_type_ref.h +++ b/ecmascript/ts_types/global_ts_type_ref.h @@ -18,7 +18,6 @@ #include "ecmascript/ecma_macros.h" #include "libpandabase/utils/bit_field.h" -#include "libpandabase/utils/logger.h" namespace panda::ecmascript { enum class TSTypeKind : int { @@ -117,7 +116,7 @@ public: uint32_t gcType = GetGCType(); uint32_t moduleId = GetModuleId(); uint32_t localId = GetLocalId(); - LOG(ERROR, ECMASCRIPT) << "kind: " << kind << " gcType: " << gcType + LOG_ECMA(ERROR) << "kind: " << kind << " gcType: " << gcType << " moduleId: " << moduleId << " localId: " << localId; } diff --git a/ecmascript/ts_types/ts_type.cpp b/ecmascript/ts_types/ts_type.cpp index 8a531f9b..1d97bfde 100644 --- a/ecmascript/ts_types/ts_type.cpp +++ b/ecmascript/ts_types/ts_type.cpp @@ -43,7 +43,7 @@ JSHClass *TSObjectType::CreateHClassByProps(JSThread *thread, JSHandleNumberOfElements(); if (numOfProps > PropertyAttributes::MAX_CAPACITY_OF_PROPERTIES) { - LOG(ERROR, RUNTIME) << "TSobject type has too many keys and cannot create hclass"; + LOG_ECMA(ERROR) << "TSobject type has too many keys and cannot create hclass"; UNREACHABLE(); } diff --git a/js_runtime_config.gni b/js_runtime_config.gni index 7127effe..5120619d 100644 --- a/js_runtime_config.gni +++ b/js_runtime_config.gni @@ -23,6 +23,7 @@ compile_llvm_online = false run_with_asan = false enable_bytrace = true enable_hitrace = true +enable_hilog = true enable_dump_in_faultlog = true asan_lib_path = "/usr/lib/llvm-10/lib/clang/10.0.0/lib/linux"