diff --git a/ecmascript/cross_vm/global_env_constants_hybrid.h b/ecmascript/cross_vm/global_env_constants_hybrid.h index 944fa7174db34f1427010967da4948fae9941bed..ab1ca1a65e8990f697a350f64022a8f7cc75387c 100644 --- a/ecmascript/cross_vm/global_env_constants_hybrid.h +++ b/ecmascript/cross_vm/global_env_constants_hybrid.h @@ -17,6 +17,8 @@ #define SHARED_GLOBAL_ENV_CONSTANT_STRING_HYBRID(V) \ V(ProxyNapiWrapperString, PROXY_NAPI_WRAPPER_INDEX, "_proxynapiwrapper") \ + V(SharedReferencePointer, SHARED_REFERENCE_POINTER_INDEX, \ + "_shared_reference_pointer") \ V(UnifiedGcCause, UNIFIED_GC_CAUSE, "unified") #define GLOBAL_ENV_CONSTANT_CLASS_HYBRID(V) \ diff --git a/ecmascript/cross_vm/jsnapi_expo_hybrid.cpp b/ecmascript/cross_vm/jsnapi_expo_hybrid.cpp index 69b8ff79391a0c82a81a1acbdb6cd985013d2a51..d2b2fec538f1d6b8f6714941176f1ba9abc6e5a0 100644 --- a/ecmascript/cross_vm/jsnapi_expo_hybrid.cpp +++ b/ecmascript/cross_vm/jsnapi_expo_hybrid.cpp @@ -40,6 +40,16 @@ Local StringRef::GetProxyNapiWrapperString(const EcmaVM *vm) return JSNApiHelper::ToLocal(proxyNapiWapperString); } +Local StringRef::GetSharedReferencePointer(const EcmaVM *vm) { + // Omit exception check because ark calls here may not + // cause side effect even pending exception exists. + CROSS_THREAD_CHECK(vm); + ecmascript::ThreadManagedScope managedScope(thread); + JSHandle proxyNapiWapperString = + thread->GlobalConstants()->GetHandledSharedReferencePointer(); + return JSNApiHelper::ToLocal(proxyNapiWapperString); +} + Local ObjectRef::NewJSXRefObject(const EcmaVM *vm) { CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, JSValueRef::Undefined(vm)); diff --git a/ecmascript/cross_vm/jsnapi_expo_hybrid.h b/ecmascript/cross_vm/jsnapi_expo_hybrid.h index ce2821898e5680a1b0fadeefa90bf788eea9c362..c86b4e20bda7c5b14f680eee676fe2ff52987aa0 100644 --- a/ecmascript/cross_vm/jsnapi_expo_hybrid.h +++ b/ecmascript/cross_vm/jsnapi_expo_hybrid.h @@ -29,7 +29,7 @@ #define OBJECTREF_PUBLIC_HYBRID_EXTENSION() \ static Local NewJSXRefObject(const EcmaVM *vm) -#define STRINGREF_PUBLIC_HYBRID_EXTENSION() \ +#define STRINGREF_PUBLIC_HYBRID_EXTENSION() \ static Local GetProxyNapiWrapperString(const EcmaVM *vm) #define JSNAPI_PUBLIC_HYBRID_EXTENSION() \ diff --git a/ecmascript/napi/include/jsnapi_expo.h b/ecmascript/napi/include/jsnapi_expo.h index 42418faaf2b59d2db68152b0d41ebbbe581ec7e8..83761999093360846b8d3631189c39cc340de77d 100644 --- a/ecmascript/napi/include/jsnapi_expo.h +++ b/ecmascript/napi/include/jsnapi_expo.h @@ -1055,6 +1055,7 @@ public: static Local GetNapiWrapperString(const EcmaVM *vm); Local EncodeIntoUint8Array(const EcmaVM *vm); STRINGREF_PUBLIC_HYBRID_EXTENSION(); + static Local GetSharedReferencePointer(const EcmaVM *vm); }; class PUBLIC_API PromiseRejectInfo {