IncDec bool needs to push a value

In the ir, it didnt, resulting in crashes/bogus values
Esse commit está contido em:
mwilliams
2013-03-26 15:58:57 -07:00
commit de Sara Golemon
commit 46fe09ca5e
4 arquivos alterados com 42 adições e 6 exclusões
@@ -506,8 +506,13 @@ void HhbcTranslator::emitIncDecL(bool pre, bool inc, uint32_t id) {
// Handle only integer inc/dec for now
Trace* exitTrace = getExitSlowTrace();
SSATmp* src = m_tb->genLdLocAsCell(id, exitTrace);
SSATmp* res = emitIncDec(pre, inc, src);
m_tb->genStLoc(id, res, false, false, nullptr);
if (src->isA(Type::Bool)) {
// inc/dec of a bool is a no-op
push(src);
} else {
SSATmp* res = emitIncDec(pre, inc, src);
m_tb->genStLoc(id, res, false, false, nullptr);
}
}
// only handles integer or double inc/dec
@@ -1032,10 +1032,8 @@ TranslatorX64::irTranslateIncDecL(const Tracelet& t,
bool pre = !post;
bool inc = (oplet == PostInc || oplet == PreInc);
// ++ and -- have no effect on booleans
if (i.inputs[0]->outerType() == KindOfBoolean) return;
HHIR_UNIMPLEMENTED_WHEN((i.inputs[0]->valueType() != KindOfInt64) &&
HHIR_UNIMPLEMENTED_WHEN((i.inputs[0]->valueType() != KindOfBoolean) &&
(i.inputs[0]->valueType() != KindOfInt64) &&
(i.inputs[0]->valueType() != KindOfDouble),
IncDecL_unsupported);
HHIR_EMIT(IncDecL, pre, inc, inputs[0]->location.offset);
+13
Ver Arquivo
@@ -0,0 +1,13 @@
<?php
function test($a, $b) {
$a++;
var_dump($a,$b);
}
$a[] = 1;
test(false, $a);
test(true, $a);
test(1, $a);
test(1.0, $a);
+20
Ver Arquivo
@@ -0,0 +1,20 @@
bool(false)
array(1) {
[0]=>
int(1)
}
bool(true)
array(1) {
[0]=>
int(1)
}
int(2)
array(1) {
[0]=>
int(1)
}
float(2)
array(1) {
[0]=>
int(1)
}