From 96e7101bc0e1562113b11716097daea1f870050c Mon Sep 17 00:00:00 2001 From: xwcai98 Date: Tue, 12 Nov 2024 21:46:57 +0800 Subject: [PATCH] Open no gc macro Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB3UIT Signed-off-by: xwcai98 Change-Id: Ib2a48a1a8c1a54bd2d765a7127d2008d4e3e7964 --- ecmascript/builtins/builtins_ark_tools.cpp | 6 +- ecmascript/builtins/builtins_regexp.cpp | 4 - ecmascript/compiler/call_signature.cpp | 94 ------------------- ecmascript/compiler/call_signature.h | 6 -- .../compiler/typed_bytecode_lowering.cpp | 6 -- ecmascript/js_map_iterator.cpp | 2 +- ecmascript/js_object.cpp | 6 +- ecmascript/js_set_iterator.cpp | 2 +- ecmascript/js_tagged_value.cpp | 42 ++++----- ecmascript/js_typed_array.cpp | 1 - ecmascript/layout_info-inl.h | 1 - ecmascript/mem/assert_scope.h | 4 - ecmascript/module/js_module_source_text.cpp | 2 - ecmascript/object_fast_operator-inl.h | 2 +- ecmascript/object_operator.cpp | 1 - ecmascript/patch/patch_loader.cpp | 31 +++--- ecmascript/stubs/runtime_stub_list.h | 6 -- ecmascript/stubs/runtime_stubs.cpp | 93 +++--------------- ecmascript/stubs/runtime_stubs.h | 8 -- 19 files changed, 57 insertions(+), 260 deletions(-) diff --git a/ecmascript/builtins/builtins_ark_tools.cpp b/ecmascript/builtins/builtins_ark_tools.cpp index ad85b0155e..5f4097418d 100644 --- a/ecmascript/builtins/builtins_ark_tools.cpp +++ b/ecmascript/builtins/builtins_ark_tools.cpp @@ -153,7 +153,7 @@ JSTaggedValue BuiltinsArkTools::IsSlicedString(EcmaRuntimeCallInfo *info) JSTaggedValue BuiltinsArkTools::IsStableJsArray(EcmaRuntimeCallInfo *info) { - [[maybe_unused]] DisallowGarbageCollection noGc; + DISALLOW_GARBAGE_COLLECTION; ASSERT(info); JSThread *thread = info->GetThread(); RETURN_IF_DISALLOW_ARKTOOLS(thread); @@ -167,7 +167,7 @@ JSTaggedValue BuiltinsArkTools::IsStableJsArray(EcmaRuntimeCallInfo *info) JSTaggedValue BuiltinsArkTools::IsNotHoleProperty(EcmaRuntimeCallInfo *info) { - [[maybe_unused]] DisallowGarbageCollection noGc; + DISALLOW_GARBAGE_COLLECTION; ASSERT(info); JSThread *thread = info->GetThread(); RETURN_IF_DISALLOW_ARKTOOLS(thread); @@ -187,7 +187,7 @@ JSTaggedValue BuiltinsArkTools::IsNotHoleProperty(EcmaRuntimeCallInfo *info) JSTaggedValue BuiltinsArkTools::HiddenStackSourceFile(EcmaRuntimeCallInfo *info) { - [[maybe_unused]] DisallowGarbageCollection noGc; + DISALLOW_GARBAGE_COLLECTION; ASSERT(info); JSThread *thread = info->GetThread(); RETURN_IF_DISALLOW_ARKTOOLS(thread); diff --git a/ecmascript/builtins/builtins_regexp.cpp b/ecmascript/builtins/builtins_regexp.cpp index 032e4b8098..777fe34611 100644 --- a/ecmascript/builtins/builtins_regexp.cpp +++ b/ecmascript/builtins/builtins_regexp.cpp @@ -52,8 +52,6 @@ JSTaggedValue BuiltinsRegExp::RegExpConstructor(EcmaRuntimeCallInfo *argv) } else { auto ecmaVm = thread->GetEcmaVM(); JSHandle env = ecmaVm->GetGlobalEnv(); - // disable gc - [[maybe_unused]] DisallowGarbageCollection noGc; // 4.a Let newTarget be the active function object. newTarget = env->GetRegExpFunction(); JSHandle constructorString = globalConst->GetHandledConstructorString(); @@ -94,8 +92,6 @@ JSTaggedValue BuiltinsRegExp::RegExpConstructor(EcmaRuntimeCallInfo *argv) } else if (patternIsRegExp) { JSHandle sourceString(globalConst->GetHandledSourceString()); JSHandle flagsString(globalConst->GetHandledFlagsString()); - // disable gc - [[maybe_unused]] DisallowGarbageCollection noGc; // 6.a Let P be Get(pattern, "source"). patternTemp = JSObject::GetProperty(thread, pattern, sourceString).GetValue(); // 6.b ReturnIfAbrupt(P). diff --git a/ecmascript/compiler/call_signature.cpp b/ecmascript/compiler/call_signature.cpp index 0d2c6a201e..3cc9cf7e25 100644 --- a/ecmascript/compiler/call_signature.cpp +++ b/ecmascript/compiler/call_signature.cpp @@ -1642,21 +1642,6 @@ DEF_CALL_SIGNATURE(ResumeRspAndRollback) callSign->SetCallConv(CallSignature::CallConv::GHCCallConv); } -DEF_CALL_SIGNATURE(StringsAreEquals) -{ - // 2 : 2 input parameters - CallSignature stringsAreEquals("StringsAreEquals", 0, 2, - ArgumentsOrder::DEFAULT_ORDER, VariableType::BOOL()); - *callSign = stringsAreEquals; - std::array params = { // 2 : 2 input parameters - VariableType::JS_POINTER(), - VariableType::JS_POINTER(), - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(JSHClassFindProtoTransitions) { // 3 : 3 input parameters @@ -2458,23 +2443,6 @@ DEF_CALL_SIGNATURE(CallDateNow) callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); } -DEF_CALL_SIGNATURE(FindElementWithCache) -{ - // 4 : 4 input parameters - CallSignature index("FindElementWithCache", 0, 4, ArgumentsOrder::DEFAULT_ORDER, VariableType::INT32()); - *callSign = index; - // 4 : 4 input parameters - std::array params = { - VariableType::NATIVE_POINTER(), - VariableType::JS_ANY(), - VariableType::JS_ANY(), - VariableType::INT32(), - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(UpdateFieldType) { // 2 : 2 input parameters @@ -2490,20 +2458,6 @@ DEF_CALL_SIGNATURE(UpdateFieldType) callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); } -DEF_CALL_SIGNATURE(NumberIsFinite) -{ - // 1 : 1 input parameters - CallSignature index("NumberIsFinite", 0, 1, ArgumentsOrder::DEFAULT_ORDER, VariableType::BOOL()); - *callSign = index; - // 1 : 1 input parameters - std::array params = { - VariableType::FLOAT64(), - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(DoubleToInt) { // 2 : 2 input parameters @@ -2519,20 +2473,6 @@ DEF_CALL_SIGNATURE(DoubleToInt) callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); } -DEF_CALL_SIGNATURE(DoubleToLength) -{ - // 1 : 1 input parameters - CallSignature index("DoubleToLength", 0, 1, ArgumentsOrder::DEFAULT_ORDER, VariableType::JS_ANY()); - *callSign = index; - // 1 : 1 input parameters - std::array params = { - VariableType::FLOAT64(), - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(MarkingBarrier) { // 4 : 4 input parameters @@ -2582,23 +2522,6 @@ DEF_CALL_SIGNATURE(SharedGCMarkingBarrier) callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); } -DEF_CALL_SIGNATURE(StoreBarrier) -{ - // 4 : 4 input parameters - CallSignature index("StoreBarrier", 0, 4, ArgumentsOrder::DEFAULT_ORDER, VariableType::VOID()); - *callSign = index; - // 4 : 4 input parameters - std::array params = { - VariableType::NATIVE_POINTER(), - VariableType::JS_POINTER(), - VariableType::NATIVE_POINTER(), - VariableType::JS_POINTER() - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(CallArg0) { // 2 : 2 input parameters @@ -2742,23 +2665,6 @@ DEF_CALL_SIGNATURE(JsBoundCallInternal) callSign->SetCallConv(CallSignature::CallConv::CCallConv); } -DEF_CALL_SIGNATURE(CreateArrayFromList) -{ - // 3 : 3 input parameters - CallSignature createArrayFromList("CreateArrayFromList", 0, 3, ArgumentsOrder::DEFAULT_ORDER, - VariableType::JS_POINTER()); - *callSign = createArrayFromList; - // 3 : 3 input parameters - std::array params = { - VariableType::NATIVE_POINTER(), - VariableType::INT32(), - VariableType::NATIVE_POINTER(), - }; - - callSign->SetParameters(params.data()); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_VARARGS); -} - DEF_CALL_SIGNATURE(DeoptHandlerAsm) { // 1 : 1 input parameters diff --git a/ecmascript/compiler/call_signature.h b/ecmascript/compiler/call_signature.h index ed81eb334e..961dbfcc76 100644 --- a/ecmascript/compiler/call_signature.h +++ b/ecmascript/compiler/call_signature.h @@ -486,7 +486,6 @@ private: V(ResumeCaughtFrameAndDispatch) \ V(ResumeUncaughtFrameAndReturn) \ V(ResumeRspAndRollback) \ - V(StringsAreEquals) \ V(BigIntEquals) \ V(BigIntSameValueZero) \ V(CallBigIntAsIntN) \ @@ -508,7 +507,6 @@ private: V(InsertLocalToShareRSet) \ V(SetBitAtomic) \ V(DoubleToInt) \ - V(DoubleToLength) \ V(FloatMod) \ V(FloatAcos) \ V(FloatAcosh) \ @@ -536,13 +534,10 @@ private: V(FloatPow) \ V(FloatCeil) \ V(CallDateNow) \ - V(NumberIsFinite) \ - V(FindElementWithCache) \ V(UpdateFieldType) \ V(MarkingBarrier) \ V(MarkingBarrierWithEden) \ V(SharedGCMarkingBarrier) \ - V(StoreBarrier) \ V(CallArg0) \ V(CallArg1) \ V(CallArgs2) \ @@ -555,7 +550,6 @@ private: V(JSFunctionEntry) \ V(OptimizedFastCallEntry) \ V(JSProxyCallInternalWithArgV) \ - V(CreateArrayFromList) \ V(JSObjectGetMethod) \ V(JsProxyCallInternal) \ V(JsBoundCallInternal) \ diff --git a/ecmascript/compiler/typed_bytecode_lowering.cpp b/ecmascript/compiler/typed_bytecode_lowering.cpp index 6b416893a9..10780a85b6 100644 --- a/ecmascript/compiler/typed_bytecode_lowering.cpp +++ b/ecmascript/compiler/typed_bytecode_lowering.cpp @@ -578,7 +578,6 @@ void TypedBytecodeLowering::DeleteConstDataIfNoUser(GateRef gate) void TypedBytecodeLowering::LowerTypedLdObjByName(GateRef gate) { - DISALLOW_GARBAGE_COLLECTION; LoadObjByNameTypeInfoAccessor tacc(compilationEnv_, circuit_, gate, chunk_); if (TryLowerTypedLdobjBynameFromGloablBuiltin(gate)) { @@ -680,7 +679,6 @@ void TypedBytecodeLowering::LowerTypedLdObjByName(GateRef gate) void TypedBytecodeLowering::LowerTypedLdPrivateProperty(GateRef gate) { - DISALLOW_GARBAGE_COLLECTION; LoadPrivatePropertyTypeInfoAccessor tacc(compilationEnv_, circuit_, gate, chunk_); if (tacc.HasIllegalType()) { @@ -718,7 +716,6 @@ void TypedBytecodeLowering::LowerTypedLdPrivateProperty(GateRef gate) void TypedBytecodeLowering::LowerTypedStPrivateProperty(GateRef gate) { - DISALLOW_GARBAGE_COLLECTION; StorePrivatePropertyTypeInfoAccessor tacc(compilationEnv_, circuit_, gate, chunk_); if (tacc.HasIllegalType()) { @@ -757,7 +754,6 @@ void TypedBytecodeLowering::LowerTypedStPrivateProperty(GateRef gate) void TypedBytecodeLowering::LowerTypedStObjByName(GateRef gate) { - DISALLOW_GARBAGE_COLLECTION; StoreObjByNameTypeInfoAccessor tacc(compilationEnv_, circuit_, gate, chunk_); if (tacc.TypesIsEmpty() || tacc.HasIllegalType()) { return; @@ -2294,7 +2290,6 @@ void TypedBytecodeLowering::LowerTypedTryLdGlobalByName(GateRef gate) if (!enableLoweringBuiltin_) { return; } - DISALLOW_GARBAGE_COLLECTION; LoadGlobalObjByNameTypeInfoAccessor tacc(compilationEnv_, circuit_, gate); JSTaggedValue key = tacc.GetKeyTaggedValue(); if (key.IsUndefined()) { @@ -2382,7 +2377,6 @@ void TypedBytecodeLowering::LowerTypedStOwnByValue(GateRef gate) void TypedBytecodeLowering::LowerCreateObjectWithBuffer(GateRef gate) { - DISALLOW_GARBAGE_COLLECTION; CreateObjWithBufferTypeInfoAccessor tacc(compilationEnv_, circuit_, gate, recordName_, chunk_); if (!tacc.CanOptimize()) { return; diff --git a/ecmascript/js_map_iterator.cpp b/ecmascript/js_map_iterator.cpp index 7b5ed30080..7a689fddfa 100644 --- a/ecmascript/js_map_iterator.cpp +++ b/ecmascript/js_map_iterator.cpp @@ -87,7 +87,7 @@ JSTaggedValue JSMapIterator::NextInternal(JSThread *thread, JSHandle &re } } if (receiver->IsJSSArray()) { - DISALLOW_GARBAGE_COLLECTION; - JSSharedArray *arr = JSSharedArray::Cast(*receiver); - uint32_t oldLength = arr->GetArrayLength(); + uint32_t oldLength = JSSharedArray::Cast(*receiver)->GetArrayLength(); if (index >= oldLength) { JSHandle newLength(thread, JSTaggedValue(static_cast(index + 1))); JSSharedArray::LengthSetter(thread, receiver, newLength); @@ -2878,7 +2876,7 @@ void JSObject::AddAccessor(JSThread *thread, const JSHandle &obj, bool JSObject::UpdatePropertyInDictionary(const JSThread *thread, JSTaggedValue key, JSTaggedValue value) { - [[maybe_unused]] DisallowGarbageCollection noGc; + DISALLOW_GARBAGE_COLLECTION; NameDictionary *dict = NameDictionary::Cast(GetProperties().GetTaggedObject()); int entry = dict->FindEntry(key); if (entry == -1) { diff --git a/ecmascript/js_set_iterator.cpp b/ecmascript/js_set_iterator.cpp index a8506b414a..6fcc51ed15 100644 --- a/ecmascript/js_set_iterator.cpp +++ b/ecmascript/js_set_iterator.cpp @@ -79,7 +79,7 @@ JSTaggedValue JSSetIterator::NextInternal(JSThread *thread, JSHandletaggedHandle(thread, tagged); diff --git a/ecmascript/js_typed_array.cpp b/ecmascript/js_typed_array.cpp index 70db6dea1d..e52fec2df0 100644 --- a/ecmascript/js_typed_array.cpp +++ b/ecmascript/js_typed_array.cpp @@ -690,7 +690,6 @@ JSTaggedValue JSTypedArray::FastGetPropertyByIndex(JSThread *thread, const JSTag return JSTaggedValue::Undefined(); } - DISALLOW_GARBAGE_COLLECTION; // Let length be the value of O’s [[ArrayLength]] internal slot. // If arrLen < 0 or index ≥ length, return undefined. uint32_t arrLen = typedarrayObj->GetArrayLength(); diff --git a/ecmascript/layout_info-inl.h b/ecmascript/layout_info-inl.h index 0de9fd3421..d3cf8262a1 100644 --- a/ecmascript/layout_info-inl.h +++ b/ecmascript/layout_info-inl.h @@ -217,7 +217,6 @@ template void LayoutInfo::AddKey(const JSThread *thread, [[maybe_unused]] int index, const JSTaggedValue &key, const PropertyAttributes &attr) { - DISALLOW_GARBAGE_COLLECTION; int number = NumberOfElements(); ASSERT(attr.GetOffset() == static_cast(number)); ASSERT(number + 1 <= GetPropertiesCapacity()); diff --git a/ecmascript/mem/assert_scope.h b/ecmascript/mem/assert_scope.h index 4a73c6f49a..d11538e36b 100644 --- a/ecmascript/mem/assert_scope.h +++ b/ecmascript/mem/assert_scope.h @@ -119,10 +119,6 @@ using AllowLocalToShareWeakRefHandle = AssertScopeT(0) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define CHECK_NO_HEAP_ALLOC ASSERT_PRINT(AllowHeapAlloc::IsAllowed(), "disallow execute heap alloc.") diff --git a/ecmascript/module/js_module_source_text.cpp b/ecmascript/module/js_module_source_text.cpp index 12d9ba6aa3..0d3b3f31ef 100644 --- a/ecmascript/module/js_module_source_text.cpp +++ b/ecmascript/module/js_module_source_text.cpp @@ -1285,7 +1285,6 @@ void SourceTextModule::AddStarExportEntry(JSThread *thread, const JSHandle ObjectFastOperator::HasOwnProperty(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key) { - [[maybe_unused]] DisallowGarbageCollection noGc; + DISALLOW_GARBAGE_COLLECTION; if (!receiver.IsHeapObject() || !(receiver.IsRegularObject())) { return std::make_pair(JSTaggedValue::Hole(), false); } diff --git a/ecmascript/object_operator.cpp b/ecmascript/object_operator.cpp index 01b962aa84..8de99552ad 100644 --- a/ecmascript/object_operator.cpp +++ b/ecmascript/object_operator.cpp @@ -412,7 +412,6 @@ SharedFieldType ObjectOperator::GetSharedFieldType() const void ObjectOperator::ToPropertyDescriptor(PropertyDescriptor &desc) const { - DISALLOW_GARBAGE_COLLECTION; if (!IsFound()) { return; } diff --git a/ecmascript/patch/patch_loader.cpp b/ecmascript/patch/patch_loader.cpp index b1a458bc13..79700d0006 100644 --- a/ecmascript/patch/patch_loader.cpp +++ b/ecmascript/patch/patch_loader.cpp @@ -22,24 +22,23 @@ PatchErrorCode PatchLoader::LoadPatchInternal(JSThread *thread, const JSPandaFil const JSPandaFile *patchFile, PatchInfo &patchInfo, const CMap &baseClassInfo) { - DISALLOW_GARBAGE_COLLECTION; EcmaVM *vm = thread->GetEcmaVM(); - - // hot reload and hot patch only support merge-abc file. - if (baseFile->IsBundlePack() || patchFile->IsBundlePack()) { - LOG_ECMA(ERROR) << "base or patch is not merge abc!"; - return PatchErrorCode::PACKAGE_NOT_ESMODULE; + { + DISALLOW_GARBAGE_COLLECTION; + // hot reload and hot patch only support merge-abc file. + if (baseFile->IsBundlePack() || patchFile->IsBundlePack()) { + LOG_ECMA(ERROR) << "base or patch is not merge abc!"; + return PatchErrorCode::PACKAGE_NOT_ESMODULE; + } + // Generate patchInfo for hot reload, hot patch and cold patch. + patchInfo = PatchLoader::GeneratePatchInfo(patchFile); + if (!thread->GetCurrentEcmaContext()->HasCachedConstpool(baseFile)) { + LOG_ECMA(INFO) << "cold patch!"; + vm->GetJsDebuggerManager()->GetHotReloadManager()->NotifyPatchLoaded(baseFile, patchFile); + return PatchErrorCode::SUCCESS; + } } - - // Generate patchInfo for hot reload, hot patch and cold patch. - patchInfo = PatchLoader::GeneratePatchInfo(patchFile); - - if (!thread->GetCurrentEcmaContext()->HasCachedConstpool(baseFile)) { - LOG_ECMA(INFO) << "cold patch!"; - vm->GetJsDebuggerManager()->GetHotReloadManager()->NotifyPatchLoaded(baseFile, patchFile); - return PatchErrorCode::SUCCESS; - } - + [[maybe_unused]] EcmaHandleScope handleScope(thread); // store base constpool in global object for avoid gc. diff --git a/ecmascript/stubs/runtime_stub_list.h b/ecmascript/stubs/runtime_stub_list.h index d748668bd5..8769e6bc36 100644 --- a/ecmascript/stubs/runtime_stub_list.h +++ b/ecmascript/stubs/runtime_stub_list.h @@ -141,9 +141,7 @@ namespace panda::ecmascript { V(MarkingBarrier) \ V(MarkingBarrierWithEden) \ V(SharedGCMarkingBarrier) \ - V(StoreBarrier) \ V(DoubleToInt) \ - V(DoubleToLength) \ V(FloatMod) \ V(FloatAcos) \ V(FloatAcosh) \ @@ -170,11 +168,7 @@ namespace panda::ecmascript { V(FloatPow) \ V(FloatCeil) \ V(CallDateNow) \ - V(NumberIsFinite) \ - V(FindElementWithCache) \ V(UpdateFieldType) \ - V(CreateArrayFromList) \ - V(StringsAreEquals) \ V(BigIntEquals) \ V(TimeClip) \ V(SetDateValues) \ diff --git a/ecmascript/stubs/runtime_stubs.cpp b/ecmascript/stubs/runtime_stubs.cpp index 74ae7fb8ce..832f2990f6 100644 --- a/ecmascript/stubs/runtime_stubs.cpp +++ b/ecmascript/stubs/runtime_stubs.cpp @@ -657,6 +657,7 @@ DEF_RUNTIME_STUBS(RuntimeDump) void RuntimeStubs::Dump(JSTaggedType rawValue) { + DISALLOW_GARBAGE_COLLECTION; std::ostringstream oss; auto value = JSTaggedValue(rawValue); value.Dump(oss); @@ -665,11 +666,13 @@ void RuntimeStubs::Dump(JSTaggedType rawValue) void RuntimeStubs::DebugDump(JSTaggedType rawValue) { + DISALLOW_GARBAGE_COLLECTION; DebugDumpWithHint(reinterpret_cast(nullptr), rawValue); } void RuntimeStubs::DumpWithHint(uintptr_t hintStrAddress, JSTaggedType rawValue) { + DISALLOW_GARBAGE_COLLECTION; const char *origHintStr = reinterpret_cast(hintStrAddress); // May be nullptr const char *hintStr = (origHintStr == nullptr) ? "" : origHintStr; DumpToStreamWithHint(std::cout, hintStr, JSTaggedValue(rawValue)); @@ -678,6 +681,7 @@ void RuntimeStubs::DumpWithHint(uintptr_t hintStrAddress, JSTaggedType rawValue) void RuntimeStubs::DebugDumpWithHint(uintptr_t hintStrAddress, JSTaggedType rawValue) { + DISALLOW_GARBAGE_COLLECTION; const char *origHintStr = reinterpret_cast(hintStrAddress); // May be nullptr const char *hintStr = (origHintStr == nullptr) ? "" : origHintStr; // The immediate lambda expression call is not evaluated when the logger is unabled. @@ -3124,35 +3128,6 @@ DEF_RUNTIME_STUBS(DecodeURIComponent) return result.GetRawData(); } -JSTaggedType RuntimeStubs::CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, - JSTaggedValue *argvPtr) -{ - auto thread = JSThread::GlueToJSThread(argGlue); - ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle taggedArray = factory->NewTaggedArray(argc - NUM_MANDATORY_JSFUNC_ARGS); - for (int index = NUM_MANDATORY_JSFUNC_ARGS; index < argc; ++index) { - taggedArray->Set(thread, index - NUM_MANDATORY_JSFUNC_ARGS, argvPtr[index]); - } - JSHandle arrHandle = JSArray::CreateArrayFromList(thread, taggedArray); - return arrHandle.GetTaggedValue().GetRawData(); -} - -int32_t RuntimeStubs::FindElementWithCache(uintptr_t argGlue, JSTaggedType hclass, - JSTaggedType key, int32_t num) -{ - auto thread = JSThread::GlueToJSThread(argGlue); - auto cls = reinterpret_cast(hclass); - JSTaggedValue propKey = JSTaggedValue(key); - auto layoutInfo = LayoutInfo::Cast(cls->GetLayout().GetTaggedObject()); - PropertiesCache *cache = thread->GetPropertiesCache(); - int index = cache->Get(cls, propKey); - if (index == PropertiesCache::NOT_FOUND) { - index = layoutInfo->BinarySearch(propKey, num); - cache->Set(cls, propKey, index); - } - return index; -} - void RuntimeStubs::UpdateFieldType(JSTaggedType hclass, uint64_t value) { auto cls = reinterpret_cast(hclass); @@ -3162,6 +3137,7 @@ void RuntimeStubs::UpdateFieldType(JSTaggedType hclass, uint64_t value) JSTaggedType RuntimeStubs::GetActualArgvNoGC(uintptr_t argGlue) { + DISALLOW_GARBAGE_COLLECTION; auto thread = JSThread::GlueToJSThread(argGlue); JSTaggedType *current = const_cast(thread->GetLastLeaveFrame()); FrameIterator it(current, thread); @@ -3302,11 +3278,6 @@ double RuntimeStubs::FloatPow(double base, double exp) return std::pow(base, exp); } -bool RuntimeStubs::NumberIsFinite(double x) -{ - return std::isfinite(x); -} - double RuntimeStubs::CallDateNow() { // time from now is in ms. @@ -3323,18 +3294,6 @@ int32_t RuntimeStubs::DoubleToInt(double x, size_t bits) return base::NumberHelper::DoubleToInt(x, bits); } -JSTaggedType RuntimeStubs::DoubleToLength(double x) -{ - double length = base::NumberHelper::TruncateDouble(x); - if (length < 0.0) { - return JSTaggedNumber(static_cast(0)).GetRawData(); - } - if (length > SAFE_NUMBER) { - return JSTaggedNumber(static_cast(SAFE_NUMBER)).GetRawData(); - } - return JSTaggedNumber(length).GetRawData(); -} - void RuntimeStubs::InsertNewToEdenRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset) { @@ -3424,52 +3383,21 @@ void RuntimeStubs::SharedGCMarkingBarrier([[maybe_unused]] uintptr_t argGlue, Ta Barriers::UpdateShared(thread, value, valueRegion); } -void RuntimeStubs::StoreBarrier([[maybe_unused]] uintptr_t argGlue, - uintptr_t object, size_t offset, TaggedObject *value) -{ - uintptr_t slotAddr = object + offset; - Region *objectRegion = Region::ObjectAddressToRange(object); - Region *valueRegion = Region::ObjectAddressToRange(value); - auto thread = JSThread::GlueToJSThread(argGlue); -#if ECMASCRIPT_ENABLE_BARRIER_CHECK - if (!thread->GetEcmaVM()->GetHeap()->IsAlive(JSTaggedValue(value).GetHeapObject())) { - LOG_FULL(FATAL) << "RuntimeStubs::StoreBarrier checked value:" << value << " is invalid!"; - } -#endif - if (objectRegion->InGeneralOldSpace() && valueRegion->InGeneralNewSpace()) { - // Should align with '8' in 64 and 32 bit platform - ASSERT((slotAddr % static_cast(MemAlignment::MEM_ALIGN_OBJECT)) == 0); - objectRegion->InsertOldToNewRSet(slotAddr); - } else if (!objectRegion->InSharedHeap() && valueRegion->InSharedSweepableSpace()) { - objectRegion->InsertLocalToShareRSet(slotAddr); - } else if (valueRegion->InEdenSpace() && objectRegion->InYoungSpace()) { - objectRegion->InsertNewToEdenRSet(slotAddr); - } - if (!valueRegion->InSharedHeap() && thread->IsConcurrentMarkingOrFinished()) { - Barriers::Update(thread, slotAddr, objectRegion, value, valueRegion); - } - if (valueRegion->InSharedSweepableSpace() && thread->IsSharedConcurrentMarkingOrFinished()) { - Barriers::UpdateShared(thread, value, valueRegion); - } -} - -bool RuntimeStubs::StringsAreEquals(EcmaString *str1, EcmaString *str2) -{ - return EcmaStringAccessor::StringsAreEqualDiffUtfEncoding(str1, str2); -} - bool RuntimeStubs::BigIntEquals(JSTaggedType left, JSTaggedType right) { + DISALLOW_GARBAGE_COLLECTION; return BigInt::Equal(JSTaggedValue(left), JSTaggedValue(right)); } bool RuntimeStubs::BigIntSameValueZero(JSTaggedType left, JSTaggedType right) { + DISALLOW_GARBAGE_COLLECTION; return BigInt::SameValueZero(JSTaggedValue(left), JSTaggedValue(right)); } JSTaggedValue RuntimeStubs::JSHClassFindProtoTransitions(JSHClass *cls, JSTaggedValue key, JSTaggedValue proto) { + DISALLOW_GARBAGE_COLLECTION; return JSTaggedValue(cls->FindProtoTransitions(key, proto)); } @@ -3487,17 +3415,20 @@ JSTaggedValue RuntimeStubs::NumberHelperStringToDouble(EcmaString *numberString) JSTaggedValue RuntimeStubs::GetStringToListCacheArray(uintptr_t argGlue) { + DISALLOW_GARBAGE_COLLECTION; auto thread = JSThread::GlueToJSThread(argGlue); return thread->GetCurrentEcmaContext()->GetStringToListResultCache().GetTaggedValue(); } double RuntimeStubs::TimeClip(double time) { + DISALLOW_GARBAGE_COLLECTION; return JSDate::TimeClip(time); } double RuntimeStubs::SetDateValues(double year, double month, double day) { + DISALLOW_GARBAGE_COLLECTION; if (std::isnan(year) || !std::isfinite(year) || std::isnan(month) || !std::isfinite(month) || std::isnan(day) || !std::isfinite(day)) { return base::NAN_VALUE; @@ -3712,6 +3643,7 @@ DEF_RUNTIME_STUBS(HClassCloneWithAddProto) void RuntimeStubs::StartCallTimer(uintptr_t argGlue, JSTaggedType func, bool isAot) { + DISALLOW_GARBAGE_COLLECTION; auto thread = JSThread::GlueToJSThread(argGlue); JSTaggedValue callTarget(func); Method *method = Method::Cast(JSFunction::Cast(callTarget)->GetMethod()); @@ -3726,6 +3658,7 @@ void RuntimeStubs::StartCallTimer(uintptr_t argGlue, JSTaggedType func, bool isA void RuntimeStubs::EndCallTimer(uintptr_t argGlue, JSTaggedType func) { + DISALLOW_GARBAGE_COLLECTION; auto thread = JSThread::GlueToJSThread(argGlue); JSTaggedValue callTarget(func); Method *method = Method::Cast(JSFunction::Cast(callTarget)->GetMethod()); diff --git a/ecmascript/stubs/runtime_stubs.h b/ecmascript/stubs/runtime_stubs.h index 7a2f82c0ff..31db016d36 100644 --- a/ecmascript/stubs/runtime_stubs.h +++ b/ecmascript/stubs/runtime_stubs.h @@ -95,9 +95,6 @@ public: static void MarkingBarrierWithEden([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset, TaggedObject *value); static void SharedGCMarkingBarrier([[maybe_unused]] uintptr_t argGlue, TaggedObject *value); - static void StoreBarrier([[maybe_unused]] uintptr_t argGlue, - uintptr_t object, size_t offset, TaggedObject *value); - static JSTaggedType CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, JSTaggedValue *argvPtr); static JSTaggedType GetActualArgvNoGC(uintptr_t argGlue); static void InsertNewToEdenRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); static void InsertOldToNewRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); @@ -105,7 +102,6 @@ public: static void SetBitAtomic(GCBitset::GCBitsetWord *word, GCBitset::GCBitsetWord mask, GCBitset::GCBitsetWord oldValue); static int32_t DoubleToInt(double x, size_t bits); - static JSTaggedType DoubleToLength(double x); static double FloatMod(double x, double y); static double FloatAcos(double x); static double FloatAcosh(double x); @@ -131,12 +127,8 @@ public: static double FloatPow(double base, double exp); static double FloatCbrt(double x); static double FloatCeil(double x); - static bool NumberIsFinite(double x); static double CallDateNow(); - static int32_t FindElementWithCache(uintptr_t argGlue, JSTaggedType hclass, - JSTaggedType key, int32_t num); static void UpdateFieldType(JSTaggedType hclass, uint64_t value); - static bool StringsAreEquals(EcmaString *str1, EcmaString *str2); static bool BigIntEquals(JSTaggedType left, JSTaggedType right); static bool BigIntSameValueZero(JSTaggedType key, JSTaggedType other); static JSTaggedValue JSHClassFindProtoTransitions(JSHClass *cls, JSTaggedValue key, JSTaggedValue proto);