Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: gin/v8_initializer.h

Issue 1156873002: Load v8 snapshots directly from APK (and store them uncompressed) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8initializer
Patch Set: Keep extracting for components/ Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GIN_V8_INITIALIZER_H_ 5 #ifndef GIN_V8_INITIALIZER_H_
6 #define GIN_V8_INITIALIZER_H_ 6 #define GIN_V8_INITIALIZER_H_
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/memory_mapped_file.h"
10 #include "base/macros.h"
9 #include "gin/array_buffer.h" 11 #include "gin/array_buffer.h"
10 #include "gin/gin_export.h" 12 #include "gin/gin_export.h"
11 #include "gin/public/isolate_holder.h" 13 #include "gin/public/isolate_holder.h"
12 #include "gin/public/v8_platform.h" 14 #include "gin/public/v8_platform.h"
13 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
14 16
15 namespace gin { 17 namespace gin {
16 18
17 class GIN_EXPORT V8Initializer { 19 class GIN_EXPORT V8Initializer {
18 public: 20 public:
19 // This should be called by IsolateHolder::Initialize(). 21 // This should be called by IsolateHolder::Initialize().
20 static void Initialize(gin::IsolateHolder::ScriptMode mode); 22 static void Initialize(gin::IsolateHolder::ScriptMode mode);
21 23
22 // Get address and size information for currently loaded snapshot. 24 // Get address and size information for currently loaded snapshot.
23 // If no snapshot is loaded, the return values are null for addresses 25 // If no snapshot is loaded, the return values are null for addresses
24 // and 0 for sizes. 26 // and 0 for sizes.
25 static void GetV8ExternalSnapshotData(const char** natives_data_out, 27 static void GetV8ExternalSnapshotData(const char** natives_data_out,
26 int* natives_size_out, 28 int* natives_size_out,
27 const char** snapshot_data_out, 29 const char** snapshot_data_out,
28 int* snapshot_size_out); 30 int* snapshot_size_out);
29 31
30 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 32 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
31
32 // Load V8 snapshot from user provided platform file descriptors. 33 // Load V8 snapshot from user provided platform file descriptors.
33 // The offset and size arguments, if non-zero, specify the portions 34 // The offset and size arguments, if non-zero, specify the portions
34 // of the files to be loaded. Since the VM can boot with or without 35 // of the files to be loaded. Since the VM can boot with or without
35 // the snapshot, this function does not return a status. 36 // the snapshot, this function does not return a status.
36 static void LoadV8SnapshotFromFD(base::PlatformFile snapshot_fd, 37 static void LoadV8SnapshotFromFD(base::PlatformFile snapshot_fd,
37 int64 snapshot_offset, 38 int64 snapshot_offset,
38 int64 snapshot_size); 39 int64 snapshot_size);
39 // Similar to LoadV8SnapshotFromFD, but for the source of the natives. 40 // Similar to LoadV8SnapshotFromFD, but for the source of the natives.
40 // Without the natives we cannot continue, so this function contains 41 // Without the natives we cannot continue, so this function contains
41 // release mode asserts and won't return if it fails. 42 // release mode asserts and won't return if it fails.
42 static void LoadV8NativesFromFD(base::PlatformFile natives_fd, 43 static void LoadV8NativesFromFD(base::PlatformFile natives_fd,
43 int64 natives_offset, 44 int64 natives_offset,
44 int64 natives_size); 45 int64 natives_size);
45 46
46 // Load V8 snapshot from default resources, if they are available. 47 // Load V8 snapshot from default resources, if they are available.
47 static void LoadV8Snapshot(); 48 static void LoadV8Snapshot();
48 49
49 // Load V8 natives source from default resources. Contains asserts 50 // Load V8 natives source from default resources. Contains asserts
50 // so that it will not return if natives cannot be loaded. 51 // so that it will not return if natives cannot be loaded.
51 static void LoadV8Natives(); 52 static void LoadV8Natives();
52 53
53 // Opens the V8 snapshot data files and returns open file descriptors to these 54 #if defined(OS_POSIX)
54 // files in |natives_fd_out| and |snapshot_fd_out|, which can be passed to 55 struct V8Files {
rmcilroy 2015/06/09 11:52:55 nit - V8StartupData
rmcilroy 2015/06/09 11:52:55 Make struct "final" (or destructor should be virtu
55 // child processes. 56 V8Files();
56 static bool OpenV8FilesForChildProcesses(base::PlatformFile* natives_fd_out, 57 ~V8Files();
57 base::PlatformFile* snapshot_fd_out) 58 base::ScopedFD natives_fd;
rmcilroy 2015/06/09 11:52:55 nit - newline between fields and constructor / des
58 WARN_UNUSED_RESULT; 59 base::ScopedFD snapshot_fd;
60 base::MemoryMappedFile::Region natives_region;
61 base::MemoryMappedFile::Region snapshot_region;
62 private:
rmcilroy 2015/06/09 11:52:55 nit - newline before "private"
63 DISALLOW_COPY_AND_ASSIGN(V8Files);
64 };
65
66 // Opens the V8 snapshot data files and returns open file descriptors and
67 // file regions to these files that can be passed to child processes.
68 static void OpenV8FilesForChildProcesses(V8Files* files_out);
69 #endif // OS_POSIX
59 #endif // V8_USE_EXTERNAL_STARTUP_DATA 70 #endif // V8_USE_EXTERNAL_STARTUP_DATA
60 }; 71 };
61 72
62 } // namespace gin 73 } // namespace gin
63 74
64 #endif // GIN_V8_INITIALIZER_H_ 75 #endif // GIN_V8_INITIALIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698