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

Side by Side Diff: src/heap.cc

Issue 11817017: Additional work to get array literal allocation tracking working, even with --always-opt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed MIPs changes, and found a bug. COPY_ON_WRITE shallow array stub didn't track allocation inf… Created 7 years, 11 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 4344 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 global->set_map(new_map); 4355 global->set_map(new_map);
4356 global->set_properties(dictionary); 4356 global->set_properties(dictionary);
4357 4357
4358 // Make sure result is a global object with properties in dictionary. 4358 // Make sure result is a global object with properties in dictionary.
4359 ASSERT(global->IsGlobalObject()); 4359 ASSERT(global->IsGlobalObject());
4360 ASSERT(!global->HasFastProperties()); 4360 ASSERT(!global->HasFastProperties());
4361 return global; 4361 return global;
4362 } 4362 }
4363 4363
4364 4364
4365 MaybeObject* Heap::CopyJSObject(JSObject* source) { 4365 MaybeObject* Heap::CopyJSObject(JSObject* source,
4366 AllocationSiteInfoMode mode) {
4366 // Never used to copy functions. If functions need to be copied we 4367 // Never used to copy functions. If functions need to be copied we
4367 // have to be careful to clear the literals array. 4368 // have to be careful to clear the literals array.
4368 SLOW_ASSERT(!source->IsJSFunction()); 4369 SLOW_ASSERT(!source->IsJSFunction());
4369 4370
4370 // Make the clone. 4371 // Make the clone.
4371 Map* map = source->map(); 4372 Map* map = source->map();
4372 int object_size = map->instance_size(); 4373 int object_size = map->instance_size();
4373 Object* clone; 4374 Object* clone;
4374 4375
4376 bool track_origin = mode == TRACK_ALLOCATION_SITE_INFO &&
4377 map->CanTrackAllocationSite();
4378
4375 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; 4379 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER;
4376 4380
4377 // If we're forced to always allocate, we use the general allocation 4381 // If we're forced to always allocate, we use the general allocation
4378 // functions which may leave us with an object in old space. 4382 // functions which may leave us with an object in old space.
4383 int adjusted_object_size = object_size;
4379 if (always_allocate()) { 4384 if (always_allocate()) {
4385 // We'll only track origin if we are certain to allocate in new space
4386 if (track_origin) {
4387 const int kMinFreeNewSpaceAfterGC = InitialSemiSpaceSize() * 3/4;
4388 if ((object_size + AllocationSiteInfo::kSize) < kMinFreeNewSpaceAfterGC) {
4389 adjusted_object_size += AllocationSiteInfo::kSize;
4390 }
4391 }
4392
4380 { MaybeObject* maybe_clone = 4393 { MaybeObject* maybe_clone =
4381 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); 4394 AllocateRaw(adjusted_object_size, NEW_SPACE, OLD_POINTER_SPACE);
4382 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 4395 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
4383 } 4396 }
4384 Address clone_address = HeapObject::cast(clone)->address(); 4397 Address clone_address = HeapObject::cast(clone)->address();
4385 CopyBlock(clone_address, 4398 CopyBlock(clone_address,
4386 source->address(), 4399 source->address(),
4387 object_size); 4400 object_size);
4388 // Update write barrier for all fields that lie beyond the header. 4401 // Update write barrier for all fields that lie beyond the header.
4389 RecordWrites(clone_address, 4402 RecordWrites(clone_address,
4390 JSObject::kHeaderSize, 4403 JSObject::kHeaderSize,
4391 (object_size - JSObject::kHeaderSize) / kPointerSize); 4404 (object_size - JSObject::kHeaderSize) / kPointerSize);
4392 } else { 4405 } else {
4393 wb_mode = SKIP_WRITE_BARRIER; 4406 wb_mode = SKIP_WRITE_BARRIER;
4394 { MaybeObject* maybe_clone = new_space_.AllocateRaw(object_size); 4407 if (track_origin) {
4408 adjusted_object_size += AllocationSiteInfo::kSize;
4409 }
4410
4411 { MaybeObject* maybe_clone = new_space_.AllocateRaw(adjusted_object_size);
4395 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 4412 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
4396 } 4413 }
4397 SLOW_ASSERT(InNewSpace(clone)); 4414 SLOW_ASSERT(InNewSpace(clone));
4398 // Since we know the clone is allocated in new space, we can copy 4415 // Since we know the clone is allocated in new space, we can copy
4399 // the contents without worrying about updating the write barrier. 4416 // the contents without worrying about updating the write barrier.
4400 CopyBlock(HeapObject::cast(clone)->address(), 4417 CopyBlock(HeapObject::cast(clone)->address(),
4401 source->address(), 4418 source->address(),
4402 object_size); 4419 object_size);
4403 } 4420 }
4404 4421
4422 if (adjusted_object_size > object_size) {
4423 AllocationSiteInfo* alloc_info = reinterpret_cast<AllocationSiteInfo*>(
4424 reinterpret_cast<Address>(clone) + object_size);
4425 alloc_info->set_map(allocation_site_info_map());
4426 alloc_info->set_payload(source);
4427 }
4428
4405 SLOW_ASSERT( 4429 SLOW_ASSERT(
4406 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); 4430 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind());
4407 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); 4431 FixedArrayBase* elements = FixedArrayBase::cast(source->elements());
4408 FixedArray* properties = FixedArray::cast(source->properties()); 4432 FixedArray* properties = FixedArray::cast(source->properties());
4409 // Update elements if necessary. 4433 // Update elements if necessary.
4410 if (elements->length() > 0) { 4434 if (elements->length() > 0) {
4411 Object* elem; 4435 Object* elem;
4412 { MaybeObject* maybe_elem; 4436 { MaybeObject* maybe_elem;
4413 if (elements->map() == fixed_cow_array_map()) { 4437 if (elements->map() == fixed_cow_array_map()) {
4414 maybe_elem = FixedArray::cast(elements); 4438 maybe_elem = FixedArray::cast(elements);
(...skipping 2941 matching lines...) Expand 10 before | Expand all | Expand 10 after
7356 static_cast<int>(object_sizes_last_time_[index])); 7380 static_cast<int>(object_sizes_last_time_[index]));
7357 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7381 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7358 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7382 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7359 7383
7360 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7384 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7361 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7385 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7362 ClearObjectStats(); 7386 ClearObjectStats();
7363 } 7387 }
7364 7388
7365 } } // namespace v8::internal 7389 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698