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

Side by Side Diff: src/heap.cc

Issue 132963012: Pretenure call new support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment response. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4389 // Allocate the JSObject. 4389 // Allocate the JSObject.
4390 int size = map->instance_size(); 4390 int size = map->instance_size();
4391 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, NOT_TENURED); 4391 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, NOT_TENURED);
4392 Object* obj; 4392 Object* obj;
4393 MaybeObject* maybe_obj = 4393 MaybeObject* maybe_obj =
4394 AllocateWithAllocationSite(map, space, allocation_site); 4394 AllocateWithAllocationSite(map, space, allocation_site);
4395 if (!maybe_obj->To(&obj)) return maybe_obj; 4395 if (!maybe_obj->To(&obj)) return maybe_obj;
4396 4396
4397 // Initialize the JSObject. 4397 // Initialize the JSObject.
4398 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map); 4398 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map);
4399 ASSERT(JSObject::cast(obj)->HasFastElements()); 4399 ASSERT(JSObject::cast(obj)->HasFastElements() ||
4400 JSObject::cast(obj)->HasExternalArrayElements());
4400 return obj; 4401 return obj;
4401 } 4402 }
4402 4403
4403 4404
4404 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, 4405 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor,
4405 PretenureFlag pretenure) { 4406 PretenureFlag pretenure) {
4406 ASSERT(constructor->has_initial_map()); 4407 ASSERT(constructor->has_initial_map());
4407 // Allocate the object based on the constructors initial map. 4408 // Allocate the object based on the constructors initial map.
4408 MaybeObject* result = AllocateJSObjectFromMap( 4409 MaybeObject* result = AllocateJSObjectFromMap(
4409 constructor->initial_map(), pretenure); 4410 constructor->initial_map(), pretenure);
4410 #ifdef DEBUG 4411 #ifdef DEBUG
4411 // Make sure result is NOT a global object if valid. 4412 // Make sure result is NOT a global object if valid.
4412 Object* non_failure; 4413 Object* non_failure;
4413 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 4414 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
4414 #endif 4415 #endif
4415 return result; 4416 return result;
4416 } 4417 }
4417 4418
4418 4419
4419 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor, 4420 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
4420 Handle<AllocationSite> allocation_site) { 4421 Handle<AllocationSite> allocation_site) {
4421 ASSERT(constructor->has_initial_map()); 4422 ASSERT(constructor->has_initial_map());
4422 // Allocate the object based on the constructors initial map, or the payload 4423 // Allocate the object based on the constructors initial map, or the payload
4423 // advice 4424 // advice
4424 Map* initial_map = constructor->initial_map(); 4425 Map* initial_map = constructor->initial_map();
4426 AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
4425 4427
4426 ElementsKind to_kind = allocation_site->GetElementsKind(); 4428 if (initial_map->instance_type() == JS_ARRAY_TYPE) {
4427 AllocationSiteMode mode = TRACK_ALLOCATION_SITE; 4429 ElementsKind to_kind = allocation_site->GetElementsKind();
4428 if (to_kind != initial_map->elements_kind()) { 4430 if (to_kind != initial_map->elements_kind()) {
4429 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); 4431 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind);
4430 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; 4432 if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
4431 // Possibly alter the mode, since we found an updated elements kind 4433 // Possibly alter the mode, since we found an updated elements kind
4432 // in the type info cell. 4434 // in the type info cell.
4433 mode = AllocationSite::GetMode(to_kind); 4435 mode = AllocationSite::GetMode(to_kind);
4436 }
4434 } 4437 }
4435 4438
4436 MaybeObject* result; 4439 MaybeObject* result;
4437 if (mode == TRACK_ALLOCATION_SITE) { 4440 if (mode == TRACK_ALLOCATION_SITE) {
4438 result = AllocateJSObjectFromMapWithAllocationSite(initial_map, 4441 result = AllocateJSObjectFromMapWithAllocationSite(initial_map,
4439 allocation_site); 4442 allocation_site);
4440 } else { 4443 } else {
4441 result = AllocateJSObjectFromMap(initial_map, NOT_TENURED); 4444 result = AllocateJSObjectFromMap(initial_map, NOT_TENURED);
4442 } 4445 }
4443 #ifdef DEBUG 4446 #ifdef DEBUG
(...skipping 3276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7720 static_cast<int>(object_sizes_last_time_[index])); 7723 static_cast<int>(object_sizes_last_time_[index]));
7721 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7724 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7722 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7725 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7723 7726
7724 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7727 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7725 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7728 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7726 ClearObjectStats(); 7729 ClearObjectStats();
7727 } 7730 }
7728 7731
7729 } } // namespace v8::internal 7732 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698