Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 827a4dc796937582ffcc1fc2e8d557899c32c97a..341e606ddb86fbb856322db7bdf641cb6232f82d 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -3161,8 +3161,7 @@ Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) { |
: result; |
} |
- |
-Context* JSReceiver::GetCreationContext() { |
+Handle<Context> JSReceiver::GetCreationContext() { |
JSReceiver* receiver = this; |
while (receiver->IsJSBoundFunction()) { |
receiver = JSBoundFunction::cast(receiver)->bound_target_function(); |
@@ -3178,7 +3177,9 @@ Context* JSReceiver::GetCreationContext() { |
function = JSFunction::cast(receiver); |
} |
- return function->context()->native_context(); |
+ return function->has_context() |
+ ? Handle<Context>(function->context()->native_context()) |
+ : Handle<Context>::null(); |
} |
Handle<Object> Map::WrapFieldType(Handle<FieldType> type) { |
@@ -5206,7 +5207,7 @@ Handle<Context> JSFunction::GetFunctionRealm(Handle<JSFunction> function) { |
MaybeHandle<Context> JSObject::GetFunctionRealm(Handle<JSObject> object) { |
DCHECK(object->map()->is_constructor()); |
DCHECK(!object->IsJSFunction()); |
- return handle(object->GetCreationContext()); |
+ return object->GetCreationContext(); |
} |