From f24ebb324a21dede00bc087fbd74b46504c8314b Mon Sep 17 00:00:00 2001 From: epertoso Date: Thu, 16 Jul 2015 05:08:01 -0700 Subject: [PATCH] Take the ScriptOrigin into account for CompileFunctionInContext R=jochen@chromium.org,yangguo@chromium.org LOG=n BUG= Review URL: https://codereview.chromium.org/1233563005 Cr-Commit-Position: refs/heads/master@{#29700} --- src/api.cc | 24 ++++++++++++++++++++---- src/compiler.cc | 13 ++++++++++--- src/compiler.h | 4 +++- src/messages.js | 2 +- test/cctest/test-compiler.cc | 26 ++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/api.cc b/src/api.cc index e2abb98ff..2697e098c 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1915,11 +1915,27 @@ MaybeLocal ScriptCompiler::CompileFunctionInContext( context = factory->NewWithContext(closure, context, extension); } + i::Handle name_obj; + int line_offset = 0; + int column_offset = 0; + if (!source->resource_name.IsEmpty()) { + name_obj = Utils::OpenHandle(*(source->resource_name)); + } + if (!source->resource_line_offset.IsEmpty()) { + line_offset = static_cast(source->resource_line_offset->Value()); + } + if (!source->resource_column_offset.IsEmpty()) { + column_offset = static_cast(source->resource_column_offset->Value()); + } i::Handle fun; - has_pending_exception = - !i::Compiler::GetFunctionFromEval( - source_string, outer_info, context, i::SLOPPY, - i::ONLY_SINGLE_FUNCTION_LITERAL, scope_position).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(); + } RETURN_ON_FAILED_EXECUTION(Function); i::Handle result; diff --git a/src/compiler.cc b/src/compiler.cc index 147adb051..ab0a620be 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1150,7 +1150,8 @@ static Handle CompileToplevel(CompilationInfo* info) { MaybeHandle Compiler::GetFunctionFromEval( Handle source, Handle outer_info, Handle context, LanguageMode language_mode, - ParseRestriction restriction, int scope_position) { + ParseRestriction restriction, int line_offset, int column_offset, + Handle script_name, ScriptOriginOptions options) { Isolate* isolate = source->GetIsolate(); int source_length = source->length(); isolate->counters()->total_eval_size()->Increment(source_length); @@ -1159,11 +1160,17 @@ MaybeHandle Compiler::GetFunctionFromEval( CompilationCache* compilation_cache = isolate->compilation_cache(); MaybeHandle maybe_shared_info = compilation_cache->LookupEval(source, outer_info, context, language_mode, - scope_position); + line_offset); Handle shared_info; if (!maybe_shared_info.ToHandle(&shared_info)) { Handle