Remove no-op OP_swap+OP_swap bytecode sequence (#143)
Observed in generated code for static initializers. We could in theory track and correct it in js_parse_class() but doing it as a peephole optimization is both easier and more general.
This commit is contained in:
parent
fb1b1ced26
commit
51633afe56
1 changed files with 9 additions and 0 deletions
|
@ -29675,6 +29675,15 @@ static __exception int resolve_labels(JSContext *ctx, JSFunctionDef *s)
|
|||
}
|
||||
goto no_change;
|
||||
|
||||
case OP_swap:
|
||||
// transformation: swap swap -> nothing!
|
||||
if (code_match(&cc, pos_next, OP_swap, -1, -1)) {
|
||||
if (cc.line_num >= 0) line_num = cc.line_num;
|
||||
pos_next = cc.pos;
|
||||
break;
|
||||
}
|
||||
goto no_change;
|
||||
|
||||
case OP_get_loc:
|
||||
{
|
||||
/* transformation:
|
||||
|
|
Loading…
Reference in a new issue