Revert of Correctly annotate eval origin. (patchset #5 id:80001 of https://codereview.chromium.org/1854713002/ )

Reason for revert:
performance impact

Original issue's description:
> Correctly annotate eval origin.
>
> There were a couple of issues with it:
> - interpreter is not supported
> - the source position was just accidentally correct for full-codegen
> - the eval origin could have been cached
>
> Also fixes a few other places to use AbstractCode.
>
> R=mstarzinger@chromium.org
>
> Committed: https://crrev.com/2f3a171adc9e620c2235bf0562145b9d4eaba66d
> Cr-Commit-Position: refs/heads/master@{#35257}
>
> Committed: https://crrev.com/ad4e8a27963b704bb70ec8bac0991c57296b1d16
> Cr-Commit-Position: refs/heads/master@{#35481}

TBR=mstarzinger@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#35491}
This commit is contained in:
yangguo 2016-04-14 05:45:00 -07:00 committed by Commit bot
parent b62af118f4
commit 5af0a68442
34 changed files with 145 additions and 173 deletions

View File

@ -661,8 +661,11 @@ void Accessors::ScriptEvalFromScriptPositionGetter(
Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
Handle<Object> result = isolate->factory()->undefined_value();
if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) {
result =
Handle<Object>(Smi::FromInt(script->eval_from_position()), isolate);
Handle<Code> code(SharedFunctionInfo::cast(
script->eval_from_shared())->code());
result = Handle<Object>(Smi::FromInt(code->SourcePosition(
script->eval_from_instructions_offset())),
isolate);
}
info.GetReturnValue().Set(Utils::ToLocal(result));
}

View File

@ -2034,7 +2034,6 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
}
i::Handle<i::Object> name_obj;
int eval_position = 0;
int line_offset = 0;
int column_offset = 0;
if (!source->resource_name.IsEmpty()) {
@ -2047,12 +2046,11 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
column_offset = static_cast<int>(source->resource_column_offset->Value());
}
i::Handle<i::JSFunction> fun;
has_pending_exception =
!i::Compiler::GetFunctionFromEval(
source_string, outer_info, context, i::SLOPPY,
i::ONLY_SINGLE_FUNCTION_LITERAL, eval_position, line_offset,
column_offset - scope_position, name_obj, source->resource_options)
.ToHandle(&fun);
has_pending_exception = !i::Compiler::GetFunctionFromEval(
source_string, outer_info, context, i::SLOPPY,
i::ONLY_SINGLE_FUNCTION_LITERAL, line_offset,
column_offset - scope_position, name_obj,
source->resource_options).ToHandle(&fun);
if (has_pending_exception) {
isolate->ReportPendingMessages();
}

View File

@ -2068,20 +2068,11 @@ MaybeHandle<JSFunction> CompileString(Handle<Context> context,
}
// Compile source string in the native context.
StackTraceFrameIterator it(isolate);
int pos = RelocInfo::kNoPosition;
Handle<SharedFunctionInfo> outer_info;
if (!it.done() && it.is_javascript()) {
FrameSummary summary = FrameSummary::GetFirst(it.javascript_frame());
pos = summary.abstract_code()->SourcePosition(summary.code_offset());
outer_info = Handle<SharedFunctionInfo>(summary.function()->shared());
} else {
outer_info =
Handle<SharedFunctionInfo>(native_context->closure()->shared());
}
Handle<SharedFunctionInfo> outer_info(native_context->closure()->shared(),
isolate);
return Compiler::GetFunctionFromEval(source, outer_info, native_context,
SLOPPY, restriction, pos);
SLOPPY, restriction,
RelocInfo::kNoPosition);
}
} // namespace

View File

@ -1233,9 +1233,8 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
Handle<Context> context, LanguageMode language_mode,
ParseRestriction restriction, int eval_position, int line_offset,
int column_offset, Handle<Object> script_name,
ScriptOriginOptions options) {
ParseRestriction restriction, int line_offset, int column_offset,
Handle<Object> script_name, ScriptOriginOptions options) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
isolate->counters()->total_eval_size()->Increment(source_length);
@ -1244,7 +1243,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
CompilationCache* compilation_cache = isolate->compilation_cache();
MaybeHandle<SharedFunctionInfo> maybe_shared_info =
compilation_cache->LookupEval(source, outer_info, context, language_mode,
eval_position);
line_offset);
Handle<SharedFunctionInfo> shared_info;
Handle<Script> script;
@ -1256,10 +1255,6 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
script->set_column_offset(column_offset);
}
script->set_origin_options(options);
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
script->set_eval_from_shared(*outer_info);
script->set_eval_from_position(eval_position);
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
@ -1269,6 +1264,8 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
parse_info.set_parse_restriction(restriction);
parse_info.set_context(context);
Debug::RecordEvalCaller(script);
shared_info = CompileToplevel(&info);
if (shared_info.is_null()) {
@ -1284,7 +1281,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
DCHECK(is_sloppy(language_mode) ||
is_strict(shared_info->language_mode()));
compilation_cache->PutEval(source, outer_info, context, shared_info,
eval_position);
line_offset);
}
}

View File

