summaryrefslogtreecommitdiff
path: root/chromium/gin
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 10:33:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:45:12 +0000
commitbe59a35641616a4cf23c4a13fa0632624b021c1b (patch)
tree9da183258bdf9cc413f7562079d25ace6955467f /chromium/gin
parentd702e4b6a64574e97fc7df8fe3238cde70242080 (diff)
downloadqtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/gin')
-rw-r--r--chromium/gin/OWNERS2
-rw-r--r--chromium/gin/isolate_holder.cc81
-rw-r--r--chromium/gin/modules/timer_unittest.cc5
-rw-r--r--chromium/gin/public/isolate_holder.h8
-rw-r--r--chromium/gin/public/v8_platform.h4
-rw-r--r--chromium/gin/v8_initializer.cc166
-rw-r--r--chromium/gin/v8_initializer.h30
-rw-r--r--chromium/gin/v8_platform.cc16
-rw-r--r--chromium/gin/v8_platform_unittest.cc2
9 files changed, 170 insertions, 144 deletions
diff --git a/chromium/gin/OWNERS b/chromium/gin/OWNERS
index ae52483ef1c..481dea8981a 100644
--- a/chromium/gin/OWNERS
+++ b/chromium/gin/OWNERS
@@ -1,4 +1,6 @@
jochen@chromium.org
+jbroman@chromium.org
+rmcilroy@chromium.org
# TEAM: blink-reviews-bindings@chromium.org
# COMPONENT: Blink>Bindings
diff --git a/chromium/gin/isolate_holder.cc b/chromium/gin/isolate_holder.cc
index d42607d86dd..6df4689e0ec 100644
--- a/chromium/gin/isolate_holder.cc
+++ b/chromium/gin/isolate_holder.cc
@@ -15,6 +15,7 @@
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/sys_info.h"
+#include "build/build_config.h"
#include "gin/debug_impl.h"
#include "gin/function_template.h"
#include "gin/per_isolate_data.h"
@@ -35,15 +36,22 @@ IsolateHolder::IsolateHolder(
IsolateHolder::IsolateHolder(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
AccessMode access_mode)
- : IsolateHolder(std::move(task_runner), access_mode, kAllowAtomicsWait) {}
+ : IsolateHolder(std::move(task_runner),
+ access_mode,
+ kAllowAtomicsWait,
+ nullptr,
+ nullptr) {}
IsolateHolder::IsolateHolder(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
AccessMode access_mode,
- AllowAtomicsWaitMode atomics_wait_mode)
+ AllowAtomicsWaitMode atomics_wait_mode,
+ intptr_t* reference,
+ v8::StartupData* startup_data)
: access_mode_(access_mode) {
v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
+
v8::Isolate::CreateParams params;
params.entry_hook = DebugImpl::GetFunctionEntryHook();
params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
@@ -51,45 +59,28 @@ IsolateHolder::IsolateHolder(
base::SysInfo::AmountOfVirtualMemory());
params.array_buffer_allocator = allocator;
params.allow_atomics_wait = atomics_wait_mode == kAllowAtomicsWait;
- isolate_ = v8::Isolate::New(params);
- isolate_data_.reset(
- new PerIsolateData(isolate_, allocator, access_mode, task_runner));
- isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
-#if defined(OS_WIN)
- {
- void* code_range;
- size_t size;
- isolate_->GetCodeRange(&code_range, &size);
- Debug::CodeRangeCreatedCallback callback =
- DebugImpl::GetCodeRangeCreatedCallback();
- if (code_range && size && callback)
- callback(code_range, size);
+ params.external_references = reference;
+
+ if (startup_data) {
+ CHECK(reference);
+ V8Initializer::GetV8ContextSnapshotData(&startup_data->data,
+ &startup_data->raw_size);
+ if (startup_data->data) {
+ params.snapshot_blob = startup_data;
+ }
}
-#endif
+ isolate_ = v8::Isolate::New(params);
+
+ SetUp(std::move(task_runner));
}
IsolateHolder::IsolateHolder(intptr_t* reference_table,
v8::StartupData* existing_blob)
: snapshot_creator_(
new v8::SnapshotCreator(reference_table, existing_blob)),
- access_mode_(kSingleThread) {
- v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
- CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
- isolate_ = snapshot_creator_->GetIsolate();
- isolate_data_.reset(
- new PerIsolateData(isolate_, allocator, access_mode_, nullptr));
- isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
-#if defined(OS_WIN)
- {
- void* code_range;
- size_t size;
- isolate_->GetCodeRange(&code_range, &size);
- Debug::CodeRangeCreatedCallback callback =
- DebugImpl::GetCodeRangeCreatedCallback();
- if (code_range && size && callback)
- callback(code_range, size);
- }
-#endif
+ isolate_(snapshot_creator_->GetIsolate()),
+ access_mode_(AccessMode::kSingleThread) {
+ SetUp(nullptr);
}
IsolateHolder::~IsolateHolder() {
@@ -109,7 +100,7 @@ IsolateHolder::~IsolateHolder() {
isolate_memory_dump_provider_.reset();
isolate_data_.reset();
isolate_->Dispose();
- isolate_ = NULL;
+ isolate_ = nullptr;
}
// static
@@ -139,4 +130,24 @@ void IsolateHolder::EnableIdleTasks(
isolate_data_->EnableIdleTasks(std::move(idle_task_runner));
}
+void IsolateHolder::SetUp(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
+ CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
+ isolate_data_.reset(
+ new PerIsolateData(isolate_, allocator, access_mode_, task_runner));
+ isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
+#if defined(OS_WIN)
+ {
+ void* code_range;
+ size_t size;
+ isolate_->GetCodeRange(&code_range, &size);
+ Debug::CodeRangeCreatedCallback callback =
+ DebugImpl::GetCodeRangeCreatedCallback();
+ if (code_range && size && callback)
+ callback(code_range, size);
+ }
+#endif
+}
+
} // namespace gin
diff --git a/chromium/gin/modules/timer_unittest.cc b/chromium/gin/modules/timer_unittest.cc
index 665ea4e788d..0a1a2b987e9 100644
--- a/chromium/gin/modules/timer_unittest.cc
+++ b/chromium/gin/modules/timer_unittest.cc
@@ -6,7 +6,6 @@
#include <memory>
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "gin/handle.h"
@@ -32,9 +31,7 @@ class Result : public Wrappable<Result> {
int count() const { return count_; }
void set_count(int count) { count_ = count; }
- void Quit() {
- base::MessageLoop::current()->QuitNow();
- }
+ void Quit() { base::RunLoop::QuitCurrentDeprecated(); }
private:
Result() : count_(0) {
diff --git a/chromium/gin/public/isolate_holder.h b/chromium/gin/public/isolate_holder.h
index e2846213865..fb7ffe0880f 100644
--- a/chromium/gin/public/isolate_holder.h
+++ b/chromium/gin/public/isolate_holder.h
@@ -59,7 +59,9 @@ class GIN_EXPORT IsolateHolder {
AccessMode access_mode);
IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
AccessMode access_mode,
- AllowAtomicsWaitMode atomics_wait_mode);
+ AllowAtomicsWaitMode atomics_wait_mode,
+ intptr_t* reference_table,
+ v8::StartupData* startup_data);
// This constructor is to create V8 snapshot for Blink.
// Note this constructor calls isolate->Enter() internally.
@@ -110,11 +112,13 @@ class GIN_EXPORT IsolateHolder {
}
private:
+ void SetUp(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+
+ std::unique_ptr<v8::SnapshotCreator> snapshot_creator_;
v8::Isolate* isolate_;
std::unique_ptr<PerIsolateData> isolate_data_;
std::unique_ptr<RunMicrotasksObserver> task_observer_;
std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_;
- std::unique_ptr<v8::SnapshotCreator> snapshot_creator_;
AccessMode access_mode_;
DISALLOW_COPY_AND_ASSIGN(IsolateHolder);
diff --git a/chromium/gin/public/v8_platform.h b/chromium/gin/public/v8_platform.h
index e86f77d5a59..b25582c1147 100644
--- a/chromium/gin/public/v8_platform.h
+++ b/chromium/gin/public/v8_platform.h
@@ -14,11 +14,12 @@
namespace gin {
// A v8::Platform implementation to use with gin.
-class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) {
+class GIN_EXPORT V8Platform : public v8::Platform {
public:
static V8Platform* Get();
// v8::Platform implementation.
+ void OnCriticalMemoryPressure() override;
size_t NumberOfAvailableBackgroundThreads() override;
void CallOnBackgroundThread(
v8::Task* task,
@@ -31,6 +32,7 @@ class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) {
v8::IdleTask* task) override;
bool IdleTasksEnabled(v8::Isolate* isolate) override;
double MonotonicallyIncreasingTime() override;
+ double CurrentClockTimeMillis() override;
StackTracePrinter GetStackTracePrinter() override;
v8::TracingController* GetTracingController() override;
diff --git a/chromium/gin/v8_initializer.cc b/chromium/gin/v8_initializer.cc
index 56011d9ff5b..e03635f4378 100644
--- a/chromium/gin/v8_initializer.cc
+++ b/chromium/gin/v8_initializer.cc
@@ -18,20 +18,20 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
+#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
+#include "build/build_config.h"
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
#if defined(OS_ANDROID)
#include "base/android/apk_assets.h"
-#endif
-#if defined(OS_MACOSX)
+#elif defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
-#endif // OS_MACOSX
-#include "base/path_service.h"
+#endif
#endif // V8_USE_EXTERNAL_STARTUP_DATA
namespace gin {
@@ -41,26 +41,20 @@ namespace {
// None of these globals are ever freed nor closed.
base::MemoryMappedFile* g_mapped_natives = nullptr;
base::MemoryMappedFile* g_mapped_snapshot = nullptr;
+base::MemoryMappedFile* g_mapped_v8_context_snapshot = nullptr;
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+const char kV8ContextSnapshotFileName[] = "v8_context_snapshot.bin";
// File handles intentionally never closed. Not using File here because its
// Windows implementation guards against two instances owning the same
// PlatformFile (which we allow since we know it is never freed).
-typedef std::map<const char*,
- std::pair<base::PlatformFile, base::MemoryMappedFile::Region>>
- OpenedFileMap;
-static base::LazyInstance<OpenedFileMap>::Leaky g_opened_files =
+using OpenedFileMap =
+ std::map<const char*,
+ std::pair<base::PlatformFile, base::MemoryMappedFile::Region>>;
+base::LazyInstance<OpenedFileMap>::Leaky g_opened_files =
LAZY_INSTANCE_INITIALIZER;
-OpenedFileMap::mapped_type& GetOpenedFile(const char* file) {
- OpenedFileMap& opened_files(g_opened_files.Get());
- if (opened_files.find(file) == opened_files.end()) {
- opened_files[file] = std::make_pair(base::kInvalidPlatformFile,
- base::MemoryMappedFile::Region());
- }
- return opened_files[file];
-}
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
const char kNativesFileName[] = "natives_blob.bin";
@@ -78,6 +72,8 @@ const char kSnapshotFileName32[] = "snapshot_blob_32.bin";
const char kSnapshotFileName[] = "snapshot_blob.bin";
#endif // defined(OS_ANDROID)
+#endif // defined(V8_USE_EXTERNAL_STATUP_DATA)
+
void GetV8FilePath(const char* file_name, base::FilePath* path_out) {
#if !defined(OS_MACOSX)
base::FilePath data_path;
@@ -97,12 +93,11 @@ void GetV8FilePath(const char* file_name, base::FilePath* path_out) {
base::SysUTF8ToCFStringRef(file_name));
*path_out = base::mac::PathForFrameworkBundleResource(natives_file_name);
#endif // !defined(OS_MACOSX)
- DCHECK(!path_out->empty());
}
-static bool MapV8File(base::PlatformFile platform_file,
- base::MemoryMappedFile::Region region,
- base::MemoryMappedFile** mmapped_file_out) {
+bool MapV8File(base::PlatformFile platform_file,
+ base::MemoryMappedFile::Region region,
+ base::MemoryMappedFile** mmapped_file_out) {
DCHECK(*mmapped_file_out == NULL);
std::unique_ptr<base::MemoryMappedFile> mmapped_file(
new base::MemoryMappedFile());
@@ -180,28 +175,24 @@ base::PlatformFile OpenV8File(const char* file_name,
return file.TakePlatformFile();
}
-static const OpenedFileMap::mapped_type OpenFileIfNecessary(
- const char* file_name) {
- OpenedFileMap::mapped_type& opened = GetOpenedFile(file_name);
- if (opened.first == base::kInvalidPlatformFile) {
- opened.first = OpenV8File(file_name, &opened.second);
- }
- return opened;
-}
+OpenedFileMap::mapped_type& GetOpenedFile(const char* filename) {
+ OpenedFileMap& opened_files(g_opened_files.Get());
+ auto result = opened_files.emplace(filename, OpenedFileMap::mapped_type());
+ OpenedFileMap::mapped_type& opened_file = result.first->second;
+ bool is_new_file = result.second;
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
+ // If we have no cache, try to open it and cache the result.
+ if (is_new_file)
+ opened_file.first = OpenV8File(filename, &opened_file.second);
+
+ return opened_file;
+}
bool GenerateEntropy(unsigned char* buffer, size_t amount) {
base::RandBytes(buffer, amount);
return true;
}
-} // namespace
-
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
-
-namespace {
-
enum LoadV8FileResult {
V8_LOAD_SUCCESS = 0,
V8_LOAD_FAILED_OPEN,
@@ -210,9 +201,8 @@ enum LoadV8FileResult {
V8_LOAD_MAX_VALUE
};
-static LoadV8FileResult MapOpenedFile(
- const OpenedFileMap::mapped_type& file_region,
- base::MemoryMappedFile** mmapped_file_out) {
+LoadV8FileResult MapOpenedFile(const OpenedFileMap::mapped_type& file_region,
+ base::MemoryMappedFile** mmapped_file_out) {
if (file_region.first == base::kInvalidPlatformFile)
return V8_LOAD_FAILED_OPEN;
if (!MapV8File(file_region.first, file_region.second, mmapped_file_out))
@@ -220,14 +210,27 @@ static LoadV8FileResult MapOpenedFile(
return V8_LOAD_SUCCESS;
}
+void GetMappedFileData(base::MemoryMappedFile* mapped_file,
+ const char** data_out,
+ int* size_out) {
+ if (mapped_file) {
+ *data_out = reinterpret_cast<const char*>(mapped_file->data());
+ *size_out = static_cast<int>(mapped_file->length());
+ } else {
+ *data_out = nullptr;
+ *size_out = 0;
+ }
+}
+
} // namespace
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+
// static
void V8Initializer::LoadV8Snapshot() {
if (g_mapped_snapshot)
return;
- OpenFileIfNecessary(kSnapshotFileName);
LoadV8FileResult result = MapOpenedFile(GetOpenedFile(kSnapshotFileName),
&g_mapped_snapshot);
// V8 can't start up without the source of the natives, but it can
@@ -240,7 +243,6 @@ void V8Initializer::LoadV8Natives() {
if (g_mapped_natives)
return;
- OpenFileIfNecessary(kNativesFileName);
LoadV8FileResult result = MapOpenedFile(GetOpenedFile(kNativesFileName),
&g_mapped_natives);
if (result != V8_LOAD_SUCCESS) {
@@ -300,37 +302,8 @@ void V8Initializer::LoadV8NativesFromFD(base::PlatformFile natives_pf,
std::make_pair(natives_pf, natives_region);
}
-// static
-base::PlatformFile V8Initializer::GetOpenNativesFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out) {
- const OpenedFileMap::mapped_type& opened =
- OpenFileIfNecessary(kNativesFileName);
- *region_out = opened.second;
- return opened.first;
-}
-
-// static
-base::PlatformFile V8Initializer::GetOpenSnapshotFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out) {
- const OpenedFileMap::mapped_type& opened =
- OpenFileIfNecessary(kSnapshotFileName);
- *region_out = opened.second;
- return opened.first;
-}
-
#if defined(OS_ANDROID)
// static
-base::PlatformFile V8Initializer::GetOpenSnapshotFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out,
- bool abi_32_bit) {
- const char* snapshot_file =
- abi_32_bit ? kSnapshotFileName32 : kSnapshotFileName64;
- const OpenedFileMap::mapped_type& opened = OpenFileIfNecessary(snapshot_file);
- *region_out = opened.second;
- return opened.first;
-}
-
-// static
base::FilePath V8Initializer::GetNativesFilePath() {
base::FilePath path;
GetV8FilePath(kNativesFileName, &path);
@@ -370,7 +343,7 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
natives.raw_size = static_cast<int>(g_mapped_natives->length());
v8::V8::SetNativesDataBlob(&natives);
- if (g_mapped_snapshot != NULL) {
+ if (g_mapped_snapshot) {
v8::StartupData snapshot;
snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data());
snapshot.raw_size = static_cast<int>(g_mapped_snapshot->length());
@@ -389,21 +362,46 @@ void V8Initializer::GetV8ExternalSnapshotData(const char** natives_data_out,
int* natives_size_out,
const char** snapshot_data_out,
int* snapshot_size_out) {
- if (g_mapped_natives) {
- *natives_data_out = reinterpret_cast<const char*>(g_mapped_natives->data());
- *natives_size_out = static_cast<int>(g_mapped_natives->length());
- } else {
- *natives_data_out = NULL;
- *natives_size_out = 0;
+ GetMappedFileData(g_mapped_natives, natives_data_out, natives_size_out);
+ GetMappedFileData(g_mapped_snapshot, snapshot_data_out, snapshot_size_out);
+}
+
+// static
+void V8Initializer::LoadV8ContextSnapshot() {
+ if (g_mapped_v8_context_snapshot)
+ return;
+
+ MapOpenedFile(GetOpenedFile(kV8ContextSnapshotFileName),
+ &g_mapped_v8_context_snapshot);
+
+ // TODO(peria): Check if the snapshot file is loaded successfully.
+}
+
+// static
+void V8Initializer::LoadV8ContextSnapshotFromFD(base::PlatformFile snapshot_pf,
+ int64_t snapshot_offset,
+ int64_t snapshot_size) {
+ if (g_mapped_v8_context_snapshot)
+ return;
+ CHECK_NE(base::kInvalidPlatformFile, snapshot_pf);
+
+ base::MemoryMappedFile::Region snapshot_region =
+ base::MemoryMappedFile::Region::kWholeFile;
+ if (snapshot_size != 0 || snapshot_offset != 0) {
+ snapshot_region.offset = snapshot_offset;
+ snapshot_region.size = snapshot_size;
}
- if (g_mapped_snapshot) {
- *snapshot_data_out =
- reinterpret_cast<const char*>(g_mapped_snapshot->data());
- *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length());
- } else {
- *snapshot_data_out = NULL;
- *snapshot_size_out = 0;
+
+ if (MapV8File(snapshot_pf, snapshot_region, &g_mapped_v8_context_snapshot)) {
+ g_opened_files.Get()[kV8ContextSnapshotFileName] =
+ std::make_pair(snapshot_pf, snapshot_region);
}
}
+// static
+void V8Initializer::GetV8ContextSnapshotData(const char** data_out,
+ int* size_out) {
+ GetMappedFileData(g_mapped_v8_context_snapshot, data_out, size_out);
+}
+
} // namespace gin
diff --git a/chromium/gin/v8_initializer.h b/chromium/gin/v8_initializer.h
index 7d16c3eb6d9..f0a7c5e0fb6 100644
--- a/chromium/gin/v8_initializer.h
+++ b/chromium/gin/v8_initializer.h
@@ -54,28 +54,26 @@ class GIN_EXPORT V8Initializer {
// so that it will not return if natives cannot be loaded.
static void LoadV8Natives();
- // Opens (unless already cached) and returns the V8 natives file.
- // Use with LoadV8NativesFromFD().
- // Asserts if the file does not exist.
- static base::PlatformFile GetOpenNativesFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out);
-
- // Opens (unless already cached) and returns the V8 snapshot file.
- // Use with LoadV8SnapshotFromFD().
- // Will return -1 if the file does not exist.
- static base::PlatformFile GetOpenSnapshotFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out);
-
#if defined(OS_ANDROID)
- static base::PlatformFile GetOpenSnapshotFileForChildProcesses(
- base::MemoryMappedFile::Region* region_out,
- bool abi_32_bit);
-
static base::FilePath GetNativesFilePath();
static base::FilePath GetSnapshotFilePath(bool abi_32_bit);
#endif
#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
+ // Load V8 context snapshot from user provided platform file descriptors.
+ // Other details are same with LoadV8SnapshotFromFD.
+ static void LoadV8ContextSnapshotFromFD(base::PlatformFile snapshot_fd,
+ int64_t snapshot_offset,
+ int64_t snapshot_size);
+
+ // Load V8 context snapshot from default resources, if they are available.
+ static void LoadV8ContextSnapshot();
+
+ // Get address and size information for currently loaded V8 context snapshot.
+ // If no snapshot is loaded, the return values are nullptr and 0.
+ static void GetV8ContextSnapshotData(const char** snapshot_data_out,
+ int* snapshot_size_out);
};
} // namespace gin
diff --git a/chromium/gin/v8_platform.cc b/chromium/gin/v8_platform.cc
index f06e60cf3c3..e9b7b026aa9 100644
--- a/chromium/gin/v8_platform.cc
+++ b/chromium/gin/v8_platform.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/allocator/partition_allocator/page_allocator.h"
#include "base/bind.h"
#include "base/debug/stack_trace.h"
#include "base/location.h"
@@ -13,6 +14,7 @@
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_scheduler.h"
#include "base/trace_event/trace_event.h"
+#include "build/build_config.h"
#include "gin/per_isolate_data.h"
namespace gin {
@@ -195,9 +197,17 @@ V8Platform::V8Platform() : tracing_controller_(new TracingControllerImpl) {}
V8Platform::~V8Platform() {}
+void V8Platform::OnCriticalMemoryPressure() {
+#if defined(OS_WIN)
+ // Some configurations do not use page_allocator. Only 32 bit Windows systems
+ // reserve memory currently.
+ base::ReleaseReservation();
+#endif
+}
+
size_t V8Platform::NumberOfAvailableBackgroundThreads() {
return std::max(1, base::TaskScheduler::GetInstance()
- ->GetMaxConcurrentTasksWithTraitsDeprecated(
+ ->GetMaxConcurrentNonBlockedTasksWithTraitsDeprecated(
kBackgroundThreadTaskTraits));
}
@@ -257,6 +267,10 @@ double V8Platform::MonotonicallyIncreasingTime() {
static_cast<double>(base::Time::kMicrosecondsPerSecond);
}
+double V8Platform::CurrentClockTimeMillis() {
+ return base::Time::Now().ToJsTime();
+}
+
v8::TracingController* V8Platform::GetTracingController() {
return tracing_controller_.get();
}
diff --git a/chromium/gin/v8_platform_unittest.cc b/chromium/gin/v8_platform_unittest.cc
index 3a5abe3ed3b..fe12bac2870 100644
--- a/chromium/gin/v8_platform_unittest.cc
+++ b/chromium/gin/v8_platform_unittest.cc
@@ -8,7 +8,7 @@
#include "testing/gtest/include/gtest/gtest.h"
class TestTraceStateObserver
- : public NON_EXPORTED_BASE(v8::TracingController::TraceStateObserver) {
+ : public v8::TracingController::TraceStateObserver {
public:
void OnTraceEnabled() final { ++enabled_; }
void OnTraceDisabled() final { ++disabled_; }