Skip to content

Commit e1674f7

Browse files
committed
Profile if value of mapping storage is NoValue.
1 parent d550c55 commit e1674f7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageNodes.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
110110
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
111111
import com.oracle.truffle.api.dsl.Cached;
112+
import com.oracle.truffle.api.dsl.Cached.Exclusive;
112113
import com.oracle.truffle.api.dsl.Cached.Shared;
113114
import com.oracle.truffle.api.dsl.Fallback;
114115
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
@@ -1167,30 +1168,34 @@ Object doEmptyStorage(VirtualFrame frame, EmptyStorage storage, Object key) {
11671168
// this is just a minor performance optimization
11681169
@Specialization
11691170
static Object doPythonObjectString(PythonObjectDictStorage storage, String key,
1170-
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey) {
1171-
return doDynamicObjectString(storage, key, readKey);
1171+
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey,
1172+
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profile) {
1173+
return doDynamicObjectString(storage, key, readKey, profile);
11721174
}
11731175

11741176
// this is just a minor performance optimization
11751177
@Specialization
11761178
static Object doPythonObjectPString(PythonObjectDictStorage storage, PString key,
1177-
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey) {
1178-
return doDynamicObjectPString(storage, key, readKey);
1179+
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey,
1180+
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profile) {
1181+
return doDynamicObjectPString(storage, key, readKey, profile);
11791182
}
11801183

11811184
// this will read from the dynamic object
11821185
@Specialization
11831186
static Object doDynamicObjectString(DynamicObjectStorage storage, String key,
1184-
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey) {
1187+
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey,
1188+
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profile) {
11851189
Object result = readKey.execute(storage.getStore(), key);
1186-
return result == PNone.NO_VALUE ? null : result;
1190+
return profile.profile(result == PNone.NO_VALUE) ? null : result;
11871191
}
11881192

11891193
@Specialization
11901194
static Object doDynamicObjectPString(DynamicObjectStorage storage, PString key,
1191-
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey) {
1195+
@Shared("readKey") @Cached ReadAttributeFromDynamicObjectNode readKey,
1196+
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profile) {
11921197
Object result = readKey.execute(storage.getStore(), key);
1193-
return result == PNone.NO_VALUE ? null : result;
1198+
return profile.profile(result == PNone.NO_VALUE) ? null : result;
11941199
}
11951200

11961201
// this must read from the non-dynamic object storage

0 commit comments

Comments
 (0)