Commit a88e54c2 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

Inline Script::SetEvalOrigin() into its (one) caller.

Script::SetEvalOrigin() could do a stackwalk depending on whether one of
its arguments is a sentinel value. This is somewhat surprising behavior,
and since this function has just one caller, it makes more sense to do
this in that location.

R=mstarzinger@chromium.org

Bug: 
Change-Id: Iddd38b42d9a3a8f4898aafb20fe165dfee51d516
Reviewed-on: https://chromium-review.googlesource.com/643386Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47715}
parent 7efb5537
......@@ -1079,7 +1079,23 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
}
script->set_origin_options(options);
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
Script::SetEvalOrigin(script, outer_info, eval_position);
script->set_eval_from_shared(*outer_info);
if (eval_position == kNoSourcePosition) {
// If the position is missing, attempt to get the code offset by
// walking the stack. Do not translate the code offset into source
// position, but store it as negative value for lazy translation.
StackTraceFrameIterator it(script->GetIsolate());
if (!it.done() && it.is_javascript()) {
FrameSummary summary = FrameSummary::GetTop(it.javascript_frame());
script->set_eval_from_shared(
summary.AsJavaScript().function()->shared());
eval_position = -summary.code_offset();
} else {
eval_position = 0;
}
}
script->set_eval_from_position(eval_position);
ParseInfo parse_info(script);
parse_info.set_eval();
......
......@@ -13253,26 +13253,6 @@ void Oddball::Initialize(Isolate* isolate, Handle<Oddball> oddball,
oddball->set_kind(kind);
}
void Script::SetEvalOrigin(Handle<Script> script,
Handle<SharedFunctionInfo> outer_info,
int eval_position) {
if (eval_position == kNoSourcePosition) {
// If the position is missing, attempt to get the code offset from the
// current activation. Do not translate the code offset into source
// position, but store it as negative value for lazy translation.
StackTraceFrameIterator it(script->GetIsolate());
if (!it.done() && it.is_javascript()) {
FrameSummary summary = FrameSummary::GetTop(it.javascript_frame());
script->set_eval_from_shared(summary.AsJavaScript().function()->shared());
script->set_eval_from_position(-summary.code_offset());
return;
}
eval_position = 0;
}
script->set_eval_from_shared(*outer_info);
script->set_eval_from_position(eval_position);
}
int Script::GetEvalPosition() {
DisallowHeapAllocation no_gc;
DCHECK(compilation_type() == Script::COMPILATION_TYPE_EVAL);
......
......@@ -112,10 +112,6 @@ class Script : public Struct {
Object* GetNameOrSourceURL();
// Set eval origin for stack trace formatting.
static void SetEvalOrigin(Handle<Script> script,
Handle<SharedFunctionInfo> outer,
int eval_position);
// Retrieve source position from where eval was called.
int GetEvalPosition();
......
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