Bug 144011

Summary: Give the heap object iterators the ability to return early.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: basile_clement, benjamin, fpizlo, ggaren, mhahnenb, mmirman, msaboff, saam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
the patch.
ggaren: review-
patch 2: no more comments. msaboff: review+

Description Mark Lam 2015-04-21 14:15:42 PDT
JSDollarVMPrototype::isValidCell() uses a heap object iterator to validate candidate cell pointers, and, when in use, is called a lot more often than the normal way those iterators are used.  As a result, I see my instrumented VM killed with a SIGXCPU (CPU time limit exceeded).  This patch gives the callback functor the ability to tell the iterators to return early when the functor no longer needs to continue iterating.  With this, my instrumented VM is useful again for debugging.

Since heap iteration is not something that we do in a typical fast path, I don’t expect this to have any noticeable impact on performance.
Comment 1 Mark Lam 2015-04-21 14:21:00 PDT
Created attachment 251261 [details]
the patch.
Comment 2 Geoffrey Garen 2015-04-21 16:05:23 PDT
Comment on attachment 251261 [details]
the patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=251261&action=review

> Source/JavaScriptCore/heap/Heap.cpp:1453
> +        return false; // Not done iterating.

If an API requires a comment at every usage site, that's a good sign that the API is not readable by design.
Comment 3 Mark Lam 2015-04-21 16:06:24 PDT
(In reply to comment #2)
> Comment on attachment 251261 [details]
> the patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251261&action=review
> 
> > Source/JavaScriptCore/heap/Heap.cpp:1453
> > +        return false; // Not done iterating.
> 
> If an API requires a comment at every usage site, that's a good sign that
> the API is not readable by design.

I'm open to suggestions.
Comment 4 Michael Saboff 2015-04-21 16:07:22 PDT
Comment on attachment 251261 [details]
the patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=251261&action=review

>>> Source/JavaScriptCore/heap/Heap.cpp:1453
>>> +        return false; // Not done iterating.
>> 
>> If an API requires a comment at every usage site, that's a good sign that the API is not readable by design.
> 
> I'm open to suggestions.

Make it an enum.
Comment 5 Mark Lam 2015-04-21 16:11:37 PDT
(In reply to comment #4)
> Comment on attachment 251261 [details]
> the patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251261&action=review
> 
> >>> Source/JavaScriptCore/heap/Heap.cpp:1453
> >>> +        return false; // Not done iterating.
> >> 
> >> If an API requires a comment at every usage site, that's a good sign that the API is not readable by design.
> > 
> > I'm open to suggestions.
> 
> Make it an enum.

Sounds like a good plan.  I will execute.
Comment 6 Mark Lam 2015-04-21 17:21:29 PDT
Created attachment 251276 [details]
patch 2: no more comments.
Comment 7 Mark Lam 2015-04-21 17:23:50 PDT
Comment on attachment 251276 [details]
patch 2: no more comments.

View in context: https://bugs.webkit.org/attachment.cgi?id=251276&action=review

> Source/JavaScriptCore/ChangeLog:17
> +        I donât expect this to have any noticeable impact on performance.

Will fix the apostrophe in “don’t” before I land.
Comment 8 Michael Saboff 2015-04-22 12:43:28 PDT
Comment on attachment 251276 [details]
patch 2: no more comments.

r=me
Comment 9 Mark Lam 2015-04-22 13:07:05 PDT
Thanks for the review.  Landed in r183124: <http://trac.webkit.org/r183124>.