Skip to content

Commit 3627caf

Browse files
author
Caio Marcelo de Oliveira Filho
committed
v8: make GetPrevious work for function contexts
The "previous context" for a function context is stored inside the closure(). The inspiration for this came from v8::internal::Context::Lookup(). Reviewed-by: Olivier Goffart
1 parent c3460b0 commit 3627caf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/3rdparty/v8/src/api.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,8 +3671,12 @@ Local<Context> v8::Context::GetPrevious() {
36713671
if (IsDeadCheck("v8::Context::GetPrevious()")) return Local<Context>();
36723672
ENTER_V8;
36733673
i::Handle<i::Context> env = Utils::OpenHandle(this);
3674-
if (env->IsGlobalContext() || env->is_function_context()) return Local<Context>();
3675-
i::Context* previous = env->previous();
3674+
if (env->IsGlobalContext()) return Local<Context>();
3675+
i::Context* previous = 0;
3676+
if (env->is_function_context())
3677+
previous = env->closure()->context();
3678+
else
3679+
previous = env->previous();
36763680
if (!previous) return Local<Context>();
36773681
i::Handle<i::Context> previous_handle(previous);
36783682
return Utils::ToLocal(previous_handle);

0 commit comments

Comments
 (0)