Reviewers: Erik Corry, jochen,

Message:
Thanks for review, Erik. I uploaded new PS and add a link to design doc.

I also changed the sentinel end-of-list value to Smi::FromInt(0) from undefined
to make the following invariant:

(!W->value()->IsUndefined()) == <W is in the list>.



https://codereview.chromium.org/640303006/diff/180001/src/heap/heap.cc
File src/heap/heap.cc (right):

https://codereview.chromium.org/640303006/diff/180001/src/heap/heap.cc#newcode2702
src/heap/heap.cc:2702:
WeakCell::cast(result)->update_value_from_gc(value);
On 2014/10/13 15:56:17, Erik Corry wrote:
This is from allocation, not from GC, so probably should not call this
function.

Introduced a new function "initialize" for this and renamed
"update_value_from_gc" to "clear".

https://codereview.chromium.org/640303006/diff/180001/src/heap/heap.cc#newcode2703
src/heap/heap.cc:2703:
WeakCell::cast(result)->set_next(undefined_value());
On 2014/10/13 15:56:17, Erik Corry wrote:
There's no need to set the write barrier when setting to undefined, is
there? I
think it's immovable and immortal.  So we could add SKIP_WRITE_BARRIER
here.

Done.

https://codereview.chromium.org/640303006/diff/180001/src/heap/mark-compact.cc
File src/heap/mark-compact.cc (right):

https://codereview.chromium.org/640303006/diff/180001/src/heap/mark-compact.cc#newcode2748
src/heap/mark-compact.cc:2748: weak_cell->set_next(undefined);
On 2014/10/13 15:56:17, Erik Corry wrote:
No write barrier needed.

Done.

https://codereview.chromium.org/640303006/diff/180001/src/heap/mark-compact.cc#newcode2760
src/heap/mark-compact.cc:2760: weak_cell->set_next(undefined);
On 2014/10/13 15:56:17, Erik Corry wrote:
No write barrier needed

Done.

https://codereview.chromium.org/640303006/diff/180001/src/heap/mark-compact.cc#newcode2777
src/heap/mark-compact.cc:2777: // We scavange new space simultaneously
with sweeping. This is done in two
On 2014/10/13 15:56:17, Erik Corry wrote:
scavange -> scavenge

Done.

https://codereview.chromium.org/640303006/diff/180001/src/objects-inl.h
File src/objects-inl.h (right):

https://codereview.chromium.org/640303006/diff/180001/src/objects-inl.h#newcode1940
src/objects-inl.h:1940: WRITE_BARRIER(GetHeap(), this, kValueOffset,
val);
On 2014/10/13 15:56:17, Erik Corry wrote:
If we are in GC, do we need the write barrier?  I think this is only
legitimately used to set the value to 'undefined', so pehaps it should
be
renamed clear_value_from_gc and it should not take an argument.

Yes, we need write barrier for the first initialization. All other
usages are indeed "set to undefined" that don't need write barrier. I
introduced two functions: initialize and clear.

https://codereview.chromium.org/640303006/diff/180001/test/cctest/test-heap.cc
File test/cctest/test-heap.cc (right):

https://codereview.chromium.org/640303006/diff/180001/test/cctest/test-heap.cc#newcode4262
test/cctest/test-heap.cc:4262: heap->CollectAllAvailableGarbage();
On 2014/10/13 15:56:17, Erik Corry wrote:
The tests should also test that the weak cell is unchanged if there is
a full GC
and the value is also reachable through normal objects.

Done.

Description:
Weak Cells

Introduce an object that holds a weak reference.
Design document: http://goo.gl/9dSvvy.

BUG=

Please review this at https://codereview.chromium.org/640303006/

Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+252, -3 lines):
  M include/v8.h
  M src/factory.h
  M src/factory.cc
  M src/heap/heap.h
  M src/heap/heap.cc
  M src/heap/mark-compact.h
  M src/heap/mark-compact.cc
  M src/heap/objects-visiting.h
  M src/heap/objects-visiting.cc
  M src/heap/objects-visiting-inl.h
  M src/objects.h
  M src/objects.cc
  M src/objects-debug.cc
  M src/objects-inl.h
  M src/objects-printer.cc
  M test/cctest/test-heap.cc


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to