Commit 3f86546b authored by hpayer@chromium.org's avatar hpayer@chromium.org

The allocation sites scratchpad becomes a heap data structure.

BUG=
R=mstarzinger@chromium.org, mvstanton@chromium.org

Review URL: https://codereview.chromium.org/143153008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19189 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4bab63d7
......@@ -5398,7 +5398,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
static const int kEmptyStringRootIndex = 146;
static const int kEmptyStringRootIndex = 147;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
......
......@@ -517,12 +517,8 @@ void Heap::UpdateAllocationSiteFeedback(HeapObject* object) {
AllocationMemento* memento = AllocationMemento::cast(candidate);
if (!memento->IsValid()) return;
if (memento->GetAllocationSite()->IncrementMementoFoundCount() &&
heap->allocation_sites_scratchpad_length <
kAllocationSiteScratchpadSize) {
heap->allocation_sites_scratchpad[
heap->allocation_sites_scratchpad_length++] =
memento->GetAllocationSite();
if (memento->GetAllocationSite()->IncrementMementoFoundCount()) {
heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite());
}
}
......
......@@ -150,7 +150,7 @@ Heap::Heap()
#ifdef VERIFY_HEAP
no_weak_object_verification_scope_depth_(0),
#endif
allocation_sites_scratchpad_length(0),
allocation_sites_scratchpad_length_(0),
promotion_queue_(this),
configured_(false),
external_string_table_(this),
......@@ -516,16 +516,17 @@ void Heap::ProcessPretenuringFeedback() {
// If the scratchpad overflowed, we have to iterate over the allocation
// sites list.
bool use_scratchpad =
allocation_sites_scratchpad_length < kAllocationSiteScratchpadSize;
allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize;
int i = 0;
Object* list_element = allocation_sites_list();
bool trigger_deoptimization = false;
while (use_scratchpad ?
i < allocation_sites_scratchpad_length :
i < allocation_sites_scratchpad_length_ :
list_element->IsAllocationSite()) {
AllocationSite* site = use_scratchpad ?
allocation_sites_scratchpad[i] : AllocationSite::cast(list_element);
AllocationSite::cast(allocation_sites_scratchpad()->get(i)) :
AllocationSite::cast(list_element);
allocation_mementos_found += site->memento_found_count();
if (site->memento_found_count() > 0) {
active_allocation_sites++;
......@@ -546,7 +547,7 @@ void Heap::ProcessPretenuringFeedback() {
if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode();
allocation_sites_scratchpad_length = 0;
FlushAllocationSitesScratchpad();
if (FLAG_trace_pretenuring_statistics &&
(allocation_mementos_found > 0 ||
......@@ -3300,6 +3301,12 @@ bool Heap::CreateInitialObjects() {
// Handling of script id generation is in Factory::NewScript.
set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId));
{ MaybeObject* maybe_obj = AllocateAllocationSitesScratchpad();
if (!maybe_obj->ToObject(&obj)) return false;
}
set_allocation_sites_scratchpad(FixedArray::cast(obj));
InitializeAllocationSitesScratchpad();
// Initialize keyed lookup cache.
isolate_->keyed_lookup_cache()->Clear();
......@@ -3589,6 +3596,39 @@ MaybeObject* Heap::Uint32ToString(uint32_t value,
}
MaybeObject* Heap::AllocateAllocationSitesScratchpad() {
MaybeObject* maybe_obj =
AllocateFixedArray(kAllocationSiteScratchpadSize, TENURED);
return maybe_obj;
}
void Heap::FlushAllocationSitesScratchpad() {
for (int i = 0; i < allocation_sites_scratchpad_length_; i++) {
allocation_sites_scratchpad()->set_undefined(i);
}
allocation_sites_scratchpad_length_ = 0;
}
void Heap::InitializeAllocationSitesScratchpad() {
ASSERT(allocation_sites_scratchpad()->length() ==
kAllocationSiteScratchpadSize);
for (int i = 0; i < kAllocationSiteScratchpadSize; i++) {
allocation_sites_scratchpad()->set_undefined(i);
}
}
void Heap::AddAllocationSiteToScratchpad(AllocationSite* site) {
if (allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize) {
allocation_sites_scratchpad()->set(
allocation_sites_scratchpad_length_, site);
allocation_sites_scratchpad_length_++;
}
}
Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) {
return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]);
}
......
......@@ -202,7 +202,8 @@ namespace internal {
V(SeededNumberDictionary, empty_slow_element_dictionary, \
EmptySlowElementDictionary) \
V(Symbol, observed_symbol, ObservedSymbol) \
V(FixedArray, materialized_objects, MaterializedObjects)
V(FixedArray, materialized_objects, MaterializedObjects) \
V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad)
#define ROOT_LIST(V) \
STRONG_ROOT_LIST(V) \
......@@ -2285,6 +2286,18 @@ class Heap {
// Flush the number to string cache.
void FlushNumberStringCache();
// Allocates a fixed-size allocation sites scratchpad.
MUST_USE_RESULT MaybeObject* AllocateAllocationSitesScratchpad();
// Sets used allocation sites entries to undefined.
void FlushAllocationSitesScratchpad();
// Initializes the allocation sites scratchpad with undefined values.
void InitializeAllocationSitesScratchpad();
// Adds an allocation site to the scratchpad if there is space left.
void AddAllocationSiteToScratchpad(AllocationSite* site);
void UpdateSurvivalRateTrend(int start_new_space_size);
enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING };
......@@ -2457,10 +2470,8 @@ class Heap {
int no_weak_object_verification_scope_depth_;
#endif
static const int kAllocationSiteScratchpadSize = 256;
int allocation_sites_scratchpad_length;
AllocationSite* allocation_sites_scratchpad[kAllocationSiteScratchpadSize];
int allocation_sites_scratchpad_length_;
static const int kMaxMarkSweepsInIdleRound = 7;
static const int kIdleScavengeThreshold = 5;
......
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