Bug 72889 - Add interface for runtime option settings
Summary: Add interface for runtime option settings
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 72938
  Show dependency treegraph
 
Reported: 2011-11-21 08:47 PST by Andy Wingo
Modified: 2011-12-15 04:01 PST (History)
8 users (show)

See Also:


Attachments
Patch (13.52 KB, patch)
2011-11-21 08:53 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (15.50 KB, patch)
2011-11-21 10:11 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (61.89 KB, patch)
2011-11-22 02:25 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Further refactor of Options.{h,cpp} (11.53 KB, patch)
2011-11-22 03:25 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (63.15 KB, patch)
2011-11-22 03:53 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (63.15 KB, patch)
2011-11-24 04:20 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (60.97 KB, patch)
2011-11-29 09:03 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Patch (62.86 KB, patch)
2011-12-12 02:58 PST, Andy Wingo
no flags Details | Formatted Diff | Diff
Andy's updated patch (63.87 KB, patch)
2011-12-14 03:53 PST, Philippe Normand
no flags Details | Formatted Diff | Diff
Andy's updated patch (65.84 KB, patch)
2011-12-14 04:13 PST, Philippe Normand
no flags Details | Formatted Diff | Diff
Andy's updated patch (67.11 KB, patch)
2011-12-14 05:09 PST, Philippe Normand
no flags Details | Formatted Diff | Diff
Andy's updated patch (67.15 KB, patch)
2011-12-14 05:54 PST, Philippe Normand
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Wingo 2011-11-21 08:47:56 PST
JSC doesn't have many runtime knobs, instead relying on compile-time ifdefs.  I would like to add some more runtime things, for debugging, and also eventually to have a runtime --harmony flag for bug 31813.

The patch to be attached is an RFC for this sort of thing.
Comment 1 Andy Wingo 2011-11-21 08:53:34 PST
Created attachment 116096 [details]
Patch
Comment 2 Andy Wingo 2011-11-21 08:57:15 PST
Beyond the idea itself, my C++ style instincts are terrible, so feedback is appreciated :)
Comment 3 Gustavo Noronha (kov) 2011-11-21 09:04:36 PST
Comment on attachment 116096 [details]
Patch

Attachment 116096 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/10472651
Comment 4 Gyuyoung Kim 2011-11-21 09:11:38 PST
Comment on attachment 116096 [details]
Patch

Attachment 116096 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/10533316
Comment 5 Andy Wingo 2011-11-21 09:16:24 PST
I'll update so it compiles on release builds, and add build support for other ports for the new files.  Feedback regarding the name would be useful, so I can add the files with the right names.
Comment 6 Andy Wingo 2011-11-21 10:11:33 PST
Created attachment 116104 [details]
Patch
Comment 7 Andy Wingo 2011-11-21 10:15:51 PST
Attached patch introduces some cruft so that accessors are always there.

To use the one flag that currently exists as an example, --dump-bytecode is only available in debug mode.  This has always been the case, under its old -d name, but now it is only present in jsc --help in debug mode.

Transcript, in debug mode:

$ ./WebKitBuild/Debug/Programs/jsc --dump-bytecode
> 1
4 m_instructions; 72 bytes at 0x1e21250; 1 parameter(s); 1 callee register(s)
[...]
> 
$ ./WebKitBuild/Debug/Programs/jsc --help
Usage: jsc [options] [files] [-- arguments]
  -e         Evaluate argument as script code
  -f         Specifies a source file (deprecated)
  -h|--help  Prints this help message
  -i         Enables interactive mode (default if no files are specified)
  -s         Installs signal handlers that exit on a crash (Unix platforms only)
  --dump-bytecode
             Dump all generated bytecode

In release mode:

$ ./WebKitBuild/Release/Programs/jsc --help
Usage: jsc [options] [files] [-- arguments]
  -e         Evaluate argument as script code
  -f         Specifies a source file (deprecated)
  -h|--help  Prints this help message
  -i         Enables interactive mode (default if no files are specified)
  -s         Installs signal handlers that exit on a crash (Unix platforms only)
$ ./WebKitBuild/Release/Programs/jsc --dump-bytecode
ERROR: This build has not been configured to allow the --dump-bytecode flag to be set at runtime.

Note the error.  In release mode, options that are not configurable compile to static methods that should inline appropriately, if I understand things right.
Comment 8 Gyuyoung Kim 2011-11-21 10:33:26 PST
Comment on attachment 116104 [details]
Patch

Attachment 116104 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/10475315
Comment 9 Filip Pizlo 2011-11-21 10:51:26 PST
Is it really necessary for this to be per-instance?  I can appreciate what the Options object might give us, but it would be unfortunate if the code became more complex in order to support per-instance run-time knobs.

Note that there is already a facility to support per-process run-time knobs.  See Heuristics.cpp.  It almost feels like this would have a better over balance between flexibility and code cleanliness if we just renamed Heuristics to Options, and started moving things like the byte code generator's dump flag into Options.
Comment 10 Andy Wingo 2011-11-21 11:00:10 PST
Sorry for my ignorance, but what do you mean by per-instance?  My patch sets global variables, basically.

I'm fine with using the Heuristics code instead.  Would you prefer that?  Would you be opposed to command-line integration, or do you think that environment variables are sufficient?  I do enjoy V8's options interface, as it is a bit more discoverable.

