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

[codegen] Use ScriptDetails as parameter in CompilationCacheScript

- Add separate script-details.h file
- Follow-up CL will add support for precise caching with custom
  host options

Bug: v8:10284
Change-Id: I37be2079434ba7029c160ca811c7ce00a147f539
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3069151
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76077}
parent 09f6912c
......@@ -1024,6 +1024,7 @@ filegroup(
"src/codegen/reloc-info.h",
"src/codegen/safepoint-table.cc",
"src/codegen/safepoint-table.h",
"src/codegen/script-details.h",
"src/codegen/signature.h",
"src/codegen/source-position-table.cc",
"src/codegen/source-position-table.h",
......
......@@ -2474,6 +2474,7 @@ v8_header_set("v8_internal_headers") {
"src/codegen/reglist.h",
"src/codegen/reloc-info.h",
"src/codegen/safepoint-table.h",
"src/codegen/script-details.h",
"src/codegen/signature.h",
"src/codegen/source-position-table.h",
"src/codegen/source-position.h",
......
......@@ -30,6 +30,7 @@
#include "src/builtins/builtins-utils.h"
#include "src/codegen/compiler.h"
#include "src/codegen/cpu-features.h"
#include "src/codegen/script-details.h"
#include "src/common/assert-scope.h"
#include "src/common/external-pointer.h"
#include "src/common/globals.h"
......@@ -2364,13 +2365,15 @@ void Module::SetSyntheticModuleExport(Local<String> export_name,
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,
ScriptOriginOptions origin_options) {
i::Compiler::ScriptDetails script_details(
Utils::OpenHandle(*(resource_name), true), origin_options);
i::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,
ScriptOriginOptions origin_options) {
i::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 =
......@@ -2405,7 +2408,7 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
i::Handle<i::SharedFunctionInfo> result;
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileScript");
i::Compiler::ScriptDetails script_details = GetScriptDetails(
i::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->resource_options);
......@@ -2533,7 +2536,7 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
extension);
}
i::Compiler::ScriptDetails script_details = GetScriptDetails(
i::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->resource_options);
......@@ -2599,7 +2602,7 @@ i::MaybeHandle<i::SharedFunctionInfo> CompileStreamedSource(
i::Isolate* isolate, ScriptCompiler::StreamedSource* v8_source,
Local<String> full_source_string, const ScriptOrigin& origin) {
i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string));
i::Compiler::ScriptDetails script_details =
i::ScriptDetails script_details =
GetScriptDetails(isolate, origin.ResourceName(), origin.LineOffset(),
origin.ColumnOffset(), origin.SourceMapUrl(),
origin.HostDefinedOptions(), origin.Options());
......
......@@ -4,6 +4,7 @@
#include "src/codegen/compilation-cache.h"
#include "src/codegen/script-details.h"
#include "src/common/globals.h"
#include "src/heap/factory.h"
#include "src/logging/counters.h"
......@@ -104,42 +105,43 @@ void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) {
CompilationCacheScript::CompilationCacheScript(Isolate* isolate)
: CompilationSubCache(isolate, 1) {}
namespace {
// We only re-use a cached function for some script source code if the
// script originates from the same place. This is to avoid issues
// when reporting errors, etc.
bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
MaybeHandle<Object> maybe_name,
int line_offset, int column_offset,
ScriptOriginOptions resource_options) {
bool HasOrigin(Isolate* isolate, Handle<SharedFunctionInfo> function_info,
const ScriptDetails& script_details) {
Handle<Script> script =
Handle<Script>(Script::cast(function_info->script()), isolate());
Handle<Script>(Script::cast(function_info->script()), isolate);
// If the script name isn't set, the boilerplate script should have
// an undefined name to have the same origin.
Handle<Object> name;
if (!maybe_name.ToHandle(&name)) {
return script->name().IsUndefined(isolate());
if (!script_details.name_obj.ToHandle(&name)) {
return script->name().IsUndefined(isolate);
}
// Do the fast bailout checks first.
if (line_offset != script->line_offset()) return false;
if (column_offset != script->column_offset()) return false;
if (script_details.line_offset != script->line_offset()) return false;
if (script_details.column_offset != script->column_offset()) return false;
// Check that both names are strings. If not, no match.
if (!name->IsString() || !script->name().IsString()) return false;
// Are the origin_options same?
if (resource_options.Flags() != script->origin_options().Flags())
if (script_details.origin_options.Flags() !=
script->origin_options().Flags()) {
return false;
}
// Compare the two name strings for equality.
return String::Equals(
isolate(), Handle<String>::cast(name),
Handle<String>(String::cast(script->name()), isolate()));
return String::Equals(isolate, Handle<String>::cast(name),
Handle<String>(String::cast(script->name()), isolate));
}
} // namespace
// TODO(245): Need to allow identical code from different contexts to
// be cached in the same script generation. Currently the first use
// will be cached, but subsequent code from different source / line
// won't.
MaybeHandle<SharedFunctionInfo> CompilationCacheScript::Lookup(
Handle<String> source, MaybeHandle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<String> source, const ScriptDetails& script_details,
LanguageMode language_mode) {
MaybeHandle<SharedFunctionInfo> result;
......@@ -156,8 +158,7 @@ MaybeHandle<SharedFunctionInfo> CompilationCacheScript::Lookup(
if (probe.ToHandle(&function_info)) {
// Break when we've found a suitable shared function info that
// matches the origin.
if (HasOrigin(function_info, name, line_offset, column_offset,
resource_options)) {
if (HasOrigin(isolate(), function_info, script_details)) {
result = scope.CloseAndEscape(function_info);
}
}
......@@ -168,12 +169,9 @@ MaybeHandle<SharedFunctionInfo> CompilationCacheScript::Lookup(
// handle created in the caller's handle scope.
Handle<SharedFunctionInfo> function_info;
if (result.ToHandle(&function_info)) {
#ifdef DEBUG
// Since HasOrigin can allocate, we need to protect the SharedFunctionInfo
// with handles during the call.
DCHECK(HasOrigin(function_info, name, line_offset, column_offset,
resource_options));
#endif
DCHECK(HasOrigin(isolate(), function_info, script_details));
isolate()->counters()->compilation_cache_hits()->Increment();
LOG(isolate(), CompilationCacheEvent("hit", "script", *function_info));
} else {
......@@ -271,13 +269,10 @@ void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) {
}
MaybeHandle<SharedFunctionInfo> CompilationCache::LookupScript(
Handle<String> source, MaybeHandle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<String> source, const ScriptDetails& script_details,
LanguageMode language_mode) {
if (!IsEnabledScriptAndEval()) return MaybeHandle<SharedFunctionInfo>();
return script_.Lookup(source, name, line_offset, column_offset,
resource_options, language_mode);
return script_.Lookup(source, script_details, language_mode);
}
InfoCellPair CompilationCache::LookupEval(Handle<String> source,
......
......@@ -16,6 +16,7 @@ template <typename T>
class Handle;
class RootVisitor;
struct ScriptDetails;
// The compilation cache consists of several generational sub-caches which uses
// this class as a base class. A sub-cache contains a compilation cache tables
......@@ -82,9 +83,7 @@ class CompilationCacheScript : public CompilationSubCache {
explicit CompilationCacheScript(Isolate* isolate);
MaybeHandle<SharedFunctionInfo> Lookup(Handle<String> source,
MaybeHandle<Object> name,
int line_offset, int column_offset,
ScriptOriginOptions resource_options,
const ScriptDetails& script_details,
LanguageMode language_mode);
void Put(Handle<String> source, LanguageMode language_mode,
......@@ -93,10 +92,6 @@ class CompilationCacheScript : public CompilationSubCache {
void Age() override;
private:
bool HasOrigin(Handle<SharedFunctionInfo> function_info,
MaybeHandle<Object> name, int line_offset, int column_offset,
ScriptOriginOptions resource_options);
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
};
......@@ -163,8 +158,7 @@ class V8_EXPORT_PRIVATE CompilationCache {
// string. Returns an empty handle if the cache doesn't contain a
// script for the given source string with the right origin.
MaybeHandle<SharedFunctionInfo> LookupScript(
Handle<String> source, MaybeHandle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<String> source, const ScriptDetails& script_details,
LanguageMode language_mode);
// Finds the shared function info for a source string for eval in a
......
......@@ -19,6 +19,7 @@
#include "src/codegen/compilation-cache.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/codegen/pending-optimization-table.h"
#include "src/codegen/script-details.h"
#include "src/codegen/unoptimized-compilation-info.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
......@@ -2600,7 +2601,7 @@ struct ScriptCompileTimerScope {
};
void SetScriptFieldsFromDetails(Isolate* isolate, Script script,
Compiler::ScriptDetails script_details,
ScriptDetails script_details,
DisallowGarbageCollection* no_gc) {
Handle<Object> script_name;
if (script_details.name_obj.ToHandle(&script_name)) {
......@@ -2625,7 +2626,7 @@ void SetScriptFieldsFromDetails(Isolate* isolate, Script script,
Handle<Script> NewScript(
Isolate* isolate, ParseInfo* parse_info, Handle<String> source,
Compiler::ScriptDetails script_details, NativesFlag natives,
ScriptDetails script_details, NativesFlag natives,
MaybeHandle<FixedArray> maybe_wrapped_arguments = kNullMaybeHandle) {
// Create a script object describing the script to be compiled.
Handle<Script> script =
......@@ -2639,7 +2640,7 @@ Handle<Script> NewScript(
MaybeHandle<SharedFunctionInfo> CompileScriptOnMainThread(
const UnoptimizedCompileFlags flags, Handle<String> source,
const Compiler::ScriptDetails& script_details, NativesFlag natives,
const ScriptDetails& script_details, NativesFlag natives,
v8::Extension* extension, Isolate* isolate,
IsCompiledScope* is_compiled_scope) {
UnoptimizedCompileState compile_state(isolate);
......@@ -2703,7 +2704,7 @@ class StressBackgroundCompileThread : public base::Thread {
v8::ScriptCompiler::StreamedSource streamed_source_;
};
bool CanBackgroundCompile(const Compiler::ScriptDetails& script_details,
bool CanBackgroundCompile(const ScriptDetails& script_details,
v8::Extension* extension,
ScriptCompiler::CompileOptions compile_options,
NativesFlag natives) {
......@@ -2726,7 +2727,7 @@ bool CompilationExceptionIsRangeError(Isolate* isolate, Handle<Object> obj) {
}
MaybeHandle<SharedFunctionInfo> CompileScriptOnBothBackgroundAndMainThread(
Handle<String> source, const Compiler::ScriptDetails& script_details,
Handle<String> source, const ScriptDetails& script_details,
Isolate* isolate, IsCompiledScope* is_compiled_scope) {
// Start a background thread compiling the script.
StressBackgroundCompileThread background_compile_thread(
......@@ -2796,7 +2797,7 @@ MaybeHandle<SharedFunctionInfo> CompileScriptOnBothBackgroundAndMainThread(
// static
MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
Isolate* isolate, Handle<String> source,
const Compiler::ScriptDetails& script_details, v8::Extension* extension,
const ScriptDetails& script_details, v8::Extension* extension,
ScriptData* cached_data, ScriptCompiler::CompileOptions compile_options,
ScriptCompiler::NoCacheReason no_cache_reason, NativesFlag natives) {
ScriptCompileTimerScope compile_timer(isolate, no_cache_reason);
......@@ -2830,10 +2831,8 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
}
// First check per-isolate compilation cache.
maybe_result = compilation_cache->LookupScript(
source, script_details.name_obj, script_details.line_offset,
script_details.column_offset, script_details.origin_options,
language_mode);
maybe_result =
compilation_cache->LookupScript(source, script_details, language_mode);
if (!maybe_result.is_null()) {
compile_timer.set_hit_isolate_cache();
} else if (can_consume_code_cache) {
......@@ -2901,7 +2900,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
// static
MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
Handle<String> source, Handle<FixedArray> arguments,
Handle<Context> context, const Compiler::ScriptDetails& script_details,
Handle<Context> context, const ScriptDetails& script_details,
ScriptData* cached_data, v8::ScriptCompiler::CompileOptions compile_options,
v8::ScriptCompiler::NoCacheReason no_cache_reason) {
Isolate* isolate = context->GetIsolate();
......@@ -3016,9 +3015,8 @@ Compiler::GetSharedFunctionInfoForStreamedScript(
{
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.StreamingFinalization.CheckCache");
maybe_result = compilation_cache->LookupScript(
source, script_details.name_obj, script_details.line_offset,
script_details.column_offset, origin_options, task->language_mode());
maybe_result = compilation_cache->LookupScript(source, script_details,
task->language_mode());
if (!maybe_result.is_null()) {
compile_timer.set_hit_isolate_cache();
}
......
......@@ -36,11 +36,12 @@ class ParseInfo;
class Parser;
class RuntimeCallStats;
class ScriptData;
struct ScriptStreamingData;
class TimedHistogram;
class UnoptimizedCompilationInfo;
class UnoptimizedCompilationJob;
class WorkerThreadRuntimeCallStats;
struct ScriptDetails;
struct ScriptStreamingData;
using UnoptimizedCompilationJobList =
std::forward_list<std::unique_ptr<UnoptimizedCompilationJob>>;
......@@ -130,27 +131,6 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
ParseRestriction restriction, int parameters_end_pos,
int eval_scope_position, int eval_position);
struct ScriptDetails {
ScriptDetails()
: line_offset(0), column_offset(0), repl_mode(REPLMode::kNo) {}
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),
origin_options(origin_options) {}
int line_offset;
int column_offset;
i::MaybeHandle<i::Object> name_obj;
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,
// with |arguments| being a list of parameters for that function.
V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> GetWrappedFunction(
......
// Copyright 2021 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.
#ifndef V8_CODEGEN_SCRIPT_DETAILS_H_
#define V8_CODEGEN_SCRIPT_DETAILS_H_
#include "src/common/globals.h"
#include "src/objects/fixed-array.h"
#include "src/objects/objects.h"
namespace v8 {
namespace internal {
struct ScriptDetails {
ScriptDetails()
: line_offset(0), column_offset(0), repl_mode(REPLMode::kNo) {}
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),
origin_options(origin_options) {}
int line_offset;
int column_offset;
MaybeHandle<Object> name_obj;
MaybeHandle<Object> source_map_url;
MaybeHandle<FixedArray> host_defined_options;
REPLMode repl_mode;
const ScriptOriginOptions origin_options;
};
} // namespace internal
} // namespace v8
#endif // V8_CODEGEN_SCRIPT_DETAILS_H_
......@@ -7,6 +7,7 @@
#include "src/builtins/accessors.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/compiler.h"
#include "src/codegen/script-details.h"
#include "src/common/globals.h"
#include "src/debug/debug-frames.h"
#include "src/debug/debug-scopes.h"
......@@ -29,8 +30,8 @@ namespace {
static MaybeHandle<SharedFunctionInfo> GetFunctionInfo(Isolate* isolate,
Handle<String> source,
REPLMode repl_mode) {
Compiler::ScriptDetails script_details(isolate->factory()->empty_string(),
ScriptOriginOptions(false, true));
ScriptDetails script_details(isolate->factory()->empty_string(),
ScriptOriginOptions(false, true));
script_details.repl_mode = repl_mode;
return Compiler::GetSharedFunctionInfoForScript(
isolate, source, script_details, nullptr, nullptr,
......
......@@ -6,6 +6,7 @@
#include "src/api/api-inl.h"
#include "src/base/utils/random-number-generator.h"
#include "src/codegen/script-details.h"
#include "src/debug/debug-coverage.h"
#include "src/debug/debug-evaluate.h"
#include "src/debug/debug-property-iterator.h"
......@@ -760,7 +761,7 @@ MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* v8_isolate,
i::ScriptData* script_data = nullptr;
i::MaybeHandle<i::SharedFunctionInfo> maybe_function_info =
i::Compiler::GetSharedFunctionInfoForScript(
isolate, str, i::Compiler::ScriptDetails(), nullptr, script_data,
isolate, str, i::ScriptDetails(), nullptr, script_data,
ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheBecauseInspector,
i::FLAG_expose_inspector_scripts ? i::NOT_NATIVES_CODE
......
......@@ -57,6 +57,7 @@
#include "src/objects/js-segmenter.h"
#include "src/objects/js-segments.h"
#endif // V8_INTL_SUPPORT
#include "src/codegen/script-details.h"
#include "src/objects/js-weak-refs.h"
#include "src/objects/ordered-hash-table.h"
#include "src/objects/property-cell.h"
......@@ -4129,8 +4130,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), extension,
nullptr, ScriptCompiler::kNoCompileOptions,
isolate, source, 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);
......
......@@ -6,6 +6,7 @@
#include "src/codegen/code-factory.h"
#include "src/codegen/compiler.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/codegen/script-details.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
#include "src/compiler/linkage.h"
......@@ -34,7 +35,7 @@ static Handle<JSFunction> Compile(const char* source) {
.ToHandleChecked();
Handle<SharedFunctionInfo> shared =
Compiler::GetSharedFunctionInfoForScript(
isolate, source_code, Compiler::ScriptDetails(), nullptr, nullptr,
isolate, source_code, ScriptDetails(), nullptr, nullptr,
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
......
......@@ -34,6 +34,7 @@
#include "src/codegen/assembler-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/macro-assembler-inl.h"
#include "src/codegen/script-details.h"
#include "src/common/globals.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
......@@ -1489,10 +1490,10 @@ TEST(CompilationCacheCachingBehavior) {
// The script should be in the cache now.
{
v8::HandleScope scope(CcTest::isolate());
ScriptDetails script_details(Handle<Object>(),
v8::ScriptOriginOptions(true, false));
MaybeHandle<SharedFunctionInfo> cached_script =
compilation_cache->LookupScript(source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(true, false),
language_mode);
compilation_cache->LookupScript(source, script_details, language_mode);
CHECK(!cached_script.is_null());
}
......@@ -1500,10 +1501,10 @@ TEST(CompilationCacheCachingBehavior) {
{
CcTest::CollectAllGarbage();
v8::HandleScope scope(CcTest::isolate());
ScriptDetails script_details(Handle<Object>(),
v8::ScriptOriginOptions(true, false));
MaybeHandle<SharedFunctionInfo> cached_script =
compilation_cache->LookupScript(source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(true, false),
language_mode);
compilation_cache->LookupScript(source, script_details, language_mode);
CHECK(!cached_script.is_null());
// Progress code age until it's old and ready for GC.
......@@ -1520,10 +1521,10 @@ TEST(CompilationCacheCachingBehavior) {
{
v8::HandleScope scope(CcTest::isolate());
// Ensure code aging cleared the entry from the cache.
ScriptDetails script_details(Handle<Object>(),
v8::ScriptOriginOptions(true, false));
MaybeHandle<SharedFunctionInfo> cached_script =
compilation_cache->LookupScript(source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(true, false),
language_mode);
compilation_cache->LookupScript(source, script_details, language_mode);
CHECK(cached_script.is_null());
}
}
......
......@@ -27,18 +27,19 @@
#include <stdlib.h>
#include <wchar.h>
#include <memory>
#include "src/init/v8.h"
#include <memory>
#include "include/v8-profiler.h"
#include "include/v8.h"
#include "src/api/api-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/codegen/script-details.h"
#include "src/diagnostics/disasm.h"
#include "src/heap/factory.h"
#include "src/heap/spaces.h"
#include "src/init/v8.h"
#include "src/interpreter/interpreter.h"
#include "src/objects/allocation-site-inl.h"
#include "src/objects/objects-inl.h"
......@@ -72,7 +73,7 @@ static Handle<JSFunction> Compile(const char* source) {
.ToHandleChecked();
Handle<SharedFunctionInfo> shared =
Compiler::GetSharedFunctionInfoForScript(
isolate, source_code, Compiler::ScriptDetails(), nullptr, nullptr,
isolate, source_code, ScriptDetails(), nullptr, nullptr,
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
......
......@@ -33,6 +33,7 @@
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/codegen/macro-assembler-inl.h"
#include "src/codegen/script-details.h"
#include "src/common/assert-scope.h"
#include "src/debug/debug.h"
#include "src/heap/heap-inl.h"
......@@ -1573,9 +1574,8 @@ 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), nullptr,
cached_data, options, ScriptCompiler::kNoCacheNoReason,
NOT_NATIVES_CODE)
isolate, source, ScriptDetails(name), nullptr, cached_data,
options, ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
}
......@@ -1584,8 +1584,8 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache(
ScriptData** script_data, v8::ScriptCompiler::CompileOptions options) {
Handle<SharedFunctionInfo> sfi =
Compiler::GetSharedFunctionInfoForScript(
isolate, source, Compiler::ScriptDetails(name), nullptr, nullptr,
options, ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
isolate, source, ScriptDetails(name), nullptr, nullptr, options,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
std::unique_ptr<ScriptCompiler::CachedData> cached_data(
ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi)));
......@@ -1730,9 +1730,10 @@ TEST(CodeSerializerPromotedToCompilationCache) {
Handle<SharedFunctionInfo> copy = CompileScript(
isolate, src, src, cache, v8::ScriptCompiler::kConsumeCodeCache);
ScriptDetails script_details(src);
MaybeHandle<SharedFunctionInfo> shared =
isolate->compilation_cache()->LookupScript(
src, src, 0, 0, v8::ScriptOriginOptions(), LanguageMode::kSloppy);
isolate->compilation_cache()->LookupScript(src, script_details,
LanguageMode::kSloppy);
CHECK(*shared.ToHandleChecked() == *copy);
......
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