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());
}
}
#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),
// 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++;
if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode();
- allocation_sites_scratchpad_length = 0;
+ FlushAllocationSitesScratchpad();
if (FLAG_trace_pretenuring_statistics &&
(allocation_mementos_found > 0 ||
// 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();
}
+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)]);
}
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) \
// 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 };
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;