Commit e4e418f3 authored by bmeurer's avatar bmeurer Committed by Commit bot

[runtime] Make %FunctionGetScript and %FunctionGetSourceCode robust.

R=jarin@chromium.org
BUG=chromium:582703
LOG=n

Review URL: https://codereview.chromium.org/1664483003

Cr-Commit-Position: refs/heads/master@{#33693}
parent 3c94fcb5
......@@ -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();
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();
if (function->IsJSFunction()) {
return *Handle<JSFunction>::cast(function)->shared()->GetSourceCode();
}
return isolate->heap()->undefined_value();
}
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
%FunctionGetScript({});
%FunctionGetSourceCode({});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment