Commit 7e05ebe2 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Return undefined as CallSite::getFunction for scripts

Scripts aren't callable functions. Even though internally they were for a
while, they aren't anymore. We shouldn't return them to users as if they were.
We already remove strict-mode functions from CallSites, so we now do the same
for internal functions that are created for scripts.

Bug: v8:10508
Change-Id: I270c714524439fba9ad90dd29826bed4811ba2b4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2193716
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67709}
parent 14984372
......@@ -76,7 +76,11 @@ BUILTIN(CallSitePrototypeGetFunction) {
GetFrameIndex(isolate, recv));
StackFrameBase* frame = it.Frame();
if (frame->IsStrict()) return ReadOnlyRoots(isolate).undefined_value();
if (frame->IsStrict() ||
(frame->GetFunction()->IsJSFunction() &&
JSFunction::cast(*frame->GetFunction()).shared().is_toplevel())) {
return ReadOnlyRoots(isolate).undefined_value();
}
isolate->CountUsage(v8::Isolate::kCallSiteAPIGetFunctionSloppyCall);
......
// Copyright 2020 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.
Error.prepareStackTrace = (error, frames) => {
// JSON.stringify executes the replacer, triggering the relevant
// code in Invoke().
JSON.stringify({}, frames[0].getFunction());
};
let v0;
try {
throw new Error();
} catch (e) {
e.stack
}
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