From ed0fdafe2a455ac468454324bd55c74d44dd46fe Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Thu, 18 Apr 2024 00:00:00 -0700 Subject: [PATCH] base --- base/BUILD.gn | 208 +++++++++--------- base/allocator/dispatcher/tls_unittest.cc | 3 +- .../partition_allocator/partition_alloc.gni | 3 +- .../partition_alloc_unittest.cc | 6 +- .../android/jni_generator/AndroidManifest.xml | 1 - base/base_paths.cc | 2 +- base/bits.h | 6 - base/debug/stack_trace_unittest.cc | 4 - base/feature_list_unittest.cc | 4 +- base/files/file_unittest.cc | 2 +- base/files/file_util.h | 1 + base/files/file_util_unittest.cc | 2 +- base/functional/callback_tags.h | 2 +- base/i18n/time_formatting.cc | 3 + base/metrics/field_trial.cc | 1 + base/metrics/histogram_macros_local.h | 1 + base/metrics/persistent_memory_allocator.cc | 5 +- base/metrics/persistent_memory_allocator.h | 2 +- .../persistent_memory_allocator_unittest.cc | 1 - base/path_service.cc | 5 +- .../profiler/stack_copier_suspend_unittest.cc | 3 + base/security_unittest.cc | 4 +- base/sequence_token.cc | 3 +- base/system/sys_info_unittest.cc | 2 +- ...ed_set_task_priority_for_current_thread.cc | 3 +- .../hierarchical_timing_wheel.h | 3 + .../sequence_manager/sequence_manager_impl.cc | 2 +- base/task/thread_pool/task_tracker.cc | 5 +- base/task/thread_pool/test_utils.cc | 17 ++ base/task/thread_pool/test_utils.h | 8 + base/test/BUILD.gn | 2 - base/third_party/double_conversion/LICENSE | 26 +++ base/third_party/symbolize/LICENSE | 28 +++ base/time/time_unittest.cc | 3 +- base/trace_event/trace_log.h | 2 +- base/values.h | 6 + 36 files changed, 225 insertions(+), 154 deletions(-) create mode 100644 base/third_party/double_conversion/LICENSE create mode 100644 base/third_party/symbolize/LICENSE diff --git a/base/BUILD.gn b/base/BUILD.gn index 5e317d9b3967..c9ee3387b69b 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -102,8 +102,8 @@ if (is_apple) { } # Determines whether libevent should be dep. -dep_libevent = - !is_fuchsia && !is_win && !is_mac && !is_nacl && !use_cobalt_customizations +dep_libevent = !is_fuchsia && !is_win && !is_mac && !is_nacl + && !use_cobalt_customizations # Determines whether message_pump_libevent should be used. use_libevent = dep_libevent && !is_ios @@ -1460,7 +1460,7 @@ component("base") { } # Fuchsia. - if (is_fuchsia && !is_starboard) { + if (is_fuchsia) { sources += [ "base_paths_fuchsia.cc", "debug/debugger_fuchsia.cc", @@ -2369,9 +2369,9 @@ component("base") { } if (!is_starboard) { - if ((is_posix && !is_apple && !is_android) || is_fuchsia) { - sources += [ "profiler/stack_sampler_posix.cc" ] - } + if ((is_posix && !is_apple && !is_android) || is_fuchsia) { + sources += [ "profiler/stack_sampler_posix.cc" ] + } } if ((is_posix && !is_apple && !is_android && !is_chromeos) || is_fuchsia || is_starboard) { @@ -2762,9 +2762,6 @@ component("i18n") { "i18n/streaming_utf8_validator.h", "i18n/string_compare.cc", "i18n/string_compare.h", - - # "i18n/string_search.cc", - # "i18n/string_search.h", "i18n/time_formatting.cc", "i18n/time_formatting.h", "i18n/timezone.cc", @@ -2799,8 +2796,8 @@ component("i18n") { configs -= [ "//starboard/build/config:size" ] configs += [ "//starboard/build/config:speed" ] } else { - configs -= [ "//build/config/compiler:default_optimization" ] - configs += [ "//build/config/compiler:optimize_max" ] + configs -= [ "//build/config/compiler:default_optimization" ] + configs += [ "//build/config/compiler:optimize_max" ] } } @@ -2817,82 +2814,82 @@ component("i18n") { } if (!is_starboard) { - test("base_perftests") { - sources = [ - "hash/hash_perftest.cc", - "message_loop/message_pump_perftest.cc", - "observer_list_perftest.cc", - "rand_util_perftest.cc", - "strings/string_util_perftest.cc", - "substring_set_matcher/substring_set_matcher_perftest.cc", - "task/job_perftest.cc", - "task/sequence_manager/sequence_manager_perftest.cc", - "task/thread_pool/thread_pool_perftest.cc", - "threading/counter_perftest.cc", - "threading/thread_local_storage_perftest.cc", - - # "test/run_all_unittests.cc", - "json/json_perftest.cc", - "synchronization/lock_perftest.cc", - "synchronization/waitable_event_perftest.cc", - "threading/thread_perftest.cc", - ] - - deps = [ - ":base", - ":debugging_buildflags", - "//base/test:test_support", - "//base/test:test_support_perf", - "//testing/gtest", - "//testing/perf", - ] +test("base_perftests") { + sources = [ + "hash/hash_perftest.cc", + "message_loop/message_pump_perftest.cc", + "observer_list_perftest.cc", + "rand_util_perftest.cc", + "strings/string_util_perftest.cc", + "substring_set_matcher/substring_set_matcher_perftest.cc", + "task/job_perftest.cc", + "task/sequence_manager/sequence_manager_perftest.cc", + "task/thread_pool/thread_pool_perftest.cc", + "threading/counter_perftest.cc", + "threading/thread_local_storage_perftest.cc", + + # "test/run_all_unittests.cc", + "json/json_perftest.cc", + "synchronization/lock_perftest.cc", + "synchronization/waitable_event_perftest.cc", + "threading/thread_perftest.cc", + ] - if (use_partition_alloc) { - sources += [ - "allocator/partition_allocator/partition_alloc_perftest.cc", - "allocator/partition_allocator/partition_lock_perftest.cc", - ] - deps += [ ":partition_alloc_test_support" ] - } + deps = [ + ":base", + ":debugging_buildflags", + "//base/test:test_support", + "//base/test:test_support_perf", + "//testing/gtest", + "//testing/perf", + ] - data_deps = [ - # Needed for isolate script to execute. - "//testing:run_perf_test", + if (use_partition_alloc) { + sources += [ + "allocator/partition_allocator/partition_alloc_perftest.cc", + "allocator/partition_allocator/partition_lock_perftest.cc", ] + deps += [ ":partition_alloc_test_support" ] + } - if (is_android) { - deps += [ "//testing/android/native_test:native_test_native_code" ] - shard_timeout = 600 - } + data_deps = [ + # Needed for isolate script to execute. + "//testing:run_perf_test", + ] - if (is_fuchsia) { - # Run these performance tests against the actual system. - run_as_chromium_system_test = true - } + if (is_android) { + deps += [ "//testing/android/native_test:native_test_native_code" ] + shard_timeout = 600 + } - if (!is_official_build) { - # The extra data tables required by stack traces are turned off for official - # build, only do stack trace perftest for unofficial build - sources += [ "debug/stack_trace_perftest.cc" ] - } + if (is_fuchsia) { + # Run these performance tests against the actual system. + run_as_chromium_system_test = true + } - if (build_allocation_stack_trace_recorder) { - sources += [ "debug/allocation_trace_perftest.cc" ] - } + if (!is_official_build) { + # The extra data tables required by stack traces are turned off for official + # build, only do stack trace perftest for unofficial build + sources += [ "debug/stack_trace_perftest.cc" ] } - test("base_i18n_perftests") { - sources = [ "i18n/streaming_utf8_validator_perftest.cc" ] - deps = [ - ":base", - ":i18n", - "//base/test:test_support", - "//base/test:test_support_perf", - "//testing/gtest", - ] + if (build_allocation_stack_trace_recorder) { + sources += [ "debug/allocation_trace_perftest.cc" ] } } +test("base_i18n_perftests") { + sources = [ "i18n/streaming_utf8_validator_perftest.cc" ] + deps = [ + ":base", + ":i18n", + "//base/test:test_support", + "//base/test:test_support_perf", + "//testing/gtest", + ] +} +} + if (!is_ios && !use_cobalt_customizations) { executable("build_utf8_validator_tables") { sources = [ "i18n/build_utf8_validator_tables.cc" ] @@ -3015,35 +3012,35 @@ source_set("base_stack_sampling_profiler_test_util") { } copy("base_unittests_bundle_data") { - testonly = true + testonly = true if (is_starboard) { install_content = true } - sources = [ - "//tools/metrics/histograms/enums.xml", - "test/data/file_util/binary_file.bin", - "test/data/file_util/binary_file_diff.bin", - "test/data/file_util/binary_file_same.bin", - "test/data/file_util/blank_line.txt", - "test/data/file_util/blank_line_crlf.txt", - "test/data/file_util/crlf.txt", - "test/data/file_util/different.txt", - "test/data/file_util/different_first.txt", - "test/data/file_util/different_last.txt", - "test/data/file_util/empty1.txt", - "test/data/file_util/empty2.txt", - "test/data/file_util/first1.txt", - "test/data/file_util/first2.txt", - "test/data/file_util/original.txt", - "test/data/file_util/same.txt", - "test/data/file_util/same_length.txt", - "test/data/file_util/shortened.txt", - "test/data/json/bom_feff.json", - "test/data/pe_image_reader/signed.exe", - "test/data/serializer_nested_test.json", - "test/data/serializer_test.json", - "test/data/serializer_test_nowhitespace.json", - ] + sources = [ + "//tools/metrics/histograms/enums.xml", + "test/data/file_util/binary_file.bin", + "test/data/file_util/binary_file_diff.bin", + "test/data/file_util/binary_file_same.bin", + "test/data/file_util/blank_line.txt", + "test/data/file_util/blank_line_crlf.txt", + "test/data/file_util/crlf.txt", + "test/data/file_util/different.txt", + "test/data/file_util/different_first.txt", + "test/data/file_util/different_last.txt", + "test/data/file_util/empty1.txt", + "test/data/file_util/empty2.txt", + "test/data/file_util/first1.txt", + "test/data/file_util/first2.txt", + "test/data/file_util/original.txt", + "test/data/file_util/same.txt", + "test/data/file_util/same_length.txt", + "test/data/file_util/shortened.txt", + "test/data/json/bom_feff.json", + "test/data/pe_image_reader/signed.exe", + "test/data/serializer_nested_test.json", + "test/data/serializer_test.json", + "test/data/serializer_test_nowhitespace.json", + ] if (is_starboard) { outputs = [ "$sb_static_contents_output_data_dir/test/base/{{source_target_relative}}" ] } else { @@ -3646,10 +3643,6 @@ test("base_unittests") { defines = [ "U_COMMON_IMPLEMENTATION" ] data_deps = [ - # "//base/test:immediate_crash_test_helper", - # "//base/test:test_child_process", - # "//base/test:test_shared_library", - # "//testing/buildbot/filters:base_unittests_filters", ] if (is_android && enable_chrome_android_internal) { @@ -3661,11 +3654,11 @@ test("base_unittests") { } if (is_apple && !is_starboard) { + public_deps = [ ":base_unittests_bundle_data" ] + deps += [ ":base_unittests_arc" ] } - public_deps = [ ":base_unittests_bundle_data" ] - if (is_starboard){ data_deps += [ ":base_unittests_bundle_data", @@ -3759,6 +3752,7 @@ test("base_unittests") { "debug/proc_maps_linux_unittest.cc", "files/scoped_file_linux_unittest.cc", ] + if (!!use_cobalt_customizations && !is_nacl) { deps += [ ":stack_canary_linux_unittests" ] } diff --git a/base/allocator/dispatcher/tls_unittest.cc b/base/allocator/dispatcher/tls_unittest.cc index a2d9ed2097c6..ccbe08a7da7e 100644 --- a/base/allocator/dispatcher/tls_unittest.cc +++ b/base/allocator/dispatcher/tls_unittest.cc @@ -7,7 +7,6 @@ #if USE_LOCAL_TLS_EMULATION() #include #include -#include #include #include #include @@ -586,4 +585,4 @@ TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfTearDownWithoutSetup) { #endif } // namespace base::allocator::dispatcher -#endif // USE_LOCAL_TLS_EMULATION() +#endif // USE_LOCAL_TLS_EMULATION() \ No newline at end of file diff --git a/base/allocator/partition_allocator/partition_alloc.gni b/base/allocator/partition_allocator/partition_alloc.gni index cfcfbee68605..e6835a8917d5 100644 --- a/base/allocator/partition_allocator/partition_alloc.gni +++ b/base/allocator/partition_allocator/partition_alloc.gni @@ -20,8 +20,7 @@ if (is_nacl) { } else if (current_cpu == "x86" || current_cpu == "arm") { has_64_bit_pointers = false } else { - has_64_bit_pointers = true - # assert(false, "Unknown CPU: $current_cpu") + assert(false, "Unknown CPU: $current_cpu") } if (use_partition_alloc_as_malloc_default) { diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc index df4ba51bb44f..9a0db5559e02 100644 --- a/base/allocator/partition_allocator/partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc @@ -97,7 +97,7 @@ bool IsLargeMemoryDevice() { } bool SetAddressSpaceLimit() { -#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) || 1 +#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) // 32 bits => address space is limited already. return true; #elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) @@ -125,7 +125,7 @@ bool SetAddressSpaceLimit() { } bool ClearAddressSpaceLimit() { -#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) || 1 +#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) return true; #elif BUILDFLAG(IS_POSIX) struct rlimit limit; @@ -622,7 +622,7 @@ void FreeFullSlotSpan(PartitionRoot* root, EXPECT_TRUE(slot_span->is_empty()); } -#if 0// BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) bool CheckPageInCore(void* ptr, bool in_core) { unsigned char ret = 0; EXPECT_EQ(0, mincore(ptr, SystemPageSize(), &ret)); diff --git a/base/android/jni_generator/AndroidManifest.xml b/base/android/jni_generator/AndroidManifest.xml index 6be3fe332fed..8fd983c53c57 100644 --- a/base/android/jni_generator/AndroidManifest.xml +++ b/base/android/jni_generator/AndroidManifest.xml @@ -7,7 +7,6 @@ - diff --git a/base/base_paths.cc b/base/base_paths.cc index 50728b2f6ce3..456b21c91f2b 100644 --- a/base/base_paths.cc +++ b/base/base_paths.cc @@ -42,7 +42,7 @@ bool PathProvider(int key, FilePath* result) { #endif // !BUILDFLAG(IS_FUCHSIA) case DIR_TEST_DATA: { FilePath test_data_path; - if (!PathService::Get(DIR_MODULE, &test_data_path)) + if (!PathService::Get(DIR_SRC_TEST_DATA_ROOT, &test_data_path)) return false; test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base")); test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test")); diff --git a/base/bits.h b/base/bits.h index 4b6521d24b81..f2d2caa1d6c8 100644 --- a/base/bits.h +++ b/base/bits.h @@ -182,11 +182,6 @@ ALWAYS_INLINE constexpr // use `Log2Floor` and add 1 to the result. // // TODO(pkasting): When C++20 is available, replace with std::bit_xxx(). -#if defined(COBALT_PENDING_CLEAN_UP) && defined(COMPILER_MSVC) -#define FUNCTION_SPECIFIER ALWAYS_INLINE -#else -#define FUNCTION_SPECIFIER constexpr -#endif ALWAYS_INLINE int Log2Floor(uint32_t n) { return 31 - CountLeadingZeroBits(n); } @@ -198,7 +193,6 @@ ALWAYS_INLINE int Log2Ceiling(uint32_t n) { // why the statement below starts with (n ? 32 : -1). return (n ? 32 : -1) - CountLeadingZeroBits(n - 1); } -#undef FUNCTION_SPECIFIER // Returns a value of type T with a single bit set in the left-most position. // Can be used instead of manually shifting a 1 to the left. diff --git a/base/debug/stack_trace_unittest.cc b/base/debug/stack_trace_unittest.cc index a6a343416814..74793e5e4e56 100644 --- a/base/debug/stack_trace_unittest.cc +++ b/base/debug/stack_trace_unittest.cc @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -276,9 +275,6 @@ NOINLINE static std::unique_ptr CopyCurrentStackAndRewritePointers( reinterpret_cast(__builtin_frame_address(0)); uintptr_t original_stack_end = GetStackEnd(); size_t stack_size = original_stack_end - reinterpret_cast(fp); - // On some platforms, stack_size overflows due to the reinterpret_cast. - const size_t max_stack_size = 102400; - stack_size = std::min(stack_size, max_stack_size); auto buffer = std::make_unique(stack_size); *out_fp = reinterpret_cast( CopyFunction::CopyStackContentsAndRewritePointers( diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc index e9b72609bf3f..3899113db394 100644 --- a/base/feature_list_unittest.cc +++ b/base/feature_list_unittest.cc @@ -626,7 +626,7 @@ TEST_F(FeatureListTest, UninitializedInstance_IsEnabledReturnsFalse) { } #if !defined(STARBOARD) -TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveFeaturesFromSharedMemory) { +TEST_F(FeatureListTest, StoreAndRetrieveFeaturesFromSharedMemory) { std::unique_ptr feature_list(new base::FeatureList); // Create some overrides. @@ -659,7 +659,7 @@ TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveFeaturesFromSharedMemory) { kFeatureOnByDefaultName, FeatureList::OVERRIDE_DISABLE_FEATURE)); } -TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveAssociatedFeaturesFromSharedMemory) { +TEST_F(FeatureListTest, StoreAndRetrieveAssociatedFeaturesFromSharedMemory) { std::unique_ptr feature_list(new base::FeatureList); // Create some overrides. diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc index bfffcb78e3d2..00180895a121 100644 --- a/base/files/file_unittest.cc +++ b/base/files/file_unittest.cc @@ -894,4 +894,4 @@ TEST(FileDeathTest, InvalidFlags) { }, "FLAG_WIN_NO_EXECUTE"); } -#endif // BUILDFLAG(IS_WIN) +#endif // BUILDFLAG(IS_WIN) \ No newline at end of file diff --git a/base/files/file_util.h b/base/files/file_util.h index de3c1737fd44..c47f00265f41 100644 --- a/base/files/file_util.h +++ b/base/files/file_util.h @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index e0e11b661224..f769fe99e31b 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -4018,7 +4018,7 @@ TEST_F(FileUtilTest, ReadStreamToString_ZeroLengthFile) { EXPECT_EQ(contents, random_data); } } -#endif // BUILDFLAG(IS_POSIX) +#endif TEST_F(FileUtilTest, ReadStreamToStringWithMaxSize) { ScopedFILE stream( diff --git a/base/functional/callback_tags.h b/base/functional/callback_tags.h index 98f1d994cda1..e359a547d320 100644 --- a/base/functional/callback_tags.h +++ b/base/functional/callback_tags.h @@ -24,7 +24,7 @@ struct DoNothingCallbackTag { struct WithBoundArguments { std::tuple bound_args; - constexpr explicit WithBoundArguments(BoundArgs&&... args) + constexpr explicit WithBoundArguments(BoundArgs... args) : bound_args(std::forward(args)...) {} }; }; diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc index 98969183eb90..4f01c76963db 100644 --- a/base/i18n/time_formatting.cc +++ b/base/i18n/time_formatting.cc @@ -260,6 +260,9 @@ std::u16string DateIntervalFormat(const Time& begin_time, UErrorCode status = U_ZERO_ERROR; std::unique_ptr formatter( +/* Cobalt + icu::DateIntervalFormat::createInstance(DateFormatToString(format), +Cobalt */ icu::DateIntervalFormat::createInstance(icu::UnicodeString(DateFormatToString(format)), status)); diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc index 9fa0c7edb000..d1853f853f18 100644 --- a/base/metrics/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -1046,6 +1046,7 @@ FieldTrialList* FieldTrialList::BackupInstanceForTesting() { void FieldTrialList::RestoreInstanceForTesting(FieldTrialList* instance) { global_ = instance; } + #ifdef COBALT_PENDING_CLEAN_UP // TODO(b/298237462): Try to enable the below code. #elif !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) diff --git a/base/metrics/histogram_macros_local.h b/base/metrics/histogram_macros_local.h index 6a574f7f5f7f..2a2f29f9c290 100644 --- a/base/metrics/histogram_macros_local.h +++ b/base/metrics/histogram_macros_local.h @@ -16,6 +16,7 @@ // Enumeration histograms. // // For usage details, see the equivalents in histogram_macros.h. + #define CR_GET_ARG(arg) arg #define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \ CR_GET_ARG(INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \ diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc index 13a847e41d54..c4976fd425e4 100644 --- a/base/metrics/persistent_memory_allocator.cc +++ b/base/metrics/persistent_memory_allocator.cc @@ -5,7 +5,6 @@ #include "base/metrics/persistent_memory_allocator.h" #include -#include #include @@ -1036,7 +1035,6 @@ void LocalPersistentMemoryAllocator::DeallocateLocalMemory(void* memory, } DCHECK_EQ(MEM_VIRTUAL, type); - #if defined(STARBOARD) #elif BUILDFLAG(IS_WIN) BOOL success = ::VirtualFree(memory, 0, MEM_DECOMMIT); @@ -1075,8 +1073,8 @@ bool WritableSharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( } #endif // !defined(STARBOARD) - //----- ReadOnlySharedPersistentMemoryAllocator -------------------------------- + #if !defined(STARBOARD) ReadOnlySharedPersistentMemoryAllocator:: ReadOnlySharedPersistentMemoryAllocator( @@ -1100,7 +1098,6 @@ bool ReadOnlySharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( const base::ReadOnlySharedMemoryMapping& memory) { return IsMemoryAcceptable(memory.memory(), memory.size(), 0, true); } - #endif // !defined(STARBOARD) #if !BUILDFLAG(IS_NACL) diff --git a/base/metrics/persistent_memory_allocator.h b/base/metrics/persistent_memory_allocator.h index 7572e04cc26c..f3e94cf78789 100644 --- a/base/metrics/persistent_memory_allocator.h +++ b/base/metrics/persistent_memory_allocator.h @@ -743,6 +743,7 @@ class BASE_EXPORT LocalPersistentMemoryAllocator static void DeallocateLocalMemory(void* memory, size_t size, MemoryType type); }; + #if !defined(STARBOARD) // This allocator takes a writable shared memory mapping object and performs // allocation from it. The allocator takes ownership of the mapping object. @@ -799,7 +800,6 @@ class BASE_EXPORT ReadOnlySharedPersistentMemoryAllocator private: base::ReadOnlySharedMemoryMapping shared_memory_; }; - #endif // !defined(STARBOARD) // NACL doesn't support any kind of file access in build. diff --git a/base/metrics/persistent_memory_allocator_unittest.cc b/base/metrics/persistent_memory_allocator_unittest.cc index 482238906e24..4d66a1c200af 100644 --- a/base/metrics/persistent_memory_allocator_unittest.cc +++ b/base/metrics/persistent_memory_allocator_unittest.cc @@ -723,7 +723,6 @@ TEST(SharedPersistentMemoryAllocatorTest, CreationTest) { EXPECT_EQ(0, data[2]); EXPECT_EQ(0, data[3]); } - #endif // !defined(STARBOARD) // TODO: b/316198056 - Re-enable this test once base/net have been updated. diff --git a/base/path_service.cc b/base/path_service.cc index e0ec4b1fa017..050f8caf0125 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -206,14 +206,15 @@ bool PathService::Get(int key, FilePath* result) { DCHECK_GT(key, PATH_START); // Special case the current directory because it can never be cached. - if (key == DIR_CURRENT) { + if (key == DIR_CURRENT) #if defined(STARBOARD) + { NOTREACHED() << "DIR_CURRENT not supported in Starboard."; return false; + } #else return GetCurrentDirectory(result); #endif - } Provider* provider = nullptr; { diff --git a/base/profiler/stack_copier_suspend_unittest.cc b/base/profiler/stack_copier_suspend_unittest.cc index 825241506634..e51e57dffc54 100644 --- a/base/profiler/stack_copier_suspend_unittest.cc +++ b/base/profiler/stack_copier_suspend_unittest.cc @@ -64,6 +64,9 @@ class TestSuspendableThreadDelegate : public SuspendableThreadDelegate { RegisterContextStackPointer(thread_context) = reinterpret_cast(&(*fake_stack_)[0]); RegisterContextInstructionPointer(thread_context) = +/* Cobalt + reinterpret_cast((*fake_stack_)[0]); +Cobalt */ static_cast((*fake_stack_)[0]); return true; } diff --git a/base/security_unittest.cc b/base/security_unittest.cc index c35c1ab770f8..6faad637362b 100644 --- a/base/security_unittest.cc +++ b/base/security_unittest.cc @@ -64,8 +64,8 @@ void OverflowTestsSoftExpectTrue(bool overflow_detected) { } } -#if BUILDFLAG(IS_APPLE) || defined(ADDRESS_SANITIZER) || \ - defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ +#if BUILDFLAG(IS_APPLE) || defined(ADDRESS_SANITIZER) || \ + defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ BUILDFLAG(IS_HWASAN) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \ SB_IS(EVERGREEN) #define MAYBE_NewOverflow DISABLED_NewOverflow diff --git a/base/sequence_token.cc b/base/sequence_token.cc index 7201831423b9..a74dc8fedbf1 100644 --- a/base/sequence_token.cc +++ b/base/sequence_token.cc @@ -202,8 +202,7 @@ ScopedSetSequenceTokenForCurrentThread::ScopedSetSequenceTokenForCurrentThread( task_token_resetter_(¤t_task_token, [] { DCHECK(!current_task_token.IsValid()); return TaskToken::Create(); - }()) { -} + }()) {} #endif #if defined(STARBOARD) diff --git a/base/system/sys_info_unittest.cc b/base/system/sys_info_unittest.cc index b0fab7779080..1f8cbbc747bb 100644 --- a/base/system/sys_info_unittest.cc +++ b/base/system/sys_info_unittest.cc @@ -270,7 +270,7 @@ TEST_F(SysInfoTest, GetHardwareInfo) { #if defined(STARBOARD) true; #elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN) || \ - BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) \ + BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) false; #else true; diff --git a/base/task/scoped_set_task_priority_for_current_thread.cc b/base/task/scoped_set_task_priority_for_current_thread.cc index 0653d803e926..74b5cb58adda 100644 --- a/base/task/scoped_set_task_priority_for_current_thread.cc +++ b/base/task/scoped_set_task_priority_for_current_thread.cc @@ -75,8 +75,7 @@ ScopedSetTaskPriorityForCurrentThread::ScopedSetTaskPriorityForCurrentThread( #else : resetter_(&task_priority_for_current_thread, priority, - TaskPriority::USER_BLOCKING) { -} + TaskPriority::USER_BLOCKING) {} #endif #if defined(STARBOARD) diff --git a/base/task/sequence_manager/hierarchical_timing_wheel.h b/base/task/sequence_manager/hierarchical_timing_wheel.h index e92b120211d3..9a1504bf71da 100644 --- a/base/task/sequence_manager/hierarchical_timing_wheel.h +++ b/base/task/sequence_manager/hierarchical_timing_wheel.h @@ -350,6 +350,9 @@ class HierarchicalTimingWheel { private: bool IsHeap(size_t hierarchy_index) { +/* Cobalt + return hierarchy_index == 0 or hierarchy_index == TotalWheels + 1; +Cobalt */ return hierarchy_index == 0 || hierarchy_index == TotalWheels + 1; } diff --git a/base/task/sequence_manager/sequence_manager_impl.cc b/base/task/sequence_manager/sequence_manager_impl.cc index f4c32b9d3c74..9cca2bbf578c 100644 --- a/base/task/sequence_manager/sequence_manager_impl.cc +++ b/base/task/sequence_manager/sequence_manager_impl.cc @@ -366,7 +366,7 @@ void SequenceManagerImpl::BindToMessagePump(std::unique_ptr pump) { } #endif - // On iOS and Starboard attach to the native loop when there is one. + // On iOS attach to the native loop when there is one. #if BUILDFLAG(IS_IOS) || defined(STARBOARD) if (settings_.message_loop_type == MessagePumpType::UI) { controller_->AttachToMessagePump(); diff --git a/base/task/thread_pool/task_tracker.cc b/base/task/thread_pool/task_tracker.cc index 9691270cccf3..8e8d5a62552c 100644 --- a/base/task/thread_pool/task_tracker.cc +++ b/base/task/thread_pool/task_tracker.cc @@ -339,11 +339,10 @@ bool TaskTracker::WillPostTask(Task* task, // A non BLOCK_SHUTDOWN task is allowed to be posted iff shutdown hasn't // started and the task is not delayed. if (shutdown_behavior != TaskShutdownBehavior::BLOCK_SHUTDOWN || - !task->delayed_run_time.is_null() || #if defined(STARBOARD) - GetFizzleBlockShutdownTasks()) { + !task->delayed_run_time.is_null() || GetFizzleBlockShutdownTasks()) { #else - fizzle_block_shutdown_tasks) { + !task->delayed_run_time.is_null() || fizzle_block_shutdown_tasks) { #endif return false; } diff --git a/base/task/thread_pool/test_utils.cc b/base/task/thread_pool/test_utils.cc index 7ef28bab96dd..e163e750f28b 100644 --- a/base/task/thread_pool/test_utils.cc +++ b/base/task/thread_pool/test_utils.cc @@ -265,12 +265,24 @@ MockJobTask::~MockJobTask() = default; MockJobTask::MockJobTask( base::RepeatingCallback worker_task, size_t num_tasks_to_run) +/* Cobalt + : worker_task_(std::move(worker_task)), + remaining_num_tasks_to_run_(num_tasks_to_run) {} +Cobalt */ : task_(std::move(worker_task)), remaining_num_tasks_to_run_(num_tasks_to_run) { CHECK(!absl::get(task_).is_null()); } MockJobTask::MockJobTask(base::OnceClosure worker_task) +/* Cobalt + : worker_task_(base::BindRepeating( + [](base::OnceClosure&& worker_task, JobDelegate*) mutable { + std::move(worker_task).Run(); + }, + base::Passed(std::move(worker_task)))), + remaining_num_tasks_to_run_(1) {} +Cobalt */ : task_(std::move(worker_task)), remaining_num_tasks_to_run_(1) { CHECK(!absl::get(task_).is_null()); } @@ -298,6 +310,11 @@ size_t MockJobTask::GetMaxConcurrency(size_t /* worker_count */) const { } void MockJobTask::Run(JobDelegate* delegate) { +/* Cobalt + worker_task_.Run(delegate); + size_t before = remaining_num_tasks_to_run_.fetch_sub(1); + DCHECK_GT(before, 0U); +Cobalt */ absl::visit( base::Overloaded{ [](OnceClosure& closure) { std::move(closure).Run(); }, diff --git a/base/task/thread_pool/test_utils.h b/base/task/thread_pool/test_utils.h index 49f75213deb0..7437835ba317 100644 --- a/base/task/thread_pool/test_utils.h +++ b/base/task/thread_pool/test_utils.h @@ -98,6 +98,11 @@ class MockJobTask : public base::RefCountedThreadSafe { // Updates the remaining number of time |worker_task| runs to // |num_tasks_to_run|. +/* Cobalt + void SetNumTasksToRun(size_t num_tasks_to_run) { + remaining_num_tasks_to_run_ = num_tasks_to_run; + } +Cobalt */ void SetNumTasksToRun(size_t num_tasks_to_run); size_t GetMaxConcurrency(size_t worker_count) const; @@ -113,6 +118,9 @@ class MockJobTask : public base::RefCountedThreadSafe { ~MockJobTask(); +/* Cobalt + base::RepeatingCallback worker_task_; +Cobalt */ absl::variant> task_; std::atomic_size_t remaining_num_tasks_to_run_; }; diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn index 18f93a328fba..65eebe9a3478 100644 --- a/base/test/BUILD.gn +++ b/base/test/BUILD.gn @@ -413,8 +413,6 @@ shared_library("immediate_crash_test_helper") { if (!use_cobalt_customizations) { # This shared library is dynamically loaded by NativeLibrary unittests. shared_library("test_shared_library") { - install_target = false - build_loader = false testonly = true sources = [ "test_shared_library.cc" ] diff --git a/base/third_party/double_conversion/LICENSE b/base/third_party/double_conversion/LICENSE new file mode 100644 index 000000000000..933718a9ef9d --- /dev/null +++ b/base/third_party/double_conversion/LICENSE @@ -0,0 +1,26 @@ +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/base/third_party/symbolize/LICENSE b/base/third_party/symbolize/LICENSE new file mode 100644 index 000000000000..433a3d1512c7 --- /dev/null +++ b/base/third_party/symbolize/LICENSE @@ -0,0 +1,28 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc index d1d190fcbf2b..5f32a35d769b 100644 --- a/base/time/time_unittest.cc +++ b/base/time/time_unittest.cc @@ -5,7 +5,6 @@ #include "base/time/time.h" #include - #include #include @@ -1047,6 +1046,7 @@ TEST_F(TimeTest, Explode_Y10KCompliance) { // A very long time ago. {Time::Min(), Time::Exploded{-290677, 12, 4, 23, 19, 59, 5, 224}}, #endif + // Before/On/After 1 Jan 1601. {make_time(-kHalfYearInMicros), Time::Exploded{1600, 7, 1, 3, 0, 0, 0, 0}}, @@ -1092,6 +1092,7 @@ TEST_F(TimeTest, Explode_Y10KCompliance) { Time::Exploded{287396, 10, 3, 12, 8, 59, 0, 992}}, {make_time(kIcuMaxMicrosOffset + kHalfYearInMicros), Time::Exploded{287397, 4, 3, 12, 8, 59, 0, 992}}, + #if !defined(STARBOARD) // A very long time from now. {Time::Max(), Time::Exploded{293878, 1, 4, 10, 4, 0, 54, 775}}, diff --git a/base/trace_event/trace_log.h b/base/trace_event/trace_log.h index e0b68f0d0a6a..cd0721102546 100644 --- a/base/trace_event/trace_log.h +++ b/base/trace_event/trace_log.h @@ -106,7 +106,7 @@ class BASE_EXPORT TraceLog : #endif // Disables tracing for all categories. Only RECORDING_MODE is supported. - void SetDisabled() {} + void SetDisabled(); void SetDisabled(uint8_t modes_to_disable) {} // Returns true if TraceLog is enabled on recording mode. diff --git a/base/values.h b/base/values.h index ed29743a0234..c8a30d63eeff 100644 --- a/base/values.h +++ b/base/values.h @@ -432,6 +432,9 @@ class BASE_EXPORT GSL_OWNER Value { Value* Set(StringPiece key, Value&& value) &; Value* Set(StringPiece key, bool value) &; template +/* Cobalt + Value* Set(StringPiece, const T*) = delete; +Cobalt */ Value* Set(StringPiece, const T*) & = delete; Value* Set(StringPiece key, int value) &; Value* Set(StringPiece key, double value) &; @@ -668,6 +671,9 @@ class BASE_EXPORT GSL_OWNER Value { void Append(Value&& value) &; void Append(bool value) &; template +/* Cobalt + void Append(const T*) = delete; +Cobalt */ void Append(const T*) & = delete; void Append(int value) &; void Append(double value) &;