Closed Bug 475863 Opened 15 years ago Closed 14 years ago

Inefficient bytecode for "(a && b) && c"

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Unassigned)

Details

(Keywords: testcase)

js> var f = function (a,b,c) { return (a && b) && c; }

js> dis(f);
flags: LAMBDA INTERPRETED
main:
00000:  getarg 0
00003:  and 9 (6) <-- extra jump in the case where |a| is false?
00006:  getarg 1
00009:  and 15 (6)
00012:  getarg 2
00015:  return
00016:  stop

js> dis(eval(uneval(f)));
flags: LAMBDA INTERPRETED
main:
00000:  getarg 0
00003:  and 15 (12)
00006:  getarg 1
00009:  and 15 (6)
00012:  getarg 2
00015:  return
00016:  stop
Will bug 461269 help here?
This is fixed:

js> var f = function (a,b,c) { return (a && b) && c; }
js> dis(f)
flags: LAMBDA NULL_CLOSURE
main:
00000:  getarg 0
00003:  and 15 (12)
00006:  getarg 1
00009:  and 15 (6)
00012:  getarg 2
00015:  return
00016:  stop

Source notes:
js> dis(eval(uneval(f)));
flags: LAMBDA NULL_CLOSURE
main:
00000:  getarg 0
00003:  and 15 (12)
00006:  getarg 1
00009:  and 15 (6)
00012:  getarg 2
00015:  return
00016:  stop
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.