Commit 01898366 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[codegen] Move ScriptOriginOptions into ScriptDetails

Follow-up CLs will use the ScriptDetails object for code cache lookups
instead of only the ScriptOriginOptions.

Bug: v8:10284
Change-Id: Idc83e6e79cfca283369a9b5ceab8bc53dae5f2dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3069149
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76073}
parent e7ad66ac
......@@ -2367,11 +2367,10 @@ namespace {
i::Compiler::ScriptDetails GetScriptDetails(
i::Isolate* isolate, Local<Value> resource_name, int resource_line_offset,
int resource_column_offset, Local<Value> source_map_url,
Local<PrimitiveArray> host_defined_options) {
i::Compiler::ScriptDetails script_details;
if (!resource_name.IsEmpty()) {
script_details.name_obj = Utils::OpenHandle(*(resource_name));
}
Local<PrimitiveArray> host_defined_options,
ScriptOriginOptions origin_options) {
i::Compiler::ScriptDetails script_details(
Utils::OpenHandle(*(resource_name), true), origin_options);
script_details.line_offset = resource_line_offset;
script_details.column_offset = resource_column_offset;
script_details.host_defined_options =
......@@ -2409,11 +2408,11 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
i::Compiler::ScriptDetails script_details = GetScriptDetails(
isolate, source->resource_name, source->resource_line_offset,
source->resource_column_offset, source->source_map_url,
source->host_defined_options);
source->host_defined_options, source->resource_options);
i::MaybeHandle<i::SharedFunctionInfo> maybe_function_info =
i::Compiler::GetSharedFunctionInfoForScript(
isolate, str, script_details, source->resource_options, nullptr,
script_data, options, no_cache_reason, i::NOT_NATIVES_CODE);
isolate, str, script_details, nullptr, script_data, options,
no_cache_reason, i::NOT_NATIVES_CODE);
if (options == kConsumeCodeCache) {
source->cached_data->rejected = script_data->rejected();
}
......@@ -2537,7 +2536,7 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
i::Compiler::ScriptDetails script_details = GetScriptDetails(
isolate, source->resource_name, source->resource_line_offset,
source->resource_column_offset, source->source_map_url,
source->host_defined_options);
source->host_defined_options, source->resource_options);
i::ScriptData* script_data = nullptr;
if (options == kConsumeCodeCache) {
......@@ -2551,8 +2550,7 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
has_pending_exception =
!i::Compiler::GetWrappedFunction(
Utils::OpenHandle(*source->source_string), arguments_list, context,
script_details, source->resource_options, script_data, options,
no_cache_reason)
script_details, script_data, options, no_cache_reason)
.ToHandle(&scoped_result);
if (options == kConsumeCodeCache) {
source->cached_data->rejected = script_data->rejected();
......@@ -2604,10 +2602,10 @@ i::MaybeHandle<i::SharedFunctionInfo> CompileStreamedSource(
i::Compiler::ScriptDetails script_details =
GetScriptDetails(isolate, origin.ResourceName(), origin.LineOffset(),
origin.ColumnOffset(), origin.SourceMapUrl(),
origin.HostDefinedOptions());
origin.HostDefinedOptions(), origin.Options());
i::ScriptStreamingData* data = v8_source->impl();
return i::Compiler::GetSharedFunctionInfoForStreamedScript(
isolate, str, script_details, origin.Options(), data);
isolate, str, script_details, data);
}
} // namespace
......
This diff is collapsed.
......@@ -133,11 +133,14 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
struct ScriptDetails {
ScriptDetails()
: line_offset(0), column_offset(0), repl_mode(REPLMode::kNo) {}
explicit ScriptDetails(Handle<Object> script_name)
explicit ScriptDetails(
Handle<Object> script_name,
ScriptOriginOptions origin_options = v8::ScriptOriginOptions())
: line_offset(0),
column_offset(0),
name_obj(script_name),
repl_mode(REPLMode::kNo) {}
repl_mode(REPLMode::kNo),
origin_options(origin_options) {}
int line_offset;
int column_offset;
......@@ -145,6 +148,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
i::MaybeHandle<i::Object> source_map_url;
i::MaybeHandle<i::FixedArray> host_defined_options;
REPLMode repl_mode;
const ScriptOriginOptions origin_options;
};
// Create a function that results from wrapping |source| in a function,
......@@ -152,7 +156,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> GetWrappedFunction(
Handle<String> source, Handle<FixedArray> arguments,
Handle<Context> context, const ScriptDetails& script_details,
ScriptOriginOptions origin_options, ScriptData* cached_data,
ScriptData* cached_data,
v8::ScriptCompiler::CompileOptions compile_options,
v8::ScriptCompiler::NoCacheReason no_cache_reason);
......@@ -176,9 +180,8 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
// Create a shared function info object for a String source.
static MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScript(
Isolate* isolate, Handle<String> source,
const ScriptDetails& script_details, ScriptOriginOptions origin_options,
v8::Extension* extension, ScriptData* cached_data,
ScriptCompiler::CompileOptions compile_options,
const ScriptDetails& script_details, v8::Extension* extension,
ScriptData* cached_data, ScriptCompiler::CompileOptions compile_options,
ScriptCompiler::NoCacheReason no_cache_reason,
NativesFlag is_natives_code);
......@@ -189,8 +192,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
// owned by the caller.
static MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
Isolate* isolate, Handle<String> source,
const ScriptDetails& script_details, ScriptOriginOptions origin_options,
ScriptStreamingData* streaming_data);
const ScriptDetails& script_details, ScriptStreamingData* streaming_data);
// Create a shared function info object for the given function literal
// node (the code may be lazily compiled).
......
......@@ -29,11 +29,11 @@ namespace {
static MaybeHandle<SharedFunctionInfo> GetFunctionInfo(Isolate* isolate,
Handle<String> source,
REPLMode repl_mode) {
Compiler::ScriptDetails script_details(isolate->factory()->empty_string());
Compiler::ScriptDetails script_details(isolate->factory()->empty_string(),
ScriptOriginOptions(false, true));
script_details.repl_mode = repl_mode;
ScriptOriginOptions origin_options(false, true);
return Compiler::GetSharedFunctionInfoForScript(
isolate, source, script_details, origin_options, nullptr, nullptr,
isolate, source, script_details, nullptr, nullptr,
ScriptCompiler::kNoCompileOptions, ScriptCompiler::kNoCacheNoReason,
NOT_NATIVES_CODE);
}
......
......@@ -757,12 +757,11 @@ MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* v8_isolate,
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::SharedFunctionInfo> result;
{
ScriptOriginOptions origin_options;
i::ScriptData* script_data = nullptr;
i::MaybeHandle<i::SharedFunctionInfo> maybe_function_info =
i::Compiler::GetSharedFunctionInfoForScript(
isolate, str, i::Compiler::ScriptDetails(), origin_options, nullptr,
script_data, ScriptCompiler::kNoCompileOptions,
isolate, str, i::Compiler::ScriptDetails(), nullptr, script_data,
ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheBecauseInspector,
i::FLAG_expose_inspector_scripts ? i::NOT_NATIVES_CODE
: i::INSPECTOR_CODE);
......
......@@ -4129,9 +4129,8 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
factory->NewStringFromUtf8(name).ToHandleChecked();
MaybeHandle<SharedFunctionInfo> maybe_function_info =
Compiler::GetSharedFunctionInfoForScript(
isolate, source, Compiler::ScriptDetails(script_name),
ScriptOriginOptions(), extension, nullptr,
ScriptCompiler::kNoCompileOptions,
isolate, source, Compiler::ScriptDetails(script_name), extension,
nullptr, ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheBecauseV8Extension, EXTENSION_CODE);
if (!maybe_function_info.ToHandle(&function_info)) return false;
cache->Add(isolate, name, function_info);
......
......@@ -34,8 +34,7 @@ static Handle<JSFunction> Compile(const char* source) {
.ToHandleChecked();
Handle<SharedFunctionInfo> shared =
Compiler::GetSharedFunctionInfoForScript(
isolate, source_code, Compiler::ScriptDetails(),
v8::ScriptOriginOptions(), nullptr, nullptr,
isolate, source_code, Compiler::ScriptDetails(), nullptr, nullptr,
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
......
......@@ -72,8 +72,7 @@ static Handle<JSFunction> Compile(const char* source) {
.ToHandleChecked();
Handle<SharedFunctionInfo> shared =
Compiler::GetSharedFunctionInfoForScript(
isolate, source_code, Compiler::ScriptDetails(),
v8::ScriptOriginOptions(), nullptr, nullptr,
isolate, source_code, Compiler::ScriptDetails(), nullptr, nullptr,
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
......
......@@ -1573,9 +1573,9 @@ static Handle<SharedFunctionInfo> CompileScript(
Isolate* isolate, Handle<String> source, Handle<String> name,
ScriptData* cached_data, v8::ScriptCompiler::CompileOptions options) {
return Compiler::GetSharedFunctionInfoForScript(
isolate, source, Compiler::ScriptDetails(name),
v8::ScriptOriginOptions(), nullptr, cached_data, options,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
isolate, source, Compiler::ScriptDetails(name), nullptr,
cached_data, options, ScriptCompiler::kNoCacheNoReason,
NOT_NATIVES_CODE)
.ToHandleChecked();
}
......@@ -1584,9 +1584,8 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache(
ScriptData** script_data, v8::ScriptCompiler::CompileOptions options) {
Handle<SharedFunctionInfo> sfi =
Compiler::GetSharedFunctionInfoForScript(
isolate, source, Compiler::ScriptDetails(name),
v8::ScriptOriginOptions(), nullptr, nullptr, options,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
isolate, source, Compiler::ScriptDetails(name), nullptr, nullptr,
options, ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
std::unique_ptr<ScriptCompiler::CachedData> cached_data(
ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi)));
......
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