Commit d0e0bf21 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup] Cleanup Isolate constructor

by using C++11's default field initializers.

Bug: v8:8238
Change-Id: I3f5f4994114da61efb5b3c22681e6c472cf6e3dc
Reviewed-on: https://chromium-review.googlesource.com/c/1302054
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57074}
parent be65511d
......@@ -15,8 +15,6 @@
namespace v8 {
namespace internal {
StackGuard::StackGuard() : isolate_(nullptr) {}
void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) {
DCHECK_NOT_NULL(isolate_);
thread_local_.set_jslimit(kInterruptLimit);
......
......@@ -67,6 +67,8 @@ class InterruptsScope;
// invocation.
class V8_EXPORT_PRIVATE StackGuard final {
public:
StackGuard(Isolate* isolate) : isolate_(isolate) {}
// Pass the address beyond which the stack should not grow. The stack
// is assumed to grow downwards.
void SetStackLimit(uintptr_t limit);
......@@ -136,8 +138,6 @@ class V8_EXPORT_PRIVATE StackGuard final {
Object* HandleInterrupts();
private:
StackGuard();
bool CheckInterrupt(InterruptFlag flag);
void RequestInterrupt(InterruptFlag flag);
void ClearInterrupt(InterruptFlag flag);
......
......@@ -130,7 +130,8 @@ class IdleScavengeObserver : public AllocationObserver {
};
Heap::Heap()
: initial_max_old_generation_size_(max_old_generation_size_),
: isolate_(isolate()),
initial_max_old_generation_size_(max_old_generation_size_),
initial_old_generation_size_(max_old_generation_size_ /
kInitalOldGenerationLimitFactor),
memory_pressure_level_(MemoryPressureLevel::kNone),
......
......@@ -2662,91 +2662,21 @@ void Isolate::Delete(Isolate* isolate) {
}
Isolate::Isolate()
: entry_stack_(nullptr),
stack_trace_nesting_level_(0),
incomplete_message_(nullptr),
bootstrapper_(nullptr),
runtime_profiler_(nullptr),
compilation_cache_(nullptr),
logger_(nullptr),
load_stub_cache_(nullptr),
store_stub_cache_(nullptr),
deoptimizer_data_(nullptr),
deoptimizer_lazy_throw_(false),
materialized_object_store_(nullptr),
capture_stack_trace_for_uncaught_exceptions_(false),
stack_trace_for_uncaught_exceptions_frame_limit_(0),
stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview),
context_slot_cache_(nullptr),
descriptor_lookup_cache_(nullptr),
handle_scope_implementer_(nullptr),
unicode_cache_(nullptr),
: id_(base::Relaxed_AtomicIncrement(&isolate_counter_, 1)),
stack_guard_(this),
allocator_(FLAG_trace_zone_stats ? new VerboseAccountingAllocator(
&heap_, 256 * KB, 128 * KB)
: new AccountingAllocator()),
inner_pointer_to_code_cache_(nullptr),
global_handles_(nullptr),
eternal_handles_(nullptr),
thread_manager_(nullptr),
builtins_(this),
setup_delegate_(nullptr),
regexp_stack_(nullptr),
date_cache_(nullptr),
// TODO(bmeurer) Initialized lazily because it depends on flags; can
// be fixed once the default isolate cleanup is done.
random_number_generator_(nullptr),
fuzzer_rng_(nullptr),
rail_mode_(PERFORMANCE_ANIMATION),
atomics_wait_callback_(nullptr),
atomics_wait_callback_data_(nullptr),
promise_hook_(nullptr),
host_import_module_dynamically_callback_(nullptr),
host_initialize_import_meta_object_callback_(nullptr),
load_start_time_ms_(0),
#ifdef V8_INTL_SUPPORT
#if USE_CHROMIUM_ICU == 0 && U_ICU_VERSION_MAJOR_NUM < 63
language_singleton_regexp_matcher_(nullptr),
language_tag_regexp_matcher_(nullptr),
language_variant_regexp_matcher_(nullptr),
#endif // USE_CHROMIUM_ICU == 0 && U_ICU_VERSION_MAJOR_NUM < 63
default_locale_(""),
#endif // V8_INTL_SUPPORT
serializer_enabled_(false),
has_fatal_error_(false),
initialized_from_snapshot_(false),
is_tail_call_elimination_enabled_(true),
is_isolate_in_background_(false),
memory_savings_mode_active_(false),
heap_profiler_(nullptr),
code_event_dispatcher_(new CodeEventDispatcher()),
function_entry_hook_(nullptr),
deferred_handles_head_(nullptr),
optimizing_compile_dispatcher_(nullptr),
stress_deopt_count_(0),
force_slow_path_(false),
next_optimization_id_(0),
#if V8_SFI_HAS_UNIQUE_ID
next_unique_sfi_id_(0),
#endif
is_running_microtasks_(false),
use_counter_callback_(nullptr),
cancelable_task_manager_(new CancelableTaskManager()),
abort_on_uncaught_exception_callback_(nullptr),
total_regexp_code_generated_(0) {
CheckIsolateLayout();
id_ = base::Relaxed_AtomicIncrement(&isolate_counter_, 1);
cancelable_task_manager_(new CancelableTaskManager()) {
TRACE_ISOLATE(constructor);
memset(isolate_addresses_, 0,
sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1));
heap_.isolate_ = this;
stack_guard_.isolate_ = this;
CheckIsolateLayout();
// ThreadManager is initialized early to support locking an isolate
// before it is entered.
thread_manager_ = new ThreadManager();
thread_manager_->isolate_ = this;
thread_manager_ = new ThreadManager(this);
handle_scope_data_.Initialize();
......@@ -3833,6 +3763,8 @@ static base::RandomNumberGenerator* ensure_rng_exists(
}
base::RandomNumberGenerator* Isolate::random_number_generator() {
// TODO(bmeurer) Initialized lazily because it depends on flags; can
// be fixed once the default isolate cleanup is done.
return ensure_rng_exists(&random_number_generator_, FLAG_random_seed);
}
......
......@@ -1693,89 +1693,92 @@ class Isolate final : private HiddenFactory {
Heap heap_;
base::Atomic32 id_;
EntryStackItem* entry_stack_;
int stack_trace_nesting_level_;
StringStream* incomplete_message_;
Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT
Bootstrapper* bootstrapper_;
RuntimeProfiler* runtime_profiler_;
CompilationCache* compilation_cache_;
EntryStackItem* entry_stack_ = nullptr;
int stack_trace_nesting_level_ = 0;
StringStream* incomplete_message_ = nullptr;
Address isolate_addresses_[kIsolateAddressCount + 1] = {};
Bootstrapper* bootstrapper_ = nullptr;
RuntimeProfiler* runtime_profiler_ = nullptr;
CompilationCache* compilation_cache_ = nullptr;
std::shared_ptr<Counters> async_counters_;
base::RecursiveMutex break_access_;
Logger* logger_;
Logger* logger_ = nullptr;
StackGuard stack_guard_;
StubCache* load_stub_cache_;
StubCache* store_stub_cache_;
DeoptimizerData* deoptimizer_data_;
bool deoptimizer_lazy_throw_;
MaterializedObjectStore* materialized_object_store_;
StubCache* load_stub_cache_ = nullptr;
StubCache* store_stub_cache_ = nullptr;
DeoptimizerData* deoptimizer_data_ = nullptr;
bool deoptimizer_lazy_throw_ = false;
MaterializedObjectStore* materialized_object_store_ = nullptr;
ThreadLocalTop thread_local_top_;
bool capture_stack_trace_for_uncaught_exceptions_;
int stack_trace_for_uncaught_exceptions_frame_limit_;
StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_;
ContextSlotCache* context_slot_cache_;
DescriptorLookupCache* descriptor_lookup_cache_;
bool capture_stack_trace_for_uncaught_exceptions_ = false;
int stack_trace_for_uncaught_exceptions_frame_limit_ = 0;
StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_ =
StackTrace::kOverview;
ContextSlotCache* context_slot_cache_ = nullptr;
DescriptorLookupCache* descriptor_lookup_cache_ = nullptr;
HandleScopeData handle_scope_data_;
HandleScopeImplementer* handle_scope_implementer_;
UnicodeCache* unicode_cache_;
AccountingAllocator* allocator_;
InnerPointerToCodeCache* inner_pointer_to_code_cache_;
GlobalHandles* global_handles_;
EternalHandles* eternal_handles_;
ThreadManager* thread_manager_;
HandleScopeImplementer* handle_scope_implementer_ = nullptr;
UnicodeCache* unicode_cache_ = nullptr;
AccountingAllocator* allocator_ = nullptr;
InnerPointerToCodeCache* inner_pointer_to_code_cache_ = nullptr;
GlobalHandles* global_handles_ = nullptr;
EternalHandles* eternal_handles_ = nullptr;
ThreadManager* thread_manager_ = nullptr;
RuntimeState runtime_state_;
Builtins builtins_;
SetupIsolateDelegate* setup_delegate_;
SetupIsolateDelegate* setup_delegate_ = nullptr;
unibrow::Mapping<unibrow::Ecma262UnCanonicalize> jsregexp_uncanonicalize_;
unibrow::Mapping<unibrow::CanonicalizationRange> jsregexp_canonrange_;
unibrow::Mapping<unibrow::Ecma262Canonicalize>
regexp_macro_assembler_canonicalize_;
RegExpStack* regexp_stack_;
RegExpStack* regexp_stack_ = nullptr;
std::vector<int> regexp_indices_;
DateCache* date_cache_;
base::RandomNumberGenerator* random_number_generator_;
base::RandomNumberGenerator* fuzzer_rng_;
DateCache* date_cache_ = nullptr;
base::RandomNumberGenerator* random_number_generator_ = nullptr;
base::RandomNumberGenerator* fuzzer_rng_ = nullptr;
base::AtomicValue<RAILMode> rail_mode_;
v8::Isolate::AtomicsWaitCallback atomics_wait_callback_;
void* atomics_wait_callback_data_;
PromiseHook promise_hook_;
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_;
v8::Isolate::AtomicsWaitCallback atomics_wait_callback_ = nullptr;
void* atomics_wait_callback_data_ = nullptr;
PromiseHook promise_hook_ = nullptr;
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_ =
nullptr;
HostInitializeImportMetaObjectCallback
host_initialize_import_meta_object_callback_;
host_initialize_import_meta_object_callback_ = nullptr;
base::Mutex rail_mutex_;
double load_start_time_ms_;
double load_start_time_ms_ = 0;
#ifdef V8_INTL_SUPPORT
#if USE_CHROMIUM_ICU == 0 && U_ICU_VERSION_MAJOR_NUM < 63
icu::RegexMatcher* language_singleton_regexp_matcher_;
icu::RegexMatcher* language_tag_regexp_matcher_;
icu::RegexMatcher* language_variant_regexp_matcher_;
icu::RegexMatcher* language_singleton_regexp_matcher_ = nullptr;
icu::RegexMatcher* language_tag_regexp_matcher_ = nullptr;
icu::RegexMatcher* language_variant_regexp_matcher_ = nullptr;
#endif // USE_CHROMIUM_ICU == 0 && U_ICU_VERSION_MAJOR_NUM < 63
std::string default_locale_;
#endif // V8_INTL_SUPPORT
// Whether the isolate has been created for snapshotting.
bool serializer_enabled_;
bool serializer_enabled_ = false;
// True if fatal error has been signaled for this isolate.
bool has_fatal_error_;
bool has_fatal_error_ = false;
// True if this isolate was initialized from a snapshot.
bool initialized_from_snapshot_;
bool initialized_from_snapshot_ = false;
// TODO(ishell): remove
// True if ES2015 tail call elimination feature is enabled.
bool is_tail_call_elimination_enabled_;
bool is_tail_call_elimination_enabled_ = true;
// True if the isolate is in background. This flag is used
// to prioritize between memory usage and latency.
bool is_isolate_in_background_;
bool is_isolate_in_background_ = false;
// True if the isolate is in memory savings mode. This flag is used to
// favor memory over runtime performance.
bool memory_savings_mode_active_;
bool memory_savings_mode_active_ = false;
// Time stamp at initialization.
double time_millis_at_init_;
double time_millis_at_init_ = 0;
#ifdef DEBUG
static std::atomic<size_t> non_disposed_isolates_;
......@@ -1783,19 +1786,19 @@ class Isolate final : private HiddenFactory {
JSObject::SpillInformation js_spill_information_;
#endif
Debug* debug_;
HeapProfiler* heap_profiler_;
Debug* debug_ = nullptr;
HeapProfiler* heap_profiler_ = nullptr;
std::unique_ptr<CodeEventDispatcher> code_event_dispatcher_;
FunctionEntryHook function_entry_hook_;
FunctionEntryHook function_entry_hook_ = nullptr;
const AstStringConstants* ast_string_constants_;
const AstStringConstants* ast_string_constants_ = nullptr;
interpreter::Interpreter* interpreter_;
interpreter::Interpreter* interpreter_ = nullptr;
compiler::PerIsolateCompilerCache* compiler_cache_ = nullptr;
Zone* compiler_zone_ = nullptr;
CompilerDispatcher* compiler_dispatcher_;
CompilerDispatcher* compiler_dispatcher_ = nullptr;
typedef std::pair<InterruptCallback, void*> InterruptEntry;
std::queue<InterruptEntry> api_interrupts_queue_;
......@@ -1821,18 +1824,18 @@ class Isolate final : private HiddenFactory {
#undef ISOLATE_FIELD_OFFSET
#endif
DeferredHandles* deferred_handles_head_;
OptimizingCompileDispatcher* optimizing_compile_dispatcher_;
DeferredHandles* deferred_handles_head_ = nullptr;
OptimizingCompileDispatcher* optimizing_compile_dispatcher_ = nullptr;
// Counts deopt points if deopt_every_n_times is enabled.
unsigned int stress_deopt_count_;
unsigned int stress_deopt_count_ = 0;
bool force_slow_path_;
bool force_slow_path_ = false;
int next_optimization_id_;
int next_optimization_id_ = 0;
#if V8_SFI_HAS_UNIQUE_ID
int next_unique_sfi_id_;
int next_unique_sfi_id_ = 0;
#endif
// Vector of callbacks before a Call starts execution.
......@@ -1843,9 +1846,9 @@ class Isolate final : private HiddenFactory {
// Vector of callbacks after microtasks were run.
std::vector<MicrotasksCompletedCallback> microtasks_completed_callbacks_;
bool is_running_microtasks_;
bool is_running_microtasks_ = false;
v8::Isolate::UseCounterCallback use_counter_callback_;
v8::Isolate::UseCounterCallback use_counter_callback_ = nullptr;
std::vector<Object*> read_only_object_cache_;
std::vector<Object*> partial_snapshot_cache_;
......@@ -1859,11 +1862,11 @@ class Isolate final : private HiddenFactory {
const uint8_t* embedded_blob_ = nullptr;
uint32_t embedded_blob_size_ = 0;
v8::ArrayBuffer::Allocator* array_buffer_allocator_;
v8::ArrayBuffer::Allocator* array_buffer_allocator_ = nullptr;
FutexWaitListNode futex_wait_list_node_;
CancelableTaskManager* cancelable_task_manager_;
CancelableTaskManager* cancelable_task_manager_ = nullptr;
debug::ConsoleDelegate* console_delegate_ = nullptr;
......@@ -1873,14 +1876,14 @@ class Isolate final : private HiddenFactory {
int async_task_count_ = 0;
v8::Isolate::AbortOnUncaughtExceptionCallback
abort_on_uncaught_exception_callback_;
abort_on_uncaught_exception_callback_ = nullptr;
bool allow_atomics_wait_;
bool allow_atomics_wait_ = true;
base::Mutex managed_ptr_destructors_mutex_;
ManagedPtrDestructor* managed_ptr_destructors_head_ = nullptr;
size_t total_regexp_code_generated_;
size_t total_regexp_code_generated_ = 0;
size_t elements_deletion_counter_ = 0;
......
......@@ -238,12 +238,13 @@ ThreadState* ThreadState::Next() {
// Thread ids must start with 1, because in TLS having thread id 0 can't
// be distinguished from not having a thread id at all (since NULL is
// defined as 0.)
ThreadManager::ThreadManager()
ThreadManager::ThreadManager(Isolate* isolate)
: mutex_owner_(ThreadId::Invalid()),
lazily_archived_thread_(ThreadId::Invalid()),
lazily_archived_thread_state_(nullptr),
free_anchor_(nullptr),
in_use_anchor_(nullptr) {
in_use_anchor_(nullptr),
isolate_(isolate) {
free_anchor_ = new ThreadState(this);
in_use_anchor_ = new ThreadState(this);
}
......
......@@ -88,7 +88,7 @@ class ThreadManager {
ThreadState* GetFreeThreadState();
private:
ThreadManager();
explicit ThreadManager(Isolate* isolate);
~ThreadManager();
void DeleteThreadStateList(ThreadState* anchor);
......
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