summaryrefslogtreecommitdiff
path: root/upb/pb
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-08-20 18:43:11 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-08-20 18:43:11 -0700
commitadb6580d9728c3533faf779812bd7f4c9b27170d (patch)
tree2aa721539ed7f067e26c2d6b16c657307700150b /upb/pb
parenta5e6a7b029850f77059800d6611f406b91f87dfe (diff)
Let the JIT emit hasbit-setting code in addition to calling a callback.
This leads to a major (20-40%) improvement in the parsetoproto2 benchmark with small messages. We now are faster than proto2 in all apples-to-apples comparisons, at least given the (admittedly limited) set of benchmarks in this source tree.
Diffstat (limited to 'upb/pb')
-rw-r--r--upb/pb/decoder_x86.dasc21
1 files changed, 9 insertions, 12 deletions
diff --git a/upb/pb/decoder_x86.dasc b/upb/pb/decoder_x86.dasc
index 3028086..fe15174 100644
--- a/upb/pb/decoder_x86.dasc
+++ b/upb/pb/decoder_x86.dasc
@@ -126,7 +126,7 @@ void upb_reg_jit_gdb(upb_decoder *d) {
|.type FRAME, upb_dispatcher_frame, r13
|.type STRREF, upb_strref, r14
|.type DECODER, upb_decoder, r15
-|.type STDARRAY, upb_stdarray, r15
+|.type STDARRAY, upb_stdarray
|
|.macro callp, addr
|| if ((uintptr_t)addr < 0xffffffff) {
@@ -273,6 +273,13 @@ void upb_reg_jit_gdb(upb_decoder *d) {
| mov64 ARG2_64, f->fval.val.uint64
|| }
|.endmacro
+|
+|.macro sethas, reg, hasbit
+|| if (hasbit >= 0) {
+| or byte [reg + (hasbit / 8)], (1 << (hasbit % 8))
+|| }
+|.endmacro
+
#include <stdlib.h>
#include "upb/pb/varint.h"
@@ -369,14 +376,6 @@ static void upb_decoder_jit_decodefield(upb_decoder *d, upb_mhandlers *m,
}
}
-// DEPENDS: closure is in ARG1_64
-static void upb_decoder_jit_sethas(upb_decoder *d, upb_fielddef *f) {
- if (f->hasbit < 0) return;
- size_t byte = f->hasbit / 8;
- uint8_t bit = 1 << (f->hasbit % 8);
- | or byte [ARG1_64 + byte], bit
-}
-
#if 0
// These appear not to speed things up, but keeping around for
// further experimentation.
@@ -465,15 +464,12 @@ static void upb_decoder_jit_callcb(upb_decoder *d, upb_fhandlers *f) {
f->value == &upb_stdmsg_setuint64 ||
f->value == &upb_stdmsg_setptr ||
f->value == &upb_stdmsg_setdouble) {
- upb_decoder_jit_sethas(d, fd);
| mov [ARG1_64 + fd->offset], ARG3_64
} else if (f->value == &upb_stdmsg_setint32 ||
f->value == &upb_stdmsg_setuint32 ||
f->value == &upb_stdmsg_setfloat) {
- upb_decoder_jit_sethas(d, fd);
| mov [ARG1_64 + fd->offset], ARG3_32
} else if (f->value == &upb_stdmsg_setbool) {
- upb_decoder_jit_sethas(d, fd);
| mov [ARG1_64 + fd->offset], ARG3_8
#if 0
// These appear not to speed things up, but keeping around for
@@ -495,6 +491,7 @@ static void upb_decoder_jit_callcb(upb_decoder *d, upb_fhandlers *f) {
| loadfval f
| callp f->value
}
+ | sethas CLOSURE, f->valuehasbit
}
// TODO: Handle UPB_SKIPSUBMSG, UPB_BREAK
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback