| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 3fac6018b02a2f4db95a9aa1ba5a5025de275a37..c52d06de30dd764f811df313d4091bb4120c3aa2 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -2877,6 +2877,16 @@ 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;
|
| + AllocationSite::cast(result)->Initialize();
|
| + return result;
|
| +}
|
| +
|
| +
|
| MaybeObject* Heap::CreateOddball(const char* to_string,
|
| Object* to_number,
|
| byte kind) {
|
| @@ -4182,7 +4192,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 +4208,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 +4467,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);
|
| @@ -4482,8 +4492,8 @@ MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
|
| AllocationSpace space = NEW_SPACE;
|
| if (map->instance_size() > Page::kMaxNonCodeHeapObjectSize) space = LO_SPACE;
|
| Object* obj;
|
| - MaybeObject* maybe_obj = AllocateWithAllocationSite(map, space,
|
| - allocation_site_info_payload);
|
| + MaybeObject* maybe_obj =
|
| + AllocateWithAllocationSite(map, space, allocation_site);
|
| if (!maybe_obj->To(&obj)) return maybe_obj;
|
|
|
| // Initialize the JSObject.
|
| @@ -4519,7 +4529,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 +4543,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 +4551,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 +4652,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 +4904,9 @@ 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);
|
| }
|
|
|
|
|
|
|