Closed
Bug 421154
Opened 17 years ago
Closed 17 years ago
Faster number conversions in the interpreter
Categories
(Core :: JavaScript Engine, enhancement, P1)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: igor, Assigned: igor)
References
Details
(Keywords: perf)
Attachments
(3 files, 3 obsolete files)
3.59 KB,
text/plain
|
Details | |
66.12 KB,
patch
|
igor
:
review+
|
Details | Diff | Splinter Review |
46.73 KB,
patch
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #415455 +++
Currently to convert non-numeric jsval into a double the interpreter calls:
extern JSBool
js_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp);
where dp an an address of a local variable. To save the generated code size and to allow better optimizations in the the interpreter I suggest to follow the idea from bug 415455 and to change the signature into:
extern jsdouble
js_ValueToNumber(JSContext *cx, jsval* vp);
Here the error reporting is done via setting *vp to JSVAL_NULL.
This also makes the function less GC-hazard friendly as now the conversion function will have an extra root to store its results.
Assignee | ||
Comment 1•17 years ago
|
||
The patch implements the signature change. In few places where I was not sure about root availability, I changes js_ValueToNumber into JS_ValueToNumber which now allows explicitly to pass an unrooted value.
Assignee | ||
Comment 2•17 years ago
|
||
The previous version missed JS_POP_TEMP_ROOT in JS_ValueToInt32.
Attachment #307548 -
Attachment is obsolete: true
Assignee | ||
Comment 3•17 years ago
|
||
This is the results for trunk versus the patch from the comment 2 applied on top of the patch from bug 415455 comment 9.
Given the line:
** TOTAL **: 1.085x as fast
I suspect that there must be some bugs in the patch. On the other hand it does pass shell and mochi tests...
Assignee | ||
Comment 4•17 years ago
|
||
Asking for inclusion in 1.9 based on the preliminary benchmarking results.
Flags: blocking1.9?
Assignee | ||
Comment 5•17 years ago
|
||
(In reply to comment #3)
>
> ** TOTAL **: 1.085x as fast
With the patch the address of the local variables jsdouble d, d2 is no longer leaked. Perhaps it allowed GCC to do better job at optimizing the code.
Comment 6•17 years ago
|
||
(In reply to comment #4)
> Asking for inclusion in 1.9 based on the preliminary benchmarking results.
>
Yep - that's easy. You got it.
Flags: blocking1.9? → blocking1.9+
Priority: -- → P1
Assignee | ||
Comment 7•17 years ago
|
||
Comment on attachment 307552 [details] [diff] [review]
v2 (quilt patch)
The patch follows the same idea as implemented in the patch from bug 415455 comment 11 for the integer conversion case.
Attachment #307552 -
Flags: review?(brendan)
Assignee | ||
Comment 8•17 years ago
|
||
Comment 9•17 years ago
|
||
Comment on attachment 307552 [details] [diff] [review]
v2 (quilt patch)
>+ * vp roots obj so we can not use it as an extra root for
s/can not/cannot/g
>+ * Convert a value to a number. On exit *vp is JSVAL_NULL if and only if there
>+ * are errors.
s/are errors/was an error/g
and maybe iff for if and only if, throughout.
Another global change that would help future jsval representation experiements. Consider:
$ grep ' == JSVAL_NULL' *.[ch] | wc -l
10
$ grep JSVAL_IS_NULL *.[ch] | wc -l
55
$ grep ' == JSVAL_VOID' *.[ch] | wc -l
11
$ grep JSVAL_IS_VOID *.[ch] | wc -l
49
Would like JSVAL_IS_NULL and JSVAL_IS_VOID used in this patch, therefore.
r+me and you have approval to land with these picked. Thanks again, the use of already-in-memory root as in/out param to convey error and propagate main result possible to registerized variable is righteous!
/be
Attachment #307552 -
Flags: review?(brendan) → review+
Assignee | ||
Comment 10•17 years ago
|
||
(In reply to comment #9)
> (From update of attachment 307552 [details] [diff] [review])
> Would like JSVAL_IS_NULL and JSVAL_IS_VOID used in this patch, therefore.
Sorry, I have not get it. Do you suggest to use JSVAL_VOID, not JSVAL_NULL, as an error indicator when converting values to numbers?
Comment 11•17 years ago
|
||
No, I mean use JSVAL_IS_NULL(v) instead of v == JSVAL_NULL, likewise for JSVAL_IS_VOID/JSVAL_VOID. Future jsval representations may allow shortcuts compared to loading a (possibly big) constant and testing equality.
/be
Assignee | ||
Comment 12•17 years ago
|
||
The new version addresses the nits from the comment 9 and makes sure that code uses JSVAL_IS_(NULL|VOID)(v) and not the explicit compare operation v == JSVAL_(NULL|VOID).
Attachment #307552 -
Attachment is obsolete: true
Attachment #307774 -
Attachment is obsolete: true
Attachment #307815 -
Flags: review+
Assignee | ||
Comment 13•17 years ago
|
||
Assignee | ||
Comment 14•17 years ago
|
||
Assignee | ||
Updated•17 years ago
|
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Flags: in-testsuite+
Flags: in-litmus-
You need to log in
before you can comment on or make changes to this bug.
Description
•