Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: src/heap.cc

Issue 15094018: Create AllocationSite objects, pointed to by AllocationSiteInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Platform ports and perf bugfix Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 3fac6018b02a2f4db95a9aa1ba5a5025de275a37..b020716431e522f799a9e9a0d962f5721e9868e7 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2877,6 +2877,17 @@ MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) {
}
+MaybeObject* Heap::AllocateAllocationSite() {
+ Object* result;
+ { MaybeObject* maybe_result = Allocate(allocation_site_map(),
+ OLD_POINTER_SPACE);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
Hannes Payer (out of office) 2013/07/03 15:26:45 why do you need that scope?
mvstanton 2013/07/05 07:56:14 No reason! Removed :).
+ AllocationSite::cast(result)->Initialize();
+ return result;
+}
+
+
MaybeObject* Heap::CreateOddball(const char* to_string,
Object* to_number,
byte kind) {
@@ -4182,7 +4193,7 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
MaybeObject* Heap::AllocateWithAllocationSite(Map* map, AllocationSpace space,
- Handle<Object> allocation_site_info_payload) {
+ Handle<AllocationSite> allocation_site) {
ASSERT(gc_state_ == NOT_IN_GC);
ASSERT(map->instance_type() != MAP_TYPE);
// If allocation failures are disallowed, we may allocate in a different
@@ -4198,7 +4209,7 @@ MaybeObject* Heap::AllocateWithAllocationSite(Map* map, AllocationSpace space,
AllocationSiteInfo* alloc_info = reinterpret_cast<AllocationSiteInfo*>(
reinterpret_cast<Address>(result) + map->instance_size());
alloc_info->set_map_no_write_barrier(allocation_site_info_map());
- alloc_info->set_payload(*allocation_site_info_payload, SKIP_WRITE_BARRIER);
+ alloc_info->set_allocation_site(*allocation_site, SKIP_WRITE_BARRIER);
return result;
}
@@ -4457,7 +4468,7 @@ MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
- Handle<Object> allocation_site_info_payload) {
+ Handle<AllocationSite> allocation_site) {
// JSFunctions should be allocated using AllocateFunction to be
// properly initialized.
ASSERT(map->instance_type() != JS_FUNCTION_TYPE);
@@ -4483,7 +4494,7 @@ MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE;
Object* obj;
MaybeObject* maybe_obj = AllocateWithAllocationSite(map, space,
- allocation_site_info_payload);
+ allocation_site);
Hannes Payer (out of office) 2013/07/03 15:26:45 Can you move AllocateWithAllocationSite into a new
mvstanton 2013/07/05 07:56:14 I *think* I got what you mean. I changed the inden
if (!maybe_obj->To(&obj)) return maybe_obj;
// Initialize the JSObject.
@@ -4519,7 +4530,7 @@ MaybeObject* Heap::AllocateJSObject(JSFunction* constructor,
MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
- Handle<Object> allocation_site_info_payload) {
+ Handle<AllocationSite> allocation_site) {
// Allocate the initial map if absent.
if (!constructor->has_initial_map()) {
Object* initial_map;
@@ -4533,8 +4544,7 @@ MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
// advice
Map* initial_map = constructor->initial_map();
- Cell* cell = Cell::cast(*allocation_site_info_payload);
- Smi* smi = Smi::cast(cell->value());
+ Smi* smi = Smi::cast(allocation_site->payload());
ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
if (to_kind != initial_map->elements_kind()) {
@@ -4542,13 +4552,13 @@ MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
// Possibly alter the mode, since we found an updated elements kind
// in the type info cell.
- mode = AllocationSiteInfo::GetMode(to_kind);
+ mode = AllocationSite::GetMode(to_kind);
}
MaybeObject* result;
if (mode == TRACK_ALLOCATION_SITE) {
result = AllocateJSObjectFromMapWithAllocationSite(initial_map,
- allocation_site_info_payload);
+ allocation_site);
} else {
result = AllocateJSObjectFromMap(initial_map, NOT_TENURED);
}
@@ -4643,10 +4653,10 @@ MaybeObject* Heap::AllocateJSArrayAndStorageWithAllocationSite(
ElementsKind elements_kind,
int length,
int capacity,
- Handle<Object> allocation_site_payload,
+ Handle<AllocationSite> allocation_site,
ArrayStorageAllocationMode mode) {
MaybeObject* maybe_array = AllocateJSArrayWithAllocationSite(elements_kind,
- allocation_site_payload);
+ allocation_site);
JSArray* array;
if (!maybe_array->To(&array)) return maybe_array;
return AllocateJSArrayStorage(array, length, capacity, mode);
@@ -4895,7 +4905,8 @@ MaybeObject* Heap::CopyJSObject(JSObject* source) {
}
-MaybeObject* Heap::CopyJSObjectWithAllocationSite(JSObject* source) {
+MaybeObject* Heap::CopyJSObjectWithAllocationSite(JSObject* source,
+ AllocationSite* site) {
// Never used to copy functions. If functions need to be copied we
// have to be careful to clear the literals array.
SLOW_ASSERT(!source->IsJSFunction());
@@ -4945,7 +4956,7 @@ MaybeObject* Heap::CopyJSObjectWithAllocationSite(JSObject* source) {
AllocationSiteInfo* alloc_info;
if (maybe_alloc_info->To(&alloc_info)) {
alloc_info->set_map_no_write_barrier(allocation_site_info_map());
- alloc_info->set_payload(source, SKIP_WRITE_BARRIER);
+ alloc_info->set_allocation_site(site, SKIP_WRITE_BARRIER);
}
}
} else {
@@ -4967,7 +4978,7 @@ MaybeObject* Heap::CopyJSObjectWithAllocationSite(JSObject* source) {
AllocationSiteInfo* alloc_info = reinterpret_cast<AllocationSiteInfo*>(
reinterpret_cast<Address>(clone) + object_size);
alloc_info->set_map_no_write_barrier(allocation_site_info_map());
- alloc_info->set_payload(source, SKIP_WRITE_BARRIER);
+ alloc_info->set_allocation_site(site, SKIP_WRITE_BARRIER);
}
SLOW_ASSERT(
@@ -5383,7 +5394,7 @@ MaybeObject* Heap::AllocateJSArray(
MaybeObject* Heap::AllocateJSArrayWithAllocationSite(
ElementsKind elements_kind,
- Handle<Object> allocation_site_info_payload) {
+ Handle<AllocationSite> allocation_site) {
Context* native_context = isolate()->context()->native_context();
JSFunction* array_function = native_context->array_function();
Map* map = array_function->initial_map();
@@ -5395,8 +5406,7 @@ MaybeObject* Heap::AllocateJSArrayWithAllocationSite(
map = Map::cast(maybe_transitioned_map);
}
}
- return AllocateJSObjectFromMapWithAllocationSite(map,
- allocation_site_info_payload);
+ return AllocateJSObjectFromMapWithAllocationSite(map, allocation_site);
}

Powered by Google App Engine
This is Rietveld 408576698