@ -77,8 +77,8 @@ class Compiler : public AllStatic {
MUST_USE_RESULT static MaybeHandle<JSFunction> GetFunctionFromEval(
Handle<String> source, Handle<SharedFunctionInfo> outer_info,
Handle<Context> context, LanguageMode language_mode,
ParseRestriction restriction, int eval_position, int line_offset = 0,
int column_offset = 0, Handle<Object> script_name = Handle<Object>(),
ParseRestriction restriction, int line_offset, int column_offset = 0,
Handle<Object> script_name = Handle<Object>(),
ScriptOriginOptions options = ScriptOriginOptions());
// Create a shared function info object for a String source within a context.

View File

@ -2456,7 +2456,7 @@ void AstGraphBuilder::VisitCall(Call* expr) {
// provide a fully resolved callee to patch into the environment.
Node* function = GetFunctionClosure();
Node* language = jsgraph()->Constant(language_mode());
Node* position = jsgraph()->Constant(expr->position());
Node* position = jsgraph()->Constant(current_scope()->start_position());
const Operator* op =
javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval);
Node* new_callee =

View File

@ -95,11 +95,11 @@ MaybeHandle<Object> DebugEvaluate::Evaluate(
}
Handle<JSFunction> eval_fun;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, eval_fun,
Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
NO_PARSE_RESTRICTION, 0),
Object);
ASSIGN_RETURN_ON_EXCEPTION(isolate, eval_fun,
Compiler::GetFunctionFromEval(
source, outer_info, context, SLOPPY,
NO_PARSE_RESTRICTION, RelocInfo::kNoPosition),
Object);
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(

View File

@ -72,7 +72,8 @@ int FrameInspector::GetSourcePosition() {
return deoptimized_frame_->GetSourcePosition();
} else if (is_interpreted_) {
InterpretedFrame* frame = reinterpret_cast<InterpretedFrame*>(frame_);
BytecodeArray* bytecode_array = frame->GetBytecodeArray();
BytecodeArray* bytecode_array =
frame->function()->shared()->bytecode_array();
return bytecode_array->SourcePosition(frame->GetBytecodeOffset());
} else {
Code* code = frame_->LookupCode();

View File

@ -260,6 +260,12 @@ BreakLocation BreakLocation::FromCodeOffset(Handle<DebugInfo> debug_info,
return it->GetBreakLocation();
}
FrameSummary GetFirstFrameSummary(JavaScriptFrame* frame) {
List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
return frames.first();
}
int CallOffsetFromCodeOffset(int code_offset, bool is_interpreted) {
// Code offset points to the instruction after the call. Subtract 1 to
// exclude that instruction from the search. For bytecode, the code offset
@ -269,7 +275,7 @@ int CallOffsetFromCodeOffset(int code_offset, bool is_interpreted) {
BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info,
JavaScriptFrame* frame) {
FrameSummary summary = FrameSummary::GetFirst(frame);
FrameSummary summary = GetFirstFrameSummary(frame);
int call_offset =
CallOffsetFromCodeOffset(summary.code_offset(), frame->is_interpreted());
return FromCodeOffset(debug_info, call_offset);
@ -625,7 +631,7 @@ void Debug::Break(JavaScriptFrame* frame) {
step_break = location.IsTailCall();
// Fall through.
case StepIn: {
FrameSummary summary = FrameSummary::GetFirst(frame);
FrameSummary summary = GetFirstFrameSummary(frame);
int offset = summary.code_offset();
step_break = step_break || location.IsReturn() ||
(current_fp != last_fp) ||
@ -1005,7 +1011,7 @@ void Debug::PrepareStep(StepAction step_action) {
}
// Get the debug info (create it if it does not exist).
FrameSummary summary = FrameSummary::GetFirst(frame);
FrameSummary summary = GetFirstFrameSummary(frame);
Handle<JSFunction> function(summary.function());
Handle<SharedFunctionInfo> shared(function->shared());
if (!EnsureDebugInfo(shared, function)) {
@ -1016,7 +1022,7 @@ void Debug::PrepareStep(StepAction step_action) {
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
// Refresh frame summary if the code has been recompiled for debugging.
if (AbstractCode::cast(shared->code()) != *summary.abstract_code()) {
summary = FrameSummary::GetFirst(frame);
summary = GetFirstFrameSummary(frame);
}
int call_offset =
@ -1598,7 +1604,7 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
if (!shared->HasDebugInfo()) return false;
DCHECK(!frame->is_optimized());
FrameSummary summary = FrameSummary::GetFirst(frame);
FrameSummary summary = GetFirstFrameSummary(frame);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
BreakLocation location =
@ -1650,6 +1656,21 @@ Handle<FixedArray> Debug::GetLoadedScripts() {
}
void Debug::RecordEvalCaller(Handle<Script> script) {
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
// For eval scripts add information on the function from which eval was
// called.
StackTraceFrameIterator it(script->GetIsolate());
if (!it.done()) {
script->set_eval_from_shared(it.frame()->function()->shared());
Code* code = it.frame()->LookupCode();
int offset = static_cast<int>(
it.frame()->pc() - code->instruction_start());
script->set_eval_from_instructions_offset(offset);
}
}
MaybeHandle<Object> Debug::MakeExecutionState() {
// Create the execution state object.
Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()) };
@ -2239,7 +2260,7 @@ void Debug::PrintBreakLocation() {
JavaScriptFrameIterator iterator(isolate_);
if (iterator.done()) return;
JavaScriptFrame* frame = iterator.frame();
FrameSummary summary = FrameSummary::GetFirst(frame);
FrameSummary summary = GetFirstFrameSummary(frame);
int source_position =
summary.abstract_code()->SourcePosition(summary.code_offset());
Handle<Object> script_obj(summary.function()->shared()->script(), isolate_);

View File

@ -498,6 +498,9 @@ class Debug {
static int ArchiveSpacePerThread();
void FreeThreadResources() { }
// Record function from which eval was called.
static void RecordEvalCaller(Handle<Script> script);
bool CheckExecutionState(int id) {
return is_active() && !debug_context().is_null() && break_id() != 0 &&
break_id() == id;

View File

@ -1374,7 +1374,8 @@ static Handle<Script> CreateScriptCopy(Handle<Script> original) {
copy->set_type(original->type());
copy->set_context_data(original->context_data());
copy->set_eval_from_shared(original->eval_from_shared());
copy->set_eval_from_position(original->eval_from_position());
copy->set_eval_from_instructions_offset(
original->eval_from_instructions_offset());
// Copy all the flags, but clear compilation state.
copy->set_flags(original->flags());

View File

@ -884,7 +884,7 @@ Handle<Script> Factory::NewScript(Handle<String> source) {
script->set_wrapper(heap->undefined_value());
script->set_line_ends(heap->undefined_value());
script->set_eval_from_shared(heap->undefined_value());
script->set_eval_from_position(0);
script->set_eval_from_instructions_offset(0);
script->set_shared_function_infos(Smi::FromInt(0));
script->set_flags(0);

View File

@ -977,12 +977,6 @@ FrameSummary::FrameSummary(Object* receiver, JSFunction* function,
CannotDeoptFromAsmCode(Code::cast(abstract_code), function));
}
FrameSummary FrameSummary::GetFirst(JavaScriptFrame* frame) {
List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
return frames.first();
}
void FrameSummary::Print() {
PrintF("receiver: ");
receiver_->ShortPrint();
@ -1234,15 +1228,15 @@ void InterpretedFrame::PatchBytecodeOffset(int new_offset) {
SetExpression(index, Smi::FromInt(raw_offset));
}
BytecodeArray* InterpretedFrame::GetBytecodeArray() const {
Object* InterpretedFrame::GetBytecodeArray() const {
const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeArrayFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
return BytecodeArray::cast(GetExpression(index));
return GetExpression(index);
}
void InterpretedFrame::PatchBytecodeArray(BytecodeArray* bytecode_array) {
void InterpretedFrame::PatchBytecodeArray(Object* bytecode_array) {
const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeArrayFromFp,

View File

@ -640,16 +640,12 @@ class ExitFrame: public StackFrame {
friend class StackFrameIteratorBase;
};
class JavaScriptFrame;
class FrameSummary BASE_EMBEDDED {
public:
FrameSummary(Object* receiver, JSFunction* function,
AbstractCode* abstract_code, int code_offset,
bool is_constructor);
static FrameSummary GetFirst(JavaScriptFrame* frame);
Handle<Object> receiver() { return receiver_; }
Handle<JSFunction> function() { return function_; }
Handle<AbstractCode> abstract_code() { return abstract_code_; }
@ -733,6 +729,7 @@ class StandardFrame : public StackFrame {
friend class SafeStackFrameIterator;
};
class JavaScriptFrame : public StandardFrame {
public:
Type type() const override { return JAVA_SCRIPT; }
@ -900,11 +897,11 @@ class InterpretedFrame : public JavaScriptFrame {
void PatchBytecodeOffset(int new_offset);
// Returns the frame's current bytecode array.
BytecodeArray* GetBytecodeArray() const;
Object* GetBytecodeArray() const;
// Updates the frame's BytecodeArray with |bytecode_array|. Used by the
// debugger to swap execution onto a BytecodeArray patched with breakpoints.
void PatchBytecodeArray(BytecodeArray* bytecode_array);
void PatchBytecodeArray(Object* bytecode_array);
// Access to the interpreter register file for this frame.
Object* GetInterpreterRegister(int register_index) const;

View File

@ -2561,8 +2561,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, r0);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// r4: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ ldr(r4, MemOperand(sp, arg_count * kPointerSize));
@ -2576,8 +2576,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// r2: language mode.
__ mov(r2, Operand(Smi::FromInt(language_mode())));
// r1: the source position of the eval call.
__ mov(r1, Operand(Smi::FromInt(expr->position())));
// r1: the start position of the scope the calls resides in.
__ mov(r1, Operand(Smi::FromInt(scope()->start_position())));
// Do the runtime call.
__ Push(r4, r3, r2, r1);
@ -2629,7 +2629,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call
// Runtime_ResolvePossiblyDirectEval to resolve the function we need
// RuntimeHidden_asResolvePossiblyDirectEval to resolve the function we need
// to call. Then we call the resolved function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
@ -2645,7 +2645,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
__ push(r1);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize));

View File

@ -2461,8 +2461,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, x0);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
ASM_LOCATION("FullCodeGenerator::EmitResolvePossiblyDirectEval");
// Prepare to push a copy of the first argument or undefined if it doesn't
// exist.
@ -2476,8 +2476,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// Prepare to push the language mode.
__ Mov(x11, Smi::FromInt(language_mode()));
// Prepare to push the source position of the eval call.
__ Mov(x12, Smi::FromInt(expr->position()));
// Prepare to push the start position of the scope the calls resides in.
__ Mov(x12, Smi::FromInt(scope()->start_position()));
// Push.
__ Push(x9, x10, x11, x12);
@ -2530,7 +2530,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
ASM_LOCATION("FullCodeGenerator::EmitPossiblyEvalCall");
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2547,7 +2547,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ Peek(x10, (arg_count + 1) * kPointerSize);
__ Push(x10);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ Poke(x0, (arg_count + 1) * kPointerSize);

View File

@ -552,7 +552,7 @@ class FullCodeGenerator: public AstVisitor {
bool NeedsHoleCheckForLoad(VariableProxy* proxy);
// Expects the arguments and the function already pushed.
void EmitResolvePossiblyDirectEval(Call* expr);
void EmitResolvePossiblyDirectEval(int arg_count);
// Platform-specific support for allocating a new closure based on
// the given function info.

View File

@ -2460,8 +2460,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, eax);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// Push copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ push(Operand(esp, arg_count * kPointerSize));
@ -2475,8 +2475,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// Push the language mode.
__ push(Immediate(Smi::FromInt(language_mode())));
// Push the source position of the eval call.
__ push(Immediate(Smi::FromInt(expr->position())));
// Push the start position of the scope the calls resides in.
__ push(Immediate(Smi::FromInt(scope()->start_position())));
// Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
@ -2524,7 +2524,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2540,7 +2540,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// Push a copy of the function (found below the arguments) and
// resolve eval.
__ push(Operand(esp, (arg_count + 1) * kPointerSize));
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);

View File

@ -2567,8 +2567,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, v0);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// t3: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ lw(t3, MemOperand(sp, arg_count * kPointerSize));
@ -2582,8 +2582,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// t1: the language mode.
__ li(t1, Operand(Smi::FromInt(language_mode())));
// t0: the source position of the eval call.
__ li(t0, Operand(Smi::FromInt(expr->position())));
// t0: the start position of the scope the calls resides in.
__ li(t0, Operand(Smi::FromInt(scope()->start_position())));
// Do the runtime call.
__ Push(t3, t2, t1, t0);
@ -2635,7 +2635,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2651,7 +2651,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
__ push(a1);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ sw(v0, MemOperand(sp, (arg_count + 1) * kPointerSize));

View File

@ -2566,8 +2566,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, v0);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// a6: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ ld(a6, MemOperand(sp, arg_count * kPointerSize));
@ -2581,8 +2581,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// a4: the language mode.
__ li(a4, Operand(Smi::FromInt(language_mode())));
// a1: the source position of the eval call.
__ li(a1, Operand(Smi::FromInt(expr->position())));
// a1: the start position of the scope the calls resides in.
__ li(a1, Operand(Smi::FromInt(scope()->start_position())));
// Do the runtime call.
__ Push(a6, a5, a4, a1);
@ -2634,7 +2634,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2650,7 +2650,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
__ push(a1);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize));

View File

@ -2555,8 +2555,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, r3);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// r7: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ LoadP(r7, MemOperand(sp, arg_count * kPointerSize), r0);
@ -2570,8 +2570,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// r5: language mode.
__ LoadSmiLiteral(r5, Smi::FromInt(language_mode()));
// r4: the source position of the eval call.
__ LoadSmiLiteral(r4, Smi::FromInt(expr->position()));
// r4: the start position of the scope the calls resides in.
__ LoadSmiLiteral(r4, Smi::FromInt(scope()->start_position()));
// Do the runtime call.
__ Push(r7, r6, r5, r4);
@ -2622,7 +2622,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2639,7 +2639,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);
__ push(r4);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);

View File

@ -2497,8 +2497,7 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, r2);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// r6: copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ LoadP(r6, MemOperand(sp, arg_count * kPointerSize), r0);
@ -2512,8 +2511,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// r4: language mode.
__ LoadSmiLiteral(r4, Smi::FromInt(language_mode()));
// r3: the source position of the eval call.
__ LoadSmiLiteral(r3, Smi::FromInt(expr->position()));
// r3: the start position of the scope the calls resides in.
__ LoadSmiLiteral(r3, Smi::FromInt(scope()->start_position()));
// Do the runtime call.
__ Push(r6, r5, r4, r3);
@ -2562,7 +2561,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
}
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2579,7 +2578,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// resolve eval.
__ LoadP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);
__ push(r3);
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ StoreP(r2, MemOperand(sp, (arg_count + 1) * kPointerSize), r0);

View File

@ -2449,8 +2449,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, rax);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// Push copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ Push(Operand(rsp, arg_count * kPointerSize));
@ -2464,8 +2464,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// Push the language mode.
__ Push(Smi::FromInt(language_mode()));
// Push the source position of the eval call.
__ Push(Smi::FromInt(expr->position()));
// Push the start position of the scope the calls resides in.
__ Push(Smi::FromInt(scope()->start_position()));
// Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
@ -2514,7 +2514,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2529,7 +2529,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// Push a copy of the function (found below the arguments) and resolve
// eval.
__ Push(Operand(rsp, (arg_count + 1) * kPointerSize));
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the callee.
__ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax);

View File

@ -2542,8 +2542,8 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
context()->DropAndPlug(1, eax);
}
void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
int arg_count = expr->arguments()->length();
void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// Push copy of the first argument or undefined if it doesn't exist.
if (arg_count > 0) {
__ push(Operand(esp, arg_count * kPointerSize));
@ -2557,8 +2557,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) {
// Push the language mode.
__ push(Immediate(Smi::FromInt(language_mode())));
// Push the source position of the eval call.
__ push(Immediate(Smi::FromInt(expr->position())));
// Push the start position of the scope the calls resides in.
__ push(Immediate(Smi::FromInt(scope()->start_position())));
// Do the runtime call.
__ CallRuntime(Runtime::kResolvePossiblyDirectEval);
@ -2606,7 +2606,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// In a call to eval, we first call Runtime_ResolvePossiblyDirectEval
// In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
// to resolve the function we need to call. Then we call the resolved
// function using the given arguments.
ZoneList<Expression*>* args = expr->arguments();
@ -2622,7 +2622,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) {
// Push a copy of the function (found below the arguments) and
// resolve eval.
__ push(Operand(esp, (arg_count + 1) * kPointerSize));
EmitResolvePossiblyDirectEval(expr);
EmitResolvePossiblyDirectEval(arg_count);
// Touch up the stack with the resolved function.
__ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);

