diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-13 13:24:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 10:57:25 +0000 |
commit | af3d4809763ef308f08ced947a73b624729ac7ea (patch) | |
tree | 4402b911e30383f6c6dace1e8cf3b8e85355db3a /chromium/gin | |
parent | 0e8ff63a407fe323e215bb1a2c423c09a4747c8a (diff) | |
download | qtwebengine-chromium-af3d4809763ef308f08ced947a73b624729ac7ea.tar.gz |
BASELINE: Update Chromium to 47.0.2526.14
Also adding in sources needed for spellchecking.
Change-Id: Idd44170fa1616f26315188970a8d5ba7d472b18a
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'chromium/gin')
-rw-r--r-- | chromium/gin/BUILD.gn | 9 | ||||
-rw-r--r-- | chromium/gin/arguments.h | 2 | ||||
-rw-r--r-- | chromium/gin/isolate_holder.cc | 6 | ||||
-rw-r--r-- | chromium/gin/modules/console.cc | 2 | ||||
-rw-r--r-- | chromium/gin/modules/file_module_provider.cc | 4 | ||||
-rw-r--r-- | chromium/gin/modules/module_registry.cc | 4 | ||||
-rw-r--r-- | chromium/gin/per_isolate_data.cc | 8 | ||||
-rw-r--r-- | chromium/gin/per_isolate_data.h | 8 | ||||
-rw-r--r-- | chromium/gin/public/gin_embedders.h | 1 | ||||
-rw-r--r-- | chromium/gin/public/isolate_holder.h | 3 | ||||
-rw-r--r-- | chromium/gin/public/v8_idle_task_runner.h | 26 | ||||
-rw-r--r-- | chromium/gin/public/v8_platform.h | 3 | ||||
-rw-r--r-- | chromium/gin/v8_initializer.cc | 6 | ||||
-rw-r--r-- | chromium/gin/v8_isolate_memory_dump_provider.cc | 50 | ||||
-rw-r--r-- | chromium/gin/v8_isolate_memory_dump_provider.h | 2 | ||||
-rw-r--r-- | chromium/gin/v8_isolate_memory_dump_provider_unittest.cc | 4 | ||||
-rw-r--r-- | chromium/gin/v8_platform.cc | 10 |
17 files changed, 126 insertions, 22 deletions
diff --git a/chromium/gin/BUILD.gn b/chromium/gin/BUILD.gn index d926cb9a05e..45350747bfe 100644 --- a/chromium/gin/BUILD.gn +++ b/chromium/gin/BUILD.gn @@ -46,6 +46,7 @@ component("gin") { "public/debug.h", "public/gin_embedders.h", "public/isolate_holder.h", + "public/v8_idle_task_runner.h", "public/v8_platform.h", "public/wrapper_info.h", "run_microtasks_observer.cc", @@ -66,6 +67,13 @@ component("gin") { "wrapper_info.cc", ] + if (v8_use_external_startup_data) { + data = [ + "$root_out_dir/natives_blob.bin", + "$root_out_dir/snapshot_blob.bin", + ] + } + defines = [ "GIN_IMPLEMENTATION" ] public_deps = [ @@ -122,6 +130,7 @@ executable("gin_shell") { ":gin", "//base", "//base:i18n", + "//build/config/sanitizers:deps", "//v8", ] } diff --git a/chromium/gin/arguments.h b/chromium/gin/arguments.h index 1affa2c8acb..b8d1296d138 100644 --- a/chromium/gin/arguments.h +++ b/chromium/gin/arguments.h @@ -75,6 +75,8 @@ class GIN_EXPORT Arguments { info_->GetReturnValue().Set(v8_value); } + // Always check the return value whether the handle is empty before + // dereferencing the handle. v8::Local<v8::Value> PeekNext() const; void ThrowError() const; diff --git a/chromium/gin/isolate_holder.cc b/chromium/gin/isolate_holder.cc index 656ce09f51a..3defd7ce9b5 100644 --- a/chromium/gin/isolate_holder.cc +++ b/chromium/gin/isolate_holder.cc @@ -92,4 +92,10 @@ void IsolateHolder::RemoveRunMicrotasksObserver() { task_observer_.reset(); } +void IsolateHolder::EnableIdleTasks( + scoped_ptr<V8IdleTaskRunner> idle_task_runner) { + DCHECK(isolate_data_.get()); + isolate_data_->EnableIdleTasks(idle_task_runner.Pass()); +} + } // namespace gin diff --git a/chromium/gin/modules/console.cc b/chromium/gin/modules/console.cc index 75241df081a..231d8fc4761 100644 --- a/chromium/gin/modules/console.cc +++ b/chromium/gin/modules/console.cc @@ -25,7 +25,7 @@ void Log(Arguments* args) { args->ThrowError(); return; } - std::cout << JoinString(messages, ' ') << std::endl; + std::cout << base::JoinString(messages, " ") << std::endl; } WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; diff --git a/chromium/gin/modules/file_module_provider.cc b/chromium/gin/modules/file_module_provider.cc index b8465ae6368..1568378ee60 100644 --- a/chromium/gin/modules/file_module_provider.cc +++ b/chromium/gin/modules/file_module_provider.cc @@ -20,8 +20,8 @@ void AttempToLoadModule(const base::WeakPtr<Runner>& runner, if (!runner) return; - std::vector<std::string> components; - base::SplitString(id, '/', &components); + std::vector<std::string> components = base::SplitString( + id, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); base::FilePath path; for (size_t i = 0; i < components.size(); ++i) { diff --git a/chromium/gin/modules/module_registry.cc b/chromium/gin/modules/module_registry.cc index 036e98df6bc..b75894cf4cb 100644 --- a/chromium/gin/modules/module_registry.cc +++ b/chromium/gin/modules/module_registry.cc @@ -66,9 +66,9 @@ void Define(const v8::FunctionCallbackInfo<Value>& info) { std::vector<std::string> dependencies; v8::Local<Value> factory; - if (args.PeekNext()->IsString()) + if (!args.PeekNext().IsEmpty() && args.PeekNext()->IsString()) args.GetNext(&id); - if (args.PeekNext()->IsArray()) + if (!args.PeekNext().IsEmpty() && args.PeekNext()->IsArray()) args.GetNext(&dependencies); if (!args.GetNext(&factory)) return args.ThrowError(); diff --git a/chromium/gin/per_isolate_data.cc b/chromium/gin/per_isolate_data.cc index 8f72d766145..cec082174bf 100644 --- a/chromium/gin/per_isolate_data.cc +++ b/chromium/gin/per_isolate_data.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "gin/per_isolate_data.h" + #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" -#include "gin/per_isolate_data.h" #include "gin/public/gin_embedders.h" using v8::ArrayBuffer; @@ -110,4 +111,9 @@ NamedPropertyInterceptor* PerIsolateData::GetNamedPropertyInterceptor( return NULL; } +void PerIsolateData::EnableIdleTasks( + scoped_ptr<V8IdleTaskRunner> idle_task_runner) { + idle_task_runner_ = idle_task_runner.Pass(); +} + } // namespace gin diff --git a/chromium/gin/per_isolate_data.h b/chromium/gin/per_isolate_data.h index 175161cebc2..ef44f313a27 100644 --- a/chromium/gin/per_isolate_data.h +++ b/chromium/gin/per_isolate_data.h @@ -9,7 +9,9 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "gin/gin_export.h" +#include "gin/public/v8_idle_task_runner.h" #include "gin/public/wrapper_info.h" #include "v8/include/v8.h" @@ -63,9 +65,14 @@ class GIN_EXPORT PerIsolateData { WrappableBase* base); NamedPropertyInterceptor* GetNamedPropertyInterceptor(WrappableBase* base); + void EnableIdleTasks(scoped_ptr<V8IdleTaskRunner> idle_task_runner); + v8::Isolate* isolate() { return isolate_; } v8::ArrayBuffer::Allocator* allocator() { return allocator_; } base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); } + V8IdleTaskRunner* idle_task_runner() { + return idle_task_runner_.get(); + } private: typedef std::map< @@ -86,6 +93,7 @@ class GIN_EXPORT PerIsolateData { IndexedPropertyInterceptorMap indexed_interceptors_; NamedPropertyInterceptorMap named_interceptors_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; + scoped_ptr<V8IdleTaskRunner> idle_task_runner_; DISALLOW_COPY_AND_ASSIGN(PerIsolateData); }; diff --git a/chromium/gin/public/gin_embedders.h b/chromium/gin/public/gin_embedders.h index bffe6e0856e..613136f83d6 100644 --- a/chromium/gin/public/gin_embedders.h +++ b/chromium/gin/public/gin_embedders.h @@ -14,6 +14,7 @@ namespace gin { enum GinEmbedder { kEmbedderNativeGin, kEmbedderBlink, + kEmbedderPDFium, }; } // namespace gin diff --git a/chromium/gin/public/isolate_holder.h b/chromium/gin/public/isolate_holder.h index 16472937e28..f7e01e8aee8 100644 --- a/chromium/gin/public/isolate_holder.h +++ b/chromium/gin/public/isolate_holder.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "gin/gin_export.h" +#include "gin/public/v8_idle_task_runner.h" #include "v8/include/v8.h" namespace gin { @@ -66,6 +67,8 @@ class GIN_EXPORT IsolateHolder { // This method returns if v8::Locker is needed to access isolate. AccessMode access_mode() const { return access_mode_; } + void EnableIdleTasks(scoped_ptr<V8IdleTaskRunner> idle_task_runner); + // This method returns V8IsolateMemoryDumpProvider of this isolate, used for // testing. V8IsolateMemoryDumpProvider* isolate_memory_dump_provider_for_testing() diff --git a/chromium/gin/public/v8_idle_task_runner.h b/chromium/gin/public/v8_idle_task_runner.h new file mode 100644 index 00000000000..f0662d19639 --- /dev/null +++ b/chromium/gin/public/v8_idle_task_runner.h @@ -0,0 +1,26 @@ +// Copyright 2013 The Chromium 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 GIN_PUBLIC_V8_IDLE_TASK_RUNNER_H_ +#define GIN_PUBLIC_V8_IDLE_TASK_RUNNER_H_ + +#include "base/basictypes.h" +#include "v8/include/v8-platform.h" + +namespace gin { + +// A V8IdleTaskRunner is a task runner for running idle tasks. +// Idle tasks have an unbound argument which is bound to a deadline in +// (v8::Platform::MonotonicallyIncreasingTime) when they are run. +// The idle task is expected to complete by this deadline. +class GIN_EXPORT V8IdleTaskRunner { + public: + virtual void PostIdleTask(v8::IdleTask* task) = 0; + + virtual ~V8IdleTaskRunner() {} +}; + +} // namespace gin + +#endif // GIN_PUBLIC_V8_IDLE_TASK_RUNNER_H_ diff --git a/chromium/gin/public/v8_platform.h b/chromium/gin/public/v8_platform.h index df189432559..d66c1fba38d 100644 --- a/chromium/gin/public/v8_platform.h +++ b/chromium/gin/public/v8_platform.h @@ -26,6 +26,9 @@ class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) { void CallDelayedOnForegroundThread(v8::Isolate* isolate, v8::Task* task, double delay_in_seconds) override; + void CallIdleOnForegroundThread(v8::Isolate* isolate, + v8::IdleTask* task) override; + bool IdleTasksEnabled(v8::Isolate* isolate) override; double MonotonicallyIncreasingTime() override; private: diff --git a/chromium/gin/v8_initializer.cc b/chromium/gin/v8_initializer.cc index a82209f9962..810225c9c86 100644 --- a/chromium/gin/v8_initializer.cc +++ b/chromium/gin/v8_initializer.cc @@ -297,6 +297,10 @@ void V8Initializer::LoadV8SnapshotFromFD(base::PlatformFile snapshot_pf, if (!VerifyV8StartupFile(&g_mapped_snapshot, g_snapshot_fingerprint)) result = V8_LOAD_FAILED_VERIFY; #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA + if (result == V8_LOAD_SUCCESS) { + g_snapshot_pf = snapshot_pf; + g_snapshot_region = snapshot_region; + } UMA_HISTOGRAM_ENUMERATION("V8.Initializer.LoadV8Snapshot.Result", result, V8_LOAD_MAX_VALUE); } @@ -325,6 +329,8 @@ void V8Initializer::LoadV8NativesFromFD(base::PlatformFile natives_pf, LOG(FATAL) << "Couldn't verify contents of v8 natives data file"; } #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA + g_natives_pf = natives_pf; + g_natives_region = natives_region; } // static diff --git a/chromium/gin/v8_isolate_memory_dump_provider.cc b/chromium/gin/v8_isolate_memory_dump_provider.cc index 28a05ecbcb5..ecbf5fffabf 100644 --- a/chromium/gin/v8_isolate_memory_dump_provider.cc +++ b/chromium/gin/v8_isolate_memory_dump_provider.cc @@ -28,17 +28,22 @@ V8IsolateMemoryDumpProvider::~V8IsolateMemoryDumpProvider() { // Called at trace dump point time. Creates a snapshot with the memory counters // for the current isolate. bool V8IsolateMemoryDumpProvider::OnMemoryDump( + const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* process_memory_dump) { + // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested + // (crbug.com/499731). + if (isolate_holder_->access_mode() == IsolateHolder::kUseLocker) { v8::Locker locked(isolate_holder_->isolate()); - DumpHeapStatistics(process_memory_dump); + DumpHeapStatistics(args, process_memory_dump); } else { - DumpHeapStatistics(process_memory_dump); + DumpHeapStatistics(args, process_memory_dump); } return true; } void V8IsolateMemoryDumpProvider::DumpHeapStatistics( + const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* process_memory_dump) { std::string dump_base_name = base::StringPrintf("v8/isolate_%p", isolate_holder_->isolate()); @@ -50,6 +55,7 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics( size_t known_spaces_used_size = 0; size_t known_spaces_size = 0; + size_t known_spaces_physical_size = 0; size_t number_of_spaces = isolate_holder_->isolate()->NumberOfHeapSpaces(); for (size_t space = 0; space < number_of_spaces; space++) { v8::HeapSpaceStatistics space_statistics; @@ -57,40 +63,54 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics( space); const size_t space_size = space_statistics.space_size(); const size_t space_used_size = space_statistics.space_used_size(); + const size_t space_physical_size = space_statistics.physical_space_size(); known_spaces_size += space_size; known_spaces_used_size += space_used_size; + known_spaces_physical_size += space_physical_size; std::string space_dump_name = space_name_prefix + "/" + space_statistics.space_name(); auto space_dump = process_memory_dump->CreateAllocatorDump(space_dump_name); space_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, base::trace_event::MemoryAllocatorDump::kUnitsBytes, + space_physical_size); + + space_dump->AddScalar("virtual_size", + base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_size); - auto space_allocated_dump = process_memory_dump->CreateAllocatorDump( - space_dump_name + "/allocated_objects"); - space_allocated_dump->AddScalar( - base::trace_event::MemoryAllocatorDump::kNameSize, - base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_used_size); + space_dump->AddScalar("allocated_objects_size", + base::trace_event::MemoryAllocatorDump::kUnitsBytes, + space_used_size); } // Compute the rest of the memory, not accounted by the spaces above. std::string other_spaces_name = space_name_prefix + "/other_spaces"; auto other_dump = process_memory_dump->CreateAllocatorDump(other_spaces_name); - other_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, - base::trace_event::MemoryAllocatorDump::kUnitsBytes, - heap_statistics.total_heap_size() - known_spaces_size); - auto other_allocated_dump = process_memory_dump->CreateAllocatorDump( - other_spaces_name + "/allocated_objects"); - other_allocated_dump->AddScalar( + other_dump->AddScalar( base::trace_event::MemoryAllocatorDump::kNameSize, base::trace_event::MemoryAllocatorDump::kUnitsBytes, + heap_statistics.total_physical_size() - known_spaces_physical_size); + + other_dump->AddScalar( + "allocated_objects_size", + base::trace_event::MemoryAllocatorDump::kUnitsBytes, heap_statistics.used_heap_size() - known_spaces_used_size); + other_dump->AddScalar("virtual_size", + base::trace_event::MemoryAllocatorDump::kUnitsBytes, + heap_statistics.total_heap_size() - known_spaces_size); + + // If light dump is requested, then object statistics are not dumped + if (args.level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT) + return; + // Dump statistics of the heap's live objects from last GC. - std::string object_name_prefix = dump_base_name + "/heap_objects"; + // TODO(primiano): these should not be tracked in the same trace event as they + // report stats for the last GC (not the current state). See crbug.com/498779. + std::string object_name_prefix = dump_base_name + "/heap_objects_at_last_gc"; bool did_dump_object_stats = false; const size_t object_types = isolate_holder_->isolate()->NumberOfTrackedHeapObjectTypes(); @@ -107,7 +127,7 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics( auto object_dump = process_memory_dump->CreateAllocatorDump(dump_name); object_dump->AddScalar( - base::trace_event::MemoryAllocatorDump::kNameObjectsCount, + base::trace_event::MemoryAllocatorDump::kNameObjectCount, base::trace_event::MemoryAllocatorDump::kUnitsObjects, object_statistics.object_count()); object_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, diff --git a/chromium/gin/v8_isolate_memory_dump_provider.h b/chromium/gin/v8_isolate_memory_dump_provider.h index 8a108708faa..2a2c5dbcdb0 100644 --- a/chromium/gin/v8_isolate_memory_dump_provider.h +++ b/chromium/gin/v8_isolate_memory_dump_provider.h @@ -24,10 +24,12 @@ class V8IsolateMemoryDumpProvider // MemoryDumpProvider implementation. bool OnMemoryDump( + const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* process_memory_dump) override; private: void DumpHeapStatistics( + const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* process_memory_dump); IsolateHolder* isolate_holder_; // Not owned. diff --git a/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc b/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc index b1693cdf062..3979a324fa3 100644 --- a/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc +++ b/chromium/gin/v8_isolate_memory_dump_provider_unittest.cc @@ -23,8 +23,10 @@ TEST_F(V8MemoryDumpProviderTest, DumpStatistics) { scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( new base::trace_event::ProcessMemoryDump(nullptr)); + base::trace_event::MemoryDumpArgs dump_args = { + base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; instance_->isolate_memory_dump_provider_for_testing()->OnMemoryDump( - process_memory_dump.get()); + dump_args, process_memory_dump.get()); const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& allocator_dumps = process_memory_dump->allocator_dumps(); diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc index 6214d3d3f33..bd32977d651 100644 --- a/chromium/gin/v8_platform.cc +++ b/chromium/gin/v8_platform.cc @@ -46,6 +46,16 @@ void V8Platform::CallDelayedOnForegroundThread(v8::Isolate* isolate, base::TimeDelta::FromSecondsD(delay_in_seconds)); } +void V8Platform::CallIdleOnForegroundThread(v8::Isolate* isolate, + v8::IdleTask* task) { + DCHECK(PerIsolateData::From(isolate)->idle_task_runner()); + PerIsolateData::From(isolate)->idle_task_runner()->PostIdleTask(task); +} + +bool V8Platform::IdleTasksEnabled(v8::Isolate* isolate) { + return PerIsolateData::From(isolate)->idle_task_runner() != nullptr; +} + double V8Platform::MonotonicallyIncreasingTime() { return base::TimeTicks::Now().ToInternalValue() / static_cast<double>(base::Time::kMicrosecondsPerSecond); |