Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: src/objects.cc

Issue 2693203003: Make CreationContext() not crash when there is no creation context. (Closed)
Patch Set: Rebase on top of other patch instead. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698