From 6ea99a96d5e57fa1246db56806773b2b6e5f20e2 Mon Sep 17 00:00:00 2001 From: Gustavo Caso Date: Mon, 10 Jan 2022 14:42:48 +0100 Subject: [PATCH] split ExceptionError function into two: ExceptionErrorWithLock and ExceptionError --- v8go.cc | 76 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/v8go.cc b/v8go.cc index 0a2add11..239fa0bb 100644 --- a/v8go.cc +++ b/v8go.cc @@ -63,10 +63,6 @@ const char* CopyString(String::Utf8Value& value) { } RtnError ExceptionError(TryCatch& try_catch, Isolate* iso, Local ctx) { - Locker locker(iso); - Isolate::Scope isolate_scope(iso); - HandleScope handle_scope(iso); - RtnError rtn = {nullptr, nullptr, nullptr}; if (try_catch.HasTerminated()) { @@ -104,6 +100,16 @@ RtnError ExceptionError(TryCatch& try_catch, Isolate* iso, Local ctx) { return rtn; } +RtnError ExceptionErrorWithLock(TryCatch& try_catch, + Isolate* iso, + Local ctx) { + Locker locker(iso); + Isolate::Scope isolate_scope(iso); + HandleScope handle_scope(iso); + + return ExceptionError(try_catch, iso, ctx); +} + m_value* tracked_value(m_ctx* ctx, m_value* val) { // (rogchap) we track values against a context so that when the context is // closed (either manually or GC'd by Go) we can also release all the @@ -299,12 +305,11 @@ RtnSnapshotBlob CreateSnapshot(const char* source, Isolate* iso = creator.GetIsolate(); size_t index; RtnSnapshotBlob rtn = {}; - RtnError error = {nullptr, nullptr, nullptr}; { HandleScope handle_scope(iso); Local ctx = Context::New(iso); - + TryCatch try_catch(iso); Context::Scope context_scope(ctx); MaybeLocal maybeSrc = @@ -316,20 +321,17 @@ RtnSnapshotBlob CreateSnapshot(const char* source, ScriptOrigin script_origin(ogn); Local