diff --git a/ecmastdlib/ecmastdlib_inline_gen.rb b/ecmastdlib/ecmastdlib_inline_gen.rb old mode 100644 new mode 100755 diff --git a/runtime/builtins.cpp b/runtime/builtins.cpp index 123b8456d18f886e5c221203fccbd192998d7f99..aefdbf1284c685cf83812f2f77c82c94bdc587fa 100644 --- a/runtime/builtins.cpp +++ b/runtime/builtins.cpp @@ -346,6 +346,7 @@ void Builtins::InitializeGlobalObject(const JSHandle &env, const JSHa // Global object test SetFunction(env, globalObject, "print", Global::PrintEntrypoint, 0); + SetFunction(env, globalObject, "gc", Global::GcEntrypoint, 0); #if ECMASCRIPT_ENABLE_RUNTIME_STAT SetFunction(env, globalObject, "startRuntimeStat", Global::StartRuntimeStat, 0); SetFunction(env, globalObject, "stopRuntimeStat", Global::StopRuntimeStat, 0); diff --git a/runtime/builtins/builtins_global.cpp b/runtime/builtins/builtins_global.cpp index 7fec05da9dd317828ab878d089679bbba7a2c027..b432b25ed2552f1c91c7c64456a5c395c07374ed 100644 --- a/runtime/builtins/builtins_global.cpp +++ b/runtime/builtins/builtins_global.cpp @@ -502,6 +502,22 @@ JSTaggedValue BuiltinsGlobal::PrintEntrypoint(EcmaRuntimeCallInfo *msg) return JSTaggedValue::Undefined(); } +JSTaggedValue BuiltinsGlobal::GcEntrypoint(EcmaRuntimeCallInfo *msg) +{ + if (msg == nullptr) { + return JSTaggedValue::Undefined(); + } + JSThread *thread = msg->GetThread(); + ASSERT(thread != nullptr); + [[maybe_unused]] EcmaHandleScope handleScope(thread); + BUILTINS_API_TRACE(thread, Global, GcEntryPoint); + + thread->GetEcmaVM()->GetGC()->WaitForGCInManaged(GCTask(GCTaskCause::EXPLICIT_CAUSE, thread)); + thread->SafepointPoll(); + + return JSTaggedValue::Undefined(); +} + JSTaggedValue BuiltinsGlobal::CallJsBoundFunction(EcmaRuntimeCallInfo *msg) { JSThread *thread = msg->GetThread(); diff --git a/runtime/builtins/builtins_global.h b/runtime/builtins/builtins_global.h index b0f713ca0b118ce1938fc302f3fb5beb14a47849..61d75fa9242f29c9bc7275f72788769855e3252b 100644 --- a/runtime/builtins/builtins_global.h +++ b/runtime/builtins/builtins_global.h @@ -42,6 +42,7 @@ public: static JSTaggedValue EncodeURIComponent(EcmaRuntimeCallInfo *msg); static JSTaggedValue PrintEntrypoint(EcmaRuntimeCallInfo *msg); + static JSTaggedValue GcEntrypoint(EcmaRuntimeCallInfo *msg); static JSTaggedValue CallJsBoundFunction(EcmaRuntimeCallInfo *msg); static JSTaggedValue CallJsProxy(EcmaRuntimeCallInfo *msg); #if ECMASCRIPT_ENABLE_RUNTIME_STAT diff --git a/runtime/runtime_call_id.h b/runtime/runtime_call_id.h index 766deb3753ee145dde5fc1466567bd5839fb28f5..72f39f1cabe4c6deb5cb2027db76a1cb18d5d670 100644 --- a/runtime/runtime_call_id.h +++ b/runtime/runtime_call_id.h @@ -318,6 +318,7 @@ namespace panda::ecmascript { V(Global, IsFinite) \ V(Global, IsNaN) \ V(Global, PrintEntryPoint) \ + V(Global, GcEntryPoint) \ V(Global, NewobjDynrange) \ V(Global, CallJsBoundFunction) \ V(Global, CallJsProxy) \ diff --git a/runtime/snapshot/mem/snapshot_serialize.cpp b/runtime/snapshot/mem/snapshot_serialize.cpp index 30a071b7b27643355370c7bae1ca17e882c7cd6f..69d83bd37d80349f34b86db2cac1b1201df8b313 100644 --- a/runtime/snapshot/mem/snapshot_serialize.cpp +++ b/runtime/snapshot/mem/snapshot_serialize.cpp @@ -433,6 +433,7 @@ static uintptr_t g_nativeTable[] = { reinterpret_cast(DataView::GetByteLength), reinterpret_cast(DataView::GetOffset), reinterpret_cast(Global::PrintEntrypoint), + reinterpret_cast(Global::GcEntrypoint), reinterpret_cast(Global::NotSupportEval), reinterpret_cast(Global::IsFinite), reinterpret_cast(Global::IsNaN),