@@ -1536,7 +1536,8 @@ static upb_tabkey strcopy(lookupkey_t k2, upb_alloc *a) {
1536
1536
char * str = upb_malloc (a , k2 .str .len + sizeof (uint32_t ) + 1 );
1537
1537
if (str == NULL ) return 0 ;
1538
1538
memcpy (str , & len , sizeof (uint32_t ));
1539
- memcpy (str + sizeof (uint32_t ), k2 .str .str , k2 .str .len + 1 );
1539
+ memcpy (str + sizeof (uint32_t ), k2 .str .str , k2 .str .len );
1540
+ str [sizeof (uint32_t ) + k2 .str .len ] = '\0' ;
1540
1541
return (uintptr_t )str ;
1541
1542
}
1542
1543
@@ -6309,12 +6310,10 @@ static void set_bytecode_handlers(mgroup *g) {
6309
6310
6310
6311
/* TODO(haberman): allow this to be constructed for an arbitrary set of dest
6311
6312
* handlers and other mgroups (but verify we have a transitive closure). */
6312
- const mgroup * mgroup_new (const upb_handlers * dest , bool allowjit , bool lazy ) {
6313
+ const mgroup * mgroup_new (const upb_handlers * dest , bool lazy ) {
6313
6314
mgroup * g ;
6314
6315
compiler * c ;
6315
6316
6316
- UPB_UNUSED (allowjit );
6317
-
6318
6317
g = newgroup ();
6319
6318
c = newcompiler (g , lazy );
6320
6319
find_methods (c , dest );
@@ -6359,7 +6358,6 @@ upb_pbcodecache *upb_pbcodecache_new(upb_handlercache *dest) {
6359
6358
if (!c ) return NULL ;
6360
6359
6361
6360
c -> dest = dest ;
6362
- c -> allow_jit = true;
6363
6361
c -> lazy = false;
6364
6362
6365
6363
c -> arena = upb_arena_new ();
@@ -6369,29 +6367,19 @@ upb_pbcodecache *upb_pbcodecache_new(upb_handlercache *dest) {
6369
6367
}
6370
6368
6371
6369
void upb_pbcodecache_free (upb_pbcodecache * c ) {
6372
- size_t i ;
6370
+ upb_inttable_iter i ;
6373
6371
6374
- for (i = 0 ; i < upb_inttable_count (& c -> groups ); i ++ ) {
6375
- upb_value v ;
6376
- bool ok = upb_inttable_lookup (& c -> groups , i , & v );
6377
- UPB_ASSERT (ok );
6378
- freegroup ((void * )upb_value_getconstptr (v ));
6372
+ upb_inttable_begin (& i , & c -> groups );
6373
+ for (; !upb_inttable_done (& i ); upb_inttable_next (& i )) {
6374
+ upb_value val = upb_inttable_iter_value (& i );
6375
+ freegroup ((void * )upb_value_getconstptr (val ));
6379
6376
}
6380
6377
6381
6378
upb_inttable_uninit (& c -> groups );
6382
6379
upb_arena_free (c -> arena );
6383
6380
upb_gfree (c );
6384
6381
}
6385
6382
6386
- bool upb_pbcodecache_allowjit (const upb_pbcodecache * c ) {
6387
- return c -> allow_jit ;
6388
- }
6389
-
6390
- void upb_pbcodecache_setallowjit (upb_pbcodecache * c , bool allow ) {
6391
- UPB_ASSERT (upb_inttable_count (& c -> groups ) == 0 );
6392
- c -> allow_jit = allow ;
6393
- }
6394
-
6395
6383
void upb_pbdecodermethodopts_setlazy (upb_pbcodecache * c , bool lazy ) {
6396
6384
UPB_ASSERT (upb_inttable_count (& c -> groups ) == 0 );
6397
6385
c -> lazy = lazy ;
@@ -6404,11 +6392,14 @@ const upb_pbdecodermethod *upb_pbcodecache_get(upb_pbcodecache *c,
6404
6392
const upb_handlers * h ;
6405
6393
const mgroup * g ;
6406
6394
6407
- /* Right now we build a new DecoderMethod every time.
6408
- * TODO(haberman): properly cache methods by their true key. */
6409
6395
h = upb_handlercache_get (c -> dest , md );
6410
- g = mgroup_new (h , c -> allow_jit , c -> lazy );
6411
- upb_inttable_push (& c -> groups , upb_value_constptr (g ));
6396
+ if (upb_inttable_lookupptr (& c -> groups , md , & v )) {
6397
+ g = upb_value_getconstptr (v );
6398
+ } else {
6399
+ g = mgroup_new (h , c -> lazy );
6400
+ ok = upb_inttable_insertptr (& c -> groups , md , upb_value_constptr (g ));
6401
+ UPB_ASSERT (ok );
6402
+ }
6412
6403
6413
6404
ok = upb_inttable_lookupptr (& g -> methods , h , & v );
6414
6405
UPB_ASSERT (ok );
@@ -6490,16 +6481,6 @@ static size_t stacksize(upb_pbdecoder *d, size_t entries) {
6490
6481
static size_t callstacksize (upb_pbdecoder * d , size_t entries ) {
6491
6482
UPB_UNUSED (d );
6492
6483
6493
- #ifdef UPB_USE_JIT_X64
6494
- if (d -> method_ -> is_native_ ) {
6495
- /* Each native stack frame needs two pointers, plus we need a few frames for
6496
- * the enter/exit trampolines. */
6497
- size_t ret = entries * sizeof (void * ) * 2 ;
6498
- ret += sizeof (void * ) * 10 ;
6499
- return ret ;
6500
- }
6501
- #endif
6502
-
6503
6484
return entries * sizeof (uint32_t * );
6504
6485
}
6505
6486
@@ -7315,17 +7296,6 @@ void *upb_pbdecoder_startbc(void *closure, const void *pc, size_t size_hint) {
7315
7296
return d ;
7316
7297
}
7317
7298
7318
- void * upb_pbdecoder_startjit (void * closure , const void * hd , size_t size_hint ) {
7319
- upb_pbdecoder * d = closure ;
7320
- UPB_UNUSED (hd );
7321
- UPB_UNUSED (size_hint );
7322
- d -> top -> end_ofs = UINT64_MAX ;
7323
- d -> bufstart_ofs = 0 ;
7324
- d -> call_len = 0 ;
7325
- d -> skip = 0 ;
7326
- return d ;
7327
- }
7328
-
7329
7299
bool upb_pbdecoder_end (void * closure , const void * handler_data ) {
7330
7300
upb_pbdecoder * d = closure ;
7331
7301
const upb_pbdecodermethod * method = handler_data ;
@@ -7351,14 +7321,6 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) {
7351
7321
end = offset (d );
7352
7322
d -> top -> end_ofs = end ;
7353
7323
7354
- #ifdef UPB_USE_JIT_X64
7355
- if (method -> is_native_ ) {
7356
- const mgroup * group = (const mgroup * )method -> group ;
7357
- if (d -> top != d -> stack )
7358
- d -> stack -> end_ofs = 0 ;
7359
- group -> jit_code (closure , method -> code_base .ptr , & dummy , 0 , NULL );
7360
- } else
7361
- #endif
7362
7324
{
7363
7325
const uint32_t * p = d -> pc ;
7364
7326
d -> stack -> end_ofs = end ;
0 commit comments