diff --git a/hphp/runtime/base/tv_helpers.cpp b/hphp/runtime/base/tv_helpers.cpp index c4241fdfe..00c610140 100644 --- a/hphp/runtime/base/tv_helpers.cpp +++ b/hphp/runtime/base/tv_helpers.cpp @@ -164,6 +164,19 @@ void cellCastToInt64InPlace(Cell* cell) { tvDecRefStr(cell); break; } + case KindOfArray: + i = cell->m_data.parr->empty() ? 0 : 1; + tvDecRefArr(cell); + break; + case KindOfObject: + i = cell->m_data.pobj->o_toInt64(); + tvDecRefObj(cell); + break; + default: + not_reached(); + } + cell->m_data.num = i; + cell->m_type = KindOfInt64; } void tvCastToInt64InPlace(TypedValue* tv) { diff --git a/hphp/runtime/vm/jit/translator-runtime.cpp b/hphp/runtime/vm/jit/translator-runtime.cpp index bc4828bbd..16377c024 100644 --- a/hphp/runtime/vm/jit/translator-runtime.cpp +++ b/hphp/runtime/vm/jit/translator-runtime.cpp @@ -159,7 +159,7 @@ int64_t convStrToIntHelper(const StringData* s) { int64_t convCellToIntHelper(TypedValue tv) { // TODO call cellToInt directly from the TC. - return cellToInt(tv); + return cellToInt(&tv); } ObjectData* convCellToObjHelper(TypedValue tv) { diff --git a/hphp/runtime/vm/member_operations.h b/hphp/runtime/vm/member_operations.h index 2f06762e3..245f71d13 100644 --- a/hphp/runtime/vm/member_operations.h +++ b/hphp/runtime/vm/member_operations.h @@ -643,7 +643,7 @@ template inline int64_t castKeyToInt(TypedValue* key) { TypedValue scratch; initScratchKey(scratch, key); - return cellToInt(*tvToCell(key)); + return cellToInt(tvToCell(key)); } template<>