diff --git a/interface/kits/jsvm.h b/interface/kits/jsvm.h index 5050c071a5a73ce7f02878329645a7aaa8efecd3..ac3c0251ef6d115f476ba8710685c449a7d22189 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 e99aef864e9104cfa158981292d199b13b2a0f17..81ea7f0605aa3a93ff46abd28d7506f03de438cc 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 1efcc748512e677c0a0000792e5f917a9a23739d..27bf83ed932edce5ef83d3ff479cf74e3721bc76 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391