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