Closed
Bug 771705
Opened 12 years ago
Closed 12 years ago
THE NUMBER OF JS_COMPILE* FUNCTIONS IS TOO DAMN HIGH
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla17
People
(Reporter: jimb, Assigned: jimb)
Details
(Whiteboard: [js:t])
Attachments
(1 file, 3 obsolete files)
(deleted),
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
At present, jsapi.h declares:
JS_CompileScript
JS_CompileScriptForPrincipals
JS_CompileScriptForPrincipalsVersion
JS_CompileUCScript
JS_CompileUCScriptForPrincipals
JS_CompileUCScriptForPrincipalsVersion
JS_CompileUCScriptForPrincipalsVersionOrigin
JS_CompileUTF8File
JS_CompileUTF8FileHandle
JS_CompileUTF8FileHandleForPrincipals
JS_CompileUTF8FileHandleForPrincipalsVersion
However, bug 765993 would like to provide source map information, and bug 637572 would like to provide origin information. The current pattern is clearly not what we want to follow.
Instead, we should have a JS::CompileOptions type, with member functions for setting various options (and checking for consistency). Then, we should have a JS::Compile function, overloaded for each way of passing text:
- char *, length
- jschar *, length
- FILE *
This would reduce the length of many argument lists within SM itself, as well.
Comment 1•12 years ago
|
||
Yes please!
For bug 462300, I'll most likely want to add yet another set of these functions in the current scheme of things, making this change even more desirable.
Assignee | ||
Comment 2•12 years ago
|
||
Here's something that compiles...
Assignee: general → jimb
Status: NEW → ASSIGNED
Assignee | ||
Comment 5•12 years ago
|
||
Assignee | ||
Comment 6•12 years ago
|
||
I screwed up the version handling; turns out that AutoVersionAPI *modifies* the version passed to it.
New try: https://tbpl.mozilla.org/?tree=Try&rev=69ff744bd1f4
Assignee | ||
Comment 7•12 years ago
|
||
Use of AutoVersionAPI updated.
Assignee | ||
Updated•12 years ago
|
Attachment #642335 -
Attachment is obsolete: true
Assignee | ||
Comment 8•12 years ago
|
||
Third try push: I mis-read the code that reads a file into memory, assuming that 'len' was the length. Shoot me now. Rewritten using Vector<char, ...>.
https://tbpl.mozilla.org/?tree=Try&rev=3d2987f423fa
Assignee | ||
Comment 9•12 years ago
|
||
All looks good. Full try:
https://tbpl.mozilla.org/?tree=Try&rev=5020615a1861
Assignee | ||
Updated•12 years ago
|
Attachment #642698 -
Flags: review?(luke)
Assignee | ||
Updated•12 years ago
|
Attachment #642698 -
Flags: review?(luke)
Assignee | ||
Comment 10•12 years ago
|
||
Updated patch.
Attachment #642698 -
Attachment is obsolete: true
Attachment #643497 -
Flags: review?(luke)
Comment 11•12 years ago
|
||
Comment on attachment 643497 [details] [diff] [review]
Pull out compilation variants into a CompileOptions structure.
Review of attachment 643497 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me, although you might want to solicit njn's opinion since he has been touching the same area recently.
::: js/src/jsapi.h
@@ +4937,5 @@
> +Compile(JSContext *cx, JSHandleObject obj, const CompileOptions &options,
> + const char *bytes, size_t length);
> +
> +extern JS_PUBLIC_API(JSScript *)
> +Compile(JSContext *cx, JSHandleObject obj, CompileOptions options,
This API passes CompileOptions by value while most of the others use const &. In general, I doubt perf here matters enough to warrant const & over passing by value (we're about to parse, after all), so I'd be just as happy if you converted all the other APIs to pass by value. By value also is a bit shorter to read :) Whichever you choose, I see a few other const&/value inconsistencies (e.g., below), so it'd be good to give the patch a quick scan to make sure they are all one way or the other.
Attachment #643497 -
Flags: review?(luke) → review+
Assignee | ||
Comment 12•12 years ago
|
||
On IRC it was resolved that both George Sand and T.S. Eliot would prefer that CompileOptions be consistently passed by value.
Assignee | ||
Comment 13•12 years ago
|
||
ONE MORE TIME: https://tbpl.mozilla.org/?tree=Try&rev=948fba659d35
Assignee | ||
Comment 14•12 years ago
|
||
That looks okay.
https://hg.mozilla.org/integration/mozilla-inbound/rev/6e7fa061e61a
Flags: in-testsuite-
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → mozilla17
Comment 15•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment 16•12 years ago
|
||
Huzzah!
You need to log in
before you can comment on or make changes to this bug.
Description
•