Fix bugs with VariableSerializer and setObjectInfo() / setResourceInfo()

Summary: writeArrayFooter() depends on m_objCode, but callers of setObjectInfo()
could possibly clobber m_objCode and not properly restore it (i.e. they
weren't following a proper "push/pop" pattern). This caused var_export()
to produce wrong output in some cases.

This diff replaces all uses of setObjectInfo() and setResourceInfo() to
instead use new push/pop APIs to avoid these kinds of bugs.

Reviewed By: @swtaarrs

Differential Revision: D1660182