summaryrefslogtreecommitdiff
path: root/chromium/gin
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-04 14:17:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-05 10:05:06 +0000
commit39d357e3248f80abea0159765ff39554affb40db (patch)
treeaba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/gin
parent87778abf5a1f89266f37d1321b92a21851d8244d (diff)
downloadqtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2 Change-Id: I20d43c737f82764d857ada9a55586901b18b9243 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/gin')
-rw-r--r--chromium/gin/BUILD.gn2
-rw-r--r--chromium/gin/fingerprint/fingerprint_v8_snapshot.gypi47
-rw-r--r--chromium/gin/gin.gyp198
-rw-r--r--chromium/gin/gin_features.cc12
-rw-r--r--chromium/gin/gin_unittests.isolate56
-rw-r--r--chromium/gin/isolate_holder.cc2
-rw-r--r--chromium/gin/per_isolate_data.cc4
-rw-r--r--chromium/gin/per_isolate_data.h8
-rw-r--r--chromium/gin/public/gin_features.h2
-rw-r--r--chromium/gin/public/v8_platform.h27
-rw-r--r--chromium/gin/v8_initializer.cc33
-rw-r--r--chromium/gin/v8_isolate_memory_dump_provider.cc9
-rw-r--r--chromium/gin/v8_platform.cc181
-rw-r--r--chromium/gin/wrappable.cc6
14 files changed, 206 insertions, 381 deletions
diff --git a/chromium/gin/BUILD.gn b/chromium/gin/BUILD.gn
index 4da04284e3f..72d0125d92c 100644
--- a/chromium/gin/BUILD.gn
+++ b/chromium/gin/BUILD.gn
@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("//build_overrides/v8.gni")
import("//testing/test.gni")
+import("//v8/gni/v8.gni")
component("gin") {
sources = [
diff --git a/chromium/gin/fingerprint/fingerprint_v8_snapshot.gypi b/chromium/gin/fingerprint/fingerprint_v8_snapshot.gypi
deleted file mode 100644
index ede0de3ea5c..00000000000
--- a/chromium/gin/fingerprint/fingerprint_v8_snapshot.gypi
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2015 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.
-
-# This file is meant to be included into a target to provide a rule that
-# fingerprints the v8 snapshot and generates a .cc file which includes this
-# fingerprint.
-#
-# To use this, create a gyp target with the following form:
-# {
-# 'target_name': 'gin_v8_snapshot_fingerprint',
-# 'type': 'none',
-# 'variables': {
-# 'snapshot_file': 'snapshot blob file to be fingerprinted',
-# 'natives_file': 'natives blob file to be fingerprinted',
-# 'output_file': 'output .cc file to generate with fingerprints',
-# },
-# 'includes': [ '../gin/fingerprint/fingerprint_v8_snapshot.gypi' ],
-# },
-#
-
-{
- 'conditions': [
- ['v8_use_external_startup_data==1', {
- 'actions': [
- {
- 'action_name': 'Generate V8 snapshot fingerprint',
- 'message': 'Generating V8 snapshot fingerprint',
- 'inputs': [
- '<(DEPTH)/gin/fingerprint/fingerprint_v8_snapshot.py',
- '<(snapshot_file)',
- '<(natives_file)',
- ],
- 'outputs': [
- '<(output_file)',
- ],
- 'action': [
- 'python', '<(DEPTH)/gin/fingerprint/fingerprint_v8_snapshot.py',
- '--snapshot_file=<(snapshot_file)',
- '--natives_file=<(natives_file)',
- '--output_file=<(output_file)',
- ],
- }
- ],
- }],
- ],
-} \ No newline at end of file
diff --git a/chromium/gin/gin.gyp b/chromium/gin/gin.gyp
deleted file mode 100644
index 0ea039fe72f..00000000000
--- a/chromium/gin/gin.gyp
+++ /dev/null
@@ -1,198 +0,0 @@
-# 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.
-
-{
- 'variables': {
- 'chromium_code': 1,
- 'gin_gen_path': '<(SHARED_INTERMEDIATE_DIR)/gin/',
- },
- 'targets': [
- {
- 'target_name': 'gin',
- 'type': '<(component)',
- 'dependencies': [
- '../base/base.gyp:base',
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../v8/src/v8.gyp:v8',
- ],
- 'export_dependent_settings': [
- '../base/base.gyp:base',
- '../v8/src/v8.gyp:v8',
- ],
- 'defines': [
- 'GIN_IMPLEMENTATION',
- ],
- 'sources': [
- 'arguments.cc',
- 'arguments.h',
- 'array_buffer.cc',
- 'array_buffer.h',
- 'context_holder.cc',
- 'converter.cc',
- 'converter.h',
- 'debug_impl.cc',
- 'debug_impl.h',
- 'dictionary.cc',
- 'dictionary.h',
- 'function_template.cc',
- 'function_template.h',
- 'gin_export.h',
- 'gin_features.cc',
- 'handle.h',
- 'interceptor.cc',
- 'interceptor.h',
- 'isolate_holder.cc',
- 'modules/console.cc',
- 'modules/console.h',
- 'modules/file_module_provider.cc',
- 'modules/file_module_provider.h',
- 'modules/module_registry.cc',
- 'modules/module_registry.h',
- 'modules/module_registry_observer.h',
- 'modules/module_runner_delegate.cc',
- 'modules/module_runner_delegate.h',
- 'modules/timer.cc',
- 'modules/timer.h',
- 'object_template_builder.cc',
- 'object_template_builder.h',
- 'per_context_data.cc',
- 'per_context_data.h',
- 'per_isolate_data.cc',
- 'per_isolate_data.h',
- 'public/context_holder.h',
- 'public/debug.h',
- 'public/gin_embedders.h',
- 'public/gin_features.h',
- 'public/isolate_holder.h',
- 'public/v8_platform.h',
- 'public/wrapper_info.h',
- 'runner.cc',
- 'runner.h',
- 'run_microtasks_observer.cc',
- 'run_microtasks_observer.h',
- 'shell_runner.cc',
- 'shell_runner.h',
- 'try_catch.cc',
- 'try_catch.h',
- 'v8_initializer.h',
- 'v8_initializer.cc',
- 'v8_isolate_memory_dump_provider.cc',
- 'v8_isolate_memory_dump_provider.h',
- 'v8_platform.cc',
- 'wrappable.cc',
- 'wrappable.h',
- 'wrapper_info.cc',
- ],
- 'conditions': [
- ['v8_use_external_startup_data==1 and OS=="win"', {
- 'dependencies': [
- 'gin_v8_snapshot_fingerprint',
- '../crypto/crypto.gyp:crypto',
- ],
- 'sources': [
- '<(gin_gen_path)/v8_snapshot_fingerprint.cc',
- ],
- 'defines': [
- 'V8_VERIFY_EXTERNAL_STARTUP_DATA',
- ]
- }],
- ],
- },
- {
- 'target_name': 'gin_v8_snapshot_fingerprint',
- 'type': 'none',
- 'variables': {
- 'snapshot_file': '<(PRODUCT_DIR)/snapshot_blob.bin',
- 'natives_file': '<(PRODUCT_DIR)/natives_blob.bin',
- 'output_file': '<(gin_gen_path)/v8_snapshot_fingerprint.cc',
- },
- 'includes': [ '../gin/fingerprint/fingerprint_v8_snapshot.gypi' ],
- },
- {
- 'target_name': 'gin_shell',
- 'type': 'executable',
- 'dependencies': [
- '../base/base.gyp:base',
- '../base/base.gyp:base_i18n',
- '../v8/src/v8.gyp:v8',
- 'gin',
- ],
- 'sources': [
- 'shell/gin_main.cc',
- ],
- 'msvs_settings': {
- 'VCLinkerTool': {
- 'SubSystem': '1', # /SUBSYSTEM:CONSOLE
- },
- },
- },
- {
- 'target_name': 'gin_test',
- 'type': 'static_library',
- 'dependencies': [
- '../testing/gtest.gyp:gtest',
- '../v8/src/v8.gyp:v8',
- 'gin',
- ],
- 'export_dependent_settings': [
- '../testing/gtest.gyp:gtest',
- 'gin',
- ],
- 'sources': [
- 'test/file.cc',
- 'test/file.h',
- 'test/file_runner.cc',
- 'test/file_runner.h',
- 'test/gc.cc',
- 'test/gc.h',
- 'test/gtest.cc',
- 'test/gtest.h',
- 'test/v8_test.cc',
- 'test/v8_test.h',
- ],
- },
- {
- 'target_name': 'gin_unittests',
- 'type': 'executable',
- 'dependencies': [
- '../base/base.gyp:test_support_base',
- '../v8/src/v8.gyp:v8',
- 'gin_shell',
- 'gin_test',
- ],
- 'sources': [
- 'converter_unittest.cc',
- 'interceptor_unittest.cc',
- 'modules/module_registry_unittest.cc',
- 'modules/timer_unittest.cc',
- 'per_context_data_unittest.cc',
- 'shell_runner_unittest.cc',
- 'shell/gin_shell_unittest.cc',
- 'test/run_all_unittests.cc',
- 'test/run_js_tests.cc',
- 'v8_isolate_memory_dump_provider_unittest.cc',
- 'wrappable_unittest.cc',
- ],
- },
- ],
- 'conditions': [
- ['test_isolation_mode != "noop"', {
- 'targets': [
- {
- 'target_name': 'gin_unittests_run',
- 'type': 'none',
- 'dependencies': [
- 'gin_unittests',
- ],
- 'includes': [
- '../build/isolate.gypi',
- ],
- 'sources': [
- 'gin_unittests.isolate',
- ],
- },
- ],
- }],
- ],
-}
diff --git a/chromium/gin/gin_features.cc b/chromium/gin/gin_features.cc
index e9bd0a52478..b474b191ac3 100644
--- a/chromium/gin/gin_features.cc
+++ b/chromium/gin/gin_features.cc
@@ -17,16 +17,4 @@ const base::Feature kV8IgnitionLowEnd {
"V8IgnitionLowEnd", base::FEATURE_ENABLED_BY_DEFAULT
};
-// Enables lazy compilation for the V8 Ignition interpreter. Only
-// one of V8IgnitionLazy or V8IgnitionEager should be enabled.
-const base::Feature kV8IgnitionLazy {
- "V8IgnitionLazy", base::FEATURE_DISABLED_BY_DEFAULT
-};
-
-// Enables eager compilation for the V8 Ignition interpreter. Only
-// one of V8IgnitionLazy or V8IgnitionEager should be enabled.
-const base::Feature kV8IgnitionEager {
- "V8IgnitionEager", base::FEATURE_DISABLED_BY_DEFAULT
-};
-
} // namespace features
diff --git a/chromium/gin/gin_unittests.isolate b/chromium/gin/gin_unittests.isolate
deleted file mode 100644
index 7313e25d73a..00000000000
--- a/chromium/gin/gin_unittests.isolate
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2015 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.
-
-{
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/gin_shell<(EXECUTABLE_SUFFIX)',
- '<(PRODUCT_DIR)/gin_unittests<(EXECUTABLE_SUFFIX)',
- 'modules/module_registry_unittests.js',
- 'shell/hello_world.js',
- 'test/expect.js',
- 'test/file_unittests.js',
- 'test/gtest_unittests.js',
- '../OWNERS',
- ],
- },
- 'conditions': [
- ['OS=="linux" or OS=="mac" or OS=="win"', {
- 'variables': {
- 'files': [
- '../testing/test_env.py',
- ],
- 'command': [
- '../testing/test_env.py',
- '<(PRODUCT_DIR)/gin_unittests<(EXECUTABLE_SUFFIX)',
- '--brave-new-test-launcher',
- '--test-launcher-bot-mode',
- '--asan=<(asan)',
- '--msan=<(msan)',
- '--tsan=<(tsan)',
- ],
- },
- }],
- ['OS=="mac" and asan==1 and fastbuild==0', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/gin_shell.dSYM/',
- '<(PRODUCT_DIR)/gin_unittests.dSYM/',
- ],
- },
- }],
- ['OS=="win" and (fastbuild==0 or fastbuild==1)', {
- 'variables': {
- 'files': [
- '<(PRODUCT_DIR)/gin_shell.exe.pdb',
- '<(PRODUCT_DIR)/gin_unittests.exe.pdb',
- ],
- },
- }],
- ],
- 'includes': [
- '../base/base.isolate',
- '../gin/v8.isolate',
- ],
-}
diff --git a/chromium/gin/isolate_holder.cc b/chromium/gin/isolate_holder.cc
index 5252400c13c..04449d26ab5 100644
--- a/chromium/gin/isolate_holder.cc
+++ b/chromium/gin/isolate_holder.cc
@@ -41,7 +41,7 @@ IsolateHolder::IsolateHolder(AccessMode access_mode)
base::SysInfo::AmountOfVirtualMemory());
params.array_buffer_allocator = allocator;
isolate_ = v8::Isolate::New(params);
- isolate_data_.reset(new PerIsolateData(isolate_, allocator));
+ isolate_data_.reset(new PerIsolateData(isolate_, allocator, access_mode));
isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
#if defined(OS_WIN)
{
diff --git a/chromium/gin/per_isolate_data.cc b/chromium/gin/per_isolate_data.cc
index ead780c0e70..261782eeaa5 100644
--- a/chromium/gin/per_isolate_data.cc
+++ b/chromium/gin/per_isolate_data.cc
@@ -22,9 +22,11 @@ using v8::ObjectTemplate;
namespace gin {
PerIsolateData::PerIsolateData(Isolate* isolate,
- ArrayBuffer::Allocator* allocator)
+ ArrayBuffer::Allocator* allocator,
+ IsolateHolder::AccessMode access_mode)
: isolate_(isolate),
allocator_(allocator),
+ access_mode_(access_mode),
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
isolate_->SetData(kEmbedderNativeGin, this);
}
diff --git a/chromium/gin/per_isolate_data.h b/chromium/gin/per_isolate_data.h
index 9b804aa4ba5..4b4037b1b8b 100644
--- a/chromium/gin/per_isolate_data.h
+++ b/chromium/gin/per_isolate_data.h
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "gin/gin_export.h"
+#include "gin/public/isolate_holder.h"
#include "gin/public/v8_idle_task_runner.h"
#include "gin/public/wrapper_info.h"
#include "v8/include/v8.h"
@@ -29,7 +30,9 @@ class WrappableBase;
// class stores all the Gin-related data that varies per isolate.
class GIN_EXPORT PerIsolateData {
public:
- PerIsolateData(v8::Isolate* isolate, v8::ArrayBuffer::Allocator* allocator);
+ PerIsolateData(v8::Isolate* isolate,
+ v8::ArrayBuffer::Allocator* allocator,
+ IsolateHolder::AccessMode access_mode);
~PerIsolateData();
static PerIsolateData* From(v8::Isolate* isolate);
@@ -74,6 +77,8 @@ class GIN_EXPORT PerIsolateData {
return idle_task_runner_.get();
}
+ IsolateHolder::AccessMode access_mode() const { return access_mode_; }
+
private:
typedef std::map<
WrapperInfo*, v8::Eternal<v8::ObjectTemplate> > ObjectTemplateMap;
@@ -88,6 +93,7 @@ class GIN_EXPORT PerIsolateData {
// owned by the IsolateHolder, which also owns the PerIsolateData.
v8::Isolate* isolate_;
v8::ArrayBuffer::Allocator* allocator_;
+ IsolateHolder::AccessMode access_mode_;
ObjectTemplateMap object_templates_;
FunctionTemplateMap function_templates_;
IndexedPropertyInterceptorMap indexed_interceptors_;
diff --git a/chromium/gin/public/gin_features.h b/chromium/gin/public/gin_features.h
index 9e26f475cd0..1a8a70456d0 100644
--- a/chromium/gin/public/gin_features.h
+++ b/chromium/gin/public/gin_features.h
@@ -15,8 +15,6 @@ namespace features {
GIN_EXPORT extern const base::Feature kV8Ignition;
GIN_EXPORT extern const base::Feature kV8IgnitionLowEnd;
-GIN_EXPORT extern const base::Feature kV8IgnitionLazy;
-GIN_EXPORT extern const base::Feature kV8IgnitionEager;
} // namespace features
diff --git a/chromium/gin/public/v8_platform.h b/chromium/gin/public/v8_platform.h
index ad37a5c4ceb..6506ce4c555 100644
--- a/chromium/gin/public/v8_platform.h
+++ b/chromium/gin/public/v8_platform.h
@@ -34,21 +34,26 @@ class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) {
const uint8_t* GetCategoryGroupEnabled(const char* name) override;
const char* GetCategoryGroupName(
const uint8_t* category_enabled_flag) override;
- uint64_t AddTraceEvent(char phase,
- const uint8_t* category_enabled_flag,
- const char* name,
- const char* scope,
- uint64_t id,
- uint64_t bind_id,
- int32_t num_args,
- const char** arg_names,
- const uint8_t* arg_types,
- const uint64_t* arg_values,
- unsigned int flags) override;
+ uint64_t AddTraceEvent(
+ char phase,
+ const uint8_t* category_enabled_flag,
+ const char* name,
+ const char* scope,
+ uint64_t id,
+ uint64_t bind_id,
+ int32_t num_args,
+ const char** arg_names,
+ const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertibles,
+ unsigned int flags) override;
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name,
uint64_t handle) override;
+ void AddTraceStateObserver(v8::Platform::TraceStateObserver*) override;
+ void RemoveTraceStateObserver(v8::Platform::TraceStateObserver*) override;
+
private:
friend struct base::DefaultLazyInstanceTraits<V8Platform>;
diff --git a/chromium/gin/v8_initializer.cc b/chromium/gin/v8_initializer.cc
index c5cf128232d..99276f4a272 100644
--- a/chromium/gin/v8_initializer.cc
+++ b/chromium/gin/v8_initializer.cc
@@ -17,7 +17,7 @@
#include "base/files/memory_mapped_file.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/metrics/histogram.h"
+#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h"
@@ -228,18 +228,6 @@ bool GenerateEntropy(unsigned char* buffer, size_t amount) {
return true;
}
-bool ShouldUseIgnition() {
- if (base::FeatureList::IsEnabled(features::kV8Ignition)) return true;
-#if defined(OS_ANDROID)
- if (base::FeatureList::IsEnabled(features::kV8IgnitionLowEnd) &&
- base::SysInfo::IsLowEndDevice()) {
- return true;
- }
-#endif
- return false;
-}
-
-
} // namespace
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
@@ -431,22 +419,15 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
}
const char* ignition_enabled_crash_key = "N";
- if (ShouldUseIgnition()) {
+ if (base::FeatureList::IsEnabled(features::kV8Ignition)) {
+ ignition_enabled_crash_key = "Y";
+ std::string flag("--ignition-staging");
+ v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size()));
+ } else if (base::FeatureList::IsEnabled(features::kV8IgnitionLowEnd) &&
+ base::SysInfo::IsLowEndDevice()) {
ignition_enabled_crash_key = "Y";
std::string flag("--ignition");
v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size()));
-
- if (base::FeatureList::IsEnabled(features::kV8IgnitionEager)) {
- std::string eager_flag("--ignition-eager");
- v8::V8::SetFlagsFromString(
- eager_flag.c_str(), static_cast<int>(eager_flag.size()));
- }
-
- if (base::FeatureList::IsEnabled(features::kV8IgnitionLazy)) {
- std::string lazy_flag("--no-ignition-eager");
- v8::V8::SetFlagsFromString(
- lazy_flag.c_str(), static_cast<int>(lazy_flag.size()));
- }
}
static const char kIgnitionEnabledKey[] = "v8-ignition";
base::debug::SetCrashKeyValue(kIgnitionEnabledKey,
diff --git a/chromium/gin/v8_isolate_memory_dump_provider.cc b/chromium/gin/v8_isolate_memory_dump_provider.cc
index 601937b45f0..b2d8b63e417 100644
--- a/chromium/gin/v8_isolate_memory_dump_provider.cc
+++ b/chromium/gin/v8_isolate_memory_dump_provider.cc
@@ -164,6 +164,9 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
malloc_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
heap_statistics.malloced_memory());
+ malloc_dump->AddScalar("peak_size",
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ heap_statistics.peak_malloced_memory());
const char* system_allocator_name =
base::trace_event::MemoryDumpManager::GetInstance()
->system_allocator_pool_name();
@@ -177,6 +180,9 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
auto* heap_spaces_dump =
process_memory_dump->CreateAllocatorDump(space_name_prefix);
+ // Dump statistics related to code and bytecode if requested.
+ DumpCodeStatistics(heap_spaces_dump, isolate_holder_);
+
// Dump object statistics only for detailed dumps.
if (args.level_of_detail !=
base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {
@@ -227,9 +233,6 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
process_memory_dump->CreateAllocatorDump(object_name_prefix)->guid(),
heap_spaces_dump->guid());
}
-
- // Dump statistics related to code and bytecode if requested.
- DumpCodeStatistics(heap_spaces_dump, isolate_holder_);
}
} // namespace gin
diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc
index 556f7fc5f24..6e5491bff11 100644
--- a/chromium/gin/v8_platform.cc
+++ b/chromium/gin/v8_platform.cc
@@ -17,6 +17,31 @@ namespace {
base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
+void RunWithLocker(v8::Isolate* isolate, v8::Task* task) {
+ v8::Locker lock(isolate);
+ task->Run();
+}
+
+class IdleTaskWithLocker : public v8::IdleTask {
+ public:
+ IdleTaskWithLocker(v8::Isolate* isolate, v8::IdleTask* task)
+ : isolate_(isolate), task_(task) {}
+
+ ~IdleTaskWithLocker() override = default;
+
+ // v8::IdleTask implementation.
+ void Run(double deadline_in_seconds) override {
+ v8::Locker lock(isolate_);
+ task_->Run(deadline_in_seconds);
+ }
+
+ private:
+ v8::Isolate* isolate_;
+ std::unique_ptr<v8::IdleTask> task_;
+
+ DISALLOW_COPY_AND_ASSIGN(IdleTaskWithLocker);
+};
+
} // namespace
// static
@@ -49,22 +74,43 @@ void V8Platform::CallOnBackgroundThread(
}
void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
- PerIsolateData::From(isolate)->task_runner()->PostTask(
- FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
+ PerIsolateData* data = PerIsolateData::From(isolate);
+ if (data->access_mode() == IsolateHolder::kUseLocker) {
+ data->task_runner()->PostTask(
+ FROM_HERE, base::Bind(RunWithLocker, base::Unretained(isolate),
+ base::Owned(task)));
+ } else {
+ data->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
+ }
}
void V8Platform::CallDelayedOnForegroundThread(v8::Isolate* isolate,
v8::Task* task,
double delay_in_seconds) {
- PerIsolateData::From(isolate)->task_runner()->PostDelayedTask(
- FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)),
- base::TimeDelta::FromSecondsD(delay_in_seconds));
+ PerIsolateData* data = PerIsolateData::From(isolate);
+ if (data->access_mode() == IsolateHolder::kUseLocker) {
+ data->task_runner()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(RunWithLocker, base::Unretained(isolate), base::Owned(task)),
+ base::TimeDelta::FromSecondsD(delay_in_seconds));
+ } else {
+ data->task_runner()->PostDelayedTask(
+ FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)),
+ 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);
+ PerIsolateData* data = PerIsolateData::From(isolate);
+ DCHECK(data->idle_task_runner());
+ if (data->access_mode() == IsolateHolder::kUseLocker) {
+ data->idle_task_runner()->PostIdleTask(
+ new IdleTaskWithLocker(isolate, task));
+ } else {
+ data->idle_task_runner()->PostIdleTask(task);
+ }
}
bool V8Platform::IdleTasksEnabled(v8::Isolate* isolate) {
@@ -86,22 +132,55 @@ const char* V8Platform::GetCategoryGroupName(
category_enabled_flag);
}
-uint64_t V8Platform::AddTraceEvent(char phase,
- const uint8_t* category_enabled_flag,
- const char* name,
- const char* scope,
- uint64_t id,
- uint64_t bind_id,
- int32_t num_args,
- const char** arg_names,
- const uint8_t* arg_types,
- const uint64_t* arg_values,
- unsigned int flags) {
+namespace {
+
+class ConvertableToTraceFormatWrapper
+ : public base::trace_event::ConvertableToTraceFormat {
+ public:
+ explicit ConvertableToTraceFormatWrapper(
+ std::unique_ptr<v8::ConvertableToTraceFormat>& inner)
+ : inner_(std::move(inner)) {}
+ ~ConvertableToTraceFormatWrapper() override = default;
+ void AppendAsTraceFormat(std::string* out) const final {
+ inner_->AppendAsTraceFormat(out);
+ }
+
+ private:
+ std::unique_ptr<v8::ConvertableToTraceFormat> inner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConvertableToTraceFormatWrapper);
+};
+
+} // namespace
+
+uint64_t V8Platform::AddTraceEvent(
+ char phase,
+ const uint8_t* category_enabled_flag,
+ const char* name,
+ const char* scope,
+ uint64_t id,
+ uint64_t bind_id,
+ int32_t num_args,
+ const char** arg_names,
+ const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags) {
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat> convertables[2];
+ if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
+ convertables[0].reset(
+ new ConvertableToTraceFormatWrapper(arg_convertables[0]));
+ }
+ if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) {
+ convertables[1].reset(
+ new ConvertableToTraceFormatWrapper(arg_convertables[1]));
+ }
+ DCHECK_LE(num_args, 2);
base::trace_event::TraceEventHandle handle =
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID(
phase, category_enabled_flag, name, scope, id, bind_id, num_args,
- arg_names, arg_types, (const long long unsigned int*)arg_values, NULL,
- flags);
+ arg_names, arg_types, (const long long unsigned int*)arg_values,
+ convertables, flags);
uint64_t result;
memcpy(&result, &handle, sizeof(result));
return result;
@@ -116,4 +195,66 @@ void V8Platform::UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
traceEventHandle);
}
+namespace {
+
+class EnabledStateObserverImpl final
+ : public base::trace_event::TraceLog::EnabledStateObserver {
+ public:
+ EnabledStateObserverImpl() = default;
+
+ void OnTraceLogEnabled() final {
+ base::AutoLock lock(mutex_);
+ for (auto o : observers_) {
+ o->OnTraceEnabled();
+ }
+ }
+
+ void OnTraceLogDisabled() final {
+ base::AutoLock lock(mutex_);
+ for (auto o : observers_) {
+ o->OnTraceDisabled();
+ }
+ }
+
+ void AddObserver(v8::Platform::TraceStateObserver* observer) {
+ base::AutoLock lock(mutex_);
+ DCHECK(!observers_.count(observer));
+ observers_.insert(observer);
+ if (observers_.size() == 1) {
+ base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
+ }
+ }
+
+ void RemoveObserver(v8::Platform::TraceStateObserver* observer) {
+ base::AutoLock lock(mutex_);
+ DCHECK(observers_.count(observer) == 1);
+ observers_.erase(observer);
+ if (observers_.empty()) {
+ base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(
+ this);
+ }
+ }
+
+ private:
+ base::Lock mutex_;
+ std::unordered_set<v8::Platform::TraceStateObserver*> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnabledStateObserverImpl);
+};
+
+base::LazyInstance<EnabledStateObserverImpl>::Leaky g_trace_state_dispatcher =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void V8Platform::AddTraceStateObserver(
+ v8::Platform::TraceStateObserver* observer) {
+ g_trace_state_dispatcher.Get().AddObserver(observer);
+}
+
+void V8Platform::RemoveTraceStateObserver(
+ v8::Platform::TraceStateObserver* observer) {
+ g_trace_state_dispatcher.Get().RemoveObserver(observer);
+}
+
} // namespace gin
diff --git a/chromium/gin/wrappable.cc b/chromium/gin/wrappable.cc
index 0fac4e0b0b8..6e1957eb77b 100644
--- a/chromium/gin/wrappable.cc
+++ b/chromium/gin/wrappable.cc
@@ -58,8 +58,10 @@ v8::Local<v8::Object> WrappableBase::GetWrapperImpl(v8::Isolate* isolate,
delete this;
return wrapper;
}
- wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info);
- wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this);
+
+ int indices[] = {kWrapperInfoIndex, kEncodedValueIndex};
+ void* values[] = {info, this};
+ wrapper->SetAlignedPointerInInternalFields(2, indices, values);
wrapper_.Reset(isolate, wrapper);
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
return wrapper;