gin: Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).
Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).
R=thakis@chromium.org
Bug: 1234043
Test: No functionality change
Change-Id: I992993b030d052e6821486adbb7f8653dd363bd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373825
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956756}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
2fdc434c32
commit
c696a4748e
@ -12,13 +12,13 @@
|
||||
#include "build/build_config.h"
|
||||
#include "gin/per_isolate_data.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifndef MAP_ANONYMOUS
|
||||
#define MAP_ANONYMOUS MAP_ANON
|
||||
#endif
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
namespace gin {
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "v8/include/v8-initialization.h"
|
||||
#endif
|
||||
|
||||
@ -21,7 +21,7 @@ void Debug::SetJitCodeEventHandler(v8::JitCodeEventHandler event_handler) {
|
||||
g_jit_code_event_handler = event_handler;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// static
|
||||
void Debug::SetUnhandledExceptionCallback(
|
||||
v8::UnhandledExceptionCallback callback) {
|
||||
|
@ -23,7 +23,7 @@ class GIN_EXPORT Debug {
|
||||
*/
|
||||
static void SetJitCodeEventHandler(v8::JitCodeEventHandler event_handler);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
/* Sets a callback that is invoked for exceptions that arise in V8-generated
|
||||
* code (jitted code or embedded builtins).
|
||||
*/
|
||||
|
@ -7,12 +7,13 @@
|
||||
#include "base/path_service.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "build/build_config.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
base::FilePath GinShellPath() {
|
||||
base::FilePath dir;
|
||||
base::PathService::Get(base::DIR_EXE, &dir);
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return dir.AppendASCII("gin_shell.exe");
|
||||
#else
|
||||
return dir.AppendASCII("gin_shell");
|
||||
|
@ -39,9 +39,9 @@
|
||||
#include "v8/include/v8-snapshot.h"
|
||||
|
||||
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#include "base/android/apk_assets.h"
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/foundation_util.h"
|
||||
#endif
|
||||
#endif // V8_USE_EXTERNAL_STARTUP_DATA
|
||||
@ -75,7 +75,7 @@ void GetMappedFileData(base::MemoryMappedFile* mapped_file,
|
||||
|
||||
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
const char kV8ContextSnapshotFileName64[] = "v8_context_snapshot_64.bin";
|
||||
const char kV8ContextSnapshotFileName32[] = "v8_context_snapshot_32.bin";
|
||||
const char kSnapshotFileName64[] = "snapshot_blob_64.bin";
|
||||
@ -89,12 +89,12 @@ const char kSnapshotFileName32[] = "snapshot_blob_32.bin";
|
||||
#define kSnapshotFileName kSnapshotFileName32
|
||||
#endif
|
||||
|
||||
#else // defined(OS_ANDROID)
|
||||
#else // BUILDFLAG(IS_ANDROID)
|
||||
#if defined(USE_V8_CONTEXT_SNAPSHOT)
|
||||
const char kV8ContextSnapshotFileName[] = V8_CONTEXT_SNAPSHOT_FILENAME;
|
||||
#endif
|
||||
const char kSnapshotFileName[] = "snapshot_blob.bin";
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
const char* GetSnapshotFileName(const V8SnapshotFileType file_type) {
|
||||
switch (file_type) {
|
||||
@ -113,11 +113,11 @@ const char* GetSnapshotFileName(const V8SnapshotFileType file_type) {
|
||||
}
|
||||
|
||||
void GetV8FilePath(const char* file_name, base::FilePath* path_out) {
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// This is the path within the .apk.
|
||||
*path_out =
|
||||
base::FilePath(FILE_PATH_LITERAL("assets")).AppendASCII(file_name);
|
||||
#elif defined(OS_MAC)
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
base::ScopedCFTypeRef<CFStringRef> bundle_resource(
|
||||
base::SysUTF8ToCFStringRef(file_name));
|
||||
*path_out = base::mac::PathForFrameworkBundleResource(bundle_resource);
|
||||
@ -158,7 +158,7 @@ base::File OpenV8File(const char* file_name,
|
||||
base::FilePath path;
|
||||
GetV8FilePath(file_name, &path);
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
base::File file(base::android::OpenApkAsset(path.value(), region_out));
|
||||
OpenV8FileResult result = file.IsValid() ? OpenV8FileResult::OPENED
|
||||
: OpenV8FileResult::FAILED_OTHER;
|
||||
@ -189,7 +189,7 @@ base::File OpenV8File(const char* file_name,
|
||||
base::PlatformThread::Sleep(base::Milliseconds(kOpenRetryDelayMillis));
|
||||
}
|
||||
}
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
UMA_HISTOGRAM_ENUMERATION("V8.Initializer.OpenV8File.Result", result,
|
||||
OpenV8FileResult::MAX_VALUE);
|
||||
@ -428,7 +428,7 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
|
||||
const size_t min_pool_size =
|
||||
base::internal::PartitionAddressSpace::ConfigurablePoolMinSize();
|
||||
size_t pool_size = max_pool_size;
|
||||
#if defined(OS_WIN)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// On Windows prior to 8.1 we allocate a smaller Pool since reserving
|
||||
// virtual memory is expensive on these OSes.
|
||||
if (base::win::GetVersion() < base::win::Version::WIN8_1) {
|
||||
@ -519,7 +519,7 @@ void V8Initializer::LoadV8SnapshotFromFile(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// static
|
||||
base::FilePath V8Initializer::GetSnapshotFilePath(
|
||||
bool abi_32_bit,
|
||||
@ -540,7 +540,7 @@ base::FilePath V8Initializer::GetSnapshotFilePath(
|
||||
GetV8FilePath(filename, &path);
|
||||
return path;
|
||||
}
|
||||
#endif // defined(OS_ANDROID)
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
V8SnapshotFileType GetLoadedSnapshotFileType() {
|
||||
DCHECK(g_snapshot_file_type.has_value());
|
||||
|
@ -52,7 +52,7 @@ class GIN_EXPORT V8Initializer {
|
||||
base::MemoryMappedFile::Region* snapshot_file_region,
|
||||
V8SnapshotFileType snapshot_file_type);
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
static base::FilePath GetSnapshotFilePath(
|
||||
bool abi_32_bit,
|
||||
V8SnapshotFileType snapshot_file_type);
|
||||
|
@ -127,7 +127,7 @@ class TimeClamper {
|
||||
public:
|
||||
// As site isolation is enabled on desktop platforms, we can safely provide
|
||||
// more timing resolution. Jittering is still enabled everywhere.
|
||||
#if defined(OS_ANDROID)
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
static constexpr double kResolutionSeconds = 100e-6;
|
||||
#else
|
||||
static constexpr double kResolutionSeconds = 5e-6;
|
||||
@ -371,7 +371,7 @@ PageAllocator* V8Platform::GetPageAllocator() {
|
||||
void V8Platform::OnCriticalMemoryPressure() {
|
||||
// We only have a reservation on 32-bit Windows systems.
|
||||
// TODO(bbudge) Make the #if's in BlinkInitializer match.
|
||||
#if defined(OS_WIN) && defined(ARCH_CPU_32_BITS)
|
||||
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_32_BITS)
|
||||
base::ReleaseReservation();
|
||||
#endif
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "v8_platform_page_allocator.h"
|
||||
|
||||
#include "base/allocator/partition_allocator/address_space_randomization.h"
|
||||
#include "base/allocator/partition_allocator/page_allocator_constants.h"
|
||||
#include "base/allocator/partition_allocator/random.h"
|
||||
#include "base/check_op.h"
|
||||
#include "base/cpu.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -85,10 +85,10 @@ bool PageAllocator::ReleasePages(void* address,
|
||||
DCHECK_LT(new_length, length);
|
||||
uint8_t* release_base = reinterpret_cast<uint8_t*>(address) + new_length;
|
||||
size_t release_size = length - new_length;
|
||||
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
|
||||
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
// On POSIX, we can unmap the trailing pages.
|
||||
base::FreePages(release_base, release_size);
|
||||
#elif defined(OS_WIN)
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
// On Windows, we can only de-commit the trailing pages. FreePages() will
|
||||
// still free all pages in the region including the released tail, so it's
|
||||
// safe to just decommit the tail.
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "gin/v8_platform_page_allocator.h"
|
||||
|
||||
#include "base/cpu.h"
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
// includes for Branch Target Instruction tests
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
#include "base/allocator/partition_allocator/arm_bti_test_functions.h"
|
||||
#include "base/allocator/partition_allocator/page_allocator_constants.h"
|
||||
#if defined(OS_POSIX)
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include <signal.h>
|
||||
#include "testing/gtest/include/gtest/gtest-death-test.h"
|
||||
#endif
|
||||
@ -98,11 +98,11 @@ TEST(V8PlatformPageAllocatorBTITest, VerifyReadExecutePagesAreProtected) {
|
||||
// the actual CPU we are running on. The code that were are trying to execute
|
||||
// is assembly code and always has BTI enabled.
|
||||
if (base::CPU::GetInstanceNoAllocation().has_bti()) {
|
||||
#if defined(OS_POSIX) // signal handling is available on POSIX compliant
|
||||
// systems only
|
||||
#if BUILDFLAG(IS_POSIX) // signal handling is available on POSIX compliant
|
||||
// systems only
|
||||
EXPECT_EXIT({ bti_invalid_fn(15); }, testing::KilledBySignal(SIGILL),
|
||||
""); // Should crash with SIGILL.
|
||||
#endif // defined(OS_POSIX)
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
} else {
|
||||
EXPECT_EQ(bti_invalid_fn(15), 17);
|
||||
}
|
||||
|
Reference in New Issue
Block a user