Remove all remaining PDFium infrastructure for V8 natives.
Bug: v8:7624
Change-Id: I59a1da39c876a38294e78ae87e012f537ec6c04f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/61290
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 83c5742..92a7bea 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -1005,11 +1005,10 @@
#ifdef PDF_ENABLE_V8
std::unique_ptr<v8::Platform> platform;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- v8::StartupData natives;
v8::StartupData snapshot;
if (!options.disable_javascript) {
platform = InitializeV8ForPDFiumWithStartupData(
- options.exe_path, options.bin_directory, &natives, &snapshot);
+ options.exe_path, options.bin_directory, &snapshot);
}
#else // V8_USE_EXTERNAL_STARTUP_DATA
if (!options.disable_javascript)
@@ -1092,7 +1091,6 @@
if (!options.disable_javascript) {
v8::V8::ShutdownPlatform();
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- free(const_cast<char*>(natives.data));
free(const_cast<char*>(snapshot.data));
#endif // V8_USE_EXTERNAL_STARTUP_DATA
}
diff --git a/testing/embedder_test_main.cpp b/testing/embedder_test_main.cpp
index 36297a5..34dfb06 100644
--- a/testing/embedder_test_main.cpp
+++ b/testing/embedder_test_main.cpp
@@ -21,7 +21,6 @@
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-v8::StartupData* g_v8_natives = nullptr;
v8::StartupData* g_v8_snapshot = nullptr;
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // PDF_ENABLE_V8
@@ -34,14 +33,13 @@
void SetUp() override {
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- if (g_v8_natives && g_v8_snapshot) {
- platform_ = InitializeV8ForPDFiumWithStartupData(
- g_exe_path, std::string(), nullptr, nullptr);
+ if (g_v8_snapshot) {
+ platform_ = InitializeV8ForPDFiumWithStartupData(g_exe_path,
+ std::string(), nullptr);
} else {
- g_v8_natives = new v8::StartupData;
g_v8_snapshot = new v8::StartupData;
platform_ = InitializeV8ForPDFiumWithStartupData(
- g_exe_path, std::string(), g_v8_natives, g_v8_snapshot);
+ g_exe_path, std::string(), g_v8_snapshot);
}
#else
platform_ = InitializeV8ForPDFium(g_exe_path);
@@ -83,8 +81,6 @@
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- if (g_v8_natives)
- free(const_cast<char*>(g_v8_natives->data));
if (g_v8_snapshot)
free(const_cast<char*>(g_v8_snapshot->data));
#endif // V8_USE_EXTERNAL_STARTUP_DATA
diff --git a/testing/fuzzers/pdf_fuzzer_init_public.cc b/testing/fuzzers/pdf_fuzzer_init_public.cc
index 1423635..5ece0bc 100644
--- a/testing/fuzzers/pdf_fuzzer_init_public.cc
+++ b/testing/fuzzers/pdf_fuzzer_init_public.cc
@@ -16,7 +16,7 @@
#endif
#ifdef _WIN32
-#include <Windows.h>
+#include <windows.h>
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#else // Linux
@@ -32,7 +32,7 @@
#ifdef _WIN32
char path[MAX_PATH];
- DWORD len = GetModuleFileNameA(NULL, path, MAX_PATH);
+ DWORD len = GetModuleFileNameA(nullptr, path, MAX_PATH);
if (len != 0)
result = std::string(path, len);
#elif defined(__APPLE__)
@@ -62,7 +62,7 @@
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
platform = InitializeV8ForPDFiumWithStartupData(
- ProgramPath(), "", &natives_blob, &snapshot_blob);
+ ProgramPath(), std::string(), &snapshot_blob);
#else
platform = InitializeV8ForPDFium(ProgramPath());
#endif // V8_USE_EXTERNAL_STARTUP_DATA
@@ -83,7 +83,6 @@
#ifdef PDF_ENABLE_V8
std::unique_ptr<v8::Platform> platform;
- v8::StartupData natives_blob;
v8::StartupData snapshot_blob;
#endif
diff --git a/testing/unit_test_main.cpp b/testing/unit_test_main.cpp
index 35c4939..5d50249 100644
--- a/testing/unit_test_main.cpp
+++ b/testing/unit_test_main.cpp
@@ -28,10 +28,9 @@
#ifdef PDF_ENABLE_V8
std::unique_ptr<v8::Platform> platform;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- static v8::StartupData* natives = new v8::StartupData;
static v8::StartupData* snapshot = new v8::StartupData;
- platform = InitializeV8ForPDFiumWithStartupData(argv[0], std::string(),
- natives, snapshot);
+ platform =
+ InitializeV8ForPDFiumWithStartupData(argv[0], std::string(), snapshot);
#else // V8_USE_EXTERNAL_STARTUP_DATA
platform = InitializeV8ForPDFium(argv[0]);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
diff --git a/testing/v8_initializer.cpp b/testing/v8_initializer.cpp
index b484ee4..8564b2e 100644
--- a/testing/v8_initializer.cpp
+++ b/testing/v8_initializer.cpp
@@ -78,13 +78,9 @@
std::unique_ptr<v8::Platform> InitializeV8ForPDFiumWithStartupData(
const std::string& exe_path,
const std::string& bin_dir,
- v8::StartupData* natives_blob,
v8::StartupData* snapshot_blob) {
- // TODO(v8:7624): Remove natives and all remaining infrastructure.
std::unique_ptr<v8::Platform> platform = InitializeV8Common(exe_path);
- if (natives_blob && snapshot_blob) {
- if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
- return nullptr;
+ if (snapshot_blob) {
if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob))
return nullptr;
v8::V8::SetSnapshotDataBlob(snapshot_blob);
diff --git a/testing/v8_initializer.h b/testing/v8_initializer.h
index 35c98d9..bd2301c 100644
--- a/testing/v8_initializer.h
+++ b/testing/v8_initializer.h
@@ -20,12 +20,10 @@
} // namespace v8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-// |natives_blob| and |snapshot_blob| are optional out parameters. They should
-// either both be valid or both be nullptrs.
+// |snapshot_blob| is an optional out parameter.
std::unique_ptr<v8::Platform> InitializeV8ForPDFiumWithStartupData(
const std::string& exe_path,
const std::string& bin_dir,
- v8::StartupData* natives_blob,
v8::StartupData* snapshot_blob);
#else
std::unique_ptr<v8::Platform> InitializeV8ForPDFium(