From 552906b0f222c5d5dd11b9fd73829d510980461a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 16 Jul 2020 11:45:35 +0200 Subject: BASELINE: Update Chromium to 83.0.4103.122 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning --- chromium/gin/BUILD.gn | 16 +++------ chromium/gin/converter_unittest.cc | 42 ++++++++++++++++++++++ chromium/gin/function_template.h | 5 +-- chromium/gin/gin_features.cc | 25 ++++--------- chromium/gin/gin_features.h | 7 ++-- chromium/gin/object_template_builder.cc | 11 ++++-- chromium/gin/object_template_builder.h | 3 ++ chromium/gin/v8_initializer.cc | 42 ++++++---------------- chromium/gin/v8_isolate_memory_dump_provider.cc | 8 +++++ .../v8_isolate_memory_dump_provider_unittest.cc | 21 +++++++++++ chromium/gin/v8_platform.cc | 25 ++++++------- 11 files changed, 120 insertions(+), 85 deletions(-) (limited to 'chromium/gin') diff --git a/chromium/gin/BUILD.gn b/chromium/gin/BUILD.gn index e49ca6c2448..9bd95191ab4 100644 --- a/chromium/gin/BUILD.gn +++ b/chromium/gin/BUILD.gn @@ -71,9 +71,7 @@ component("gin") { ] if (v8_use_external_startup_data) { - data = [ - "$root_out_dir/snapshot_blob.bin", - ] + data = [ "$root_out_dir/snapshot_blob.bin" ] } defines = [ "GIN_IMPLEMENTATION" ] @@ -82,9 +80,7 @@ component("gin") { "//base", "//v8", ] - deps = [ - "//base/third_party/dynamic_annotations", - ] + deps = [ "//base/third_party/dynamic_annotations" ] if (is_mac) { libs = [ "CoreFoundation.framework" ] @@ -94,9 +90,7 @@ component("gin") { } executable("gin_shell") { - sources = [ - "shell/gin_main.cc", - ] + sources = [ "shell/gin_main.cc" ] deps = [ ":gin", @@ -157,9 +151,7 @@ test("gin_unittests") { "//v8:external_startup_data", ] - data_deps = [ - "//tools/v8_context_snapshot:v8_context_snapshot", - ] + data_deps = [ "//tools/v8_context_snapshot:v8_context_snapshot" ] data = [] # gin_shell is not an Android app. diff --git a/chromium/gin/converter_unittest.cc b/chromium/gin/converter_unittest.cc index 6f9205f06a3..162572385bd 100644 --- a/chromium/gin/converter_unittest.cc +++ b/chromium/gin/converter_unittest.cc @@ -12,6 +12,7 @@ #include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "gin/function_template.h" #include "gin/handle.h" #include "gin/public/isolate_holder.h" #include "gin/test/v8_test.h" @@ -224,4 +225,45 @@ TEST_F(ConverterTest, VectorOfWrappables) { EXPECT_THAT(out_value2, testing::ContainerEq(vector)); } +namespace { + +class MoveOnlyObject { + public: + MoveOnlyObject() = default; + MoveOnlyObject(const MoveOnlyObject&) = delete; + MoveOnlyObject& operator=(const MoveOnlyObject&) = delete; + + MoveOnlyObject(MoveOnlyObject&&) noexcept = default; + MoveOnlyObject& operator=(MoveOnlyObject&&) noexcept = default; +}; + +} // namespace + +template <> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, MoveOnlyObject in) { + return v8::Undefined(isolate); + } + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + MoveOnlyObject* out) { + *out = MoveOnlyObject(); + return true; + } +}; + +TEST_F(ConverterTest, MoveOnlyParameters) { + v8::Isolate* isolate = instance_->isolate(); + v8::HandleScope handle_scope(isolate); + + auto receives_move_only_obj = [](MoveOnlyObject obj) {}; + auto func_templ = gin::CreateFunctionTemplate( + isolate, base::BindRepeating(receives_move_only_obj)); + + v8::Local context = instance_->isolate()->GetCurrentContext(); + auto func = func_templ->GetFunction(context).ToLocalChecked(); + v8::Local argv[] = {v8::Undefined(isolate)}; + func->Call(context, v8::Undefined(isolate), 1, argv).ToLocalChecked(); +} + } // namespace gin diff --git a/chromium/gin/function_template.h b/chromium/gin/function_template.h index 7edcc9e20df..8c641d934fd 100644 --- a/chromium/gin/function_template.h +++ b/chromium/gin/function_template.h @@ -166,14 +166,15 @@ class Invoker, ArgTypes...> template void DispatchToCallback( base::RepeatingCallback callback) { - args_->Return(callback.Run(ArgumentHolder::value...)); + args_->Return( + callback.Run(std::move(ArgumentHolder::value)...)); } // In C++, you can declare the function foo(void), but you can't pass a void // expression to foo. As a result, we must specialize the case of Callbacks // that have the void return type. void DispatchToCallback(base::RepeatingCallback callback) { - callback.Run(ArgumentHolder::value...); + callback.Run(std::move(ArgumentHolder::value)...); } private: diff --git a/chromium/gin/gin_features.cc b/chromium/gin/gin_features.cc index 2acd379b5e5..d24cf1e4d28 100644 --- a/chromium/gin/gin_features.cc +++ b/chromium/gin/gin_features.cc @@ -18,24 +18,11 @@ const base::Feature kV8FlushBytecode{"V8FlushBytecode", const base::Feature kV8LazyFeedbackAllocation{"V8LazyFeedbackAllocation", base::FEATURE_ENABLED_BY_DEFAULT}; -// Enables memory reducer for small heaps in V8. -const base::Feature kV8MemoryReducerForSmallHeaps{ - "V8MemoryReducerForSmallHeaps", base::FEATURE_ENABLED_BY_DEFAULT}; - -// Increase V8 heap size to 4GB if the physical memory is bigger than 16 GB. -const base::Feature kV8HugeMaxOldGenerationSize{ - "V8HugeMaxOldGenerationSize", base::FEATURE_ENABLED_BY_DEFAULT}; - -// Enables new background GC scheduling heuristics. -const base::Feature kV8GCBackgroundSchedule{"V8GCBackgroundSchedule", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Perform less compaction in non-memory reducing mode. -const base::Feature kV8GCLessCompaction{"V8GCLessCompaction", - base::FEATURE_DISABLED_BY_DEFAULT}; - -// Always promote young objects in Mark-Compact GC. -const base::Feature kV8GCAlwaysPromoteYoungMC{ - "V8GCAlwaysPromoteYoungMC", base::FEATURE_DISABLED_BY_DEFAULT}; +// Enable concurrent inlining in TurboFan. +const base::Feature kV8ConcurrentInlining{"V8ConcurrentInlining", + base::FEATURE_DISABLED_BY_DEFAULT}; +// Enable per-context marking worklists in V8 GC. +const base::Feature kV8PerContextMarkingWorklist{ + "V8PerContextMarkingWorklist", base::FEATURE_DISABLED_BY_DEFAULT}; } // namespace features diff --git a/chromium/gin/gin_features.h b/chromium/gin/gin_features.h index 810b4a60784..6502de3ad89 100644 --- a/chromium/gin/gin_features.h +++ b/chromium/gin/gin_features.h @@ -13,11 +13,8 @@ namespace features { GIN_EXPORT extern const base::Feature kV8OptimizeJavascript; GIN_EXPORT extern const base::Feature kV8FlushBytecode; GIN_EXPORT extern const base::Feature kV8LazyFeedbackAllocation; -GIN_EXPORT extern const base::Feature kV8MemoryReducerForSmallHeaps; -GIN_EXPORT extern const base::Feature kV8HugeMaxOldGenerationSize; -GIN_EXPORT extern const base::Feature kV8GCBackgroundSchedule; -GIN_EXPORT extern const base::Feature kV8GCLessCompaction; -GIN_EXPORT extern const base::Feature kV8GCAlwaysPromoteYoungMC; +GIN_EXPORT extern const base::Feature kV8ConcurrentInlining; +GIN_EXPORT extern const base::Feature kV8PerContextMarkingWorklist; } // namespace features diff --git a/chromium/gin/object_template_builder.cc b/chromium/gin/object_template_builder.cc index 543cd694e7b..9add555497b 100644 --- a/chromium/gin/object_template_builder.cc +++ b/chromium/gin/object_template_builder.cc @@ -145,9 +145,14 @@ ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate) ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate, const char* type_name) - : isolate_(isolate), - type_name_(type_name), - template_(v8::ObjectTemplate::New(isolate)) { + : ObjectTemplateBuilder(isolate, + type_name, + v8::ObjectTemplate::New(isolate)) {} + +ObjectTemplateBuilder::ObjectTemplateBuilder(v8::Isolate* isolate, + const char* type_name, + v8::Local tmpl) + : isolate_(isolate), type_name_(type_name), template_(tmpl) { template_->SetInternalFieldCount(kNumberOfInternalFields); } diff --git a/chromium/gin/object_template_builder.h b/chromium/gin/object_template_builder.h index 6fb331cbbfe..edbf0b66f8b 100644 --- a/chromium/gin/object_template_builder.h +++ b/chromium/gin/object_template_builder.h @@ -46,6 +46,9 @@ class GIN_EXPORT ObjectTemplateBuilder { public: explicit ObjectTemplateBuilder(v8::Isolate* isolate); ObjectTemplateBuilder(v8::Isolate* isolate, const char* type_name); + ObjectTemplateBuilder(v8::Isolate* isolate, + const char* type_name, + v8::Local tmpl); ObjectTemplateBuilder(const ObjectTemplateBuilder& other); ~ObjectTemplateBuilder(); diff --git a/chromium/gin/v8_initializer.cc b/chromium/gin/v8_initializer.cc index 9298a9c7554..3a3742ed911 100644 --- a/chromium/gin/v8_initializer.cc +++ b/chromium/gin/v8_initializer.cc @@ -218,40 +218,18 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode) { sizeof(no_lazy_feedback_allocation) - 1); } - if (!base::FeatureList::IsEnabled(features::kV8MemoryReducerForSmallHeaps)) { - static const char no_memory_reducer[] = - "--no-memory-reducer-for-small-heaps"; - v8::V8::SetFlagsFromString(no_memory_reducer, - sizeof(no_memory_reducer) - 1); + if (base::FeatureList::IsEnabled(features::kV8ConcurrentInlining)) { + static const char tf_experiment_concurrent_inlining[] = + "--concurrent_inlining"; + v8::V8::SetFlagsFromString(tf_experiment_concurrent_inlining, + sizeof(tf_experiment_concurrent_inlining) - 1); } - if (base::FeatureList::IsEnabled(features::kV8HugeMaxOldGenerationSize)) { - static const char huge_max_old_generation_size[] = - "--huge_max_old_generation_size"; - v8::V8::SetFlagsFromString(huge_max_old_generation_size, - sizeof(huge_max_old_generation_size) - 1); - } - - if (base::FeatureList::IsEnabled(features::kV8GCBackgroundSchedule)) { - static const char gc_experiment_background_schedule[] = - "--gc_experiment_background_schedule"; - v8::V8::SetFlagsFromString(gc_experiment_background_schedule, - sizeof(gc_experiment_background_schedule) - 1); - } - - if (base::FeatureList::IsEnabled(features::kV8GCLessCompaction)) { - static const char gc_experiment_less_compaction[] = - "--gc_experiment_less_compaction"; - v8::V8::SetFlagsFromString(gc_experiment_less_compaction, - sizeof(gc_experiment_less_compaction) - 1); - } - - if (base::FeatureList::IsEnabled(features::kV8GCAlwaysPromoteYoungMC)) { - static const char gc_experiment_always_promote_young_mc[] = - "--always_promote_young_mc"; - v8::V8::SetFlagsFromString( - gc_experiment_always_promote_young_mc, - sizeof(gc_experiment_always_promote_young_mc) - 1); + if (base::FeatureList::IsEnabled(features::kV8PerContextMarkingWorklist)) { + static const char stress_per_context_marking_worklist[] = + "--stress-per-context-marking-worklist"; + v8::V8::SetFlagsFromString(stress_per_context_marking_worklist, + sizeof(stress_per_context_marking_worklist) - 1); } if (IsolateHolder::kStrictMode == mode) { diff --git a/chromium/gin/v8_isolate_memory_dump_provider.cc b/chromium/gin/v8_isolate_memory_dump_provider.cc index 4e328f11573..010bf88c6fc 100644 --- a/chromium/gin/v8_isolate_memory_dump_provider.cc +++ b/chromium/gin/v8_isolate_memory_dump_provider.cc @@ -253,6 +253,14 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics( // Dump statistics related to code and bytecode if requested. DumpCodeStatistics(code_stats_dump, isolate_holder_); + // Dump statistics for global handles. + auto* global_handles_dump = process_memory_dump->CreateAllocatorDump( + dump_base_name + "/global_handles" + dump_name_suffix); + global_handles_dump->AddScalar( + base::trace_event::MemoryAllocatorDump::kNameSize, + base::trace_event::MemoryAllocatorDump::kUnitsBytes, + heap_statistics.total_global_handles_size()); + // Dump object statistics only for detailed dumps. if (args.level_of_detail != base::trace_event::MemoryDumpLevelOfDetail::DETAILED) { diff --git a/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc b/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc index b003a234380..124cc4fdabb 100644 --- a/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc +++ b/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc @@ -64,6 +64,27 @@ TEST_F(V8MemoryDumpProviderTest, DumpStatistics) { ASSERT_TRUE(did_dump_objects_stats); } +TEST_F(V8MemoryDumpProviderTest, DumpGlobalHandlesSize) { + base::trace_event::MemoryDumpArgs dump_args = { + base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND}; + std::unique_ptr process_memory_dump( + new base::trace_event::ProcessMemoryDump(dump_args)); + instance_->isolate_memory_dump_provider_for_testing()->OnMemoryDump( + dump_args, process_memory_dump.get()); + const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& + allocator_dumps = process_memory_dump->allocator_dumps(); + + bool did_dump_global_handles = false; + for (const auto& name_dump : allocator_dumps) { + const std::string& name = name_dump.first; + if (name.find("v8/main/global_handles") != std::string::npos) { + did_dump_global_handles = true; + } + } + + ASSERT_TRUE(did_dump_global_handles); +} + TEST_F(V8MemoryDumpProviderTest, DumpContextStatistics) { base::trace_event::MemoryDumpArgs dump_args = { base::trace_event::MemoryDumpLevelOfDetail::LIGHT}; diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc index cbd61e81090..119e69b6b09 100644 --- a/chromium/gin/v8_platform.cc +++ b/chromium/gin/v8_platform.cc @@ -31,13 +31,13 @@ namespace { base::LazyInstance::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER; constexpr base::TaskTraits kLowPriorityTaskTraits = { - base::ThreadPool(), base::TaskPriority::BEST_EFFORT}; + base::TaskPriority::BEST_EFFORT}; constexpr base::TaskTraits kDefaultTaskTraits = { - base::ThreadPool(), base::TaskPriority::USER_VISIBLE}; + base::TaskPriority::USER_VISIBLE}; constexpr base::TaskTraits kBlockingTaskTraits = { - base::ThreadPool(), base::TaskPriority::USER_BLOCKING}; + base::TaskPriority::USER_BLOCKING}; void PrintStackTrace() { base::debug::StackTrace trace; @@ -417,27 +417,28 @@ int V8Platform::NumberOfWorkerThreads() { } void V8Platform::CallOnWorkerThread(std::unique_ptr task) { - base::PostTask(FROM_HERE, kDefaultTaskTraits, - base::BindOnce(&v8::Task::Run, std::move(task))); + base::ThreadPool::PostTask(FROM_HERE, kDefaultTaskTraits, + base::BindOnce(&v8::Task::Run, std::move(task))); } void V8Platform::CallBlockingTaskOnWorkerThread( std::unique_ptr task) { - base::PostTask(FROM_HERE, kBlockingTaskTraits, - base::BindOnce(&v8::Task::Run, std::move(task))); + base::ThreadPool::PostTask(FROM_HERE, kBlockingTaskTraits, + base::BindOnce(&v8::Task::Run, std::move(task))); } void V8Platform::CallLowPriorityTaskOnWorkerThread( std::unique_ptr task) { - base::PostTask(FROM_HERE, kLowPriorityTaskTraits, - base::BindOnce(&v8::Task::Run, std::move(task))); + base::ThreadPool::PostTask(FROM_HERE, kLowPriorityTaskTraits, + base::BindOnce(&v8::Task::Run, std::move(task))); } void V8Platform::CallDelayedOnWorkerThread(std::unique_ptr task, double delay_in_seconds) { - base::PostDelayedTask(FROM_HERE, kDefaultTaskTraits, - base::BindOnce(&v8::Task::Run, std::move(task)), - base::TimeDelta::FromSecondsD(delay_in_seconds)); + base::ThreadPool::PostDelayedTask( + FROM_HERE, kDefaultTaskTraits, + base::BindOnce(&v8::Task::Run, std::move(task)), + base::TimeDelta::FromSecondsD(delay_in_seconds)); } bool V8Platform::IdleTasksEnabled(v8::Isolate* isolate) { -- cgit v1.2.1