Skip to content

Commit c89bd60

Browse files
committed
Use hint in order to do indexed lookups of attributes in the v-table delegation case; should be a small win for parsing, invocation, etc.
1 parent ef1c9e3 commit c89bd60

File tree

2 files changed

+72
-36
lines changed

2 files changed

+72
-36
lines changed

src/ops/nqp.ops

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,12 @@ inline op stable_publish_vtable_handler_mapping(in PMC, in PMC) :base_core {
902902
}
903903
}
904904
if (idx >= 0) {
905-
st->parrot_vtable_handler_mapping[idx].class_handle = VTABLE_get_pmc_keyed_int(interp,slot,0);
906-
st->parrot_vtable_handler_mapping[idx].attr_name = VTABLE_get_string_keyed_int(interp,slot,1);
905+
PMC *class_handle = VTABLE_get_pmc_keyed_int(interp, slot, 0);
906+
STRING *attr_name = VTABLE_get_string_keyed_int(interp, slot, 1);
907+
st->parrot_vtable_handler_mapping[idx].class_handle = class_handle;
908+
st->parrot_vtable_handler_mapping[idx].attr_name = attr_name;
909+
st->parrot_vtable_handler_mapping[idx].hint =
910+
REPR(class_handle)->hint_for(interp, class_handle, attr_name);
907911
}
908912
else
909913
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,

