Skip to content

Commit b7fe541

Browse files
committed
HashinStorage: pass the gil to calling the length message
1 parent 95da727 commit b7fe541

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ public DictKey next() {
804804
public String toString() {
805805
CompilerAsserts.neverPartOfCompilation();
806806
StringBuilder builder = new StringBuilder();
807-
builder.append("map(size=").append(length()).append(", {");
807+
GilNode gil = GilNode.getUncached();
808+
builder.append("map(size=").append(length(gil)).append(", {");
808809
String sep = "";
809810
MapCursor<DictKey, Object> cursor = map.getEntries();
810811
while (advance(cursor)) {

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,9 @@ public PKeyword[] getStore() {
7777
return keywords;
7878
}
7979

80-
@Override
8180
@ExportMessage
8281
public int length() {
83-
GilNode gil = GilNode.getUncached();
84-
boolean mustRelease = gil.acquire();
85-
try {
86-
return keywords.length;
87-
} finally {
88-
gil.release(mustRelease);
89-
}
82+
return keywords.length;
9083
}
9184

9285
@ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL_UNTIL_RETURN)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ HashingStorage setItemWithState(Object key, Object value, ThreadState state,
216216
@Exclusive @Cached("createBinaryProfile()") ConditionProfile gotState, @Exclusive @Cached GilNode gil) {
217217
boolean mustRelease = gil.acquire();
218218
try {
219-
HashingStorage result = generalize(lib);
219+
HashingStorage result = generalize(lib, gil);
220220
if (gotState.profile(state != null)) {
221221
return lib.setItemWithState(result, key, value, state);
222222
} else {
@@ -233,7 +233,7 @@ HashingStorage delItemWithState(Object key, ThreadState state,
233233
@Exclusive @Cached("createBinaryProfile()") ConditionProfile gotState, @Exclusive @Cached GilNode gil) {
234234
boolean mustRelease = gil.acquire();
235235
try {
236-
HashingStorage result = generalize(lib);
236+
HashingStorage result = generalize(lib, gil);
237237
if (gotState.profile(state != null)) {
238238
return lib.delItemWithState(result, key, state);
239239
} else {
@@ -244,8 +244,8 @@ HashingStorage delItemWithState(Object key, ThreadState state,
244244
}
245245
}
246246

247-
private HashingStorage generalize(HashingStorageLibrary lib) {
248-
HashingStorage result = EconomicMapStorage.create(length());
247+
private HashingStorage generalize(HashingStorageLibrary lib, GilNode gil) {
248+
HashingStorage result = EconomicMapStorage.create(length(gil));
249249
result = lib.addAllToOther(this, result);
250250
return result;
251251
}

0 commit comments

Comments
 (0)