Closed
Bug 447762
Opened 18 years ago
Closed 18 years ago
SM: merging var and local bytecodes
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: igor, Assigned: igor)
References
Details
(Keywords: perf)
Attachments
(1 file, 4 obsolete files)
|
48.72 KB,
patch
|
igor
:
review+
|
Details | Diff | Splinter Review |
With the bug 441686 fixed, the interpreter uses the same code for VAR and LOCAL bytecode pairs. These pairs can be replaced with single bytecodes if the decompile learns how to distinguish a variable from a local based on its slot number.
| Assignee | ||
Comment 1•18 years ago
|
||
This patch compiles but untested. With the patch there is no longer any VAR bytecodes, all of them are merged into the corresponding LOCAL version, which eliminated 9 bytecodes in total.
| Assignee | ||
Comment 2•18 years ago
|
||
The new version of the patch passes shell and mochi tests. Most of the changes are in the decompiler to distinguish local from var index based on the slot number.
Attachment #331213 -
Attachment is obsolete: true
Attachment #331324 -
Flags: review?(brendan)
| Assignee | ||
Comment 3•18 years ago
|
||
I forgot in v1 to bump the XDR version, the new version fixes that.
Attachment #331324 -
Attachment is obsolete: true
Attachment #331325 -
Flags: review?(brendan)
Attachment #331324 -
Flags: review?(brendan)
Comment 4•18 years ago
|
||
Comment on attachment 331325 [details] [diff] [review]
v2
>+static jsint
>+ReadSlot(JSPrinter *jp, jsbytecode *pc, JSSlotKind *kindp)
>+{
>+ jsint i;
>+
>+ i = GET_SLOTNO(pc);
>+ if (i < jp->script->nfixed) {
>+ *kindp = JSSK_VAR;
>+ i += jp->fun->nargs;
>+ } else {
>+ *kindp = JSSK_LOCAL;
>+ i -= jp->script->nfixed;
>+ }
>+ return i;
>+}
Hard to improve on ReadSlot, yet it seems missnamed. Get is the usual verb, whether decoding an immediate from pc or getting an atom from an atomMap, etc. GetSlotAndKind is too long, though. Not really commenting usefully here, just ruminating in case you get a better idea from this.
On jsopcode.tbl changes:
> /* ECMA-compliant for-in loop with argument or local variable loop control. */
> OPDEF(JSOP_FORARG, 10, "forarg", NULL, 3, 0, 1, 19, JOF_QARG|JOF_NAME|JOF_FOR)
>-OPDEF(JSOP_FORVAR, 11, "forvar", NULL, 3, 0, 1, 19, JOF_QVAR|JOF_NAME|JOF_FOR)
>+OPDEF(JSOP_FORLOCAL, 11,"forlocal", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME|JOF_FOR)
Please keep columns aligned, in this case the "forlocal" opname needs a space before and take away one after. Same goes for later.
We will need to compress and reorder the table in one big patch, so these kinds of patches could just set ops to UNUSED status and leave others where they were -- but I'm in favor of this patch being non-minimal in that sense, to get the LOCAL ops down where the VAR ones were.
r=me with nits picked.
/be
Attachment #331325 -
Flags: review?(brendan) → review+
| Assignee | ||
Comment 5•18 years ago
|
||
The new version of the patch fixes the nits and adds comments. I changed ReadSlot into IsVarSlot:
-static jsint
-ReadSlot(JSPrinter *jp, jsbytecode *pc, JSSlotKind *kindp)
+static JSBool
+IsVarSlot(JSPrinter *jp, jsbytecode *pc, jsint *indexp)
This emphasis that the main purpose of the function is to decided whether the slot is var or local. The index is just a bonus. The change allowed to eliminate that slotKind local variable and made var/let ifs less noisy.
Attachment #331325 -
Attachment is obsolete: true
Attachment #332521 -
Flags: review+
| Assignee | ||
Comment 6•18 years ago
|
||
The new version gives better comments to IsVarSlot.
Attachment #332521 -
Attachment is obsolete: true
Attachment #332524 -
Flags: review+
| Assignee | ||
Comment 7•18 years ago
|
||
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Updated•18 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
•