View File

@ -766,10 +766,10 @@ void Heap::PreprocessStackTraces() {
// If GC happens while adding a stack trace to the weak fixed array,
// which has been copied into a larger backing store, we may run into
// a stack trace that has already been preprocessed. Guard against this.
if (!maybe_code->IsAbstractCode()) break;
AbstractCode* abstract_code = AbstractCode::cast(maybe_code);
if (!maybe_code->IsCode()) break;
Code* code = Code::cast(maybe_code);
int offset = Smi::cast(elements->get(j + 3))->value();
int pos = abstract_code->SourcePosition(offset);
int pos = code->SourcePosition(offset);
elements->set(j + 2, Smi::FromInt(pos));
}
}

View File

@ -2473,7 +2473,8 @@ void BytecodeGenerator::VisitCall(Call* expr) {
.MoveRegister(Register::function_closure(), function)
.LoadLiteral(Smi::FromInt(language_mode()))
.StoreAccumulatorInRegister(language)
.LoadLiteral(Smi::FromInt(expr->position()))
.LoadLiteral(
Smi::FromInt(execution_context()->scope()->start_position()))
.StoreAccumulatorInRegister(position);
// Call ResolvePossiblyDirectEval and modify the callee.

View File

@ -5503,7 +5503,8 @@ ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset)
SMI_ACCESSORS(Script, type, kTypeOffset)
ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
ACCESSORS(Script, eval_from_shared, Object, kEvalFromSharedOffset)
SMI_ACCESSORS(Script, eval_from_position, kEvalFromPositionOffset)
SMI_ACCESSORS(Script, eval_from_instructions_offset,
kEvalFrominstructionsOffsetOffset)
ACCESSORS(Script, shared_function_infos, Object, kSharedFunctionInfosOffset)
SMI_ACCESSORS(Script, flags, kFlagsOffset)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)

