Inherit ScriptOriginOptions in eval()

In general, whether an error thrown from a script will be muted is
passed as (part of) ScriptOriginOptions when the script is compiled.
Currently, when eval is called, that information is not given, and it
uses the default options (IsSharedCrossOrigin = false,
IsOpaque = false). Give it the options for the script in which eval
is called.

Bug: chromium:875153
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng;luci.chromium.try:linux_chromium_rel_ng
Change-Id: I4b5b872b4a8c2b8e503d457f199d85892a4c817c
Reviewed-on: https://chromium-review.googlesource.com/1188052
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55596}
This commit is contained in:
Yutaka Hirano 2018-09-03 16:29:23 +09:00 committed by Commit Bot
parent b898112277
commit 137f0c56dd

View File

@ -124,6 +124,14 @@ void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
shared->DebugName()));
}
ScriptOriginOptions OriginOptionsForEval(Object* script) {
if (!script->IsScript()) return ScriptOriginOptions();
const auto outer_origin_options = Script::cast(script)->origin_options();
return ScriptOriginOptions(outer_origin_options.IsSharedCrossOrigin(),
outer_origin_options.IsOpaque());
}
} // namespace
// ----------------------------------------------------------------------------
@ -1235,7 +1243,8 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
allow_eval_cache = true;
} else {
ParseInfo parse_info(isolate);
script = parse_info.CreateScript(isolate, source, ScriptOriginOptions());
script = parse_info.CreateScript(
isolate, source, OriginOptionsForEval(outer_info->script()));
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
script->set_eval_from_shared(*outer_info);
if (eval_position == kNoSourcePosition) {
@ -1247,6 +1256,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
FrameSummary summary = FrameSummary::GetTop(it.javascript_frame());
script->set_eval_from_shared(
summary.AsJavaScript().function()->shared());
script->set_origin_options(OriginOptionsForEval(*summary.script()));
eval_position = -summary.code_offset();
} else {
eval_position = 0;