diff --git a/ecmascript/compiler/aot_compiler.cpp b/ecmascript/compiler/aot_compiler.cpp index 7cc17b50087c2cac2004f172c27f9ce0efb5089f..19ce1a6de9d6624fdc78d52506d31a0b1943709f 100644 --- a/ecmascript/compiler/aot_compiler.cpp +++ b/ecmascript/compiler/aot_compiler.cpp @@ -186,7 +186,8 @@ int Main(const int argc, const char **argv) cPreprocessor.GetCallMethodFlagMap(), cPreprocessor.GetAbcFileInfo(), cPreprocessor.GetBcInfoCollectors(), - cOptions.optBCRange_); + cOptions.optBCRange_, + cOptions.enableDebugInfo_); bool isEnableLiteCG = runtimeOptions.IsCompilerEnableLiteCG(); compilerStats.SetIsLiteCg(isEnableLiteCG); diff --git a/ecmascript/compiler/aot_compiler_preprocessor.cpp b/ecmascript/compiler/aot_compiler_preprocessor.cpp index f9b9411d6c08f2fedcb550a4c79e6d9235ff6879..69978e627b7e6c182d5f516b73844d25679dab85 100644 --- a/ecmascript/compiler/aot_compiler_preprocessor.cpp +++ b/ecmascript/compiler/aot_compiler_preprocessor.cpp @@ -66,6 +66,7 @@ CompilationOptions::CompilationOptions(JSRuntimeOptions &runtimeOptions) isEnableVerifierPass_ = !runtimeOptions.IsTargetCompilerMode(); isEnableBaselinePgo_ = runtimeOptions.IsEnableBaselinePgo(); isEnableMergePoly_ = runtimeOptions.IsEnableMergePoly(); + enableDebugInfo_ = runtimeOptions.IsEnableDebugInfo(); std::string optionSelectMethods = runtimeOptions.GetCompilerSelectMethods(); std::string optionSkipMethods = runtimeOptions.GetCompilerSkipMethods(); if (!optionSelectMethods.empty() && !optionSkipMethods.empty()) { diff --git a/ecmascript/compiler/aot_compiler_preprocessor.h b/ecmascript/compiler/aot_compiler_preprocessor.h index 40023aa3cc62b46c3e038208592c1251d0cfc2a2..1c8f81d17ed318648eae46a9c960054ff11d9bbe 100644 --- a/ecmascript/compiler/aot_compiler_preprocessor.h +++ b/ecmascript/compiler/aot_compiler_preprocessor.h @@ -98,6 +98,7 @@ struct CompilationOptions { std::map> optionSelectMethods_; std::map> optionSkipMethods_; size_t anFileMaxByteSize_ {0_MB}; + bool enableDebugInfo_ {false}; }; class AotCompilerPreprocessor { diff --git a/ecmascript/compiler/aot_file/tests/aot_file_test.cpp b/ecmascript/compiler/aot_file/tests/aot_file_test.cpp index 2f5c0c4c2e3d01b6d926a3393e3cf33afec2d135..12dddec706462d61ee330ec9a8e6f69acd3163c1 100644 --- a/ecmascript/compiler/aot_file/tests/aot_file_test.cpp +++ b/ecmascript/compiler/aot_file/tests/aot_file_test.cpp @@ -231,7 +231,7 @@ protected: PassManager passManager(&aotCompilationEnv, cOptions.triple_, cOptions.optLevel_, cOptions.relocMode_, &log, &logList, cOptions.maxAotMethodSize_, cOptions.maxMethodsInModule_, profilerDecoder, &passOptions, cPreprocessor.GetCallMethodFlagMap(), cPreprocessor.GetAbcFileInfo(), - cPreprocessor.GetBcInfoCollectors(), cOptions.optBCRange_); + cPreprocessor.GetBcInfoCollectors(), cOptions.optBCRange_, cOptions.enableDebugInfo_); AOTFileGeneratorMock generator(&log, &logList, &aotCompilationEnv, cOptions.triple_, false, limitSizeByte); passManager.CompileValidFiles(generator, ret, compilerStats); if (generator.SaveAndGetAOTFileSize(cOptions.outputFileName_ + AOTFileManager::FILE_EXTENSION_AN, "", diff --git a/ecmascript/compiler/ntype_bytecode_lowering.cpp b/ecmascript/compiler/ntype_bytecode_lowering.cpp index 18a6fe2d6aada2ad2e12e5ec71ff077f039fe6c4..3a8eec3e9a0ba775859e9c56d0e0fa73311b5797 100644 --- a/ecmascript/compiler/ntype_bytecode_lowering.cpp +++ b/ecmascript/compiler/ntype_bytecode_lowering.cpp @@ -122,7 +122,9 @@ void NTypeBytecodeLowering::Lower(GateRef gate) void NTypeBytecodeLowering::LowerThrowUndefinedIfHoleWithName(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef value = acc_.GetValueIn(gate, 1); // 1: the second parameter builder_.LexVarIsHoleCheck(value); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), Circuit::NullGate()); @@ -130,7 +132,9 @@ void NTypeBytecodeLowering::LowerThrowUndefinedIfHoleWithName(GateRef gate) void NTypeBytecodeLowering::LowerThrowIfSuperNotCorrectCall(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef index = acc_.GetValueIn(gate, 0); GateRef value = acc_.GetValueIn(gate, 1); uint32_t indexValue = static_cast(acc_.GetConstantValue(index)); @@ -146,7 +150,9 @@ void NTypeBytecodeLowering::LowerThrowIfSuperNotCorrectCall(GateRef gate) void NTypeBytecodeLowering::LowerThrowIfNotObject(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef value = acc_.GetValueIn(gate, 0); // 0: the first parameter builder_.EcmaObjectCheck(value); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), Circuit::NullGate()); @@ -154,7 +160,9 @@ void NTypeBytecodeLowering::LowerThrowIfNotObject(GateRef gate) void NTypeBytecodeLowering::LowerLdLexVar(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef level = acc_.GetValueIn(gate, 0); // 0: first parameter GateRef index = acc_.GetValueIn(gate, 1); // 1: the second parameter GateRef currentEnv = acc_.GetValueIn(gate, 2); // 2: the third parameter @@ -177,7 +185,9 @@ void NTypeBytecodeLowering::LowerLdLexVar(GateRef gate) void NTypeBytecodeLowering::LowerStLexVar(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef level = acc_.GetValueIn(gate, 0); // 0: first parameter GateRef index = acc_.GetValueIn(gate, 1); // 1: the second parameter GateRef currentEnv = acc_.GetValueIn(gate, 2); // 2: the third parameter @@ -203,7 +213,9 @@ void NTypeBytecodeLowering::LowerNTypedCreateEmptyArray(GateRef gate) { // in the future, the type of the elements in the array will be obtained through pgo, // and the type will be used to determine whether to create a typed-array. - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } ElementsKind kind = acc_.TryGetElementsKind(gate); uint32_t length = acc_.TryGetArrayElementsLength(gate); RegionSpaceFlag flag = acc_.TryGetRegionSpaceFlag(gate); @@ -225,7 +237,9 @@ void NTypeBytecodeLowering::LowerNTypedCreateArrayWithBuffer(GateRef gate) if (arr.IsUndefined()) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } ElementsKind kind = acc_.TryGetElementsKind(gate); RegionSpaceFlag flag = acc_.TryGetRegionSpaceFlag(gate); GateRef cpIdGr = builder_.Int32(cpId); @@ -239,7 +253,9 @@ void NTypeBytecodeLowering::LowerNTypedCopyRestArgs(GateRef gate) { ASSERT(acc_.GetNumValueIn(gate) == 1); GateRef restIdx = acc_.GetValueIn(gate, 0); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } ElementsKind kind = acc_.TryGetElementsKind(gate); GateRef arguments = builder_.CreateArguments(kind, CreateArgumentsAccessor::Mode::REST_ARGUMENTS, restIdx); @@ -250,7 +266,9 @@ void NTypeBytecodeLowering::LowerNTypedGetUnmappedArgs(GateRef gate) { ASSERT(acc_.GetNumValueIn(gate) == 0); GateRef restIdx = builder_.Int32(0); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } ElementsKind kind = acc_.TryGetElementsKind(gate); GateRef arguments = builder_.CreateArguments(kind, CreateArgumentsAccessor::Mode::UNMAPPED_ARGUMENTS, restIdx); @@ -270,7 +288,9 @@ void NTypeBytecodeLowering::LowerNTypedStownByIndex(GateRef gate) } builder_.COWArrayCheck(receiver); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } uint32_t indexValue = static_cast(acc_.GetConstantValue(index)); uint32_t arraySize = acc_.GetArraySize(receiver); if (indexValue > arraySize) { @@ -334,7 +354,9 @@ void NTypeBytecodeLowering::AddProfiling(GateRef gate) void NTypeBytecodeLowering::LowerLdLocalMoudleVar(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef jsFunc = argAcc_->GetFrameArgsIn(gate, FrameArgIdx::FUNC); GateRef index = acc_.GetValueIn(gate, 0); GateRef result = builder_.LdLocalModuleVar(jsFunc, index); @@ -374,7 +396,9 @@ void NTypeBytecodeLowering::LowerLdExternalMoudleVar(GateRef gate) void NTypeBytecodeLowering::LowerStModuleVar(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef jsFunc = argAcc_->GetFrameArgsIn(gate, FrameArgIdx::FUNC); GateRef index = acc_.GetValueIn(gate, 0); GateRef value = acc_.GetValueIn(gate, 1); diff --git a/ecmascript/compiler/ntype_bytecode_lowering.h b/ecmascript/compiler/ntype_bytecode_lowering.h index 3a595baaaaac9a23f92bc4ff8620e20ae396d6f4..60c13a5650a1c25ad017a81b7c3d3753ae9489d9 100644 --- a/ecmascript/compiler/ntype_bytecode_lowering.h +++ b/ecmascript/compiler/ntype_bytecode_lowering.h @@ -23,7 +23,8 @@ namespace panda::ecmascript::kungfu { class NTypeBytecodeLowering { public: NTypeBytecodeLowering(Circuit *circuit, PassContext *ctx, - bool enableLog, bool enableLazyDeopt, const std::string& name, const CString& recordName) + bool enableLog, bool enableLazyDeopt, const std::string& name, + const CString& recordName, bool enableDebugInfo) : circuit_(circuit), acc_(circuit), builder_(circuit, ctx->GetCompilerConfig()), @@ -35,6 +36,7 @@ public: traceBc_(ctx->GetCompilerConfig()->IsTraceBC()), methodName_(name), recordName_(recordName), + enableDebugInfo_(enableDebugInfo), glue_(acc_.GetGlueFromArgList()), argAcc_(circuit->GetArgumentAccessor()), compilationEnv_(ctx->GetCompilationEnv()) {} @@ -92,6 +94,11 @@ private: return compilationEnv_->GetArrayLiteralFromCache(unsharedCp, cpIdx, recordName_); } + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } + enum SuperCorrectCallCheck : uint8_t { CALL_SUPER_BEFORE_THIS_CHECK = 0, FORBIDDEN_SUPER_REBIND_THIS_CHECK, @@ -112,6 +119,7 @@ private: GateRef glue_ {Circuit::NullGate()}; ArgumentAccessor *argAcc_; const CompilationEnv *compilationEnv_ {nullptr}; + bool enableDebugInfo_ {false}; }; } // panda::ecmascript::kungfu #endif // ECMASCRIPT_COMPILER_NTYPE_BYTECODE_LOWERING_H diff --git a/ecmascript/compiler/pass.h b/ecmascript/compiler/pass.h index e36c9c3ded1454581182c3f23ad9abe7944018c1..4248d1341ec5dbcc3058031eb74e68ccc261891b 100644 --- a/ecmascript/compiler/pass.h +++ b/ecmascript/compiler/pass.h @@ -75,12 +75,12 @@ public: uint32_t methodOffset = 0, CallMethodFlagMap *callMethodFlagMap = nullptr, const CVector &fileInfos = CVector{}, NativeAreaAllocator *allocator = nullptr, PGOProfilerDecoder *decoder = nullptr, PassOptions *passOptions = nullptr, - std::string optBCRange = "") + std::string optBCRange = "", bool enableDebugInfo = false) : builder_(builder), circuit_(circuit), ctx_(ctx), log_(log), methodName_(methodName), methodInfo_(methodInfo), recordName_(recordName), methodLiteral_(methodLiteral), methodOffset_(methodOffset), callMethodFlagMap_(callMethodFlagMap), fileInfos_(fileInfos), allocator_(allocator), decoder_(decoder), passOptions_(passOptions), - optBCRange_(optBCRange) + optBCRange_(optBCRange), enableDebugInfo_(enableDebugInfo) { } @@ -202,6 +202,11 @@ public: methodInfo_->SetIsCompiled(false); } + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } + private: BytecodeCircuitBuilder *builder_ {nullptr}; Circuit *circuit_ {nullptr}; @@ -219,6 +224,7 @@ private: PGOProfilerDecoder *decoder_ {nullptr}; PassOptions *passOptions_ {nullptr}; std::string optBCRange_; + bool enableDebugInfo_ {false}; }; template @@ -336,12 +342,13 @@ public: data->GetCallMethodFlagMap(), data->GetPGOProfilerDecoder(), data->GetOptBCRange(), - data->GetMethodLiteral()); + data->GetMethodLiteral(), + data->IsEnableDebugInfo()); lowering.RunTypedBytecodeLowering(); CombinedPassVisitor visitor(data->GetCircuit(), enableLog, data->GetMethodName(), &chunk); DeadCodeElimination deadCodeElimination(data->GetCircuit(), &visitor, &chunk); TSHCROptPass optimization(data->GetCircuit(), &visitor, &chunk, data->GetPassContext(), enableLog, - data->GetMethodName()); + data->GetMethodName(), data->IsEnableDebugInfo()); visitor.AddPass(&optimization); visitor.AddPass(&deadCodeElimination); @@ -363,7 +370,8 @@ public: data->GetMethodOffset(), data->GetLog()); bool enableLog = data->GetLog()->EnableMethodCIRLog(); NTypeBytecodeLowering lowering(data->GetCircuit(), data->GetPassContext(), enableLog, - passOptions->EnableLazyDeopt(), data->GetMethodName(), data->GetRecordName()); + passOptions->EnableLazyDeopt(), data->GetMethodName(), + data->GetRecordName(), data->IsEnableDebugInfo()); lowering.RunNTypeBytecodeLowering(); Chunk chunk(data->GetNativeAreaAllocator()); CombinedPassVisitor visitor(data->GetCircuit(), enableLog, data->GetMethodName(), &chunk); @@ -523,7 +531,7 @@ public: CombinedPassVisitor visitor(data->GetCircuit(), enableLog, data->GetMethodName(), &chunk); DeadCodeElimination deadCodeElimination(data->GetCircuit(), &visitor, &chunk); TSHCROptPass optimization(data->GetCircuit(), &visitor, &chunk, data->GetPassContext(), enableLog, - data->GetMethodName()); + data->GetMethodName(), data->IsEnableDebugInfo()); visitor.AddPass(&optimization); visitor.AddPass(&deadCodeElimination); @@ -541,7 +549,8 @@ public: TimeScope timescope("SlowPathLoweringPass", data->GetMethodName(), data->GetMethodOffset(), data->GetLog()); bool enableLog = data->GetLog()->EnableMethodCIRLog(); SlowPathLowering lowering(data->GetCircuit(), data->GetCompilerConfig(), data->GetPassContext(), - data->GetMethodLiteral(), enableLog, data->GetMethodName(), data->GetRecordName()); + data->GetMethodLiteral(), enableLog, data->GetMethodName(), data->GetRecordName(), + data->IsEnableDebugInfo()); lowering.CallRuntimeLowering(); return true; } diff --git a/ecmascript/compiler/pass_manager.cpp b/ecmascript/compiler/pass_manager.cpp index 280589e15232183f6ed9c8e02f5e20216b0bc199..63de08076782e240217924920c56b5e75681879d 100644 --- a/ecmascript/compiler/pass_manager.cpp +++ b/ecmascript/compiler/pass_manager.cpp @@ -308,7 +308,7 @@ bool PassManager::Compile(JSPandaFile *jsPandaFile, const std::string &fileName, PassData data(&builder, &circuit, &ctx, log_, fullName, &methodInfo, recordName, methodLiteral, methodOffset, callMethodFlagMap_, fileInfos_, compilationEnv_->GetNativeAreaAllocator(), decoder, passOptions_, - optBCRange_); + optBCRange_, enableDebugInfo_); PassRunner pipeline(&data); if (!pipeline.RunPass()) { return; diff --git a/ecmascript/compiler/pass_manager.h b/ecmascript/compiler/pass_manager.h index 94e06b4c41c2c670aa9e2d42d42f8412a2f7f6e9..75c1bfcb012ca807f8fec2777b35473ee041f0f4 100644 --- a/ecmascript/compiler/pass_manager.h +++ b/ecmascript/compiler/pass_manager.h @@ -124,11 +124,12 @@ public: CompilerLog *log, AotMethodLogList *logList, size_t maxAotMethodSize, size_t maxMethodsInModule, PGOProfilerDecoder &profilerDecoder, PassOptions *passOptions, CallMethodFlagMap *callMethodFlagMap, const CVector &fileInfos, const CVector> &bcInfoCollectors, - std::string optBCRange) + std::string optBCRange, bool enableDebugInfo) : compilationEnv_(env), triple_(triple), optLevel_(optLevel), relocMode_(relocMode), log_(log), logList_(logList), maxAotMethodSize_(maxAotMethodSize), maxMethodsInModule_(maxMethodsInModule), profilerDecoder_(profilerDecoder), passOptions_(passOptions), callMethodFlagMap_(callMethodFlagMap), - fileInfos_(fileInfos), bcInfoCollectors_(bcInfoCollectors), optBCRange_(optBCRange) { + fileInfos_(fileInfos), bcInfoCollectors_(bcInfoCollectors), optBCRange_(optBCRange), + enableDebugInfo_(enableDebugInfo) { enableJITLog_ = compilationEnv_->GetJSOptions().GetTraceJIT(); }; @@ -157,6 +158,7 @@ protected: const CVector> &bcInfoCollectors_; std::string optBCRange_ {}; bool enableJITLog_ {false}; + bool enableDebugInfo_ {false}; }; class JitPassManager : public PassManager { diff --git a/ecmascript/compiler/slowpath_lowering.cpp b/ecmascript/compiler/slowpath_lowering.cpp index 30f1e9d82d72248c7798fb5c93f3221d3829359f..69adfa3cfc5a8344fb18eddbf61988f0e4ec5692 100644 --- a/ecmascript/compiler/slowpath_lowering.cpp +++ b/ecmascript/compiler/slowpath_lowering.cpp @@ -290,7 +290,9 @@ void SlowPathLowering::Lower(GateRef gate) EcmaOpcode ecmaOpcode = acc_.GetByteCodeOpcode(gate); // initialize label manager Environment env(gate, circuit_, &builder_); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } switch (ecmaOpcode) { case EcmaOpcode::CALLARG0_IMM8: LowerCallArg0Stub(gate); @@ -1030,7 +1032,9 @@ void SlowPathLowering::LowerSuspendGenerator(GateRef gate) { SaveFrameToContext(gate); acc_.SetDep(gate, builder_.GetDepend()); - AddProfiling(gate, false); + if (IsEnableDebugInfo()) { + AddProfiling(gate, false); + } const int id = RTSTUB_ID(OptSuspendGenerator); auto value = acc_.GetValueIn(gate, 2); // 2: acc auto genObj = acc_.GetValueIn(gate, 1); @@ -3218,7 +3222,9 @@ void SlowPathLowering::LowerResumeGenerator(GateRef gate) GateRef obj = acc_.GetValueIn(gate, 0); std::vector registerGates {}; - AddProfiling(gate, false); + if (IsEnableDebugInfo()) { + AddProfiling(gate, false); + } GateRef contextOffset = builder_.IntPtr(JSGeneratorObject::GENERATOR_CONTEXT_OFFSET); GateRef contextGate = builder_.Load(VariableType::JS_POINTER(), glue_, obj, contextOffset); GateRef arrayOffset = builder_.IntPtr(GeneratorContext::GENERATOR_REGS_ARRAY_OFFSET); diff --git a/ecmascript/compiler/slowpath_lowering.h b/ecmascript/compiler/slowpath_lowering.h index 4f973810ac1f987e7996e2d8758199190058b4e9..44c16c3c7ca85bfd1d46c20ccf058ee2f98f983f 100644 --- a/ecmascript/compiler/slowpath_lowering.h +++ b/ecmascript/compiler/slowpath_lowering.h @@ -114,11 +114,13 @@ class SlowPathLowering { public: SlowPathLowering(Circuit *circuit, CompilationConfig *cmpCfg, PassContext *ctx, const MethodLiteral *methodLiteral, - bool enableLog, const std::string& name, const CString &recordName) + bool enableLog, const std::string& name, const CString &recordName, + bool enableDebugInfo) : compilationEnv_(ctx->GetCompilationEnv()), methodLiteral_(methodLiteral), circuit_(circuit), acc_(circuit), argAcc_(circuit->GetArgumentAccessor()), builder_(circuit, cmpCfg), - enableLog_(enableLog), methodName_(name), recordName_(recordName), glue_(acc_.GetGlueFromArgList()) + enableLog_(enableLog), methodName_(name), recordName_(recordName), enableDebugInfo_(enableDebugInfo), + glue_(acc_.GetGlueFromArgList()) { traceBc_ = cmpCfg->IsTraceBC(); profiling_ = cmpCfg->IsProfiling(); @@ -147,6 +149,11 @@ public: return stressDeopt_; } + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } + private: const std::string& GetMethodName() const { @@ -370,6 +377,7 @@ private: const CString &recordName_; GateRef glue_ {Circuit::NullGate()}; CVector unsharedCP_; + bool enableDebugInfo_ {false}; }; } // panda::ecmascript::kungfu #endif // ECMASCRIPT_COMPILER_SLOWPATH_LOWERING_H diff --git a/ecmascript/compiler/ts_hcr_opt_pass.cpp b/ecmascript/compiler/ts_hcr_opt_pass.cpp index 65706a2a1a81c7b39111213669b64760752849b1..e7e4546dc824dd9b516b4d7e8951f5848018997b 100644 --- a/ecmascript/compiler/ts_hcr_opt_pass.cpp +++ b/ecmascript/compiler/ts_hcr_opt_pass.cpp @@ -20,7 +20,9 @@ namespace panda::ecmascript::kungfu { GateRef TSHCROptPass::VisitGate(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } auto opcode = acc_.GetOpCode(gate); switch (opcode) { case OpCode::TYPED_BINARY_OP: diff --git a/ecmascript/compiler/ts_hcr_opt_pass.h b/ecmascript/compiler/ts_hcr_opt_pass.h index af4ee35149e6fb926b1775be0617004f5135a397..1ce47d77bd1a53eca0c4350f824eaedfba3318be 100644 --- a/ecmascript/compiler/ts_hcr_opt_pass.h +++ b/ecmascript/compiler/ts_hcr_opt_pass.h @@ -29,12 +29,14 @@ public: Chunk* chunk, PassContext *ctx, bool enableLog, - const std::string &name) + const std::string &name, + bool enableDebugInfo) : PassVisitor(circuit, chunk, visitor), builder_(circuit, ctx->GetCompilerConfig()), compilationEnv_(ctx->GetCompilationEnv()), enableLog_(enableLog), methodName_(name), + enableDebugInfo_(enableDebugInfo), glue_(acc_.GetGlueFromArgList()) { if (ctx->GetCompilerConfig() != nullptr) { @@ -78,6 +80,10 @@ private: GateRef ConvertStringEqualToConst(GateRef left, GateRef right); GateRef ConvertConstSingleCharToInt32(GateRef gate); GateRef ConvertToSingleCharComparison(GateRef left, GateRef right); + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } CircuitBuilder builder_; const CompilationEnv *compilationEnv_ {nullptr}; @@ -85,6 +91,7 @@ private: std::string methodName_; bool typedOpProfiling_ {false}; GateRef glue_ {Circuit::NullGate()}; + bool enableDebugInfo_ {false}; }; } // panda::ecmascript::kungfu #endif // ECMASCRIPT_COMPILER_TS_HCR_OPT_PASS_H diff --git a/ecmascript/compiler/typed_bytecode_lowering.cpp b/ecmascript/compiler/typed_bytecode_lowering.cpp index 0517a10973fbaeee0886d54d504e8d3110f2d845..254e0176a2cecb76cc93eca42282df2dffca7e0d 100644 --- a/ecmascript/compiler/typed_bytecode_lowering.cpp +++ b/ecmascript/compiler/typed_bytecode_lowering.cpp @@ -377,7 +377,9 @@ void TypedBytecodeLowering::LowerTypedEqOrNotEq(GateRef gate) { BinOpTypeInfoAccessor tacc(compilationEnv_, circuit_, gate); if (tacc.LeftOrRightIsUndefinedOrNull()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); GateRef result = builder_.TypedBinaryOp(left, right, tacc.GetParamType()); @@ -419,7 +421,9 @@ void TypedBytecodeLowering::SpeculateInternStrings(const BinOpTypeInfoAccessor & SpeculateStrings(tacc); return; } - AddProfiling(tacc.GetGate()); + if (IsEnableDebugInfo()) { + AddProfiling(tacc.GetGate()); + } GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); InternStringCheck(left); @@ -432,7 +436,9 @@ template void TypedBytecodeLowering::SpeculateStrings(const BinOpTypeInfoAccessor &tacc) { if (Op == TypedBinOp::TYPED_EQ || Op == TypedBinOp::TYPED_ADD) { - AddProfiling(tacc.GetGate()); + if (IsEnableDebugInfo()) { + AddProfiling(tacc.GetGate()); + } GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); if (!TypeInfoAccessor::IsTrustedStringType(compilationEnv_, circuit_, chunk_, acc_, left)) { @@ -457,7 +463,9 @@ void TypedBytecodeLowering::SpeculateStrings(const BinOpTypeInfoAccessor &tacc) template void TypedBytecodeLowering::SpeculateNumbers(const BinOpTypeInfoAccessor &tacc) { - AddProfiling(tacc.GetGate()); + if (IsEnableDebugInfo()) { + AddProfiling(tacc.GetGate()); + } pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), true); GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); @@ -468,7 +476,9 @@ void TypedBytecodeLowering::SpeculateNumbers(const BinOpTypeInfoAccessor &tacc) template void TypedBytecodeLowering::SpeculateNumber(const UnOpTypeInfoAccessor &tacc) { - AddProfiling(tacc.GetGate()); + if (IsEnableDebugInfo()) { + AddProfiling(tacc.GetGate()); + } pgoTypeLog_.CollectGateTypeLogInfo(tacc.GetGate(), false); GateRef result = builder_.TypedUnaryOp(tacc.GetValue(), tacc.GetParamType()); acc_.ReplaceHirAndReplaceDeadIfException(tacc.GetGate(), builder_.GetStateDepend(), result); @@ -503,7 +513,9 @@ template void TypedBytecodeLowering::SpeculateNumbersOrString(const BinOpTypeInfoAccessor &tacc) { if (Op == TypedBinOp::TYPED_ADD) { - AddProfiling(tacc.GetGate()); + if (IsEnableDebugInfo()) { + AddProfiling(tacc.GetGate()); + } GateRef left = tacc.GetLeftGate(); GateRef right = tacc.GetReightGate(); @@ -526,7 +538,9 @@ void TypedBytecodeLowering::LowerTypeToNumeric(GateRef gate) { UnOpTypeInfoAccessor tacc(compilationEnv_, circuit_, gate); if (tacc.HasNumberType()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } LowerPrimitiveTypeToNumber(tacc); } } @@ -541,7 +555,9 @@ void TypedBytecodeLowering::LowerConditionJump(GateRef gate, bool flag) { ConditionJumpTypeInfoAccessor tacc(compilationEnv_, circuit_, gate); if (TypeInfoAccessor::IsTrustedBooleanType(acc_, tacc.GetValue())) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } SpeculateConditionJump(tacc, flag); } } @@ -895,7 +911,9 @@ void TypedBytecodeLowering::LowerTypedLdObjByName(GateRef gate) if (enableMergePoly_) { tacc.TryMergeExpectedHClass(); } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (tacc.IsMono()) { LowerTypedMonoLdObjByName(tacc); return; @@ -911,7 +929,9 @@ void TypedBytecodeLowering::LowerTypedLdPrivateProperty(GateRef gate) return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } Label exit(&builder_); GateRef receiver = tacc.GetReceiver(); @@ -948,7 +968,9 @@ void TypedBytecodeLowering::LowerTypedStPrivateProperty(GateRef gate) return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } Label exit(&builder_); GateRef receiver = tacc.GetReceiver(); @@ -1014,7 +1036,9 @@ void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate) fails.emplace_back(Label(&builder_)); } Label exit(&builder_); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef frameState = Circuit::NullGate(); auto opcode = acc_.GetByteCodeOpcode(gate); // The framestate of Call and Accessor related instructions directives is placed on IR. Using the depend edge to @@ -1309,7 +1333,9 @@ bool TypedBytecodeLowering::TryLowerTypedLdObjByNameForGlobalsId(const LoadBuilt if (!plr.IsFound() || plr.IsAccessor()) { return false; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } // 1. check hclass builder_.HeapObjectCheck(receiver, frameState); GateRef receiverHClass = builder_.LoadHClassByConstOffset(glue_, receiver); @@ -1331,7 +1357,9 @@ bool TypedBytecodeLowering::TryLowerTypedLdObjByNameForGlobalsId(const LoadBuilt return false; } SetPlrLdFromIterResult(index, plr); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } // 1. check hclass builder_.HeapObjectCheck(receiver, frameState); GateRef receiverHClass = builder_.LoadHClassByConstOffset(glue_, receiver); @@ -1369,7 +1397,9 @@ bool TypedBytecodeLowering::TryLowerTypedLdobjBynameFromGloablBuiltin(GateRef ga if (!plr.IsFound() || plr.IsAccessor()) { return false; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } builder_.MathHClassConsistencyCheck(receiver); GateRef plrGate = builder_.Int32(plr.GetData()); GateRef result = builder_.LoadProperty(receiver, plrGate, plr.IsFunction()); @@ -1385,7 +1415,9 @@ void TypedBytecodeLowering::LowerTypedLdArrayLength(const LoadBuiltinObjTypeInfo GateRef gate = tacc.GetGate(); GateRef array = tacc.GetReceiver(); ElementsKind kind = acc_.TryGetElementsKind(gate); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { if (!acc_.IsCreateArray(array)) { builder_.StableArrayCheck(array, kind, ArrayMetaDataAccessor::Mode::LOAD_LENGTH); @@ -1400,7 +1432,9 @@ void TypedBytecodeLowering::LowerTypedLdTypedArrayLength(const LoadBuiltinObjTyp { GateRef gate = tacc.GetGate(); GateRef array = tacc.GetReceiver(); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } ParamType arrayType = tacc.GetParamType(); OnHeapMode onHeap = acc_.TryGetOnHeapMode(gate); if (!Uncheck()) { @@ -1414,7 +1448,9 @@ void TypedBytecodeLowering::LowerTypedLdStringLength(const LoadBuiltinObjTypeInf { GateRef gate = tacc.GetGate(); GateRef str = tacc.GetReceiver(); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!TypeInfoAccessor::IsTrustedStringType(compilationEnv_, circuit_, chunk_, acc_, str)) { if (!Uncheck()) { builder_.EcmaStringCheck(str); @@ -1428,7 +1464,9 @@ void TypedBytecodeLowering::LowerTypedLdMapSize(const LoadBuiltinObjTypeInfoAcce { GateRef gate = tacc.GetGate(); GateRef jsMap = tacc.GetReceiver(); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.EcmaMapCheck(jsMap); } @@ -1471,7 +1509,9 @@ bool TypedBytecodeLowering::TryLowerTypedLdObjByNameForBuiltinMethod(const LoadB return false; } } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef receiver = acc_.GetValueIn(gate, 2); if (!Uncheck()) { /** @@ -1515,7 +1555,9 @@ bool TypedBytecodeLowering::TryLowerTypedLdObjByIndexForBuiltin(GateRef gate) // Just supported mono. if (tacc.IsMono()) { if (tacc.IsBuiltinsTypeArray()) { // pgo need dump profile type - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } result = LoadTypedArrayByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), result); return true; @@ -1540,7 +1582,9 @@ bool TypedBytecodeLowering::TryLowerTypedStObjByIndexForBuiltin(GateRef gate) if (tacc.GetBuiltinsJSType() != JSType::JS_FLOAT32_ARRAY) { return false; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef receiver = tacc.GetReceiver(); ParamType receiverType = tacc.GetParamType(); if (!Uncheck()) { @@ -1573,17 +1617,23 @@ bool TypedBytecodeLowering::TryLowerTypedLdObjByValueForBuiltin(GateRef gate) // Just supported mono. if (tacc.IsMono()) { if (tacc.IsBuiltinsString()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } result = LoadStringByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), result); return true; } else if (tacc.IsBuiltinsArray()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } result = LoadJSArrayByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), result); return true; } else if (tacc.IsBuiltinsTypeArray()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } result = LoadTypedArrayByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), result); return true; @@ -1606,7 +1656,9 @@ void TypedBytecodeLowering::LowerTypedLdObjByValue(GateRef gate) return; } DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.Hole()); - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef frameState = acc_.FindNearestFrameState(gate); if (tacc.IsMono()) { if (!tacc.GetName()->IsString()) { @@ -1837,12 +1889,16 @@ bool TypedBytecodeLowering::TryLowerTypedStObjByValueForBuiltin(GateRef gate) // Just supported mono. if (tacc.IsMono() && !tacc.IsStoreOutOfBounds()) { if (tacc.IsBuiltinsArray()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } StoreJSArrayByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), Circuit::NullGate()); return true; } else if (tacc.IsBuiltinsTypeArray()) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } StoreTypedArrayByIndex(tacc); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), Circuit::NullGate()); return true; @@ -1879,7 +1935,9 @@ void TypedBytecodeLowering::LowerTypedIsTrueOrFalse(GateRef gate, bool flag) } else { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef result; if (!flag) { result = builder_.TypedUnaryOp(tacc.GetValue(), paramType); @@ -1934,7 +1992,9 @@ void TypedBytecodeLowering::LowerTypedNewObjRange(GateRef gate) if (method == nullptr || !value.IsJSHClass() || hclass->GetObjectType() != JSType::JS_OBJECT) { return ; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef ctor = tacc.GetValue(); GateRef hclassIndex = tacc.GetHClassIndex(); GateRef stateSplit = acc_.GetDep(gate); @@ -1984,14 +2044,18 @@ bool TypedBytecodeLowering::TryLowerNewBuiltinConstructor(GateRef gate) GateRef ctor = tacc.GetValue(); GateRef constructGate = Circuit::NullGate(); if (tacc.IsBuiltinId(BuiltinsStubCSigns::ID::ObjectConstructor)) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.ObjectConstructorCheck(ctor); } constructGate = builder_.BuiltinConstructor(BuiltinsStubCSigns::ID::ObjectConstructor, gate); } else if (tacc.IsBuiltinId(BuiltinsStubCSigns::ID::BooleanConstructor)) { if (acc_.GetNumValueIn(gate) <= 2) { // 2: ctor and first arg - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.BooleanConstructorCheck(ctor); } @@ -1999,7 +2063,9 @@ bool TypedBytecodeLowering::TryLowerNewBuiltinConstructor(GateRef gate) } } else if (tacc.IsBuiltinId(BuiltinsStubCSigns::ID::Float32ArrayConstructor)) { if (acc_.GetNumValueIn(gate) <= 2) { // 2: ctor and first arg - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.Float32ArrayConstructorCheck(ctor); } @@ -2008,7 +2074,9 @@ bool TypedBytecodeLowering::TryLowerNewBuiltinConstructor(GateRef gate) } if (constructGate == Circuit::NullGate()) { // for other builtin constructor, do necessory check and just call runtime JSCallNew. - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.TypedConstructorCheck(ctor, GET_TYPED_GLOBAL_ENV_INDEX(id)); } @@ -2042,7 +2110,9 @@ void TypedBytecodeLowering::LowerTypedSuperCall(GateRef gate) if (!tacc.IsValidCallMethodId()) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef ctor = tacc.GetCtor(); @@ -2369,7 +2439,9 @@ void TypedBytecodeLowering::LowerTypedCall(const TypeAccessor &tacc) if (argc != len) { return ; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } CheckCallTargetAndLowerCall(tacc, args, argsFastCall); } @@ -2418,7 +2490,9 @@ void TypedBytecodeLowering::LowerTypedCallArg1(GateRef gate) if (IS_TYPED_INLINE_BUILTINS_ID(id)) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (IsFuncFromGlobal(func)) { // No need to do CallTargetCheck if func is from LOAD_BUILTIN_OBJECT. SpeculateCallBuiltinFromGlobal(gate, { a0Value }, id, true); @@ -2546,7 +2620,9 @@ void TypedBytecodeLowering::LowerTypedThisCall(const TypeAccessor &tacc) argsFastCall.emplace_back(builder_.Undefined()); args.emplace_back(builder_.Undefined()); } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } CheckThisCallTargetAndLowerCall(tacc, args, argsFastCall); } @@ -2558,7 +2634,9 @@ void TypedBytecodeLowering::LowerTypedCallthis0(GateRef gate) CallThis0TypeInfoAccessor tacc(compilationEnv_, circuit_, gate, GetCalleePandaFile(gate), callMethodFlagMap_); BuiltinsStubCSigns::ID pgoFuncId = tacc.TryGetPGOBuiltinMethodId(); if (!IS_INVALID_ID(pgoFuncId) && IS_TYPED_BUILTINS_ID_CALL_THIS0(pgoFuncId)) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } SpeculateCallBuiltin(gate, tacc.GetFunc(), {tacc.GetThisObj()}, pgoFuncId, true); return; } @@ -2576,7 +2654,9 @@ void TypedBytecodeLowering::LowerTypedCallthis1(GateRef gate) CallThis1TypeInfoAccessor tacc(compilationEnv_, circuit_, gate, GetCalleePandaFile(gate), callMethodFlagMap_); BuiltinsStubCSigns::ID pgoFuncId = tacc.TryGetPGOBuiltinMethodId(); if (!IS_INVALID_ID(pgoFuncId) && IS_TYPED_BUILTINS_ID_CALL_THIS1(pgoFuncId)) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } SpeculateCallBuiltin(gate, tacc.GetFunc(), {tacc.GetArgs()}, pgoFuncId, true); return; } @@ -2594,7 +2674,9 @@ void TypedBytecodeLowering::LowerTypedCallthis2(GateRef gate) CallThis2TypeInfoAccessor tacc(compilationEnv_, circuit_, gate, GetCalleePandaFile(gate), callMethodFlagMap_); BuiltinsStubCSigns::ID pgoFuncId = tacc.TryGetPGOBuiltinMethodId(); if (!IS_INVALID_ID(pgoFuncId) && IS_TYPED_BUILTINS_ID_CALL_THIS2(pgoFuncId)) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } SpeculateCallBuiltin(gate, tacc.GetFunc(), { tacc.GetArgs() }, pgoFuncId, true); return; } @@ -2612,7 +2694,9 @@ void TypedBytecodeLowering::LowerTypedCallthis3(GateRef gate) CallThis3TypeInfoAccessor tacc(compilationEnv_, circuit_, gate, GetCalleePandaFile(gate), callMethodFlagMap_); BuiltinsStubCSigns::ID pgoFuncId = tacc.TryGetPGOBuiltinMethodId(); if (!IS_INVALID_ID(pgoFuncId) && IS_TYPED_BUILTINS_ID_CALL_THIS3(pgoFuncId)) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } SpeculateCallBuiltin(gate, tacc.GetFunc(), { tacc.GetArgs() }, pgoFuncId, true); return; } @@ -2722,7 +2806,9 @@ void TypedBytecodeLowering::LowerTypedTypeOf(GateRef gate) if (tacc.IsIllegalType()) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } if (!Uncheck()) { builder_.TypeOfCheck(tacc.GetValue(), tacc.GetParamType()); } @@ -2740,7 +2826,9 @@ void TypedBytecodeLowering::LowerGetIterator(GateRef gate) if (IS_INVALID_ID(id) || id == BuiltinsStubCSigns::ID::NONE) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef obj = tacc.GetCallee(); SpeculateCallBuiltin(gate, obj, { obj }, id, true); } @@ -2759,7 +2847,9 @@ void TypedBytecodeLowering::LowerTypedTryLdGlobalByName(GateRef gate) BuiltinIndex& builtin = BuiltinIndex::GetInstance(); auto index = builtin.GetBuiltinIndex(compilationEnv_->GetJSThread(), key); if (index != builtin.NOT_FOUND) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef result = builder_.LoadBuiltinObject(index); acc_.ReplaceHirAndReplaceDeadIfException(gate, builder_.GetStateDepend(), result); DeleteConstDataIfNoUser(tacc.GetKey()); @@ -2774,7 +2864,9 @@ void TypedBytecodeLowering::LowerTypedTryLdGlobalByName(GateRef gate) if (heapConstantIndex == JitCompilationEnv::INVALID_HEAP_CONSTANT_INDEX) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef frameState = acc_.FindNearestFrameState(builder_.GetDepend()); GateRef propertyBoxConst = builder_.HeapConstant(heapConstantIndex); GateRef boxValue = builder_.LoadConstOffset( @@ -2791,7 +2883,9 @@ void TypedBytecodeLowering::LowerInstanceOf(GateRef gate) if (tacc.TypesIsEmpty() || tacc.HasIllegalType()) { return; } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } size_t typeCount = tacc.GetTypeCount(); std::vector expectedHCIndexes; for (size_t i = 0; i < typeCount; ++i) { @@ -2814,7 +2908,9 @@ void TypedBytecodeLowering::LowerInstanceOf(GateRef gate) void TypedBytecodeLowering::LowerCreateEmptyObject(GateRef gate) { - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } GateRef globalEnv = circuit_->GetGlobalEnvCache(); GateRef hclass = builder_.GetGlobalEnvObjHClass(globalEnv, GlobalEnv::OBJECT_FUNCTION_INDEX); @@ -2848,7 +2944,9 @@ void TypedBytecodeLowering::LowerCreateEmptyObject(GateRef gate) void TypedBytecodeLowering::LowerTypedStOwnByValue(GateRef gate) { // StOwnByValue is rarely used, so the callruntime solution is used - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } return; } @@ -2890,7 +2988,9 @@ void TypedBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate) } } - AddProfiling(gate); + if (IsEnableDebugInfo()) { + AddProfiling(gate); + } auto size = newClass->GetObjectSize(); std::vector valueIn; valueIn.emplace_back(builder_.IntPtr(size)); diff --git a/ecmascript/compiler/typed_bytecode_lowering.h b/ecmascript/compiler/typed_bytecode_lowering.h index 59c77f4f1aa5a10a88fe8b2d315173be196448cc..db99a5efe10556e15236f93b8fa13ac88288647d 100644 --- a/ecmascript/compiler/typed_bytecode_lowering.h +++ b/ecmascript/compiler/typed_bytecode_lowering.h @@ -44,7 +44,8 @@ public: const CallMethodFlagMap* callMethodFlagMap, PGOProfilerDecoder *decoder, const std::string optBCRange, - const MethodLiteral *currentMethod) + const MethodLiteral *currentMethod, + bool enableDebugInfo) : circuit_(circuit), acc_(circuit), ctx_(ctx), @@ -69,7 +70,8 @@ public: callMethodFlagMap_(callMethodFlagMap), decoder_(decoder), optBCRange_(optBCRange), - currentMethod_(currentMethod) + currentMethod_(currentMethod), + enableDebugInfo_(enableDebugInfo) { auto currentMethodId = currentMethod_->GetMethodId(); panda_file::IndexAccessor indexAccessor(*(ctx_->GetJSPandaFile()->GetPandaFile()), @@ -132,6 +134,11 @@ private: return methodName_; } + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } + void Lower(GateRef gate); template void LowerTypedBinOp(GateRef gate); @@ -410,6 +417,7 @@ private: std::vector> optBCRangeList_; const MethodLiteral *currentMethod_ {nullptr}; uint32_t constPoolId_ {0}; + bool enableDebugInfo_ {false}; }; } // panda::ecmascript::kungfu #endif // ECMASCRIPT_COMPILER_TYPED_BYTECODE_LOWERING_H diff --git a/ecmascript/js_runtime_options.cpp b/ecmascript/js_runtime_options.cpp index 33582f0066b3775dde87d1bb4ca492dbcfc395d0..abdbcb50318c10ffc08459075c75091c9ea6ca3e 100644 --- a/ecmascript/js_runtime_options.cpp +++ b/ecmascript/js_runtime_options.cpp @@ -385,6 +385,7 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) {"compiler-enable-merge-poly", required_argument, nullptr, OPTION_COMPILER_ENABLE_MERGE_POLY}, {"mem-config", required_argument, nullptr, OPTION_MEM_CONFIG}, {"multi-context", required_argument, nullptr, OPTION_MULTI_CONTEXT}, + {"enable-debug-info", required_argument, nullptr, OPTION_ENABLE_DEBUG_INFO}, {nullptr, 0, nullptr, 0}, }; @@ -1507,6 +1508,13 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) return false; } break; + case OPTION_ENABLE_DEBUG_INFO: + ret = ParseBoolParam(&argBool); + if (ret) { + SetEnableDebugInfo(argBool); + } else { + return false; + } default: LOG_ECMA(ERROR) << "Invalid option\n"; return false; diff --git a/ecmascript/js_runtime_options.h b/ecmascript/js_runtime_options.h index da92db275b4d4f7af717236d01544b7fb95141b7..1ad95d4c30929effa60e027d088f90b525300b5f 100644 --- a/ecmascript/js_runtime_options.h +++ b/ecmascript/js_runtime_options.h @@ -246,6 +246,7 @@ enum CommandValues { OPTION_COMPILER_ENABLE_MERGE_POLY, OPTION_MEM_CONFIG, OPTION_MULTI_CONTEXT, + OPTION_ENABLE_DEBUG_INFO, // OPTION_LAST should at the last OPTION_LAST, @@ -2260,6 +2261,16 @@ public: return enableGCTimeoutCheck_; } + void SetEnableDebugInfo(bool value) + { + enableDebugInfo_ = value; + } + + bool IsEnableDebugInfo() const + { + return enableDebugInfo_; + } + static bool ParseBool(const std::string &arg, bool* argBool); static bool ParseInt(const std::string &arg, int* argInt); static bool ParseUint32(const std::string &arg, uint32_t* argUInt32); @@ -2581,6 +2592,7 @@ private: bool enableWarmStartupSmartGC_ {false}; bool disableModuleSnapshot_ { false }; bool enableGCTimeoutCheck_ {true}; + bool enableDebugInfo_ {false}; }; } // namespace panda::ecmascript