Commit 4408f8f1 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[runtime] Change MessageLocation::function to SFI.

This changes the {MessageLocation} structure to no longer contain a
concrete {JSFunction} object but rather a {SharedFunctionInfo}. It is
much easier by now to determine, and also the concrete closure is never
actually being used.

R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2628973005
Cr-Commit-Position: refs/heads/master@{#42324}
parent 1ff4a817
......@@ -1503,7 +1503,7 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
frame->Summarize(&frames);
FrameSummary& summary = frames.last();
int pos = summary.SourcePosition();
Handle<JSFunction> fun;
Handle<SharedFunctionInfo> shared;
Handle<Object> script = summary.script();
if (!script->IsScript() ||
(Script::cast(*script)->source()->IsUndefined(this))) {
......@@ -1515,8 +1515,10 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
// incomplete (see bug v8:5007).
if (summary.IsWasmCompiled() && !FLAG_wasm_trap_if) return false;
if (summary.IsJavaScript()) fun = summary.AsJavaScript().function();
*target = MessageLocation(Handle<Script>::cast(script), pos, pos + 1, fun);
if (summary.IsJavaScript()) {
shared = handle(summary.AsJavaScript().function()->shared());
}
*target = MessageLocation(Handle<Script>::cast(script), pos, pos + 1, shared);
return true;
}
......
......@@ -21,11 +21,11 @@ MessageLocation::MessageLocation(Handle<Script> script, int start_pos,
int end_pos)
: script_(script), start_pos_(start_pos), end_pos_(end_pos) {}
MessageLocation::MessageLocation(Handle<Script> script, int start_pos,
int end_pos, Handle<JSFunction> function)
int end_pos, Handle<SharedFunctionInfo> shared)
: script_(script),
start_pos_(start_pos),
end_pos_(end_pos),
function_(function) {}
shared_(shared) {}
MessageLocation::MessageLocation() : start_pos_(-1), end_pos_(-1) {}
// If no message listeners have been registered this one is called
......
......@@ -23,25 +23,26 @@ class AbstractCode;
class FrameArray;
class JSMessageObject;
class LookupIterator;
class SharedFunctionInfo;
class SourceInfo;
class MessageLocation {
public:
MessageLocation(Handle<Script> script, int start_pos, int end_pos);
MessageLocation(Handle<Script> script, int start_pos, int end_pos,
Handle<JSFunction> function);
Handle<SharedFunctionInfo> shared);
MessageLocation();
Handle<Script> script() const { return script_; }
int start_pos() const { return start_pos_; }
int end_pos() const { return end_pos_; }
Handle<JSFunction> function() const { return function_; }
Handle<SharedFunctionInfo> shared() const { return shared_; }
private:
Handle<Script> script_;
int start_pos_;
int end_pos_;
Handle<JSFunction> function_;
Handle<SharedFunctionInfo> shared_;
};
class StackFrameBase {
......
......@@ -333,13 +333,13 @@ bool ComputeLocation(Isolate* isolate, MessageLocation* target) {
List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
it.frame()->Summarize(&frames);
auto& summary = frames.last().AsJavaScript();
Handle<JSFunction> function = summary.function();
Handle<Object> script(function->shared()->script(), isolate);
Handle<SharedFunctionInfo> shared(summary.function()->shared());
Handle<Object> script(shared->script(), isolate);
int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
if (script->IsScript() &&
!(Handle<Script>::cast(script)->source()->IsUndefined(isolate))) {
Handle<Script> casted_script = Handle<Script>::cast(script);
*target = MessageLocation(casted_script, pos, pos + 1, function);
*target = MessageLocation(casted_script, pos, pos + 1, shared);
return true;
}
}
......@@ -351,11 +351,9 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) {
MessageLocation location;
if (ComputeLocation(isolate, &location)) {
Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<ParseInfo> info(
new ParseInfo(&zone, handle(location.function()->shared())));
std::unique_ptr<ParseInfo> info(new ParseInfo(&zone, location.shared()));
if (parsing::ParseAny(info.get())) {
CallPrinter printer(isolate,
location.function()->shared()->IsUserJavaScript());
CallPrinter printer(isolate, location.shared()->IsUserJavaScript());
Handle<String> str = printer.Print(info->literal(), location.start_pos());
if (str->length() > 0) return str;
} else {
......
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