Closed Bug 445636 Opened 16 years ago Closed 3 years ago

Explain perf gains from adding instructions in call-threaded SM

Categories

(Core :: JavaScript Engine, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: dmandelin, Unassigned)

References

Details

Attachments

(1 file)

I have found that I can increase performance by adding instructions in call-threaded SM. If anyone can explain how this works and what it implies for optimizing the cases in general, it would really help me a lot. :-)

First, I should say that I only have one small test right now, which adds numbers in a tight loop, so the opcode sequence in the loop is "getvar, getvar, add, setvar, pop, incvar, pop, getvar, int8, lt". I'm running 32-bit code on OS 10.5 on a MacBook Pro with a Core 2 Duo.

In call-threaded SM, I arrange for each case to end with a ret (near) instruction, and then I "JIT" a JS method by generating a sequence of call (near) instructions to each entry point. (I also generate a jmp for GOTO, and a test, jne for IFNE). I have found that in a particular configuration, if I *add* a pair of pop and push instructions (to memory) to the case for jsop_int8, it decreases total run time by 6%. See attachment for the code

I gave some thought to the idea that jump target alignment is the cause of the difference, but I'm not so sure. Setting alignments to 8 or 16 bytes helps, but not as much as adding in that pop/push pair. I'm wondering if it could also relate to the path length between the call and return somehow interacting with the branch predictor. It seems like figuring this issue out could help by a good percentage overall in the call-threaded version. It could also be relevant to trunk SM.
David,

I'm OOO now but will be back next week. Will look at this case when I come back.

- moh
Assignee: general → nobody

Old bug, no longer valid.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: