From b19c83c7e4f8a02e60c908b172e8cd8d2c52954d Mon Sep 17 00:00:00 2001 From: luochuhao Date: Tue, 11 Jan 2022 12:03:15 +0800 Subject: [PATCH] Add pre-stub compilation and utilization control mechanism. Signed-off-by: luochuhao Change-Id: I745d468a63ff5cf08997738866a50d999e193a44 --- BUILD.gn | 18 ++++++++ ecmascript/compiler/BUILD.gn | 1 + ecmascript/compiler/fast_stub_define.h | 41 +++++++++++-------- ecmascript/compiler/stub_aot_compiler.cpp | 6 +-- ecmascript/compiler/tests/stub_tests.cpp | 35 +++++++++++++++- .../interpreter/fast_runtime_stub-inl.h | 27 ++++++------ ecmascript/interpreter/interpreter-inl.h | 24 +++++------ js_runtime_config.gni | 18 ++++++++ 8 files changed, 123 insertions(+), 47 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a749a09185..db42241373 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -128,6 +128,24 @@ source_set("libark_js_intl_static") { config("ark_jsruntime_common_config") { defines = [ "PANDA_ENABLE_LTO" ] + defines += [ + "ENABLE_FAST_ADD_STUB=" + enable_fast_add_stub, + "ENABLE_FAST_SUB_STUB=" + enable_fast_sub_stub, + "ENABLE_FAST_MUL_STUB=" + enable_fast_mul_stub, + "ENABLE_FAST_DIV_STUB=" + enable_fast_div_stub, + "ENABLE_FAST_MOD_STUB=" + enable_fast_mod_stub, + "ENABLE_FAST_EQUAL_STUB=" + enable_fast_equal_stub, + "ENABLE_FAST_TYPE_OF_STUB=" + enable_fast_type_of_stub, + "ENABLE_GET_PROP_BY_NAME_STUB=" + enable_get_prop_by_name_stub, + "ENABLE_SET_PROP_BY_NAME_STUB=" + enable_set_prop_by_name_stub, + "ENABLE_GET_PROP_BY_IDX_STUB=" + enable_get_prop_by_idx_stub, + "ENABLE_SET_PROP_BY_IDX_STUB=" + enable_set_prop_by_idx_stub, + "ENABLE_GET_PROP_BY_VALUE_STUB=" + enable_get_prop_by_value_stub, + "ENABLE_TRY_LD_IC_BY_NAME_STUB=" + enable_try_ld_ic_by_name_stub, + "ENABLE_TRY_LD_IC_BY_VALUE_STUB=" + enable_try_ld_ic_by_value_stub, + "ENABLE_TRY_ST_IC_BY_NAME_STUB=" + enable_try_st_ic_by_name_stub, + "ENABLE_TRY_ST_IC_BY_VALUE_STUB=" + enable_try_st_ic_by_value_stub, + ] if (enable_stub_aot) { defines += [ "ECMASCRIPT_ENABLE_STUB_AOT" ] } diff --git a/ecmascript/compiler/BUILD.gn b/ecmascript/compiler/BUILD.gn index 6f43046fc7..66efd65fec 100644 --- a/ecmascript/compiler/BUILD.gn +++ b/ecmascript/compiler/BUILD.gn @@ -37,6 +37,7 @@ config("include_llvm") { config("ark_jsruntime_compiler_config") { configs = [ "//ark/js_runtime:ark_jsruntime_common_config" ] + cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ] } source_set("libark_jsoptimizer_static") { diff --git a/ecmascript/compiler/fast_stub_define.h b/ecmascript/compiler/fast_stub_define.h index 72f1c4f8ac..a1f7147193 100644 --- a/ecmascript/compiler/fast_stub_define.h +++ b/ecmascript/compiler/fast_stub_define.h @@ -17,6 +17,11 @@ #define ECMASCRIPT_COMPILER_FASTSTUB_DEFINE_H namespace panda::ecmascript::kungfu { +#define IF_EXEC(condition, call) IF_EXEC_IMPL(condition, call) +#define IF_EXEC_IMPL(condition, ...) IF_EXEC_ ## condition (__VA_ARGS__) +#define IF_EXEC_0(foo, ...) +#define IF_EXEC_1(foo, ...) foo, ##__VA_ARGS__ + // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define EXTERNAL_RUNTIMESTUB_LIST(V) \ V(AddElementInternal, 5) \ @@ -47,24 +52,24 @@ namespace panda::ecmascript::kungfu { V(DebugPrint, 1) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define FAST_RUNTIME_STUB_LIST(V) \ - V(FastAdd, 2) \ - V(FastSub, 2) \ - V(FastMul, 2) \ - V(FastDiv, 2) \ - V(FastMod, 3) \ - V(FastEqual, 2) \ - V(FastTypeOf, 2) \ - V(GetPropertyByName, 3) \ - V(SetPropertyByName, 4) \ - V(SetPropertyByNameWithOwn, 4) \ - V(GetPropertyByIndex, 3) \ - V(SetPropertyByIndex, 4) \ - V(GetPropertyByValue, 3) \ - V(TryLoadICByName, 4) \ - V(TryLoadICByValue, 5) \ - V(TryStoreICByName, 5) \ - V(TryStoreICByValue, 6) +#define FAST_RUNTIME_STUB_LIST(V) \ + IF_EXEC(ENABLE_FAST_ADD_STUB, V(FastAdd, 2)) \ + IF_EXEC(ENABLE_FAST_SUB_STUB, V(FastSub, 2)) \ + IF_EXEC(ENABLE_FAST_MUL_STUB, V(FastMul, 2)) \ + IF_EXEC(ENABLE_FAST_DIV_STUB, V(FastDiv, 2)) \ + IF_EXEC(ENABLE_FAST_MOD_STUB, V(FastMod, 3)) \ + IF_EXEC(ENABLE_FAST_EQUAL_STUB, V(FastEqual, 2)) \ + IF_EXEC(ENABLE_FAST_TYPE_OF_STUB, V(FastTypeOf, 2)) \ + IF_EXEC(ENABLE_GET_PROP_BY_NAME_STUB, V(GetPropertyByName, 3)) \ + IF_EXEC(ENABLE_SET_PROP_BY_NAME_STUB, V(SetPropertyByName, 4)) \ + IF_EXEC(ENABLE_SET_PROP_BY_NAME_STUB, V(SetPropertyByNameWithOwn, 4)) \ + IF_EXEC(ENABLE_GET_PROP_BY_IDX_STUB, V(GetPropertyByIndex, 3)) \ + IF_EXEC(ENABLE_SET_PROP_BY_IDX_STUB, V(SetPropertyByIndex, 4)) \ + IF_EXEC(ENABLE_GET_PROP_BY_VALUE_STUB, V(GetPropertyByValue, 3)) \ + IF_EXEC(ENABLE_TRY_LD_IC_BY_NAME_STUB, V(TryLoadICByName, 4)) \ + IF_EXEC(ENABLE_TRY_LD_IC_BY_VALUE_STUB, V(TryLoadICByValue, 5)) \ + IF_EXEC(ENABLE_TRY_ST_IC_BY_NAME_STUB, V(TryStoreICByName, 5)) \ + IF_EXEC(ENABLE_TRY_ST_IC_BY_VALUE_STUB, V(TryStoreICByValue, 6)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define TEST_FUNC_LIST(V) \ diff --git a/ecmascript/compiler/stub_aot_compiler.cpp b/ecmascript/compiler/stub_aot_compiler.cpp index dd31188134..d8a37a498d 100644 --- a/ecmascript/compiler/stub_aot_compiler.cpp +++ b/ecmascript/compiler/stub_aot_compiler.cpp @@ -195,15 +195,15 @@ int main(const int argc, const char **argv) std::string tripleString = stubOptions.GetTargetTriple(); std::string moduleFilename = stubOptions.GetStubOutputFile(); - panda::ecmascript::kungfu::StubAotCompiler mouldeBuilder; + panda::ecmascript::kungfu::StubAotCompiler moduleBuilder; #define SET_STUB_TO_MODULE(name, counter) \ panda::ecmascript::kungfu::Circuit name##Circuit; \ panda::ecmascript::kungfu::name##Stub name##Stub(& name##Circuit); \ - mouldeBuilder.SetStub(FAST_STUB_ID(name), &name##Stub); + moduleBuilder.SetStub(FAST_STUB_ID(name), &name##Stub); FAST_RUNTIME_STUB_LIST(SET_STUB_TO_MODULE) #undef SET_STUB_TO_MODULE panda::ecmascript::StubModule stubModule; - mouldeBuilder.BuildStubModuleAndSave(tripleString, &stubModule, moduleFilename); + moduleBuilder.BuildStubModuleAndSave(tripleString, &stubModule, moduleFilename); std::cout << "BuildStubModuleAndSave success" << std::endl; return 0; } diff --git a/ecmascript/compiler/tests/stub_tests.cpp b/ecmascript/compiler/tests/stub_tests.cpp index f3ce856e22..e3df619a66 100644 --- a/ecmascript/compiler/tests/stub_tests.cpp +++ b/ecmascript/compiler/tests/stub_tests.cpp @@ -151,6 +151,7 @@ HWTEST_F_L0(StubTest, LoopTest1) } #endif +#if (ENABLE_FAST_ADD_STUB == 1) HWTEST_F_L0(StubTest, FastAddTest) { auto module = stubModule.GetModule(); @@ -182,7 +183,9 @@ HWTEST_F_L0(StubTest, FastAddTest) auto expectedG = FastRuntimeStub::FastAdd(JSTaggedValue(x1), JSTaggedValue(y1)); EXPECT_EQ(resG, expectedG); } +#endif // ENABLE_FAST_ADD_STUB +#if (ENABLE_FAST_SUB_STUB == 1) HWTEST_F_L0(StubTest, FastSubTest) { auto module = stubModule.GetModule(); @@ -209,8 +212,9 @@ HWTEST_F_L0(StubTest, FastSubTest) EXPECT_EQ(resB, JSTaggedValue(5)); EXPECT_EQ(resC, JSTaggedValue(0)); } +#endif // ENABLE_FAST_SUB_STUB - +#if (ENABLE_FAST_MUL_STUB == 1) HWTEST_F_L0(StubTest, FastMulTest) { auto module = stubModule.GetModule(); @@ -257,7 +261,9 @@ HWTEST_F_L0(StubTest, FastMulTest) auto expectedG = FastRuntimeStub::FastMul(JSTaggedValue(x1), JSTaggedValue(y1)); EXPECT_EQ(resG, expectedG); } +#endif // ENABLE_FAST_MUL_STUB +#if (ENABLE_FAST_DIV_STUB == 1) HWTEST_F_L0(StubTest, FastDivTest) { auto module = stubModule.GetModule(); @@ -300,7 +306,9 @@ HWTEST_F_L0(StubTest, FastDivTest) auto expectedG3 = FastRuntimeStub::FastDiv(JSTaggedValue(x3), JSTaggedValue(y3)); EXPECT_EQ(res3, expectedG3); } +#endif // ENABLE_FAST_DIV_STUB +#if (ENABLE_FAST_MOD_STUB == 1) HWTEST_F_L0(StubTest, FastModTest) { auto module = stubModule.GetModule(); @@ -364,7 +372,9 @@ HWTEST_F_L0(StubTest, FastModTest) LOG_ECMA(INFO) << "result1 for FastMod(7, 'helloworld') = " << result5.GetRawData(); EXPECT_EQ(result5, expectRes5); } +#endif // ENABLE_FAST_MOD_STUB +#if (ENABLE_TRY_LD_IC_BY_NAME_STUB == 1) HWTEST_F_L0(StubTest, TryLoadICByName) { auto module = stubModule.GetModule(); @@ -380,7 +390,9 @@ HWTEST_F_L0(StubTest, TryLoadICByName) LLVMAssembler assembler(module); assembler.Run(); } +#endif // ENABLE_TRY_LD_IC_BY_NAME_STUB +#if (ENABLE_TRY_LD_IC_BY_VALUE_STUB == 1) HWTEST_F_L0(StubTest, TryLoadICByValue) { auto module = stubModule.GetModule(); @@ -396,7 +408,9 @@ HWTEST_F_L0(StubTest, TryLoadICByValue) LLVMAssembler assembler(module); assembler.Run(); } +#endif // ENABLE_TRY_LD_IC_BY_VALUE_STUB +#if (ENABLE_TRY_ST_IC_BY_NAME_STUB == 1) HWTEST_F_L0(StubTest, TryStoreICByName) { auto module = stubModule.GetModule(); @@ -412,7 +426,9 @@ HWTEST_F_L0(StubTest, TryStoreICByName) LLVMAssembler assembler(module); assembler.Run(); } +#endif // ENABLE_TRY_ST_IC_BY_NAME_STUB +#if (ENABLE_TRY_ST_IC_BY_VALUE_STUB == 1) HWTEST_F_L0(StubTest, TryStoreICByValue) { auto module = stubModule.GetModule(); @@ -428,6 +444,7 @@ HWTEST_F_L0(StubTest, TryStoreICByValue) LLVMAssembler assembler(module); assembler.Run(); } +#endif // ENABLE_TRY_ST_IC_BY_VALUE_STUB struct ThreadTy { intptr_t magic; // 0x11223344 @@ -912,6 +929,7 @@ void DoSafepoint() } } +#if (ENABLE_GET_PROP_BY_IDX_STUB == 1) HWTEST_F_L0(StubTest, GetPropertyByIndexStub) { auto module = stubModule.GetModule(); @@ -940,7 +958,9 @@ HWTEST_F_L0(StubTest, GetPropertyByIndexStub) resVal = getpropertyByIndex(thread->GetGlueAddr(), obj.GetTaggedValue(), 10250); EXPECT_EQ(resVal.GetNumber(), y); } +#endif // ENABLE_GET_PROP_BY_IDX_STUB +#if (ENABLE_SET_PROP_BY_IDX_STUB == 1) HWTEST_F_L0(StubTest, SetPropertyByIndexStub) { auto module = stubModule.GetModule(); @@ -973,7 +993,9 @@ HWTEST_F_L0(StubTest, SetPropertyByIndexStub) JSArray::FastGetPropertyByValue(thread, JSHandle::Cast(array), i).GetTaggedValue()); } } +#endif // ENABLE_SET_PROP_BY_IDX_STUB +#if (ENABLE_GET_PROP_BY_NAME_STUB == 1) HWTEST_F_L0(StubTest, GetPropertyByNameStub) { auto module = stubModule.GetModule(); @@ -1008,8 +1030,10 @@ HWTEST_F_L0(StubTest, GetPropertyByNameStub) strBig.GetTaggedValue().GetRawData()); EXPECT_EQ(resVal.GetNumber(), y); } +#endif // ENABLE_GET_PROP_BY_NAME_STUB #ifdef ARK_GC_SUPPORT +#if (ENABLE_SET_PROP_BY_NAME_STUB == 1) HWTEST_F_L0(StubTest, SetPropertyByNameStub) { auto module = stubModule.GetModule(); @@ -1041,8 +1065,10 @@ HWTEST_F_L0(StubTest, SetPropertyByNameStub) auto resB = FastRuntimeStub::GetPropertyByName(thread, obj.GetTaggedValue(), strBig.GetTaggedValue()); EXPECT_EQ(resB.GetNumber(), y); } -#endif +#endif // ENABLE_SET_PROP_BY_NAME_STUB +#endif // ARK_GC_SUPPORT +#if (ENABLE_GET_PROP_BY_VALUE_STUB == 1) HWTEST_F_L0(StubTest, GetPropertyByValueStub) { auto module = stubModule.GetModule(); @@ -1131,7 +1157,9 @@ HWTEST_F_L0(StubTest, GetPropertyByValueStub) JSTaggedValue(key).GetRawData()); EXPECT_EQ(resVal.GetRawData(), 0); } +#endif // ENABLE_GET_PROP_BY_VALUE_STUB +#if (ENABLE_FAST_TYPE_OF_STUB == 1) HWTEST_F_L0(StubTest, FastTypeOfTest) { auto module = stubModule.GetModule(); @@ -1216,7 +1244,9 @@ HWTEST_F_L0(StubTest, FastTypeOfTest) EXPECT_EQ(resultVal9, globalConst->GetObjectString()); EXPECT_EQ(resultVal9, expectResult9); } +#endif // ENABLE_FAST_TYPE_OF_STUB +#if (ENABLE_FAST_EQUAL_STUB == 1) HWTEST_F_L0(StubTest, FastEqualTest) { auto module = stubModule.GetModule(); @@ -1284,4 +1314,5 @@ HWTEST_F_L0(StubTest, FastEqualTest) auto expectI = FastRuntimeStub::FastEqual(obj1.GetTaggedValue(), obj2.GetTaggedValue()); EXPECT_EQ(resI, expectI); } +#endif // ENABLE_FAST_EQUAL_STUB } // namespace panda::test diff --git a/ecmascript/interpreter/fast_runtime_stub-inl.h b/ecmascript/interpreter/fast_runtime_stub-inl.h index d3d40c49ea..aaa96ce5bb 100644 --- a/ecmascript/interpreter/fast_runtime_stub-inl.h +++ b/ecmascript/interpreter/fast_runtime_stub-inl.h @@ -638,11 +638,12 @@ bool FastRuntimeStub::FastSetPropertyByIndex(JSThread *thread, JSTaggedValue rec JSTaggedValue value) { INTERPRETER_TRACE(thread, FastSetPropertyByIndex); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT1 +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_SET_PROP_BY_IDX_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(SetPropertyByIndex)); - typedef JSTaggedValue (*PFSetPropertyByIndex)(uintptr_t, JSTaggedValue, uint32_t, JSTaggedValue); + typedef JSTaggedType (*PFSetPropertyByIndex)(uintptr_t, JSTaggedType, uint32_t, JSTaggedType); auto setPropertyByIndex = reinterpret_cast(stubAddr); - JSTaggedValue result = setPropertyByIndex(thread->GetGlueAddr(), receiver, index, value); + JSTaggedValue result = JSTaggedValue(setPropertyByIndex(thread->GetGlueAddr(), receiver.GetRawData(), index, + value.GetRawData())); #else JSTaggedValue result = FastRuntimeStub::SetPropertyByIndex(thread, receiver, index, value); #endif @@ -677,11 +678,12 @@ JSTaggedValue FastRuntimeStub::FastGetPropertyByName(JSThread *thread, JSTaggedV // Maybe moved by GC receiver = receiverHandler.GetTaggedValue(); } -#ifdef ECMASCRIPT_ENABLE_STUB_AOT1 +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByName)); - typedef JSTaggedValue (*PFGetPropertyByName)(uintptr_t, JSTaggedValue, JSTaggedValue); + typedef JSTaggedType (*PFGetPropertyByName)(uintptr_t, JSTaggedType, JSTaggedType); auto getPropertyByNamePtr = reinterpret_cast(stubAddr); - JSTaggedValue result = getPropertyByNamePtr(thread->GetGlueAddr(), receiver, key); + JSTaggedValue result = JSTaggedValue(getPropertyByNamePtr(thread->GetGlueAddr(), receiver.GetRawData(), + key.GetRawData())); #else JSTaggedValue result = FastRuntimeStub::GetPropertyByName(thread, receiver, key); #endif @@ -697,11 +699,12 @@ JSTaggedValue FastRuntimeStub::FastGetPropertyByName(JSThread *thread, JSTaggedV JSTaggedValue FastRuntimeStub::FastGetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key) { INTERPRETER_TRACE(thread, FastGetPropertyByValue); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT1 +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_VALUE_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByValue)); - typedef JSTaggedValue (*PFGetPropertyByValue)(uintptr_t, JSTaggedValue, JSTaggedValue); + typedef JSTaggedType (*PFGetPropertyByValue)(uintptr_t, JSTaggedType, JSTaggedType); auto getPropertyByValuePtr = reinterpret_cast(stubAddr); - JSTaggedValue result = getPropertyByValuePtr(thread->GetGlueAddr(), receiver, key); + JSTaggedValue result = JSTaggedValue(getPropertyByValuePtr(thread->GetGlueAddr(), + receiver.GetRawData(), key.GetRawData())); #else JSTaggedValue result = FastRuntimeStub::GetPropertyByValue(thread, receiver, key); #endif @@ -718,11 +721,11 @@ template // UseHole is only for Array::Sort() which requires Hole JSTaggedValue FastRuntimeStub::FastGetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index) { INTERPRETER_TRACE(thread, FastGetPropertyByIndex); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT1 +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_IDX_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByIndex)); - typedef JSTaggedValue (*PFGetPropertyByIndex)(uintptr_t, JSTaggedValue, uint32_t); + typedef JSTaggedType (*PFGetPropertyByIndex)(uintptr_t, JSTaggedType, uint32_t); auto getPropertyByIndex = reinterpret_cast(stubAddr); - JSTaggedValue result = getPropertyByIndex(thread->GetGlueAddr(), receiver, index); + JSTaggedValue result = JSTaggedValue(getPropertyByIndex(thread->GetGlueAddr(), receiver.GetRawData(), index)); #else JSTaggedValue result = FastRuntimeStub::GetPropertyByIndex(thread, receiver, index); #endif diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index 267968e3c0..7185e924b1 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -1251,7 +1251,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool } HANDLE_OPCODE(HANDLE_TYPEOFDYN_PREF) { LOG_INST() << "intrinsics::typeofdyn"; -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_FAST_TYPE_OF_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(FastTypeOf)); typedef JSTaggedType (*PFFastTypeOf)(uintptr_t, JSTaggedType); auto fastTypeOfPtr = reinterpret_cast(stubAddr); @@ -1416,7 +1416,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool << " v" << v0; JSTaggedValue left = GET_VREG_VALUE(v0); JSTaggedValue right = acc; -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_FAST_MUL_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(FastMul)); typedef JSTaggedType (*PFFastMul)(JSTaggedType, JSTaggedType); auto fastMulPtr = reinterpret_cast(stubAddr); @@ -1459,7 +1459,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSTaggedValue left = GET_VREG_VALUE(vs); JSTaggedValue right = GET_ACC(); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_FAST_MOD_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(FastMod)); typedef JSTaggedType (*PFFastMod)(uintptr_t, JSTaggedType, JSTaggedType); auto fastModPtr = reinterpret_cast(stubAddr); @@ -1484,7 +1484,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool << " v" << v0; JSTaggedValue left = GET_VREG_VALUE(v0); JSTaggedValue right = acc; -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_FAST_EQUAL_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(FastEqual)); typedef JSTaggedType (*PFFastEqual)(JSTaggedType, JSTaggedType); auto fastEqualPtr = reinterpret_cast(stubAddr); @@ -2269,7 +2269,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSTaggedValue value = GET_ACC(); // fast path SAVE_ACC(); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_SET_PROP_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(SetPropertyByNameWithOwn)); typedef JSTaggedType (*PFSetPropertyByName)(uintptr_t, JSTaggedType, JSTaggedType, JSTaggedType); auto setPropertyByNamePtr = reinterpret_cast(stubAddr); @@ -2603,7 +2603,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSTaggedValue receiver = GET_VREG_VALUE(v0); // fast path if (LIKELY(receiver.IsHeapObject())) { -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_IDX_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByIndex)); typedef JSTaggedType (*PFGetPropertyByIndex)(uintptr_t, JSTaggedType, uint32_t); auto getPropertyByIndex = reinterpret_cast(stubAddr); @@ -2635,7 +2635,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool SAVE_ACC(); JSTaggedValue value = GET_ACC(); // fast path -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_SET_PROP_BY_IDX_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(SetPropertyByIndex)); typedef JSTaggedType (*PFSetPropertyByIndex)(uintptr_t, JSTaggedType, uint32_t, JSTaggedType); auto setPropertyByIndex = reinterpret_cast(stubAddr); @@ -2697,7 +2697,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool #endif // fast path if (LIKELY(receiver.IsHeapObject())) { -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_VALUE_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByValue)); typedef JSTaggedType (*PFGetPropertyByValue)(uintptr_t, JSTaggedType, JSTaggedType); auto getPropertyByValuePtr = reinterpret_cast(stubAddr); @@ -2991,7 +2991,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool JSTaggedValue value = GET_ACC(); // fast path SAVE_ACC(); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_SET_PROP_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(SetPropertyByNameWithOwn)); typedef JSTaggedType (*PFSetPropertyByName)(uintptr_t, JSTaggedType, JSTaggedType, JSTaggedType); auto setPropertyByNamePtr = reinterpret_cast(stubAddr); @@ -3088,7 +3088,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool if (LIKELY(receiver.IsHeapObject())) { // fast path -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_GET_PROP_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(GetPropertyByName)); typedef JSTaggedType (*PFGetPropertyByName)(uintptr_t, JSTaggedType, JSTaggedType); auto getPropertyByNamePtr = reinterpret_cast(stubAddr); @@ -3126,7 +3126,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool if (LIKELY(firstValue.IsHeapObject())) { JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_TRY_ST_IC_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(TryStoreICByName)); typedef JSTaggedType (*PFTryStoreICByName)(uintptr_t, JSTaggedType, JSTaggedType, JSTaggedType, JSTaggedType); @@ -3162,7 +3162,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, ConstantPool value = GET_ACC(); // fast path SAVE_ACC(); -#ifdef ECMASCRIPT_ENABLE_STUB_AOT +#if defined(ECMASCRIPT_ENABLE_STUB_AOT) && (ENABLE_SET_PROP_BY_NAME_STUB == 1) auto stubAddr = thread->GetFastStubEntry(FAST_STUB_ID(SetPropertyByName)); typedef JSTaggedType (*PFSetPropertyByName)(uintptr_t, JSTaggedType, JSTaggedType, JSTaggedType); auto setPropertyByNamePtr = reinterpret_cast(stubAddr); diff --git a/js_runtime_config.gni b/js_runtime_config.gni index dec26b1a06..3a3d644ba4 100644 --- a/js_runtime_config.gni +++ b/js_runtime_config.gni @@ -17,6 +17,24 @@ compile_llvm_online = false run_with_asan = false enable_stub_aot = false enable_specific_stubs = false + +enable_fast_add_stub = "1" +enable_fast_sub_stub = "1" +enable_fast_mul_stub = "1" +enable_fast_div_stub = "1" +enable_fast_mod_stub = "0" +enable_fast_equal_stub = "1" +enable_fast_type_of_stub = "1" +enable_get_prop_by_name_stub = "1" +enable_set_prop_by_name_stub = "1" +enable_get_prop_by_idx_stub = "1" +enable_set_prop_by_idx_stub = "1" +enable_get_prop_by_value_stub = "1" +enable_try_ld_ic_by_name_stub = "1" +enable_try_ld_ic_by_value_stub = "1" +enable_try_st_ic_by_name_stub = "1" +enable_try_st_ic_by_value_stub = "1" + asan_lib_path = "/usr/lib/llvm-10/lib/clang/10.0.0/lib/linux" # For OpenHarmony build, always link with the static lib: -- Gitee