View File

@ -1144,7 +1144,8 @@ void Script::ScriptPrint(std::ostream& os) { // NOLINT
os << "\n - compilation type: " << compilation_type();
os << "\n - line ends: " << Brief(line_ends());
os << "\n - eval from shared: " << Brief(eval_from_shared());
os << "\n - eval from position: " << eval_from_position();
os << "\n - eval from instructions offset: "
<< eval_from_instructions_offset();
os << "\n - shared function infos: " << Brief(shared_function_infos());
os << "\n";
}

View File

@ -6436,9 +6436,9 @@ class Script: public Struct {
// function from which eval was called.
DECL_ACCESSORS(eval_from_shared, Object)
// [eval_from_position]: the source position in the code for the
// function from which eval was called.
DECL_INT_ACCESSORS(eval_from_position)
// [eval_from_instructions_offset]: the instruction offset in the code for the
// function from which eval was called where eval was called.
DECL_INT_ACCESSORS(eval_from_instructions_offset)
// [shared_function_infos]: weak fixed array containing all shared
// function infos created from this script.
@ -6525,10 +6525,10 @@ class Script: public Struct {
static const int kLineEndsOffset = kTypeOffset + kPointerSize;
static const int kIdOffset = kLineEndsOffset + kPointerSize;
static const int kEvalFromSharedOffset = kIdOffset + kPointerSize;
static const int kEvalFromPositionOffset =
static const int kEvalFrominstructionsOffsetOffset =
kEvalFromSharedOffset + kPointerSize;
static const int kSharedFunctionInfosOffset =
kEvalFromPositionOffset + kPointerSize;
kEvalFrominstructionsOffsetOffset + kPointerSize;
static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;

View File

@ -305,10 +305,11 @@ bool CodeGenerationFromStringsAllowed(Isolate* isolate,
}
}
static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
Handle<SharedFunctionInfo> outer_info,
LanguageMode language_mode,
int eval_position) {
int scope_position) {
Handle<Context> context = Handle<Context>(isolate->context());
Handle<Context> native_context = Handle<Context>(context->native_context());
@ -332,7 +333,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, compiled,
Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
restriction, eval_position),
restriction, scope_position),
isolate->heap()->exception());
return *compiled;
}

