Revision: 4881
Author: lukezarko
Date: Wed Jun 16 09:04:30 2010
Log: [Isolates] Make instance variables of Heap non-static.
Review URL: http://codereview.chromium.org/2827008
http://code.google.com/p/v8/source/detail?r=4881
Modified:
/branches/experimental/isolates/src/factory.h
/branches/experimental/isolates/src/heap.cc
/branches/experimental/isolates/src/heap.h
=======================================
--- /branches/experimental/isolates/src/factory.h Wed Apr 28 05:05:40 2010
+++ /branches/experimental/isolates/src/factory.h Wed Jun 16 09:04:30 2010
@@ -326,7 +326,7 @@
#define ROOT_ACCESSOR(type, name,
camel_name) \
static inline Handle<type> name()
{ \
return Handle<type>(BitCast<type**,
Object**>( \
-
&Heap::roots_[Heap::k##camel_name##RootIndex])); \
+
&Isolate::Current()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
}
ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR_ACCESSOR
@@ -334,13 +334,13 @@
#define SYMBOL_ACCESSOR(name, str) \
static inline Handle<String> name()
{ \
return Handle<String>(BitCast<String**,
Object**>( \
-
&Heap::roots_[Heap::k##name##RootIndex])); \
+
&Isolate::Current()->heap()->roots_[Heap::k##name##RootIndex])); \
}
SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
static Handle<String> hidden_symbol() {
- return Handle<String>(&Heap::hidden_symbol_);
+ return Handle<String>(&Isolate::Current()->heap()->hidden_symbol_);
}
static Handle<SharedFunctionInfo> NewSharedFunctionInfo(
=======================================
--- /branches/experimental/isolates/src/heap.cc Tue Jun 15 12:28:12 2010
+++ /branches/experimental/isolates/src/heap.cc Wed Jun 16 09:04:30 2010
@@ -56,97 +56,74 @@
namespace internal {
-String* Heap::hidden_symbol_;
-Object* Heap::roots_[Heap::kRootListLength];
-
-
-NewSpace Heap::new_space_;
-OldSpace* Heap::old_pointer_space_ = NULL;
-OldSpace* Heap::old_data_space_ = NULL;
-OldSpace* Heap::code_space_ = NULL;
-MapSpace* Heap::map_space_ = NULL;
-CellSpace* Heap::cell_space_ = NULL;
-LargeObjectSpace* Heap::lo_space_ = NULL;
-
static const int kMinimumPromotionLimit = 2*MB;
static const int kMinimumAllocationLimit = 8*MB;
-int Heap::old_gen_promotion_limit_ = kMinimumPromotionLimit;
-int Heap::old_gen_allocation_limit_ = kMinimumAllocationLimit;
-
-int Heap::old_gen_exhausted_ = false;
-
-int Heap::amount_of_external_allocated_memory_ = 0;
-int Heap::amount_of_external_allocated_memory_at_last_global_gc_ = 0;
-
+
+int GCTracer::alive_after_last_gc_ = 0;
+double GCTracer::last_gc_end_timestamp_ = 0.0;
+int GCTracer::max_gc_pause_ = 0;
+int GCTracer::max_alive_after_gc_ = 0;
+int GCTracer::min_in_mutator_ = kMaxInt;
+
+Heap::Heap()
+ : isolate_(NULL),
// semispace_size_ should be a power of 2 and old_generation_size_ should
be
// a multiple of Page::kPageSize.
#if defined(ANDROID)
-int Heap::max_semispace_size_ = 2*MB;
-int Heap::max_old_generation_size_ = 192*MB;
-int Heap::initial_semispace_size_ = 128*KB;
-size_t Heap::code_range_size_ = 0;
+ reserved_semispace_size_(2*MB),
+ max_semispace_size_(2*MB),
+ initial_semispace_size_(128*KB),
+ max_old_generation_size_(192*MB),
+ code_range_size_(0),
#elif defined(V8_TARGET_ARCH_X64)
-int Heap::max_semispace_size_ = 16*MB;
-int Heap::max_old_generation_size_ = 1*GB;
-int Heap::initial_semispace_size_ = 1*MB;
-size_t Heap::code_range_size_ = 512*MB;
+ reserved_semispace_size_(16*MB),
+ max_semispace_size_(16*MB),
+ initial_semispace_size_(1*MB),
+ max_old_generation_size_(1*GB),
+ code_range_size_(512*MB),
#else
-int Heap::max_semispace_size_ = 8*MB;
-int Heap::max_old_generation_size_ = 512*MB;
-int Heap::initial_semispace_size_ = 512*KB;
-size_t Heap::code_range_size_ = 0;
+ reserved_semispace_size_(8*MB),
+ max_semispace_size_(8*MB),
+ initial_semispace_size_(512*KB),
+ max_old_generation_size_(512*MB),
+ code_range_size_(0),
#endif
-
-// The snapshot semispace size will be the default semispace size if
-// snapshotting is used and will be the requested semispace size as
-// set up by ConfigureHeap otherwise.
-int Heap::reserved_semispace_size_ = Heap::max_semispace_size_;
-
-List<Heap::GCPrologueCallbackPair> Heap::gc_prologue_callbacks_;
-List<Heap::GCEpilogueCallbackPair> Heap::gc_epilogue_callbacks_;
-
-GCCallback Heap::global_gc_prologue_callback_ = NULL;
-GCCallback Heap::global_gc_epilogue_callback_ = NULL;
-
// Variables set based on semispace_size_ and old_generation_size_ in
-// ConfigureHeap.
-
+// ConfigureHeap (survived_since_last_expansion_,
external_allocation_limit_)
// Will be 4 * reserved_semispace_size_ to ensure that young
// generation can be aligned to its size.
-int Heap::survived_since_last_expansion_ = 0;
-int Heap::external_allocation_limit_ = 0;
-
-Heap::HeapState Heap::gc_state_ = NOT_IN_GC;
-
-int Heap::mc_count_ = 0;
-int Heap::ms_count_ = 0;
-int Heap::gc_count_ = 0;
-
-GCTracer* Heap::tracer_ = NULL;
-
-int Heap::unflattened_strings_length_ = 0;
-
-int Heap::always_allocate_scope_depth_ = 0;
-int Heap::linear_allocation_scope_depth_ = 0;
-int Heap::contexts_disposed_ = 0;
-
+ survived_since_last_expansion_(0),
+ always_allocate_scope_depth_(0),
+ linear_allocation_scope_depth_(0),
+ contexts_disposed_(0),
+ old_pointer_space_(NULL),
+ old_data_space_(NULL),
+ code_space_(NULL),
+ map_space_(NULL),
+ cell_space_(NULL),
+ lo_space_(NULL),
+ gc_state_(NOT_IN_GC),
+ mc_count_(0),
+ ms_count_(0),
+ gc_count_(0),
+ unflattened_strings_length_(0),
#ifdef DEBUG
-bool Heap::allocation_allowed_ = true;
-
-int Heap::allocation_timeout_ = 0;
-bool Heap::disallow_allocation_failure_ = false;
+ allocation_allowed_(true),
+ allocation_timeout_(0),
+ disallow_allocation_failure_(false),
#endif // DEBUG
-
-int GCTracer::alive_after_last_gc_ = 0;
-double GCTracer::last_gc_end_timestamp_ = 0.0;
-int GCTracer::max_gc_pause_ = 0;
-int GCTracer::max_alive_after_gc_ = 0;
-int GCTracer::min_in_mutator_ = kMaxInt;
-
-Heap::Heap() : isolate_(NULL) {
- // TODO(zarko): members that previously relied on static initialization
- // should be initialized here.
+ old_gen_promotion_limit_(kMinimumPromotionLimit),
+ old_gen_allocation_limit_(kMinimumAllocationLimit),
+ external_allocation_limit_(0),
+ amount_of_external_allocated_memory_(0),
+ amount_of_external_allocated_memory_at_last_global_gc_(0),
+ old_gen_exhausted_(false),
+ hidden_symbol_(NULL),
+ global_gc_prologue_callback_(NULL),
+ global_gc_epilogue_callback_(NULL),
+ tracer_(NULL) {
+ memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
}
=======================================
--- /branches/experimental/isolates/src/heap.h Tue Jun 15 12:28:12 2010
+++ /branches/experimental/isolates/src/heap.h Wed Jun 16 09:04:30 2010
@@ -1030,21 +1030,21 @@
// any pointer to Heap.
Isolate* isolate_;
- static int reserved_semispace_size_;
- static int max_semispace_size_;
- static int initial_semispace_size_;
- static int max_old_generation_size_;
- static size_t code_range_size_;
+ int reserved_semispace_size_;
+ int max_semispace_size_;
+ int initial_semispace_size_;
+ int max_old_generation_size_;
+ size_t code_range_size_;
// For keeping track of how much data has survived
// scavenge since last new space expansion.
- static int survived_since_last_expansion_;
-
- static int always_allocate_scope_depth_;
- static int linear_allocation_scope_depth_;
+ int survived_since_last_expansion_;
+
+ int always_allocate_scope_depth_;
+ int linear_allocation_scope_depth_;
// For keeping track of context disposals.
- static int contexts_disposed_;
+ int contexts_disposed_;
#if defined(V8_TARGET_ARCH_X64)
static const int kMaxObjectSizeInNewSpace = 512*KB;
@@ -1052,14 +1052,14 @@
static const int kMaxObjectSizeInNewSpace = 256*KB;
#endif
- static NewSpace new_space_;
- static OldSpace* old_pointer_space_;
- static OldSpace* old_data_space_;
- static OldSpace* code_space_;
- static MapSpace* map_space_;
- static CellSpace* cell_space_;
- static LargeObjectSpace* lo_space_;
- static HeapState gc_state_;
+ NewSpace new_space_;
+ OldSpace* old_pointer_space_;
+ OldSpace* old_data_space_;
+ OldSpace* code_space_;
+ MapSpace* map_space_;
+ CellSpace* cell_space_;
+ LargeObjectSpace* lo_space_;
+ HeapState gc_state_;
// Returns the size of object residing in non new spaces.
int PromotedSpaceSize();
@@ -1067,59 +1067,59 @@
// Returns the amount of external memory registered since last global gc.
int PromotedExternalMemorySize();
- static int mc_count_; // how many mark-compact collections happened
- static int ms_count_; // how many mark-sweep collections happened
- static int gc_count_; // how many gc happened
+ int mc_count_; // how many mark-compact collections happened
+ int ms_count_; // how many mark-sweep collections happened
+ int gc_count_; // how many gc happened
// Total length of the strings we failed to flatten since the last GC.
- static int unflattened_strings_length_;
+ int unflattened_strings_length_;
#define ROOT_ACCESSOR(type, name,
camel_name) \
- static inline void set_##name(type* value)
{ \
+ inline void set_##name(type* value) { \
roots_[k##camel_name##RootIndex] =
value; \
}
ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
#ifdef DEBUG
- static bool allocation_allowed_;
+ bool allocation_allowed_;
// If the --gc-interval flag is set to a positive value, this
// variable holds the value indicating the number of allocations
// remain until the next failure and garbage collection.
- static int allocation_timeout_;
+ int allocation_timeout_;
// Do we expect to be able to handle allocation failure at this
// time?
- static bool disallow_allocation_failure_;
+ bool disallow_allocation_failure_;
#endif // DEBUG
// Limit that triggers a global GC on the next (normally caused) GC.
This
// is checked when we have already decided to do a GC to help determine
// which collector to invoke.
- static int old_gen_promotion_limit_;
+ int old_gen_promotion_limit_;
// Limit that triggers a global GC as soon as is reasonable. This is
// checked before expanding a paged space in the old generation and on
// every allocation in large object space.
- static int old_gen_allocation_limit_;
+ int old_gen_allocation_limit_;
// Limit on the amount of externally allocated memory allowed
// between global GCs. If reached a global GC is forced.
- static int external_allocation_limit_;
+ int external_allocation_limit_;
// The amount of external memory registered through the API kept alive
// by global handles
- static int amount_of_external_allocated_memory_;
+ int amount_of_external_allocated_memory_;
// Caches the amount of external memory registered at the last global gc.
- static int amount_of_external_allocated_memory_at_last_global_gc_;
+ int amount_of_external_allocated_memory_at_last_global_gc_;
// Indicates that an allocation has failed in the old generation since
the
// last GC.
- static int old_gen_exhausted_;
-
- static Object* roots_[kRootListLength];
+ int old_gen_exhausted_;
+
+ Object* roots_[kRootListLength];
struct StringTypeTable {
InstanceType type;
@@ -1144,7 +1144,7 @@
// The special hidden symbol which is an empty string, but does not match
// any string when looked up in properties.
- static String* hidden_symbol_;
+ String* hidden_symbol_;
// GC callback function, called before and after mark-compact GC.
// Allocations in the callback function are disallowed.
@@ -1158,7 +1158,7 @@
GCPrologueCallback callback;
GCType gc_type;
};
- static List<GCPrologueCallbackPair> gc_prologue_callbacks_;
+ List<GCPrologueCallbackPair> gc_prologue_callbacks_;
struct GCEpilogueCallbackPair {
GCEpilogueCallbackPair(GCEpilogueCallback callback, GCType gc_type)
@@ -1170,10 +1170,10 @@
GCEpilogueCallback callback;
GCType gc_type;
};
- static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_;
-
- static GCCallback global_gc_prologue_callback_;
- static GCCallback global_gc_epilogue_callback_;
+ List<GCEpilogueCallbackPair> gc_epilogue_callbacks_;
+
+ GCCallback global_gc_prologue_callback_;
+ GCCallback global_gc_epilogue_callback_;
// Checks whether a global GC is necessary
GarbageCollector SelectGarbageCollector(AllocationSpace space);
@@ -1262,7 +1262,7 @@
SharedFunctionInfo* shared,
Object* prototype);
- static GCTracer* tracer_;
+ GCTracer* tracer_;
// Initializes the number to string cache based on the max semispace
size.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev