d55c44a8ca
Our ext_hhvm generated code is casting TypedValue* to Value* on the assumption that the offset of TypedValue::m_data is 0. Fix this assumption, and also while in the same code, replace some (t == KindOfString || t == KindOfStaticString) with IS_STATIC_STRING(t), which does a single bit test instead of two comparisons.
203 linhas
7.6 KiB
C++
203 linhas
7.6 KiB
C++
/*
|
|
+----------------------------------------------------------------------+
|
|
| HipHop for PHP |
|
|
+----------------------------------------------------------------------+
|
|
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
|
|
| Copyright (c) 1997-2010 The PHP Group |
|
|
+----------------------------------------------------------------------+
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
| available through the world-wide-web at the following url: |
|
|
| http://www.php.net/license/3_01.txt |
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
+----------------------------------------------------------------------+
|
|
*/
|
|
#include <runtime/ext_hhvm/ext_hhvm.h>
|
|
#include <runtime/base/builtin_functions.h>
|
|
#include <runtime/base/array/array_init.h>
|
|
#include <runtime/ext/ext.h>
|
|
#include <runtime/vm/class.h>
|
|
#include <runtime/vm/runtime.h>
|
|
#include <exception>
|
|
|
|
namespace HPHP {
|
|
|
|
/*
|
|
int HPHP::f_thrift_protocol_set_compact_version(int)
|
|
_ZN4HPHP37f_thrift_protocol_set_compact_versionEi
|
|
|
|
(return value) => rax
|
|
version => rdi
|
|
*/
|
|
|
|
int fh_thrift_protocol_set_compact_version(int version) asm("_ZN4HPHP37f_thrift_protocol_set_compact_versionEi");
|
|
|
|
TypedValue * fg1_thrift_protocol_set_compact_version(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
|
TypedValue * fg1_thrift_protocol_set_compact_version(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
rv->m_type = KindOfInt64;
|
|
tvCastToInt64InPlace(args-0);
|
|
rv->m_data.num = (int64_t)fh_thrift_protocol_set_compact_version((int)(args[-0].m_data.num));
|
|
return rv;
|
|
}
|
|
|
|
TypedValue* fg_thrift_protocol_set_compact_version(HPHP::VM::ActRec *ar) {
|
|
TypedValue rv;
|
|
int64_t count = ar->numArgs();
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
if (count == 1LL) {
|
|
if ((args-0)->m_type == KindOfInt64) {
|
|
rv.m_type = KindOfInt64;
|
|
rv.m_data.num = (int64_t)fh_thrift_protocol_set_compact_version((int)(args[-0].m_data.num));
|
|
frame_free_locals_no_this_inl(ar, 1);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
} else {
|
|
fg1_thrift_protocol_set_compact_version(&rv, ar, count);
|
|
frame_free_locals_no_this_inl(ar, 1);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
}
|
|
} else {
|
|
throw_wrong_arguments_nr("thrift_protocol_set_compact_version", count, 1, 1, 1);
|
|
}
|
|
rv.m_data.num = 0LL;
|
|
rv.m_type = KindOfNull;
|
|
frame_free_locals_no_this_inl(ar, 1);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
return &ar->m_r;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
void HPHP::f_thrift_protocol_write_compact(HPHP::Object const&, HPHP::String const&, long, HPHP::Object const&, int)
|
|
_ZN4HPHP31f_thrift_protocol_write_compactERKNS_6ObjectERKNS_6StringElS2_i
|
|
|
|
transportobj => rdi
|
|
method_name => rsi
|
|
msgtype => rdx
|
|
request_struct => rcx
|
|
seqid => r8
|
|
*/
|
|
|
|
void fh_thrift_protocol_write_compact(Value* transportobj, Value* method_name, long msgtype, Value* request_struct, int seqid) asm("_ZN4HPHP31f_thrift_protocol_write_compactERKNS_6ObjectERKNS_6StringElS2_i");
|
|
|
|
TypedValue * fg1_thrift_protocol_write_compact(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
|
TypedValue * fg1_thrift_protocol_write_compact(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
rv->m_data.num = 0LL;
|
|
rv->m_type = KindOfNull;
|
|
if ((args-4)->m_type != KindOfInt64) {
|
|
tvCastToInt64InPlace(args-4);
|
|
}
|
|
if ((args-3)->m_type != KindOfObject) {
|
|
tvCastToObjectInPlace(args-3);
|
|
}
|
|
if ((args-2)->m_type != KindOfInt64) {
|
|
tvCastToInt64InPlace(args-2);
|
|
}
|
|
if (!IS_STRING_TYPE((args-1)->m_type)) {
|
|
tvCastToStringInPlace(args-1);
|
|
}
|
|
if ((args-0)->m_type != KindOfObject) {
|
|
tvCastToObjectInPlace(args-0);
|
|
}
|
|
fh_thrift_protocol_write_compact(&args[-0].m_data, &args[-1].m_data, (long)(args[-2].m_data.num), &args[-3].m_data, (int)(args[-4].m_data.num));
|
|
return rv;
|
|
}
|
|
|
|
TypedValue* fg_thrift_protocol_write_compact(HPHP::VM::ActRec *ar) {
|
|
TypedValue rv;
|
|
int64_t count = ar->numArgs();
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
if (count == 5LL) {
|
|
if ((args-4)->m_type == KindOfInt64 && (args-3)->m_type == KindOfObject && (args-2)->m_type == KindOfInt64 && IS_STRING_TYPE((args-1)->m_type) && (args-0)->m_type == KindOfObject) {
|
|
rv.m_data.num = 0LL;
|
|
rv.m_type = KindOfNull;
|
|
fh_thrift_protocol_write_compact(&args[-0].m_data, &args[-1].m_data, (long)(args[-2].m_data.num), &args[-3].m_data, (int)(args[-4].m_data.num));
|
|
frame_free_locals_no_this_inl(ar, 5);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
} else {
|
|
fg1_thrift_protocol_write_compact(&rv, ar, count);
|
|
frame_free_locals_no_this_inl(ar, 5);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
}
|
|
} else {
|
|
throw_wrong_arguments_nr("thrift_protocol_write_compact", count, 5, 5, 1);
|
|
}
|
|
rv.m_data.num = 0LL;
|
|
rv.m_type = KindOfNull;
|
|
frame_free_locals_no_this_inl(ar, 5);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
return &ar->m_r;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
HPHP::Variant HPHP::f_thrift_protocol_read_compact(HPHP::Object const&, HPHP::String const&)
|
|
_ZN4HPHP30f_thrift_protocol_read_compactERKNS_6ObjectERKNS_6StringE
|
|
|
|
(return value) => rax
|
|
_rv => rdi
|
|
transportobj => rsi
|
|
obj_typename => rdx
|
|
*/
|
|
|
|
TypedValue* fh_thrift_protocol_read_compact(TypedValue* _rv, Value* transportobj, Value* obj_typename) asm("_ZN4HPHP30f_thrift_protocol_read_compactERKNS_6ObjectERKNS_6StringE");
|
|
|
|
TypedValue * fg1_thrift_protocol_read_compact(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
|
TypedValue * fg1_thrift_protocol_read_compact(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
if (!IS_STRING_TYPE((args-1)->m_type)) {
|
|
tvCastToStringInPlace(args-1);
|
|
}
|
|
if ((args-0)->m_type != KindOfObject) {
|
|
tvCastToObjectInPlace(args-0);
|
|
}
|
|
fh_thrift_protocol_read_compact((rv), &args[-0].m_data, &args[-1].m_data);
|
|
if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
|
|
return rv;
|
|
}
|
|
|
|
TypedValue* fg_thrift_protocol_read_compact(HPHP::VM::ActRec *ar) {
|
|
TypedValue rv;
|
|
int64_t count = ar->numArgs();
|
|
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
|
if (count == 2LL) {
|
|
if (IS_STRING_TYPE((args-1)->m_type) && (args-0)->m_type == KindOfObject) {
|
|
fh_thrift_protocol_read_compact((&(rv)), &args[-0].m_data, &args[-1].m_data);
|
|
if (rv.m_type == KindOfUninit) rv.m_type = KindOfNull;
|
|
frame_free_locals_no_this_inl(ar, 2);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
} else {
|
|
fg1_thrift_protocol_read_compact(&rv, ar, count);
|
|
frame_free_locals_no_this_inl(ar, 2);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
}
|
|
} else {
|
|
throw_wrong_arguments_nr("thrift_protocol_read_compact", count, 2, 2, 1);
|
|
}
|
|
rv.m_data.num = 0LL;
|
|
rv.m_type = KindOfNull;
|
|
frame_free_locals_no_this_inl(ar, 2);
|
|
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
|
return &ar->m_r;
|
|
return &ar->m_r;
|
|
}
|
|
|
|
|
|
|
|
|
|
} // !HPHP
|
|
|