@@ -877,9 +877,11 @@ unsigned parsePoolEntry(Thread* t,
877
877
Stream& s,
878
878
uint32_t * index,
879
879
GcSingleton* pool,
880
+ GcList* invocations,
880
881
unsigned i)
881
882
{
882
883
PROTECT (t, pool);
884
+ PROTECT (t, invocations);
883
885
884
886
s.setPosition (index [i]);
885
887
@@ -921,7 +923,7 @@ unsigned parsePoolEntry(Thread* t,
921
923
case CONSTANT_Class: {
922
924
if (singletonObject (t, pool, i) == 0 ) {
923
925
unsigned si = s.read2 () - 1 ;
924
- parsePoolEntry (t, s, index , pool, si);
926
+ parsePoolEntry (t, s, index , pool, invocations, si);
925
927
926
928
GcReference* value = makeReference (
927
929
t, 0 , 0 , cast<GcByteArray>(t, singletonObject (t, pool, si)), 0 );
@@ -937,7 +939,7 @@ unsigned parsePoolEntry(Thread* t,
937
939
case CONSTANT_String: {
938
940
if (singletonObject (t, pool, i) == 0 ) {
939
941
unsigned si = s.read2 () - 1 ;
940
- parsePoolEntry (t, s, index , pool, si);
942
+ parsePoolEntry (t, s, index , pool, invocations, si);
941
943
942
944
object value
943
945
= parseUtf8 (t, cast<GcByteArray>(t, singletonObject (t, pool, si)));
@@ -958,8 +960,8 @@ unsigned parsePoolEntry(Thread* t,
958
960
unsigned ni = s.read2 () - 1 ;
959
961
unsigned ti = s.read2 () - 1 ;
960
962
961
- parsePoolEntry (t, s, index , pool, ni);
962
- parsePoolEntry (t, s, index , pool, ti);
963
+ parsePoolEntry (t, s, index , pool, invocations, ni);
964
+ parsePoolEntry (t, s, index , pool, invocations, ti);
963
965
964
966
GcByteArray* name = cast<GcByteArray>(t, singletonObject (t, pool, ni));
965
967
GcByteArray* type = cast<GcByteArray>(t, singletonObject (t, pool, ti));
@@ -984,8 +986,8 @@ unsigned parsePoolEntry(Thread* t,
984
986
unsigned ci = s.read2 () - 1 ;
985
987
unsigned nti = s.read2 () - 1 ;
986
988
987
- parsePoolEntry (t, s, index , pool, ci);
988
- parsePoolEntry (t, s, index , pool, nti);
989
+ parsePoolEntry (t, s, index , pool, invocations, ci);
990
+ parsePoolEntry (t, s, index , pool, invocations, nti);
989
991
990
992
GcByteArray* className
991
993
= cast<GcReference>(t, singletonObject (t, pool, ci))->name ();
@@ -1015,7 +1017,7 @@ unsigned parsePoolEntry(Thread* t,
1015
1017
unsigned kind = s.read1 ();
1016
1018
unsigned ri = s.read2 () - 1 ;
1017
1019
1018
- parsePoolEntry (t, s, index , pool, ri);
1020
+ parsePoolEntry (t, s, index , pool, invocations, ri);
1019
1021
1020
1022
GcReference* value = cast<GcReference>(t, singletonObject (t, pool, ri));
1021
1023
@@ -1040,7 +1042,7 @@ unsigned parsePoolEntry(Thread* t,
1040
1042
if (singletonObject (t, pool, i) == 0 ) {
1041
1043
unsigned ni = s.read2 () - 1 ;
1042
1044
1043
- parsePoolEntry (t, s, index , pool, ni);
1045
+ parsePoolEntry (t, s, index , pool, invocations, ni);
1044
1046
1045
1047
pool->setBodyElement (
1046
1048
t, i, reinterpret_cast <uintptr_t >(singletonObject (t, pool, ni)));
@@ -1052,7 +1054,7 @@ unsigned parsePoolEntry(Thread* t,
1052
1054
unsigned bootstrap = s.read2 ();
1053
1055
unsigned nti = s.read2 () - 1 ;
1054
1056
1055
- parsePoolEntry (t, s, index , pool, nti);
1057
+ parsePoolEntry (t, s, index , pool, invocations, nti);
1056
1058
1057
1059
GcPair* nameAndType = cast<GcPair>(t, singletonObject (t, pool, nti));
1058
1060
@@ -1086,9 +1088,12 @@ unsigned parsePoolEntry(Thread* t,
1086
1088
0 );
1087
1089
1088
1090
object value = reinterpret_cast <object>(
1089
- makeInvocation (t, bootstrap, -1 , 0 , pool, template_, 0 ));
1091
+ makeInvocation (t, bootstrap, -1 , 0 , pool, template_, 0 , 0 ));
1092
+ PROTECT (t, value);
1090
1093
1091
1094
pool->setBodyElement (t, i, reinterpret_cast <uintptr_t >(value));
1095
+
1096
+ listAppend (t, invocations, value);
1092
1097
}
1093
1098
return 1 ;
1094
1099
@@ -1097,8 +1102,10 @@ unsigned parsePoolEntry(Thread* t,
1097
1102
}
1098
1103
}
1099
1104
1100
- GcSingleton* parsePool (Thread* t, Stream& s)
1105
+ GcSingleton* parsePool (Thread* t, Stream& s, GcList* invocations )
1101
1106
{
1107
+ PROTECT (t, invocations);
1108
+
1102
1109
unsigned count = s.read2 () - 1 ;
1103
1110
GcSingleton* pool = makeSingletonOfSize (t, count + poolMaskSize (count));
1104
1111
PROTECT (t, pool);
@@ -1184,7 +1191,7 @@ GcSingleton* parsePool(Thread* t, Stream& s)
1184
1191
unsigned end = s.position ();
1185
1192
1186
1193
for (unsigned i = 0 ; i < count;) {
1187
- i += parsePoolEntry (t, s, index , pool, i);
1194
+ i += parsePoolEntry (t, s, index , pool, invocations, i);
1188
1195
}
1189
1196
1190
1197
s.setPosition (end);
@@ -1220,7 +1227,7 @@ GcClassAddendum* getClassAddendum(Thread* t, GcClass* class_, GcSingleton* pool)
1220
1227
if (addendum == 0 ) {
1221
1228
PROTECT (t, class_);
1222
1229
1223
- addendum = makeClassAddendum (t, pool, 0 , 0 , 0 , 0 , -1 , 0 , 0 , 0 , 0 );
1230
+ addendum = makeClassAddendum (t, pool, 0 , 0 , 0 , 0 , -1 , 0 , 0 );
1224
1231
setField (t, class_, ClassAddendum, addendum);
1225
1232
}
1226
1233
return addendum;
@@ -2753,10 +2760,12 @@ void parseMethodTable(Thread* t, Stream& s, GcClass* class_, GcSingleton* pool)
2753
2760
void parseAttributeTable (Thread* t,
2754
2761
Stream& s,
2755
2762
GcClass* class_,
2756
- GcSingleton* pool)
2763
+ GcSingleton* pool,
2764
+ GcList* invocations)
2757
2765
{
2758
2766
PROTECT (t, class_);
2759
2767
PROTECT (t, pool);
2768
+ PROTECT (t, invocations);
2760
2769
2761
2770
unsigned attributeCount = s.read2 ();
2762
2771
for (unsigned j = 0 ; j < attributeCount; ++j) {
@@ -2814,7 +2823,7 @@ void parseAttributeTable(Thread* t,
2814
2823
} else if (vm::strcmp (reinterpret_cast <const int8_t *>(" BootstrapMethods" ),
2815
2824
name->body ().begin ()) == 0 ) {
2816
2825
unsigned count = s.read2 ();
2817
- GcArray* array = makeArray (t, count);
2826
+ GcArray* array = makeArray (t, count * 2 );
2818
2827
PROTECT (t, array);
2819
2828
2820
2829
for (unsigned i = 0 ; i < count; ++i) {
@@ -2828,8 +2837,10 @@ void parseAttributeTable(Thread* t,
2828
2837
array->setBodyElement (t, i, element);
2829
2838
}
2830
2839
2831
- GcClassAddendum* addendum = getClassAddendum (t, class_, pool);
2832
- addendum->setBootstrapMethodTable (t, array);
2840
+ for (GcPair* p = cast<GcPair>(t, invocations->front ()); p;
2841
+ p = cast<GcPair>(t, p->second ())) {
2842
+ cast<GcInvocation>(t, p->first ())->setBootstrapMethodTable (t, array);
2843
+ }
2833
2844
} else if (vm::strcmp (reinterpret_cast <const int8_t *>(" EnclosingMethod" ),
2834
2845
name->body ().begin ()) == 0 ) {
2835
2846
int16_t enclosingClass = s.read2 ();
@@ -4757,7 +4768,10 @@ GcClass* parseClass(Thread* t,
4757
4768
fprintf (stderr, " read class (minor %d major %d)\n " , minorVer, majorVer);
4758
4769
}
4759
4770
4760
- GcSingleton* pool = parsePool (t, s);
4771
+ GcList* invocations = makeList (t, 0 , 0 , 0 );
4772
+ PROTECT (t, invocations);
4773
+
4774
+ GcSingleton* pool = parsePool (t, s, invocations);
4761
4775
PROTECT (t, pool);
4762
4776
4763
4777
unsigned flags = s.read2 ();
@@ -4812,7 +4826,7 @@ GcClass* parseClass(Thread* t,
4812
4826
4813
4827
parseMethodTable (t, s, class_, pool);
4814
4828
4815
- parseAttributeTable (t, s, class_, pool);
4829
+ parseAttributeTable (t, s, class_, pool, invocations );
4816
4830
4817
4831
GcArray* vtable = cast<GcArray>(t, class_->virtualTable ());
4818
4832
unsigned vtableLength = (vtable ? vtable->length () : 0 );
@@ -6080,9 +6094,8 @@ GcCallSite* resolveDynamic(Thread* t, GcInvocation* invocation)
6080
6094
6081
6095
// First element points to the bootstrap method. The rest are static data passed to the BSM.
6082
6096
GcCharArray* bootstrapArray = cast<GcCharArray>(
6083
- t,
6084
- cast<GcArray>(t, c->addendum ()->bootstrapMethodTable ())
6085
- ->body ()[invocation->bootstrap ()]);
6097
+ t, cast<GcArray>(t, invocation->bootstrapMethodTable ())
6098
+ ->body ()[invocation->bootstrap ()]);
6086
6099
6087
6100
PROTECT (t, bootstrapArray);
6088
6101
0 commit comments