From adb6580d9728c3533faf779812bd7f4c9b27170d Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 20 Aug 2011 18:43:11 -0700 Subject: 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. --- upb/pb/decoder_x86.dasc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'upb/pb') 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 #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 } -- cgit v1.2.3