Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 = FLAG_track_allocation_sites && | |
| 4377 mode == TRACK_ALLOCATION_SITE_INFO; | |
| 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. |
| 4379 if (always_allocate()) { | 4383 if (always_allocate()) { |
| 4380 { MaybeObject* maybe_clone = | 4384 { MaybeObject* maybe_clone = |
| 4381 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); | 4385 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); |
| 4382 if (!maybe_clone->ToObject(&clone)) return maybe_clone; | 4386 if (!maybe_clone->ToObject(&clone)) return maybe_clone; |
| 4383 } | 4387 } |
| 4384 Address clone_address = HeapObject::cast(clone)->address(); | 4388 Address clone_address = HeapObject::cast(clone)->address(); |
| 4385 CopyBlock(clone_address, | 4389 CopyBlock(clone_address, |
| 4386 source->address(), | 4390 source->address(), |
| 4387 object_size); | 4391 object_size); |
| 4388 // Update write barrier for all fields that lie beyond the header. | 4392 // Update write barrier for all fields that lie beyond the header. |
| 4389 RecordWrites(clone_address, | 4393 RecordWrites(clone_address, |
| 4390 JSObject::kHeaderSize, | 4394 JSObject::kHeaderSize, |
| 4391 (object_size - JSObject::kHeaderSize) / kPointerSize); | 4395 (object_size - JSObject::kHeaderSize) / kPointerSize); |
| 4396 | |
| 4397 // Track allocation site information | |
| 4398 if (track_origin && InNewSpace(clone)) { | |
|
danno
2013/01/10 22:58:59
This is a bit dicey. Although I don't see a reason
mvstanton
2013/01/11 13:43:01
Thanks, good advice. I actually removed the FLAG_t
| |
| 4399 MaybeObject* maybe_alloc_info = | |
| 4400 AllocateStruct(ALLOCATION_SITE_INFO_TYPE); | |
| 4401 AllocationSiteInfo* alloc_info; | |
| 4402 if (maybe_alloc_info->To(&alloc_info)) { | |
| 4403 alloc_info->set_map(allocation_site_info_map()); | |
| 4404 alloc_info->set_payload(source); | |
| 4405 } | |
| 4406 } | |
| 4392 } else { | 4407 } else { |
| 4393 wb_mode = SKIP_WRITE_BARRIER; | 4408 wb_mode = SKIP_WRITE_BARRIER; |
| 4394 { MaybeObject* maybe_clone = new_space_.AllocateRaw(object_size); | 4409 |
| 4410 int adjusted_object_size = object_size; | |
| 4411 if (track_origin) { | |
| 4412 adjusted_object_size += AllocationSiteInfo::kSize; | |
| 4413 } | |
| 4414 | |
| 4415 { MaybeObject* maybe_clone = new_space_.AllocateRaw(adjusted_object_size); | |
| 4395 if (!maybe_clone->ToObject(&clone)) return maybe_clone; | 4416 if (!maybe_clone->ToObject(&clone)) return maybe_clone; |
| 4396 } | 4417 } |
| 4397 SLOW_ASSERT(InNewSpace(clone)); | 4418 SLOW_ASSERT(InNewSpace(clone)); |
| 4398 // Since we know the clone is allocated in new space, we can copy | 4419 // Since we know the clone is allocated in new space, we can copy |
| 4399 // the contents without worrying about updating the write barrier. | 4420 // the contents without worrying about updating the write barrier. |
| 4400 CopyBlock(HeapObject::cast(clone)->address(), | 4421 CopyBlock(HeapObject::cast(clone)->address(), |
| 4401 source->address(), | 4422 source->address(), |
| 4402 object_size); | 4423 object_size); |
| 4424 | |
| 4425 if (track_origin) { | |
| 4426 AllocationSiteInfo* alloc_info = reinterpret_cast<AllocationSiteInfo*>( | |
| 4427 reinterpret_cast<Address>(clone) + object_size); | |
| 4428 alloc_info->set_map(allocation_site_info_map()); | |
| 4429 // TODO(mvstanton): I don't understand this payload? the original object? | |
|
danno
2013/01/10 22:58:59
Yes. And as discussed today, this is a bit wrong r
mvstanton
2013/01/11 13:43:01
Right. For the moment, the boilerplate is exactly
| |
| 4430 alloc_info->set_payload(source); | |
| 4431 } | |
| 4403 } | 4432 } |
| 4404 | 4433 |
| 4405 SLOW_ASSERT( | 4434 SLOW_ASSERT( |
| 4406 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); | 4435 JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); |
| 4407 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); | 4436 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); |
| 4408 FixedArray* properties = FixedArray::cast(source->properties()); | 4437 FixedArray* properties = FixedArray::cast(source->properties()); |
| 4409 // Update elements if necessary. | 4438 // Update elements if necessary. |
| 4410 if (elements->length() > 0) { | 4439 if (elements->length() > 0) { |
| 4411 Object* elem; | 4440 Object* elem; |
| 4412 { MaybeObject* maybe_elem; | 4441 { MaybeObject* maybe_elem; |
| (...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7356 static_cast<int>(object_sizes_last_time_[index])); | 7385 static_cast<int>(object_sizes_last_time_[index])); |
| 7357 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7386 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7358 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7387 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7359 | 7388 |
| 7360 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7389 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7361 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7390 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7362 ClearObjectStats(); | 7391 ClearObjectStats(); |
| 7363 } | 7392 } |
| 7364 | 7393 |
| 7365 } } // namespace v8::internal | 7394 } } // namespace v8::internal |
| OLD | NEW |