Fix AddNewElemC bugs in HHIR
commit85aa9442acd23616c6d5c68a4ea5dd67db420361
authorJordan DeLong <jdelong@fb.com>
Mon, 27 May 2013 18:41:41 +0000 (27 11:41 -0700)
committersgolemon <sgolemon@hiphop-ubuntu-12.04-64>
Fri, 31 May 2013 00:32:59 +0000 (30 17:32 -0700)
treeed988ebc1259dd277857729fe84b70f86f1d7e07
parentcd734dec99c7c680b74368b54f558f178120d3bc
Fix AddNewElemC bugs in HHIR

emitAddNewElemC didn't properly implement the specified
behavior for this opcode.  It assumed topC(1) was always an non-static
array with refcount 1 or 0.  This changes to interp the case when it's
not an array, and make the helper support static arrays.  (If it
matters for perf, we should engineer the bytecode spec to require this
as well, since the point of this opcode is initializing array literals
that can't be done as static arrays.)  In practice I think this is
only working because it always comes after a NewArray with a capacity
hint != 1, which means it's a newly allocated non-static array.
Ignoring the capacity hint would've broken it.
hphp/runtime/base/array/hphp_array.cpp
hphp/runtime/vm/translator/hopt/hhbctranslator.cpp
hphp/test/quick/asm_array_elem.hhas [new file with mode: 0644]
hphp/test/quick/asm_array_elem.hhas.expect [new file with mode: 0644]
hphp/test/quick/asm_bad_array_elem.hhas [new file with mode: 0644]
hphp/test/quick/asm_bad_array_elem.hhas.expectf [new file with mode: 0644]