Commit 54723cae authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

v8: Build with -Wexit-time-destructors.

Bug: chromium:101600, v8:8257
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ie6c4f80cdec855355c0b8985e4f8a88da2ddfef9
Reviewed-on: https://chromium-review.googlesource.com/c/1273322Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56538}
parent 1e06ed35
...@@ -224,10 +224,10 @@ config("internal_config") { ...@@ -224,10 +224,10 @@ config("internal_config") {
"$target_gen_dir", "$target_gen_dir",
] ]
defines = [] configs = [ "//build/config/compiler:wexit_time_destructors" ]
if (is_component_build) { if (is_component_build) {
defines += [ "BUILDING_V8_SHARED" ] defines = [ "BUILDING_V8_SHARED" ]
} }
} }
......
...@@ -45,13 +45,16 @@ struct InitializePageAllocator { ...@@ -45,13 +45,16 @@ struct InitializePageAllocator {
v8::PageAllocator* page_allocator = v8::PageAllocator* page_allocator =
V8::GetCurrentPlatform()->GetPageAllocator(); V8::GetCurrentPlatform()->GetPageAllocator();
if (page_allocator == nullptr) { if (page_allocator == nullptr) {
static v8::base::PageAllocator default_allocator; // On the heap and leaked so that no destructor needs to run at exit time.
page_allocator = &default_allocator; static auto* default_allocator = new v8::base::PageAllocator;
page_allocator = default_allocator;
} }
#if defined(LEAK_SANITIZER) #if defined(LEAK_SANITIZER)
{ {
static v8::base::LsanPageAllocator lsan_allocator(page_allocator); // On the heap and leaked so that no destructor needs to run at exit time.
page_allocator = &lsan_allocator; static auto* lsan_allocator =
new v8::base::LsanPageAllocator(page_allocator);
page_allocator = lsan_allocator;
} }
#endif #endif
*page_allocator_ptr = page_allocator; *page_allocator_ptr = page_allocator;
......
...@@ -417,8 +417,9 @@ class WasmVirtualScript : public V8DebuggerScript { ...@@ -417,8 +417,9 @@ class WasmVirtualScript : public V8DebuggerScript {
private: private:
static const String16& emptyString() { static const String16& emptyString() {
static const String16 singleEmptyString; // On the heap and leaked so that no destructor needs to run at exit time.
return singleEmptyString; static const String16* singleEmptyString = new String16;
return *singleEmptyString;
} }
v8::Local<v8::debug::Script> script() const override { v8::Local<v8::debug::Script> script() const override {
......
...@@ -135,9 +135,9 @@ const std::vector<PatternData> CreateCommonData(const PatternData& hour_data) { ...@@ -135,9 +135,9 @@ const std::vector<PatternData> CreateCommonData(const PatternData& hour_data) {
const std::vector<PatternData> CreateData(const char* digit2, const std::vector<PatternData> CreateData(const char* digit2,
const char* numeric) { const char* numeric) {
static std::vector<const char*> k2DigitNumeric = {"2-digit", "numeric"}; return CreateCommonData(
return CreateCommonData(PatternData( PatternData("hour", {{digit2, "2-digit"}, {numeric, "numeric"}},
"hour", {{digit2, "2-digit"}, {numeric, "numeric"}}, k2DigitNumeric)); {"2-digit", "numeric"}));
} }
const std::vector<PatternData> GetPatternData(HourOption option) { const std::vector<PatternData> GetPatternData(HourOption option) {
...@@ -754,8 +754,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize( ...@@ -754,8 +754,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize(
// 7. Let hourCycle be ? GetOption(options, "hourCycle", "string", « "h11", // 7. Let hourCycle be ? GetOption(options, "hourCycle", "string", « "h11",
// "h12", "h23", "h24" », undefined). // "h12", "h23", "h24" », undefined).
static std::vector<const char*> hour_cycle_values = {"h11", "h12", "h23", const std::vector<const char*> hour_cycle_values{"h11", "h12", "h23", "h24"};
"h24"};
std::unique_ptr<char[]> hour_cycle = nullptr; std::unique_ptr<char[]> hour_cycle = nullptr;
Maybe<bool> maybe_hour_cycle = Maybe<bool> maybe_hour_cycle =
Intl::GetStringOption(isolate, options, "hourCycle", hour_cycle_values, Intl::GetStringOption(isolate, options, "hourCycle", hour_cycle_values,
...@@ -785,7 +784,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize( ...@@ -785,7 +784,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::Initialize(
DCHECK(!icu_locale.isBogus()); DCHECK(!icu_locale.isBogus());
// 17. Let timeZone be ? Get(options, "timeZone"). // 17. Let timeZone be ? Get(options, "timeZone").
static std::vector<const char*> empty_values = {}; const std::vector<const char*> empty_values;
std::unique_ptr<char[]> timezone = nullptr; std::unique_ptr<char[]> timezone = nullptr;
Maybe<bool> maybe_timezone = Maybe<bool> maybe_timezone =
Intl::GetStringOption(isolate, options, "timeZone", empty_values, Intl::GetStringOption(isolate, options, "timeZone", empty_values,
......
...@@ -113,22 +113,23 @@ bool ContainsUpperCase(const std::string& s) { ...@@ -113,22 +113,23 @@ bool ContainsUpperCase(const std::string& s) {
// keywords, e.g.: 'True', 'Undefined', etc. // keywords, e.g.: 'True', 'Undefined', etc.
// These do not need to follow the default naming convention for constants. // These do not need to follow the default naming convention for constants.
bool IsKeywordLikeName(const std::string& s) { bool IsKeywordLikeName(const std::string& s) {
static const std::vector<std::string> keyword_like_constants{ static const char* const keyword_like_constants[]{"True", "False", "Hole",
"True", "False", "Hole", "Null", "Undefined"}; "Null", "Undefined"};
return std::find(keyword_like_constants.begin(), keyword_like_constants.end(), return std::find(std::begin(keyword_like_constants),
s) != keyword_like_constants.end(); std::end(keyword_like_constants),
s) != std::end(keyword_like_constants);
} }
// Untagged/MachineTypes like 'int32', 'intptr' etc. follow a 'all-lowercase' // Untagged/MachineTypes like 'int32', 'intptr' etc. follow a 'all-lowercase'
// naming convention and are those exempt from the normal type convention. // naming convention and are those exempt from the normal type convention.
bool IsMachineType(const std::string& s) { bool IsMachineType(const std::string& s) {
static const std::vector<std::string> machine_types{ static const char* const machine_types[]{
"void", "never", "int32", "uint32", "int64", "intptr", "void", "never", "int32", "uint32", "int64", "intptr",
"uintptr", "float32", "float64", "bool", "string", "int31"}; "uintptr", "float32", "float64", "bool", "string", "int31"};
return std::find(machine_types.begin(), machine_types.end(), s) != return std::find(std::begin(machine_types), std::end(machine_types), s) !=
machine_types.end(); std::end(machine_types);
} }
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment