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

Unified Diff: src/runtime/runtime-function.cc

Issue 1664483003: [runtime] Make %FunctionGetScript and %FunctionGetSourceCode robust. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | test/mjsunit/regress/regress-crbug-582703.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-function.cc
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc
index 938293b387c7f846c0e1655a48fd91c83fc8b0d5..e29b3c8c5f02f437934e42556e3dfa83029570ae 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -55,11 +55,14 @@ RUNTIME_FUNCTION(Runtime_FunctionGetScript) {
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
- if (function->IsJSBoundFunction()) return isolate->heap()->undefined_value();
- Handle<Object> script(Handle<JSFunction>::cast(function)->shared()->script(),
- isolate);
- if (!script->IsScript()) return isolate->heap()->undefined_value();
- return *Script::GetWrapper(Handle<Script>::cast(script));
+ if (function->IsJSFunction()) {
+ Handle<Object> script(
+ Handle<JSFunction>::cast(function)->shared()->script(), isolate);
+ if (script->IsScript()) {
+ return *Script::GetWrapper(Handle<Script>::cast(script));
+ }
+ }
+ return isolate->heap()->undefined_value();
}
@@ -67,8 +70,10 @@ RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
- if (function->IsJSBoundFunction()) return isolate->heap()->undefined_value();
- return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode();
+ if (function->IsJSFunction()) {
+ return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode();
+ }
+ return isolate->heap()->undefined_value();
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-582703.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698