Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

Commit 940a00d

Browse files
committed
Bring over the latest S-Table bits. This stubs in some bits for method cache and type check support.
1 parent 0fc4e19 commit 940a00d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/metamodel/rakudoobject.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,19 @@ PMC * wrap_object(PARROT_INTERP, void *obj) {
5151
static PMC * default_find_method(PARROT_INTERP, PMC *obj, STRING *name, INTVAL hint) {
5252
/* See if we can find it by hint. */
5353
STable *st = STABLE(obj);
54-
if (hint != NO_HINT && st->vtable && hint < st->vtable_length) {
54+
PMC *cached_method;
55+
if (st->vtable && hint != NO_HINT && hint < st->vtable_length) {
5556
/* Yes, just grab it from the v-table. */
5657
return st->vtable[hint];
5758
}
59+
60+
/* Try the by-name method cache, if the HOW published one. */
61+
else if (st->method_cache && !PMC_IS_NULL(cached_method =
62+
VTABLE_get_pmc_keyed_str(interp, st->method_cache, name))) {
63+
return cached_method;
64+
}
65+
66+
/* Otherwise delegate to the HOW. */
5867
else
5968
{
6069
/* Find the finder - the find_method method. */
@@ -63,6 +72,7 @@ static PMC * default_find_method(PARROT_INTERP, PMC *obj, STRING *name, INTVAL h
6372
PMC *meth = STABLE(HOW)->find_method(interp, HOW, find_method_str, NO_HINT);
6473

6574
/* Call it to get the method to call. */
75+
/* XXX Really want a way to do this without creating a nested runloop. */
6676
PMC *result;
6777
Parrot_ext_call(interp, meth, "PiPS->P", HOW, obj, name, &result);
6878
return result;

src/metamodel/rakudoobject.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,23 @@ typedef struct {
2626
/* The method finder. */
2727
PMC * (*find_method) (PARROT_INTERP, PMC *obj, STRING *name, INTVAL hint);
2828

29+
/* By-name method dispatch cache. */
30+
PMC *method_cache;
31+
2932
/* The computed v-table for static dispatch. */
3033
PMC **vtable;
3134

3235
/* The length of the v-table. */
3336
INTVAL vtable_length;
3437

38+
/* Array of type objects. If this is set, then it is expected to contain
39+
* the type objects of all types that this type is equivalent to (e.g.
40+
* all the things it isa and all the things it does). */
41+
PMC **type_check_cache;
42+
43+
/* The length of the type check cache. */
44+
INTVAL type_check_cache_length;
45+
3546
/* An ID solely for use in caches that last a VM instance. Thus it
3647
* should never, ever be serialized and you should NEVER make a
3748
* type directory based upon this ID. Otherwise you'll create memory

0 commit comments

Comments
 (0)