From e684a3455bcc29a6e3e66a004e352dea4e1141e7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 13 Feb 2019 15:05:36 +0100 Subject: BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922 Reviewed-by: Michael BrĂ¼ning --- chromium/gin/arguments_unittest.cc | 3 +- chromium/gin/converter.cc | 19 ++++++- chromium/gin/converter.h | 9 ++++ chromium/gin/converter_unittest.cc | 63 +++++++++++++--------- chromium/gin/debug_impl.cc | 11 ---- chromium/gin/debug_impl.h | 1 - chromium/gin/interceptor_unittest.cc | 3 +- chromium/gin/isolate_holder.cc | 3 +- chromium/gin/public/debug.h | 8 --- chromium/gin/public/gin_embedders.h | 1 + chromium/gin/v8_foreground_task_runner.cc | 10 ++++ chromium/gin/v8_foreground_task_runner.h | 4 ++ .../gin/v8_foreground_task_runner_with_locker.cc | 11 ++++ .../gin/v8_foreground_task_runner_with_locker.h | 4 ++ chromium/gin/v8_initializer.cc | 2 +- chromium/gin/v8_platform.cc | 19 +++++-- chromium/gin/wrappable_unittest.cc | 9 ++-- 17 files changed, 123 insertions(+), 57 deletions(-) (limited to 'chromium/gin') diff --git a/chromium/gin/arguments_unittest.cc b/chromium/gin/arguments_unittest.cc index f1506ddba10..144e9af03cc 100644 --- a/chromium/gin/arguments_unittest.cc +++ b/chromium/gin/arguments_unittest.cc @@ -51,7 +51,8 @@ TEST_F(ArgumentsTest, TestArgumentsHolderCreationContext) { ASSERT_TRUE(ConvertFromV8(isolate, script->Run(context).ToLocalChecked(), &function)); v8::Local args[] = {object}; - function->Call(v8::Undefined(isolate), arraysize(args), args); + function->Call(context, v8::Undefined(isolate), base::size(args), args) + .ToLocalChecked(); }; // Test calling in the creation context. diff --git a/chromium/gin/converter.cc b/chromium/gin/converter.cc index 975a5c8b9e5..ce40d590e8f 100644 --- a/chromium/gin/converter.cc +++ b/chromium/gin/converter.cc @@ -20,6 +20,7 @@ using v8::Maybe; using v8::MaybeLocal; using v8::Number; using v8::Object; +using v8::Promise; using v8::String; using v8::Uint32; using v8::Value; @@ -43,7 +44,9 @@ Local Converter::ToV8(Isolate* isolate, bool val) { } bool Converter::FromV8(Isolate* isolate, Local val, bool* out) { - return FromMaybe(val->BooleanValue(isolate->GetCurrentContext()), out); + *out = val->BooleanValue(isolate); + // BooleanValue cannot throw. + return true; } Local Converter::ToV8(Isolate* isolate, int32_t val) { @@ -171,6 +174,20 @@ bool Converter>::FromV8(Isolate* isolate, return true; } +Local Converter>::ToV8(Isolate* isolate, + Local val) { + return val.As(); +} + +bool Converter>::FromV8(Isolate* isolate, + Local val, + Local* out) { + if (!val->IsPromise()) + return false; + *out = Local::Cast(val); + return true; +} + Local Converter>::ToV8(Isolate* isolate, Local val) { return val.As(); diff --git a/chromium/gin/converter.h b/chromium/gin/converter.h index a501714a5e8..e4ef0a3ecc1 100644 --- a/chromium/gin/converter.h +++ b/chromium/gin/converter.h @@ -135,6 +135,15 @@ struct GIN_EXPORT Converter > { v8::Local* out); }; +template <> +struct GIN_EXPORT Converter> { + static v8::Local ToV8(v8::Isolate* isolate, + v8::Local val); + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + v8::Local* out); +}; + template<> struct GIN_EXPORT Converter > { static v8::Local ToV8(v8::Isolate* isolate, diff --git a/chromium/gin/converter_unittest.cc b/chromium/gin/converter_unittest.cc index ee486206448..066cc57a89c 100644 --- a/chromium/gin/converter_unittest.cc +++ b/chromium/gin/converter_unittest.cc @@ -45,17 +45,24 @@ TEST_F(ConverterTest, Bool) { Local input; bool expected; } test_data[] = { - { Boolean::New(instance_->isolate(), false).As(), false }, - { Boolean::New(instance_->isolate(), true).As(), true }, - { Number::New(instance_->isolate(), 0).As(), false }, - { Number::New(instance_->isolate(), 1).As(), true }, - { Number::New(instance_->isolate(), -1).As(), true }, - { Number::New(instance_->isolate(), 0.1).As(), true }, - { String::NewFromUtf8(instance_->isolate(), "").As(), false }, - { String::NewFromUtf8(instance_->isolate(), "foo").As(), true }, - { Object::New(instance_->isolate()).As(), true }, - { Null(instance_->isolate()).As(), false }, - { Undefined(instance_->isolate()).As(), false }, + {Boolean::New(instance_->isolate(), false).As(), false}, + {Boolean::New(instance_->isolate(), true).As(), true}, + {Number::New(instance_->isolate(), 0).As(), false}, + {Number::New(instance_->isolate(), 1).As(), true}, + {Number::New(instance_->isolate(), -1).As(), true}, + {Number::New(instance_->isolate(), 0.1).As(), true}, + {String::NewFromUtf8(instance_->isolate(), "", v8::NewStringType::kNormal) + .ToLocalChecked() + .As(), + false}, + {String::NewFromUtf8(instance_->isolate(), "foo", + v8::NewStringType::kNormal) + .ToLocalChecked() + .As(), + true}, + {Object::New(instance_->isolate()).As(), true}, + {Null(instance_->isolate()).As(), false}, + {Undefined(instance_->isolate()).As(), false}, }; for (size_t i = 0; i < arraysize(test_data); ++i) { @@ -86,19 +93,27 @@ TEST_F(ConverterTest, Int32) { bool expect_success; int expected_result; } test_data_from[] = { - { Boolean::New(instance_->isolate(), false).As(), false, 0 }, - { Boolean::New(instance_->isolate(), true).As(), false, 0 }, - { Integer::New(instance_->isolate(), -1).As(), true, -1 }, - { Integer::New(instance_->isolate(), 0).As(), true, 0 }, - { Integer::New(instance_->isolate(), 1).As(), true, 1 }, - { Number::New(instance_->isolate(), -1).As(), true, -1 }, - { Number::New(instance_->isolate(), 1.1).As(), false, 0 }, - { String::NewFromUtf8(instance_->isolate(), "42").As(), false, 0 }, - { String::NewFromUtf8(instance_->isolate(), "foo").As(), false, 0 }, - { Object::New(instance_->isolate()).As(), false, 0 }, - { Array::New(instance_->isolate()).As(), false, 0 }, - { v8::Null(instance_->isolate()).As(), false, 0 }, - { v8::Undefined(instance_->isolate()).As(), false, 0 }, + {Boolean::New(instance_->isolate(), false).As(), false, 0}, + {Boolean::New(instance_->isolate(), true).As(), false, 0}, + {Integer::New(instance_->isolate(), -1).As(), true, -1}, + {Integer::New(instance_->isolate(), 0).As(), true, 0}, + {Integer::New(instance_->isolate(), 1).As(), true, 1}, + {Number::New(instance_->isolate(), -1).As(), true, -1}, + {Number::New(instance_->isolate(), 1.1).As(), false, 0}, + {String::NewFromUtf8(instance_->isolate(), "42", + v8::NewStringType::kNormal) + .ToLocalChecked() + .As(), + false, 0}, + {String::NewFromUtf8(instance_->isolate(), "foo", + v8::NewStringType::kNormal) + .ToLocalChecked() + .As(), + false, 0}, + {Object::New(instance_->isolate()).As(), false, 0}, + {Array::New(instance_->isolate()).As(), false, 0}, + {v8::Null(instance_->isolate()).As(), false, 0}, + {v8::Undefined(instance_->isolate()).As(), false, 0}, }; for (size_t i = 0; i < arraysize(test_data_from); ++i) { diff --git a/chromium/gin/debug_impl.cc b/chromium/gin/debug_impl.cc index 5657ec38e9b..5c3b7ffc932 100644 --- a/chromium/gin/debug_impl.cc +++ b/chromium/gin/debug_impl.cc @@ -7,7 +7,6 @@ namespace gin { namespace { -v8::FunctionEntryHook g_entry_hook = NULL; v8::JitCodeEventHandler g_jit_code_event_handler = NULL; #if defined(OS_WIN) Debug::CodeRangeCreatedCallback g_code_range_created_callback = NULL; @@ -15,11 +14,6 @@ Debug::CodeRangeDeletedCallback g_code_range_deleted_callback = NULL; #endif } // namespace -// static -void Debug::SetFunctionEntryHook(v8::FunctionEntryHook entry_hook) { - g_entry_hook = entry_hook; -} - // static void Debug::SetJitCodeEventHandler(v8::JitCodeEventHandler event_handler) { g_jit_code_event_handler = event_handler; @@ -37,11 +31,6 @@ void Debug::SetCodeRangeDeletedCallback(CodeRangeDeletedCallback callback) { } #endif -// static -v8::FunctionEntryHook DebugImpl::GetFunctionEntryHook() { - return g_entry_hook; -} - // static v8::JitCodeEventHandler DebugImpl::GetJitCodeEventHandler() { return g_jit_code_event_handler; diff --git a/chromium/gin/debug_impl.h b/chromium/gin/debug_impl.h index 96d48ad3ffb..b88c0b6c089 100644 --- a/chromium/gin/debug_impl.h +++ b/chromium/gin/debug_impl.h @@ -12,7 +12,6 @@ namespace gin { class DebugImpl { public: - static v8::FunctionEntryHook GetFunctionEntryHook(); static v8::JitCodeEventHandler GetJitCodeEventHandler(); #if defined(OS_WIN) static Debug::CodeRangeCreatedCallback GetCodeRangeCreatedCallback(); diff --git a/chromium/gin/interceptor_unittest.cc b/chromium/gin/interceptor_unittest.cc index 58f209a6023..ffffaae4808 100644 --- a/chromium/gin/interceptor_unittest.cc +++ b/chromium/gin/interceptor_unittest.cc @@ -157,7 +157,8 @@ class InterceptorTest : public V8Test { v8::Local argv[] = { ConvertToV8(isolate, obj.get()).ToLocalChecked(), }; - func->Call(v8::Undefined(isolate), 1, argv); + func->Call(context_.Get(isolate), v8::Undefined(isolate), 1, argv) + .ToLocalChecked(); EXPECT_FALSE(try_catch.HasCaught()); EXPECT_EQ("", try_catch.GetStackTrace()); diff --git a/chromium/gin/isolate_holder.cc b/chromium/gin/isolate_holder.cc index 4491b392412..5670a2e55ef 100644 --- a/chromium/gin/isolate_holder.cc +++ b/chromium/gin/isolate_holder.cc @@ -14,7 +14,7 @@ #include "base/logging.h" #include "base/message_loop/message_loop_current.h" #include "base/single_thread_task_runner.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "gin/debug_impl.h" @@ -71,7 +71,6 @@ IsolateHolder::IsolateHolder( DCHECK_EQ(isolate_, snapshot_creator_->GetIsolate()); } else { v8::Isolate::CreateParams params; - params.entry_hook = DebugImpl::GetFunctionEntryHook(); params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); params.constraints.ConfigureDefaults( base::SysInfo::AmountOfPhysicalMemory(), diff --git a/chromium/gin/public/debug.h b/chromium/gin/public/debug.h index 14e30170985..8c2eee341c3 100644 --- a/chromium/gin/public/debug.h +++ b/chromium/gin/public/debug.h @@ -15,14 +15,6 @@ namespace gin { class GIN_EXPORT Debug { public: - /* Installs a callback that is invoked on entry to every V8-generated - * function. - * - * This only affects IsolateHolder instances created after - * SetFunctionEntryHook was invoked. - */ - static void SetFunctionEntryHook(v8::FunctionEntryHook entry_hook); - /* Installs a callback that is invoked each time jit code is added, moved, * or removed. * diff --git a/chromium/gin/public/gin_embedders.h b/chromium/gin/public/gin_embedders.h index 613136f83d6..30f48a6c859 100644 --- a/chromium/gin/public/gin_embedders.h +++ b/chromium/gin/public/gin_embedders.h @@ -15,6 +15,7 @@ enum GinEmbedder { kEmbedderNativeGin, kEmbedderBlink, kEmbedderPDFium, + kEmbedderFuchsia, }; } // namespace gin diff --git a/chromium/gin/v8_foreground_task_runner.cc b/chromium/gin/v8_foreground_task_runner.cc index d53085cc567..f6d916cd05e 100644 --- a/chromium/gin/v8_foreground_task_runner.cc +++ b/chromium/gin/v8_foreground_task_runner.cc @@ -24,6 +24,12 @@ void V8ForegroundTaskRunner::PostTask(std::unique_ptr task) { base::BindOnce(&v8::Task::Run, std::move(task))); } +void V8ForegroundTaskRunner::PostNonNestableTask( + std::unique_ptr task) { + task_runner_->PostNonNestableTask( + FROM_HERE, base::BindOnce(&v8::Task::Run, std::move(task))); +} + void V8ForegroundTaskRunner::PostDelayedTask(std::unique_ptr task, double delay_in_seconds) { task_runner_->PostDelayedTask( @@ -36,4 +42,8 @@ void V8ForegroundTaskRunner::PostIdleTask(std::unique_ptr task) { idle_task_runner()->PostIdleTask(std::move(task)); } +bool V8ForegroundTaskRunner::NonNestableTasksEnabled() const { + return true; +} + } // namespace gin diff --git a/chromium/gin/v8_foreground_task_runner.h b/chromium/gin/v8_foreground_task_runner.h index b9da5f1bf40..62e4f3ad450 100644 --- a/chromium/gin/v8_foreground_task_runner.h +++ b/chromium/gin/v8_foreground_task_runner.h @@ -24,11 +24,15 @@ class V8ForegroundTaskRunner : public V8ForegroundTaskRunnerBase { // v8::Platform implementation. void PostTask(std::unique_ptr task) override; + void PostNonNestableTask(std::unique_ptr task) override; + void PostDelayedTask(std::unique_ptr task, double delay_in_seconds) override; void PostIdleTask(std::unique_ptr task) override; + bool NonNestableTasksEnabled() const override; + private: scoped_refptr task_runner_; }; diff --git a/chromium/gin/v8_foreground_task_runner_with_locker.cc b/chromium/gin/v8_foreground_task_runner_with_locker.cc index 032cf906e99..73425e218b9 100644 --- a/chromium/gin/v8_foreground_task_runner_with_locker.cc +++ b/chromium/gin/v8_foreground_task_runner_with_locker.cc @@ -57,6 +57,13 @@ void V8ForegroundTaskRunnerWithLocker::PostTask( std::move(task))); } +void V8ForegroundTaskRunnerWithLocker::PostNonNestableTask( + std::unique_ptr task) { + task_runner_->PostNonNestableTask( + FROM_HERE, base::BindOnce(RunWithLocker, base::Unretained(isolate_), + std::move(task))); +} + void V8ForegroundTaskRunnerWithLocker::PostDelayedTask( std::unique_ptr task, double delay_in_seconds) { @@ -74,4 +81,8 @@ void V8ForegroundTaskRunnerWithLocker::PostIdleTask( std::make_unique(isolate_, std::move(task))); } +bool V8ForegroundTaskRunnerWithLocker::NonNestableTasksEnabled() const { + return true; +} + } // namespace gin diff --git a/chromium/gin/v8_foreground_task_runner_with_locker.h b/chromium/gin/v8_foreground_task_runner_with_locker.h index 68c716f2446..22bc10d67bf 100644 --- a/chromium/gin/v8_foreground_task_runner_with_locker.h +++ b/chromium/gin/v8_foreground_task_runner_with_locker.h @@ -25,11 +25,15 @@ class V8ForegroundTaskRunnerWithLocker : public V8ForegroundTaskRunnerBase { // v8::Platform implementation. void PostTask(std::unique_ptr task) override; + void PostNonNestableTask(std::unique_ptr task) override; + void PostDelayedTask(std::unique_ptr task, double delay_in_seconds) override; void PostIdleTask(std::unique_ptr task) override; + bool NonNestableTasksEnabled() const override; + private: v8::Isolate* isolate_; scoped_refptr task_runner_; diff --git a/chromium/gin/v8_initializer.cc b/chromium/gin/v8_initializer.cc index 48116401c0b..4b3ef5cfa06 100644 --- a/chromium/gin/v8_initializer.cc +++ b/chromium/gin/v8_initializer.cc @@ -21,7 +21,7 @@ #include "base/path_service.h" #include "base/rand_util.h" #include "base/strings/sys_string_conversions.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "build/build_config.h" diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc index 0f42722c2fc..e6eeb7b45e9 100644 --- a/chromium/gin/v8_platform.cc +++ b/chromium/gin/v8_platform.cc @@ -15,7 +15,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/rand_util.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "base/task/post_task.h" #include "base/task/task_scheduler/task_scheduler.h" #include "base/task/task_traits.h" @@ -114,7 +114,13 @@ base::LazyInstance::Leaky g_trace_state_dispatcher = // TODO(skyostil): Deduplicate this with the clamper in Blink. class TimeClamper { public: - static constexpr double kResolutionSeconds = 0.001; +// As site isolation is enabled on desktop platforms, we can safely provide +// more timing resolution. Jittering is still enabled everywhere. +#if defined(OS_ANDROID) + static constexpr double kResolutionSeconds = 100e-6; +#else + static constexpr double kResolutionSeconds = 5e-6; +#endif TimeClamper() : secret_(base::RandUint64()) {} @@ -239,10 +245,15 @@ class PageAllocator : public v8::PageAllocator { base::DecommitSystemPages(address, length); return true; } else { - return base::SetSystemPagesAccess(address, length, - GetPageConfig(permissions)); + return base::TrySetSystemPagesAccess(address, length, + GetPageConfig(permissions)); } } + + bool DiscardSystemPages(void* address, size_t size) override { + base::DiscardSystemPages(address, size); + return true; + } }; base::LazyInstance::Leaky g_page_allocator = diff --git a/chromium/gin/wrappable_unittest.cc b/chromium/gin/wrappable_unittest.cc index 701991b4483..74aa7e8dccb 100644 --- a/chromium/gin/wrappable_unittest.cc +++ b/chromium/gin/wrappable_unittest.cc @@ -167,7 +167,8 @@ TEST_F(WrappableTest, GetAndSetProperty) { v8::Local argv[] = { ConvertToV8(isolate, obj.get()).ToLocalChecked(), }; - func->Call(v8::Undefined(isolate), 1, argv); + func->Call(context_.Get(isolate), v8::Undefined(isolate), 1, argv) + .ToLocalChecked(); EXPECT_FALSE(try_catch.HasCaught()); EXPECT_EQ("", try_catch.GetStackTrace()); @@ -206,7 +207,8 @@ TEST_F(WrappableTest, MethodInvocationErrorsOnUnnamedObject) { v8::Local func; EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); v8::Local argv[] = {function_to_run, context_object}; - func->Call(v8::Undefined(isolate), arraysize(argv), argv); + func->Call(context, v8::Undefined(isolate), base::size(argv), argv) + .FromMaybe(v8::Local()); if (!try_catch.HasCaught()) return std::string(); return V8ToString(isolate, try_catch.Message()->Get()); @@ -261,7 +263,8 @@ TEST_F(WrappableTest, MethodInvocationErrorsOnNamedObject) { v8::Local func; EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); v8::Local argv[] = {function_to_run, context_object}; - func->Call(v8::Undefined(isolate), arraysize(argv), argv); + func->Call(context, v8::Undefined(isolate), base::size(argv), argv) + .FromMaybe(v8::Local()); if (!try_catch.HasCaught()) return std::string(); return V8ToString(isolate, try_catch.Message()->Get()); -- cgit v1.2.1