summaryrefslogtreecommitdiff
path: root/tests/pb
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-11-18 15:21:50 -0800
committerJosh Haberman <jhaberman@gmail.com>2014-11-18 15:21:50 -0800
commit3d0c7c45da5b72a88bfb03dc5ce3384b7f01cef6 (patch)
tree1c9fd69700e1162c7ed78458160800b586600c9b /tests/pb
parent648afe3da654b6e08fe6ea26ae520581eb892e23 (diff)
Sync to Google-internal development.
Diffstat (limited to 'tests/pb')
-rw-r--r--tests/pb/test_decoder.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc
index 2d94d82..d976a54 100644
--- a/tests/pb/test_decoder.cc
+++ b/tests/pb/test_decoder.cc
@@ -207,8 +207,16 @@ void indentbuf(string *buf, int depth) {
buf->append(2 * depth, ' ');
}
+void check_stack_alignment() {
+#ifdef UPB_USE_JIT_X64
+ void *rsp = __builtin_frame_address(0);
+ ASSERT(((uintptr_t)rsp % 16) == 0);
+#endif
+}
+
#define NUMERIC_VALUE_HANDLER(member, ctype, fmt) \
bool value_##member(int* depth, const uint32_t* num, ctype val) { \
+ check_stack_alignment(); \
indentbuf(&output, *depth); \
appendf(&output, "%" PRIu32 ":%" fmt "\n", *num, val); \
return true; \
@@ -222,12 +230,14 @@ NUMERIC_VALUE_HANDLER(float, float, "g")
NUMERIC_VALUE_HANDLER(double, double, "g")
bool value_bool(int* depth, const uint32_t* num, bool val) {
+ check_stack_alignment();
indentbuf(&output, *depth);
appendf(&output, "%" PRIu32 ":%s\n", *num, val ? "true" : "false");
return true;
}
int* startstr(int* depth, const uint32_t* num, size_t size_hint) {
+ check_stack_alignment();
indentbuf(&output, *depth);
appendf(&output, "%" PRIu32 ":(%zu)\"", *num, size_hint);
return depth + 1;
@@ -237,6 +247,7 @@ size_t value_string(int* depth, const uint32_t* num, const char* buf,
size_t n, const upb::BufferHandle* handle) {
UPB_UNUSED(num);
UPB_UNUSED(depth);
+ check_stack_alignment();
output.append(buf, n);
ASSERT(handle == &global_handle);
return n;
@@ -245,11 +256,13 @@ size_t value_string(int* depth, const uint32_t* num, const char* buf,
bool endstr(int* depth, const uint32_t* num) {
UPB_UNUSED(depth);
UPB_UNUSED(num);
+ check_stack_alignment();
output.append("\"\n");
return true;
}
int* startsubmsg(int* depth, const uint32_t* num) {
+ check_stack_alignment();
indentbuf(&output, *depth);
appendf(&output, "%" PRIu32 ":{\n", *num);
return depth + 1;
@@ -257,12 +270,14 @@ int* startsubmsg(int* depth, const uint32_t* num) {
bool endsubmsg(int* depth, const uint32_t* num) {
UPB_UNUSED(num);
+ check_stack_alignment();
indentbuf(&output, *depth);
output.append("}\n");
return true;
}
int* startseq(int* depth, const uint32_t* num) {
+ check_stack_alignment();
indentbuf(&output, *depth);
appendf(&output, "%" PRIu32 ":[\n", *num);
return depth + 1;
@@ -270,12 +285,14 @@ int* startseq(int* depth, const uint32_t* num) {
bool endseq(int* depth, const uint32_t* num) {
UPB_UNUSED(num);
+ check_stack_alignment();
indentbuf(&output, *depth);
output.append("]\n");
return true;
}
bool startmsg(int* depth) {
+ check_stack_alignment();
indentbuf(&output, *depth);
output.append("<\n");
return true;
@@ -283,6 +300,7 @@ bool startmsg(int* depth) {
bool endmsg(int* depth, upb_status* status) {
UPB_UNUSED(status);
+ check_stack_alignment();
indentbuf(&output, *depth);
output.append(">\n");
return true;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback