Open Bug 1392223 Opened 8 years ago Updated 2 years ago

Do not generate bytecode for absolutely-unreachable code

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox57 --- fix-optional

People

(Reporter: arai, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [js:tech-debt])

code: `dis(function (o) {return 10; eval(o)})` actual result: bytecode for `eval(o)` is generated expected result: don't generate code for unreachanbel code see also: https://dxr.mozilla.org/mozilla-central/rev/7dddbd85047c6dc73ddbe1e423cd643a217845b3/devtools/client/debugger/new/parser-worker.js#17334 (that seems to be an optimization(?) for V8) currently we're emitting warning for unreachable code. we could use the same information in bytecode emitter. we should make sure declaration etc keeps working.
might be related to bug 1341943. but in this case it's explicit JS statements, not implicit return.
See Also: → 1341943
Priority: -- → P3
Whiteboard: [js:tech-debt]
Depends on: 1413061

(In reply to Tooru Fujisawa [:arai] from comment #0)

see also:
https://dxr.mozilla.org/mozilla-central/rev/
7dddbd85047c6dc73ddbe1e423cd643a217845b3/devtools/client/debugger/new/parser-
worker.js#17334
(that seems to be an optimization(?) for V8)

The link doesn't work, but the code is the following:

	module.exports = function toFastproperties(o) {
		function Sub() {}
		Sub.prototype = o;
		var receiver = new Sub(); // create an instance
		function ic() { return typeof receiver.foo; } // perform access
		ic(); 
		ic();
		return o;
		eval("o" + o); // ensure no dead code elimination
	}
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.