Permalink
Browse files

condition of for-statement

Summary: if condition expression in for statement is expression list - emit all but the last elements of the list as ignored expressions

Reviewed By: oulgen

Differential Revision: D5378053

fbshipit-source-id: 8b667f23b849c7e603c420a74a39d5bd21b41aa3
  • Loading branch information...
vladima authored and hhvm-bot committed Jul 7, 2017
1 parent 216a29d commit c1ae3cd132250cd99d88bc3bdd2c48e2428371dc
Showing with 14 additions and 6 deletions.
  1. +14 −5 hphp/hack/src/hhbc/emit_statement.ml
  2. +0 −1 hphp/test/hhcodegen_failing_tests_slow
@@ -368,19 +368,28 @@ and emit_for env e1 e2 e3 b =
instr_jmp start_label;
instr_label break_label;
*)
let check_cond e inst =
match e with
let emit_cond ~jmpz label =
let final cond =
if jmpz then emit_jmpz env cond label else emit_jmpnz env cond label
in
let rec expr_list h tl =
match tl with
| [] -> [final @@ (Pos.none, A.Expr_list [h])]
| h1 :: t1 -> emit_ignored_expr env h :: expr_list h1 t1
in
match e2 with
| _, A.Expr_list [] -> empty
| _ -> inst
| _, A.Expr_list (h::t) -> gather @@ expr_list h t
| cond -> final cond
in
let instrs = gather [
emit_ignored_expr env e1;
check_cond e2 (emit_jmpz env e2 break_label);
emit_cond ~jmpz:true break_label;
instr_label start_label;
emit_stmt env b;
instr_label cont_label;
emit_ignored_expr env e3;
check_cond e2 (emit_jmpnz env e2 start_label);
emit_cond ~jmpz:false start_label;
instr_label break_label;
] in
CBR.rewrite_in_loop instrs cont_label break_label None
@@ -68,7 +68,6 @@ slow/compilation/1238.php
slow/compilation/1247.php
slow/compilation/1259.php
slow/compilation/1282.php
slow/compilation/1295.php
slow/compilation/1301.php
slow/compilation/1311.php
slow/compilation/1316.php

0 comments on commit c1ae3cd

Please sign in to comment.