From 37f63c54e4ee8d4673094263b7b8ee8666197c74 Mon Sep 17 00:00:00 2001 From: zhangsizheng Date: Thu, 24 Apr 2025 16:00:30 +0800 Subject: [PATCH] new API test Signed-off-by: zhangsizheng --- interface/kits/jsvm.h | 12 ++++++++++++ interface/kits/jsvm_types.h | 10 ++++++++++ src/js_native_api_v8.cpp | 8 ++++++++ test | 0 4 files changed, 30 insertions(+) create mode 100644 test diff --git a/interface/kits/jsvm.h b/interface/kits/jsvm.h index 5050c07..ac3c025 100644 --- a/interface/kits/jsvm.h +++ b/interface/kits/jsvm.h @@ -785,6 +785,18 @@ JSVM_EXTERN JSVM_Status OH_JSVM_OpenEscapableHandleScope(JSVM_Env env, JSVM_Esca */ JSVM_EXTERN JSVM_Status OH_JSVM_CloseEscapableHandleScope(JSVM_Env env, JSVM_EscapableHandleScope scope); +/** + * @brief This API is used to enable a certain debug option. + * + * @param env: The environment that the API is invoked under. + * @param debugFlagValue: The debug option that is enabled. + * @return Returns JSVM funtions result code. + * {@link JSVM_OK } if the function executed successfully.\n + * {@link JSVM_INVALID_ARG } if env is null.\n + * @since 20 + */ +JSVM_EXTERN JSVM_Status OH_JSVM_SetDebugFlag(JSVM_Env env, JSVM_DebugOption debugFlagValue); + /** * @brief This API promotes the handle to the JavaScript object so that it is valid for the lifetime * of the outer scope. It can only be called once per scope. If it is called more than once an error diff --git a/interface/kits/jsvm_types.h b/interface/kits/jsvm_types.h index e99aef8..81ea7f0 100644 --- a/interface/kits/jsvm_types.h +++ b/interface/kits/jsvm_types.h @@ -994,4 +994,14 @@ typedef enum { /** Tracing more detailed interface invoking of WASM, such as background compilation and wrappers. */ JSVM_TRACE_WASM_DETAILED } JSVM_TraceCategory; + +/** + * @brief Debug options. + * + * @since 20 + */ +typedef enum { + /** Enable scope check with ScopeLifecycleTracker. */ + JSVM_SCOPE_CHECK = 1 << 0 +} JSVM_DebugOption; #endif /* ARK_RUNTIME_JSVM_JSVM_TYPE_H */ diff --git a/src/js_native_api_v8.cpp b/src/js_native_api_v8.cpp index 1efcc74..27bf83e 100644 --- a/src/js_native_api_v8.cpp +++ b/src/js_native_api_v8.cpp @@ -212,6 +212,7 @@ static std::unique_ptr defaultArrayBufferAllocator; static std::unique_ptr g_trace_stream; + constexpr uint32_t TRACE_CATEGORY_COUNT = 7; static constexpr const char* INTERNAL_TRACE_CATEGORIES[] = { "v8", @@ -3490,6 +3491,13 @@ JSVM_Status OH_JSVM_CloseEscapableHandleScope(JSVM_Env env, JSVM_EscapableHandle return ClearLastError(env); } +JSVM_Status OH_JSVM_SetDebugFlag(JSVM_Env env, JSVM_DebugOption debugFlagValue) +{ + CHECK_ENV(env); + env->debugFlagValue = debugFlagValue; + return JSVM_OK; +} + JSVM_Status OH_JSVM_EscapeHandle(JSVM_Env env, JSVM_EscapableHandleScope scope, JSVM_Value escapee, JSVM_Value* result) { // Omit JSVM_PREAMBLE and GET_RETURN_STATUS because V8 calls here cannot throw diff --git a/test b/test new file mode 100644 index 0000000..e69de29 -- Gitee