src/pmc/sixmodelobject.pmc

Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
262262
return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
263263
}
264264
else if (vth && vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].class_handle) {
265-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].class_handle,
266-
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].attr_name);
265+
PMC *val = REPR(decont)->get_attribute(interp, decont,
266+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].class_handle,
267+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].attr_name,
268+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED].hint);
267269
return VTABLE_get_pmc_keyed(interp, val, key);
268270
}
269271
else
@@ -287,8 +289,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
287289
return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
288290
}
289291
else if (vth && vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].class_handle) {
290-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].class_handle,
291-
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].attr_name);
292+
PMC *val = REPR(decont)->get_attribute(interp, decont,
293+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].class_handle,
294+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].attr_name,
295+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_INT].hint);
292296
return VTABLE_get_pmc_keyed_int(interp, val, key);
293297
}
294298
else
@@ -311,8 +315,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
311315
return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
312316
}
313317
else if (vth && vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].class_handle) {
314-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].class_handle,
315-
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].attr_name);
318+
PMC *val = REPR(decont)->get_attribute(interp, decont,
319+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].class_handle,
320+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].attr_name,
321+
vth[PARROT_VTABLE_SLOT_GET_PMC_KEYED_STR].hint);
316322
return VTABLE_get_pmc_keyed_str(interp, val, key);
317323
}
318324
else
@@ -341,8 +347,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
341347
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
342348
}
343349
else if (vth && vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].class_handle) {
344-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].class_handle,
345-
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].attr_name);
350+
PMC *val = REPR(decont)->get_attribute(interp, decont,
351+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].class_handle,
352+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].attr_name,
353+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED].hint);
346354
VTABLE_set_pmc_keyed(interp, val, key, value);
347355
}
348356
else
@@ -365,8 +373,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
365373
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
366374
}
367375
else if (vth && vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].class_handle) {
368-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].class_handle,
369-
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].attr_name);
376+
PMC *val = REPR(decont)->get_attribute(interp, decont,
377+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].class_handle,
378+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].attr_name,
379+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_INT].hint);
370380
VTABLE_set_pmc_keyed_int(interp, val, key, value);
371381
}
372382
else
@@ -388,8 +398,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
388398
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
389399
}
390400
else if (vth && vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].class_handle) {
391-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].class_handle,
392-
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].attr_name);
401+
PMC *val = REPR(decont)->get_attribute(interp, decont,
402+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].class_handle,
403+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].attr_name,
404+
vth[PARROT_VTABLE_SLOT_SET_PMC_KEYED_STR].hint);
393405
VTABLE_set_pmc_keyed_str(interp, val, key, value);
394406
}
395407
else
@@ -419,8 +431,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
419431
return VTABLE_get_integer_keyed_int(interp, cappy, 0);
420432
}
421433
else if (vth && vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].class_handle) {
422-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].class_handle,
423-
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].attr_name);
434+
PMC *val = REPR(decont)->get_attribute(interp, decont,
435+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].class_handle,
436+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].attr_name,
437+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED].hint);
424438
return VTABLE_exists_keyed(interp, val, key);
425439
}
426440
else
@@ -444,8 +458,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
444458
return VTABLE_get_integer_keyed_int(interp, cappy, 0);
445459
}
446460
else if (vth && vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].class_handle) {
447-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].class_handle,
448-
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].attr_name);
461+
PMC *val = REPR(decont)->get_attribute(interp, decont,
462+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].class_handle,
463+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].attr_name,
464+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_INT].hint);
449465
return VTABLE_exists_keyed_int(interp, val, key);
450466
}
451467
else
@@ -468,8 +484,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
468484
return VTABLE_get_integer_keyed_int(interp, cappy, 0);
469485
}
470486
else if (vth && vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].class_handle) {
471-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].class_handle,
472-
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].attr_name);
487+
PMC *val = REPR(decont)->get_attribute(interp, decont,
488+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].class_handle,
489+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].attr_name,
490+
vth[PARROT_VTABLE_SLOT_EXISTS_KEYED_STR].hint);
473491
return VTABLE_exists_keyed_str(interp, val, key);
474492
}
475493
else
@@ -498,9 +516,11 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
498516
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
499517
}
500518
else if (vth && vth[PARROT_VTABLE_SLOT_DELETE_KEYED].class_handle) {
501-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_DELETE_KEYED].class_handle,
502-
vth[PARROT_VTABLE_SLOT_DELETE_KEYED].attr_name);
503-
VTABLE_delete_keyed(interp, val, key);
519+
PMC *val = REPR(decont)->get_attribute(interp, decont,
520+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED].class_handle,
521+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED].attr_name,
522+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED].hint);
523+
VTABLE_delete_keyed(interp, val, key);
504524
}
505525
else
506526
SUPER(key);
@@ -522,8 +542,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
522542
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
523543
}
524544
else if (vth && vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].class_handle) {
525-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].class_handle,
526-
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].attr_name);
545+
PMC *val = REPR(decont)->get_attribute(interp, decont,
546+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].class_handle,
547+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].attr_name,
548+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_INT].hint);
527549
VTABLE_delete_keyed_int(interp, val, key);
528550
}
529551
else
@@ -545,8 +567,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
545567
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
546568
}
547569
else if (vth && vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].class_handle) {
548-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].class_handle,
549-
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].attr_name);
570+
PMC *val = REPR(decont)->get_attribute(interp, decont,
571+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].class_handle,
572+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].attr_name,
573+
vth[PARROT_VTABLE_SLOT_DELETE_KEYED_STR].hint);
550574
VTABLE_delete_keyed_str(interp, val, key);
551575
}
552576
else
@@ -568,9 +592,11 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
568592
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
569593
}
570594
else if (vth && vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].class_handle) {
571-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].class_handle,
572-
vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].attr_name);
573-
VTABLE_unshift_pmc(interp, val, value);
595+
PMC *val = REPR(decont)->get_attribute(interp, decont,
596+
vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].class_handle,
597+
vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].attr_name,
598+
vth[PARROT_VTABLE_SLOT_UNSHIFT_PMC].hint);
599+
VTABLE_unshift_pmc(interp, val, value);
574600
}
575601
else
576602
SUPER(value);
@@ -591,8 +617,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
591617
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
592618
}
593619
else if (vth && vth[PARROT_VTABLE_SLOT_PUSH_PMC].class_handle) {
594-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_PUSH_PMC].class_handle,
595-
vth[PARROT_VTABLE_SLOT_PUSH_PMC].attr_name);
620+
PMC *val = REPR(decont)->get_attribute(interp, decont,
621+
vth[PARROT_VTABLE_SLOT_PUSH_PMC].class_handle,
622+
vth[PARROT_VTABLE_SLOT_PUSH_PMC].attr_name,
623+
vth[PARROT_VTABLE_SLOT_PUSH_PMC].hint);
596624
VTABLE_push_pmc(interp, val, value);
597625
}
598626
else
@@ -611,8 +639,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
611639
return (opcode_t *)next;
612640
}
613641
else if (vth && vth[PARROT_VTABLE_SLOT_INVOKE].class_handle) {
614-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_INVOKE].class_handle,
615-
vth[PARROT_VTABLE_SLOT_INVOKE].attr_name);
642+
PMC *val = REPR(decont)->get_attribute(interp, decont,
643+
vth[PARROT_VTABLE_SLOT_INVOKE].class_handle,
644+
vth[PARROT_VTABLE_SLOT_INVOKE].attr_name,
645+
vth[PARROT_VTABLE_SLOT_INVOKE].hint);
616646
return VTABLE_invoke(interp, val, next);
617647
}
618648
else
@@ -634,8 +664,10 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
634664
return VTABLE_get_pmc_keyed_int(interp, cappy, 0);
635665
}
636666
else if (vth && vth[PARROT_VTABLE_SLOT_GET_ITER].class_handle) {
637-
PMC *val = VTABLE_get_attr_keyed(interp, decont, vth[PARROT_VTABLE_SLOT_GET_ITER].class_handle,
638-
vth[PARROT_VTABLE_SLOT_GET_ITER].attr_name);
667+
PMC *val = REPR(decont)->get_attribute(interp, decont,
668+
vth[PARROT_VTABLE_SLOT_GET_ITER].class_handle,
669+
vth[PARROT_VTABLE_SLOT_GET_ITER].attr_name,
670+
vth[PARROT_VTABLE_SLOT_GET_ITER].hint);
639671
return VTABLE_get_iter(interp, val);
640672
}
641673
else

0 commit comments

Comments
 (0)