Fix JIT for new interface.

pull/13171/head
Joshua Haberman 14 years ago
parent 2fe68c6a5a
commit a5506318aa
  1. 28
      src/upb_decoder_x86.dasc
  2. 2
      src/upb_handlers.c
  3. 4
      tests/test_decoder.c

@ -361,10 +361,10 @@ static void upb_decoder_jit_field(upb_decoder *d, uint32_t tag, uint32_t next_ta
// Call callbacks.
if (upb_issubmsgtype(f->type)) {
// Call startsubmsg handler (if any).
if (f->cb.startsubmsg != upb_startsubmsg_nop) {
if (f->startsubmsg != upb_startsubmsg_nop) {
// upb_sflow_t startsubmsg(void *closure, upb_value fval)
| mov r12d, ARG3_32
| callp f->cb.startsubmsg
| callp f->startsubmsg
} else {
| mov rdx, CLOSURE
| mov r12d, ARG3_32
@ -388,7 +388,7 @@ static void upb_decoder_jit_field(upb_decoder *d, uint32_t tag, uint32_t next_ta
| mov DECODER->dispatcher.top, rax
| mov FRAME, rax
upb_mhandlers *sub_m = upb_handlers_getmsgent(d->dispatcher.handlers, f);
upb_mhandlers *sub_m = upb_fhandlers_getsubmsg(f);
if (sub_m->jit_parent_field_done_pclabel != UPB_MULTIPLE) {
| jmp =>sub_m->jit_startmsg_pclabel;
} else {
@ -410,7 +410,7 @@ static void upb_decoder_jit_field(upb_decoder *d, uint32_t tag, uint32_t next_ta
| callp f->endsubmsg
}
} else {
| callp f->cb.value
| callp f->value
}
// TODO: Handle UPB_SKIPSUBMSG, UPB_BREAK
@ -529,14 +529,14 @@ static void upb_decoder_jit(upb_decoder *d) {
| mov PTR, DECODER->ptr
upb_handlers *h = d->dispatcher.handlers;
if (h->msgs[0].jit_parent_field_done_pclabel == UPB_MULTIPLE) {
| call =>h->msgs[0].jit_startmsg_pclabel
if (h->msgs[0]->jit_parent_field_done_pclabel == UPB_MULTIPLE) {
| call =>h->msgs[0]->jit_startmsg_pclabel
| jmp ->exit_jit
}
// TODO: push return addresses for re-entry (will be necessary for multiple
// buffer support).
for (int i = 0; i < h->msgs_len; i++) upb_decoder_jit_msg(d, &h->msgs[i]);
for (int i = 0; i < h->msgs_len; i++) upb_decoder_jit_msg(d, h->msgs[i]);
|->exit_jit:
| pop rbx
@ -581,13 +581,13 @@ void upb_decoder_jit_assignmsglabs(upb_mhandlers *m, uint32_t *pclabel_count) {
// Second pass: for messages that have only one parent, link them to the field
// from which they are called.
void upb_decoder_jit_assignmsglabs2(upb_handlers *h, upb_mhandlers *m) {
void upb_decoder_jit_assignmsglabs2(upb_mhandlers *m) {
upb_inttable_iter i;
for(i = upb_inttable_begin(&m->fieldtab); !upb_inttable_done(i);
i = upb_inttable_next(&m->fieldtab, i)) {
upb_fhandlers *f = upb_inttable_iter_value(i);
if (upb_issubmsgtype(f->type)) {
upb_mhandlers *sub_m = upb_handlers_getmsgent(h, f);
upb_mhandlers *sub_m = upb_fhandlers_getsubmsg(f);
if (sub_m->jit_parent_field_done_pclabel == UPB_NONE) {
sub_m->jit_parent_field_done_pclabel = f->jit_submsg_done_pclabel;
} else {
@ -604,12 +604,12 @@ void upb_decoder_makejit(upb_decoder *d) {
uint32_t pclabel_count = 1;
upb_handlers *h = d->dispatcher.handlers;
for (int i = 0; i < h->msgs_len; i++)
upb_decoder_jit_assignmsglabs(&h->msgs[i], &pclabel_count);
upb_decoder_jit_assignmsglabs(h->msgs[i], &pclabel_count);
for (int i = 0; i < h->msgs_len; i++)
upb_decoder_jit_assignmsglabs2(h, &h->msgs[i]);
upb_decoder_jit_assignmsglabs2(h->msgs[i]);
if (h->msgs[0].jit_parent_field_done_pclabel == UPB_NONE) {
h->msgs[0].jit_parent_field_done_pclabel = UPB_TOPLEVEL_ONE;
if (h->msgs[0]->jit_parent_field_done_pclabel == UPB_NONE) {
h->msgs[0]->jit_parent_field_done_pclabel = UPB_TOPLEVEL_ONE;
}
void **globals = malloc(UPB_JIT_GLOBAL__MAX * sizeof(*globals));
@ -631,7 +631,7 @@ void upb_decoder_makejit(upb_decoder *d) {
// Create dispatch tables.
for (int i = 0; i < h->msgs_len; i++) {
upb_mhandlers *m = &h->msgs[i];
upb_mhandlers *m = h->msgs[i];
for (uint32_t j = 0; j <= m->max_field_number; j++) {
upb_fhandlers *f = NULL;
for (int k = 0; k < 8; k++) {

@ -97,7 +97,6 @@ static upb_mhandlers *upb_regmsg_dfs(upb_handlers *h, upb_msgdef *m,
void *closure, upb_strtable *mtab) {
upb_mhandlers *mh = upb_handlers_newmsg(h);
upb_mtab_ent e = {{m->base.fqname, 0}, mh};
printf("Inserting: " UPB_STRFMT "\n", UPB_STRARG(m->base.fqname));
upb_strtable_insert(mtab, &e.e);
if (msgreg_cb) msgreg_cb(closure, mh, m);
upb_msg_iter i;
@ -108,7 +107,6 @@ static upb_mhandlers *upb_regmsg_dfs(upb_handlers *h, upb_msgdef *m,
upb_mhandlers *sub_mh;
upb_mtab_ent *subm_ent;
// The table lookup is necessary to break the DFS for type cycles.
printf("Testing: " UPB_STRFMT "\n", UPB_STRARG(f->def->fqname));
if ((subm_ent = upb_strtable_lookup(mtab, f->def->fqname)) != NULL) {
sub_mh = subm_ent->mh;
} else {

@ -46,10 +46,10 @@ int main(int argc, char *argv[]) {
upb_stdio_reset(out, stdout);
upb_handlers handlers;
upb_handlers_init(&handlers, m);
upb_handlers_init(&handlers);
upb_textprinter *p = upb_textprinter_new();
upb_textprinter_reset(p, upb_stdio_bytesink(out), false);
upb_textprinter_reghandlers(&handlers);
upb_textprinter_reghandlers(&handlers, m);
upb_decoder d;
upb_decoder_init(&d, &handlers);

Loading…
Cancel
Save