67
67
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
68
68
import com .oracle .truffle .api .dsl .Cached .Shared ;
69
69
import com .oracle .truffle .api .dsl .Fallback ;
70
+ import com .oracle .truffle .api .dsl .GenerateCached ;
71
+ import com .oracle .truffle .api .dsl .GenerateInline ;
70
72
import com .oracle .truffle .api .dsl .GenerateUncached ;
71
73
import com .oracle .truffle .api .dsl .ImportStatic ;
72
74
import com .oracle .truffle .api .dsl .NeverDefault ;
@@ -873,6 +875,7 @@ static Object keywords(KeywordsStorage self, HashingStorageIterator it) {
873
875
}
874
876
}
875
877
878
+ // TODO: DSL inlining: inline this other nodes in this file
876
879
@ GenerateUncached
877
880
@ ImportStatic ({PGuards .class })
878
881
public abstract static class HashingStorageIteratorKey extends Node {
@@ -1003,7 +1006,7 @@ public Throwable fillInStackTrace() {
1003
1006
}
1004
1007
1005
1008
public abstract static class HashingStorageForEachCallback <T > extends Node {
1006
- public abstract T execute (Frame frame , HashingStorage storage , HashingStorageIterator it , T accumulator );
1009
+ public abstract T execute (Frame frame , Node inliningTarget , HashingStorage storage , HashingStorageIterator it , T accumulator );
1007
1010
}
1008
1011
1009
1012
@ GenerateUncached
@@ -1012,13 +1015,19 @@ public abstract static class HashingStorageForEach extends Node {
1012
1015
@ SuppressWarnings ("unchecked" )
1013
1016
public final <T > T execute (Frame frame , HashingStorage storage , HashingStorageForEachCallback <T > callback , T accumulator ) {
1014
1017
CompilerAsserts .partialEvaluationConstant (callback );
1015
- return (T ) executeUntyped (frame , storage , (HashingStorageForEachCallback <Object >) callback , accumulator );
1018
+ return (T ) executeUntyped (frame , null , storage , (HashingStorageForEachCallback <Object >) callback , accumulator );
1016
1019
}
1017
1020
1018
- abstract Object executeUntyped (Frame frame , HashingStorage storage , HashingStorageForEachCallback <Object > callback , Object accumulator );
1021
+ @ SuppressWarnings ("unchecked" )
1022
+ public final <T > T execute (Frame frame , Node callbackInliningTarget , HashingStorage storage , HashingStorageForEachCallback <T > callback , T accumulator ) {
1023
+ CompilerAsserts .partialEvaluationConstant (callback );
1024
+ return (T ) executeUntyped (frame , callbackInliningTarget , storage , (HashingStorageForEachCallback <Object >) callback , accumulator );
1025
+ }
1026
+
1027
+ abstract Object executeUntyped (Frame frame , Node callbackInliningTarget , HashingStorage storage , HashingStorageForEachCallback <Object > callback , Object accumulator );
1019
1028
1020
1029
@ Specialization
1021
- static Object doIt (Frame frame , HashingStorage storage , HashingStorageForEachCallback <Object > callback , Object accumulatorIn ,
1030
+ static Object doIt (Frame frame , Node callbackInliningTarget , HashingStorage storage , HashingStorageForEachCallback <Object > callback , Object accumulatorIn ,
1022
1031
@ Cached HashingStorageGetIterator getIter ,
1023
1032
@ Cached HashingStorageIteratorNext iterNext ,
1024
1033
@ Cached LoopConditionProfile loopProfile ) {
@@ -1030,7 +1039,7 @@ static Object doIt(Frame frame, HashingStorage storage, HashingStorageForEachCal
1030
1039
if (CompilerDirectives .hasNextTier ()) {
1031
1040
index ++;
1032
1041
}
1033
- accumulator = callback .execute (frame , storage , aIter , accumulator );
1042
+ accumulator = callback .execute (frame , callbackInliningTarget , storage , aIter , accumulator );
1034
1043
}
1035
1044
} finally {
1036
1045
if (index != 0 ) {
@@ -1053,19 +1062,21 @@ public ResultAndOther(ObjectHashMap result, HashingStorage other) {
1053
1062
}
1054
1063
1055
1064
@ GenerateUncached
1065
+ @ GenerateInline
1066
+ @ GenerateCached (false )
1056
1067
@ ImportStatic ({PGuards .class })
1057
1068
public abstract static class HashingStorageXorCallback extends HashingStorageForEachCallback <ResultAndOther > {
1058
1069
1059
1070
@ Override
1060
- public abstract ResultAndOther execute (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1071
+ public abstract ResultAndOther execute (Frame frame , Node inliningTarget , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1061
1072
1062
1073
@ Specialization
1063
- static ResultAndOther doGeneric (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther acc ,
1064
- @ Cached ObjectHashMap .PutNode putResultNode ,
1065
- @ Cached HashingStorageGetItemWithHash getFromOther ,
1066
- @ Cached HashingStorageIteratorKey iterKey ,
1067
- @ Cached HashingStorageIteratorValue iterValue ,
1068
- @ Cached HashingStorageIteratorKeyHash iterHash ) {
1074
+ static ResultAndOther doGeneric (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , HashingStorage storage , HashingStorageIterator it , ResultAndOther acc ,
1075
+ @ Cached ( inline = false ) ObjectHashMap .PutNode putResultNode ,
1076
+ @ Cached ( inline = false ) HashingStorageGetItemWithHash getFromOther ,
1077
+ @ Cached ( inline = false ) HashingStorageIteratorKey iterKey ,
1078
+ @ Cached ( inline = false ) HashingStorageIteratorValue iterValue ,
1079
+ @ Cached ( inline = false ) HashingStorageIteratorKeyHash iterHash ) {
1069
1080
Object key = iterKey .execute (storage , it );
1070
1081
long hash = iterHash .execute (storage , it );
1071
1082
Object otherValue = getFromOther .execute (frame , acc .other , key , hash );
@@ -1083,6 +1094,7 @@ public abstract static class HashingStorageXor extends Node {
1083
1094
1084
1095
@ Specialization
1085
1096
static HashingStorage doIt (Frame frame , HashingStorage aStorage , HashingStorage bStorage ,
1097
+ @ Bind ("this" ) Node inliningTarget ,
1086
1098
@ Cached HashingStorageForEach forEachA ,
1087
1099
@ Cached HashingStorageForEach forEachB ,
1088
1100
@ Cached HashingStorageXorCallback callbackA ,
@@ -1091,28 +1103,30 @@ static HashingStorage doIt(Frame frame, HashingStorage aStorage, HashingStorage
1091
1103
ObjectHashMap resultMap = result .map ;
1092
1104
1093
1105
ResultAndOther accA = new ResultAndOther (resultMap , bStorage );
1094
- forEachA .execute (frame , aStorage , callbackA , accA );
1106
+ forEachA .execute (frame , inliningTarget , aStorage , callbackA , accA );
1095
1107
1096
1108
ResultAndOther accB = new ResultAndOther (resultMap , aStorage );
1097
- forEachB .execute (frame , bStorage , callbackB , accB );
1109
+ forEachB .execute (frame , inliningTarget , bStorage , callbackB , accB );
1098
1110
1099
1111
return result ;
1100
1112
}
1101
1113
}
1102
1114
1103
1115
@ GenerateUncached
1116
+ @ GenerateInline
1117
+ @ GenerateCached (false )
1104
1118
@ ImportStatic ({PGuards .class })
1105
1119
public abstract static class HashingStorageIntersectCallback extends HashingStorageForEachCallback <ResultAndOther > {
1106
1120
1107
1121
@ Override
1108
- public abstract ResultAndOther execute (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1122
+ public abstract ResultAndOther execute (Frame frame , Node inliningTarget , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1109
1123
1110
1124
@ Specialization
1111
1125
static ResultAndOther doGeneric (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther acc ,
1112
- @ Cached ObjectHashMap .PutNode putResultNode ,
1113
- @ Cached HashingStorageGetItemWithHash getFromOther ,
1114
- @ Cached HashingStorageIteratorKey iterKey ,
1115
- @ Cached HashingStorageIteratorKeyHash iterHash ) {
1126
+ @ Cached ( inline = false ) ObjectHashMap .PutNode putResultNode ,
1127
+ @ Cached ( inline = false ) HashingStorageGetItemWithHash getFromOther ,
1128
+ @ Cached ( inline = false ) HashingStorageIteratorKey iterKey ,
1129
+ @ Cached ( inline = false ) HashingStorageIteratorKeyHash iterHash ) {
1116
1130
Object key = iterKey .execute (storage , it );
1117
1131
long hash = iterHash .execute (storage , it );
1118
1132
Object otherValue = getFromOther .execute (frame , acc .other , key , hash );
@@ -1133,11 +1147,12 @@ public abstract static class HashingStorageIntersect extends Node {
1133
1147
1134
1148
@ Specialization
1135
1149
static HashingStorage doIt (Frame frame , HashingStorage aStorage , HashingStorage bStorage ,
1150
+ @ Bind ("this" ) Node inliningTarget ,
1136
1151
@ Cached HashingStorageForEach forEachA ,
1137
1152
@ Cached HashingStorageIntersectCallback callback ) {
1138
1153
final EconomicMapStorage result = EconomicMapStorage .createWithSideEffects ();
1139
1154
ResultAndOther acc = new ResultAndOther (result .map , bStorage );
1140
- forEachA .execute (frame , aStorage , callback , acc );
1155
+ forEachA .execute (frame , inliningTarget , aStorage , callback , acc );
1141
1156
return result ;
1142
1157
}
1143
1158
}
@@ -1147,10 +1162,10 @@ static HashingStorage doIt(Frame frame, HashingStorage aStorage, HashingStorage
1147
1162
public abstract static class HashingStorageDiffCallback extends HashingStorageForEachCallback <ResultAndOther > {
1148
1163
1149
1164
@ Override
1150
- public abstract ResultAndOther execute (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1165
+ public abstract ResultAndOther execute (Frame frame , Node inliningTarget , HashingStorage storage , HashingStorageIterator it , ResultAndOther accumulator );
1151
1166
1152
1167
@ Specialization
1153
- static ResultAndOther doGeneric (Frame frame , HashingStorage storage , HashingStorageIterator it , ResultAndOther acc ,
1168
+ static ResultAndOther doGeneric (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , HashingStorage storage , HashingStorageIterator it , ResultAndOther acc ,
1154
1169
@ Cached ObjectHashMap .PutNode putResultNode ,
1155
1170
@ Cached HashingStorageGetItemWithHash getFromOther ,
1156
1171
@ Cached HashingStorageIteratorKey iterKey ,
@@ -1193,10 +1208,10 @@ static HashingStorage doIt(Frame frame, HashingStorage aStorage, HashingStorage
1193
1208
public abstract static class HashingStorageCompareKeysCallback extends HashingStorageForEachCallback <HashingStorage > {
1194
1209
1195
1210
@ Override
1196
- public abstract HashingStorage execute (Frame frame , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage );
1211
+ public abstract HashingStorage execute (Frame frame , Node inliningTarget , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage );
1197
1212
1198
1213
@ Specialization
1199
- static HashingStorage doGeneric (Frame frame , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage ,
1214
+ static HashingStorage doGeneric (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage ,
1200
1215
@ Cached HashingStorageGetItemWithHash getFromOther ,
1201
1216
@ Cached HashingStorageIteratorKey iterKey ,
1202
1217
@ Cached HashingStorageIteratorKeyHash iterHash ) {
@@ -1253,10 +1268,10 @@ static int doGeneric(Frame frame, HashingStorage aStorage, HashingStorage bStora
1253
1268
public abstract static class HashingStorageAreDisjointCallback extends HashingStorageForEachCallback <HashingStorage > {
1254
1269
1255
1270
@ Override
1256
- public abstract HashingStorage execute (Frame frame , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage );
1271
+ public abstract HashingStorage execute (Frame frame , Node inliningTarget , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage );
1257
1272
1258
1273
@ Specialization
1259
- static HashingStorage doGeneric (Frame frame , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage ,
1274
+ static HashingStorage doGeneric (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , HashingStorage aStorage , HashingStorageIterator it , HashingStorage bStorage ,
1260
1275
@ Cached HashingStorageGetItemWithHash getFromOther ,
1261
1276
@ Cached HashingStorageIteratorKey iterKey ,
1262
1277
@ Cached HashingStorageIteratorKeyHash iterHash ) {
@@ -1299,18 +1314,18 @@ static boolean doGeneric(Frame frame, HashingStorage aStorage, HashingStorage bS
1299
1314
@ GenerateUncached
1300
1315
public abstract static class HashingStorageTransferItem extends HashingStorageForEachCallback <HashingStorage > {
1301
1316
@ Override
1302
- public abstract HashingStorage execute (Frame frame , HashingStorage src , HashingStorageIterator it , HashingStorage destStorage );
1317
+ public abstract HashingStorage execute (Frame frame , Node inliningTarget , HashingStorage src , HashingStorageIterator it , HashingStorage destStorage );
1303
1318
1304
1319
@ Specialization
1305
- static EconomicMapStorage economic2Economic (Frame frame , EconomicMapStorage src , HashingStorageIterator it , EconomicMapStorage destStorage ,
1320
+ static EconomicMapStorage economic2Economic (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , EconomicMapStorage src , HashingStorageIterator it , EconomicMapStorage destStorage ,
1306
1321
@ Cached PutNode putNode ) {
1307
1322
ObjectHashMap srcMap = src .map ;
1308
1323
putNode .put (frame , destStorage .map , srcMap .getKey (it .index ), srcMap .hashes [it .index ], srcMap .getValue (it .index ));
1309
1324
return destStorage ;
1310
1325
}
1311
1326
1312
1327
@ Specialization (replaces = "economic2Economic" )
1313
- static HashingStorage economic2Generic (Frame frame , EconomicMapStorage src , HashingStorageIterator it , HashingStorage destStorage ,
1328
+ static HashingStorage economic2Generic (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , EconomicMapStorage src , HashingStorageIterator it , HashingStorage destStorage ,
1314
1329
@ Cached HashingStorageSetItemWithHash setItemWithHash ) {
1315
1330
// Note that the point is to avoid side-effecting __hash__ call. Since the source is
1316
1331
// economic map, the key may be an arbitrary object.
@@ -1319,7 +1334,7 @@ static HashingStorage economic2Generic(Frame frame, EconomicMapStorage src, Hash
1319
1334
}
1320
1335
1321
1336
@ Fallback
1322
- static HashingStorage generic2Generic (Frame frame , HashingStorage src , HashingStorageIterator it , HashingStorage destStorage ,
1337
+ static HashingStorage generic2Generic (Frame frame , @ SuppressWarnings ( "unused" ) Node inliningTarget , HashingStorage src , HashingStorageIterator it , HashingStorage destStorage ,
1323
1338
@ Cached HashingStorageIteratorKey iterKey ,
1324
1339
@ Cached HashingStorageIteratorValue iterValue ,
1325
1340
@ Cached HashingStorageSetItem setItem ) {
0 commit comments