summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/environment.cc5
-rw-r--r--src/api/exceptions.cc3
-rw-r--r--src/api/hooks.cc11
3 files changed, 11 insertions, 8 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc
index 6a56ddb511..cd3e3aefc2 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -23,6 +23,7 @@ using v8::MaybeLocal;
using v8::Message;
using v8::MicrotasksPolicy;
using v8::ObjectTemplate;
+using v8::SealHandleScope;
using v8::String;
using v8::Value;
@@ -34,7 +35,9 @@ static bool AllowWasmCodeGenerationCallback(Local<Context> context,
}
static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
- HandleScope scope(isolate);
+#ifdef DEBUG
+ SealHandleScope scope(isolate);
+#endif
Environment* env = Environment::GetCurrent(isolate);
return env != nullptr &&
(env->is_main_thread() || !env->is_stopping_worker()) &&
diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc
index 897a4de365..ceac937408 100644
--- a/src/api/exceptions.cc
+++ b/src/api/exceptions.cc
@@ -28,6 +28,7 @@ Local<Value> ErrnoException(Isolate* isolate,
const char* msg,
const char* path) {
Environment* env = Environment::GetCurrent(isolate);
+ CHECK_NOT_NULL(env);
Local<Value> e;
Local<String> estring = OneByteString(isolate, errors::errno_string(errorno));
@@ -99,6 +100,7 @@ Local<Value> UVException(Isolate* isolate,
const char* path,
const char* dest) {
Environment* env = Environment::GetCurrent(isolate);
+ CHECK_NOT_NULL(env);
if (!msg || !msg[0])
msg = uv_strerror(errorno);
@@ -187,6 +189,7 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
const char* msg,
const char* path) {
Environment* env = Environment::GetCurrent(isolate);
+ CHECK_NOT_NULL(env);
Local<Value> e;
bool must_free = false;
if (!msg || !msg[0]) {
diff --git a/src/api/hooks.cc b/src/api/hooks.cc
index b54292638d..aa647778d5 100644
--- a/src/api/hooks.cc
+++ b/src/api/hooks.cc
@@ -11,6 +11,7 @@ using v8::Integer;
using v8::Isolate;
using v8::Local;
using v8::Object;
+using v8::SealHandleScope;
using v8::String;
using v8::Value;
using v8::NewStringType;
@@ -88,16 +89,12 @@ void RemoveEnvironmentCleanupHook(Isolate* isolate,
}
async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
- // Environment::GetCurrent() allocates a Local<> handle.
- HandleScope handle_scope(isolate);
Environment* env = Environment::GetCurrent(isolate);
if (env == nullptr) return -1;
return env->execution_async_id();
}
async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) {
- // Environment::GetCurrent() allocates a Local<> handle.
- HandleScope handle_scope(isolate);
Environment* env = Environment::GetCurrent(isolate);
if (env == nullptr) return -1;
return env->trigger_async_id();
@@ -119,7 +116,9 @@ async_context EmitAsyncInit(Isolate* isolate,
Local<Object> resource,
Local<String> name,
async_id trigger_async_id) {
- HandleScope handle_scope(isolate);
+#ifdef DEBUG
+ SealHandleScope handle_scope(isolate);
+#endif
Environment* env = Environment::GetCurrent(isolate);
CHECK_NOT_NULL(env);
@@ -140,8 +139,6 @@ async_context EmitAsyncInit(Isolate* isolate,
}
void EmitAsyncDestroy(Isolate* isolate, async_context asyncContext) {
- // Environment::GetCurrent() allocates a Local<> handle.
- HandleScope handle_scope(isolate);
AsyncWrap::EmitDestroy(
Environment::GetCurrent(isolate), asyncContext.async_id);
}