View File

@ -36,7 +36,7 @@ bytecodes: [
B(Mov), R(closure), R(6),
B(LdaZero),
B(Star), R(7),
B(LdaSmi), U8(52),
B(LdaSmi), U8(30),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(5),
B(Star), R(1),

View File

@ -34,7 +34,7 @@ bytecodes: [
B(Mov), R(closure), R(6),
B(LdaZero),
B(Star), R(7),
B(LdaSmi), U8(41),
B(LdaSmi), U8(30),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(5),
B(Star), R(1),

View File

@ -34,7 +34,7 @@ bytecodes: [
B(Mov), R(closure), R(6),
B(LdaZero),
B(Star), R(7),
B(LdaSmi), U8(34),
B(LdaSmi), U8(30),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(5),
B(Star), R(1),
@ -77,7 +77,7 @@ bytecodes: [
B(Mov), R(closure), R(6),
B(LdaZero),
B(Star), R(7),
B(LdaSmi), U8(34),
B(LdaSmi), U8(30),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(5),
B(Star), R(1),
@ -123,7 +123,7 @@ bytecodes: [
B(Mov), R(closure), R(6),
B(LdaZero),
B(Star), R(7),
B(LdaSmi), U8(49),
B(LdaSmi), U8(30),
B(Star), R(8),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(5),
B(Star), R(1),

View File

@ -1,37 +0,0 @@
// 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.
Error.prepareStackTrace = function(exception, frames) {
return frames[0].getEvalOrigin();
}
var source = "new Error()";
var eval_origin;
var geval = eval;
var log = [];
(function() {
log.push([geval(source).stack, "15:13"]);
log.push([geval(source).stack, "16:13"]);
log.push([geval(source).stack, "17:13"]);
})();
(function() {
log.push([eval(source).stack, "21:13"]);
log.push([eval(source).stack, "22:13"]);
log.push([eval(source).stack, "23:13"]);
})();
log.push([eval(source).stack, "26:11"]);
log.push([eval(source).stack, "27:11"]);
log.push([eval(source).stack, "28:11"]);
Error.prepareStackTrace = undefined;
for (var item of log) {
var stacktraceline = item[0];
var expectation = item[1];
var re = new RegExp(`:${expectation}\\)$`);
assertTrue(re.test(stacktraceline));
}