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

Issue 260017: Implemented really weak handles. (Closed)

Created:
11 years, 2 months ago by Vitaly Repeshko
Modified:
7 years, 5 months ago
CC:
v8-dev
Visibility:
Public.

Description

Implemented really weak handles. Really weak handles are like normal weak handles except that objects are collected as soon as they are found to be unreachable and not on the next GC. When used for wrapper objects really weak handles can significantly reduce time spent in GC. With them we do more minor and less major collections. Note, in this change I also removed global object handle counting, which nobody was using and which can be easily put back if someone needs it again.

Patch Set 1 #

Patch Set 2 : Removed debug traces. #

Patch Set 3 : Fix typo. #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+214 lines, -91 lines) Patch
M include/v8.h View 1 2 3 chunks +27 lines, -3 lines 1 comment Download
M src/api.cc View 2 chunks +10 lines, -1 line 0 comments Download
M src/global-handles.h View 3 chunks +6 lines, -11 lines 0 comments Download
M src/global-handles.cc View 1 13 chunks +35 lines, -18 lines 3 comments Download
M test/cctest/test-api.cc View 2 chunks +136 lines, -58 lines 2 comments Download

Messages

Total messages: 3 (0 generated)
Vitaly Repeshko
11 years, 2 months ago (2009-10-06 12:31:44 UTC) #1
Christian Plesner Hansen
Overall lgtm. The state NEAR_DEATH has become misleading since it is now also used after ...
11 years, 2 months ago (2009-10-06 13:47:21 UTC) #2
antonm
11 years, 1 month ago (2009-10-29 10:16:59 UTC) #3
One problem and one observation.  If you don't think they are real problems,
could you add unittests to prove that?

Problem. Imagine we have objects A and B, A refers to B, A is held only by weak
handle, B is only held by really weak handle.  Now, GC occurs and both A and B
are found to be only weakly reachable.  Now imagine that weak reference callback
of A makes A strongly reachable.  If I understand this change correctly, that's
a problem as B would be already collected even though it becoms stronlgy
reachable after A's weak callback.

One solution I can immediately think of is to collect immediately only objects
held exactly by one really weak handle, but I am not sure what's the price to
pay.

Another solution is to defer collect after all weak callbacks were ran, but that
seems quite heaviweight.

Observation. Imaging object A held by really weak handle.  Once again GC occurs,
finds this A only weakly reachable and collects it.  However, before weak
reference callback of A is invoked, some other weak reference callback is
invoked which  goes back to V8.  This running code attempts to access A's handle
(e.g. via DOM node map), handle is yet in the map (A's weak reference callback
hasn't been invoked), but object is already collected.  Cure is simple---for
caches one need to check if handle is near death---but that need to be
implemented and has (probably non-existent) performance penalties.

Powered by Google App Engine
This is Rietveld 408576698