Bug 144011 - Give the heap object iterators the ability to return early.
Summary: Give the heap object iterators the ability to return early.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-21 14:15 PDT by Mark Lam
Modified: 2015-04-22 13:07 PDT (History)
8 users (show)

See Also:


Attachments
the patch. (17.45 KB, patch)
2015-04-21 14:21 PDT, Mark Lam
ggaren: review-
Details | Formatted Diff | Diff
patch 2: no more comments. (28.03 KB, patch)
2015-04-21 17:21 PDT, Mark Lam
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>.