Andy
Comment 11 Filip Pizlo 2011-11-21 11:12:56 PST
(In reply to comment #10)
> Sorry for my ignorance, but what do you mean by per-instance?  My patch sets global variables, basically.

Ooops, it was me who was being ignorant.  I saw that Options class and assumed that you wanted to pass different instances of it around.  Now I see that it's meant to be static.

I do like the way you've structured Options, in that it should presumably allow adding new options fairly simple and provide discoverability.  But on the other hand, anything you do in Options should be done in such a way that it can be tuned from a full browser.  The environment variables are a cheap way to accomplish this.  Do you know how you'd interface this to WebCore/WebKit so that the options can be modified even for a browser?
Comment 12 Early Warning System Bot 2011-11-21 12:35:12 PST
Comment on attachment 116104 [details]
Patch

Attachment 116104 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/10541008
Comment 13 Andy Wingo 2011-11-22 01:51:35 PST
(In reply to comment #11)
> I saw that Options class and assumed that you wanted to pass different instances of it around.  Now I see that it's meant to be static.

Yes, it's an abuse of classes as an organizational device.

Like I said, my C++ instincts are terrible :), but I thought that it could be a good idea to avoid accidental modification of the options / heuristics, and so hide them behind a static method. The method should inline, just in case that's important.

> Anything you do in Options should be done in such a way that it can be tuned from a full browser.  The environment variables are a cheap way to accomplish this.  Do you know how you'd interface this to WebCore/WebKit so that the options can be modified even for a browser?

We could provide the same interface, or we could provide API, or provide a little parser for e.g. JSC_HEURISTICS='likely-to-take-slow-case-threshold=4,maximum-optimization-delay=35,..'

I like your suggestion of just renaming Heuristics to Options and refactoring from there.  I'll post a patch to do that.
Comment 14 Andy Wingo 2011-11-22 02:25:03 PST
Created attachment 116193 [details]
Patch
Comment 15 Andy Wingo 2011-11-22 03:25:51 PST
Created attachment 116194 [details]
Further refactor of Options.{h,cpp}

Attached a patch to macro-ify the current heuristics.
Comment 16 Andy Wingo 2011-11-22 03:26:31 PST
Comment on attachment 116194 [details]
Further refactor of Options.{h,cpp}

Clearing review bit so the bots don't run this one.
Comment 17 Andy Wingo 2011-11-22 03:53:38 PST
Created attachment 116196 [details]
Patch
Comment 18 Andy Wingo 2011-11-22 03:54:37 PST
Fixed testRegexp.cpp, which hopefully will fix the windows build.  I'll move further patches to other bugs.
Comment 19 Filip Pizlo 2011-11-22 13:29:53 PST
Comment on attachment 116196 [details]
Patch

r=me
Comment 20 Andy Wingo 2011-11-22 13:32:44 PST
Comment on attachment 116196 [details]
Patch

cq?
Comment 21 Filip Pizlo 2011-11-22 13:47:50 PST
Comment on attachment 116196 [details]
Patch

You missed a reference to Heuristics in the Xcode project junk.  (Just do a search for Heuristics in project.pbxproj and you'll see what I mean.)
Comment 22 Andy Wingo 2011-11-24 04:20:36 PST
Created attachment 116496 [details]
Patch
Comment 23 Andy Wingo 2011-11-24 04:21:14 PST
Comment on attachment 116496 [details]
Patch

Whoops.  I think I've fixed it now.
Comment 24 Andy Wingo 2011-11-29 01:43:27 PST
Ping :)
Comment 25 Andy Wingo 2011-11-29 09:03:00 PST
Created attachment 116979 [details]
Patch
Comment 26 Andy Wingo 2011-11-29 09:04:14 PST
Updated for recent change in heuristics.
Comment 27 Andy Wingo 2011-11-30 10:51:24 PST
  Hark!  A patch revised
    packaged for your consumption
      waits expectantly
Comment 28 Andy Wingo 2011-12-01 10:38:46 PST
  A patch on a bug grows rotten
  If it feels that it has been forgotten
    You know what to do;
    I wrote you a haiku!
  R+, of limericks are you begotten?

(ok, that was pretty bad)
Comment 29 Andy Wingo 2011-12-12 02:58:44 PST
Created attachment 118760 [details]
Patch
Comment 30 Andy Wingo 2011-12-12 03:12:03 PST
Comment on attachment 118760 [details]
Patch

Filip, would you mind taking a look at this?

Thanks!
Comment 31 Philippe Normand 2011-12-14 03:53:56 PST
Created attachment 119194 [details]
Andy's updated patch

So we give it a chance on mac's EWS.
Comment 32 Philippe Normand 2011-12-14 04:13:50 PST
Created attachment 119198 [details]
Andy's updated patch
Comment 33 Philippe Normand 2011-12-14 05:09:50 PST
Created attachment 119205 [details]
Andy's updated patch
Comment 34 Philippe Normand 2011-12-14 05:54:20 PST
Created attachment 119211 [details]
Andy's updated patch

Should build on mac this time :)
Comment 35 Filip Pizlo 2011-12-15 03:40:45 PST
Comment on attachment 119211 [details]
Andy's updated patch

R=me.  Apologies for the long delay!
Comment 36 WebKit Review Bot 2011-12-15 04:01:47 PST
Comment on attachment 119211 [details]
Andy's updated patch

Clearing flags on attachment: 119211

Committed r102917: <http://trac.webkit.org/changeset/102917>
Comment 37 WebKit Review Bot 2011-12-15 04:01:54 PST
All reviewed patches have been landed.  Closing bug.