Hi Zaheer,

Please take a look inside RecordWrites. It checks whether address points to
the new space and does _nothing_ in this case.

Removing this check is possible (allocator knows which space was used for
allocation) but I don't thinks it will bring any serious speedup.

--
Vyacheslav Egorov


On Wed, Jun 16, 2010 at 8:05 AM, zaheer ahmad <[email protected]> wrote:

> In the following code, looks like the if case can be optimized to call
> RecordWrites only if the clone is allocated in old space?
>
> Thanks
> Zaheer
>
>  // If we're forced to always allocate, we use the general allocation
>  // functions which may leave us with an object in old space.
>  if (always_allocate()) {
>    clone = AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE);
>    if (clone->IsFailure()) return clone;
>    Address clone_address = HeapObject::cast(clone)->address();
>    CopyBlock(clone_address,
>              source->address(),
>              object_size);
>    // Update write barrier for all fields that lie beyond the header.
>    RecordWrites(clone_address,
>                 JSObject::kHeaderSize,
>                 (object_size - JSObject::kHeaderSize) / kPointerSize);
>  } else {
>    clone = new_space_.AllocateRaw(object_size);
>    if (clone->IsFailure()) return clone;
>    ASSERT(Heap::InNewSpace(clone));
>    // Since we know the clone is allocated in new space, we can copy
>    // the contents without worrying about updating the write barrier.
>    CopyBlock(HeapObject::cast(clone)->address(),
>              source->address(),
>              object_size);
>  }
>
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
>

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to