Skip to content

Commit 91258e2

Browse files
Revert double free detection
1 parent 268f613 commit 91258e2

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

Runtime/src/object-heap.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ref } from "./types.js";
44
type SwiftRuntimeHeapEntry = {
55
id: number;
66
rc: number;
7-
released: boolean;
87
};
98
export class SwiftRuntimeHeap {
109
private _heapValueById: Map<number, any>;
@@ -16,11 +15,7 @@ export class SwiftRuntimeHeap {
1615
this._heapValueById.set(0, globalVariable);
1716

1817
this._heapEntryByValue = new Map();
19-
this._heapEntryByValue.set(globalVariable, {
20-
id: 0,
21-
rc: 1,
22-
released: false,
23-
});
18+
this._heapEntryByValue.set(globalVariable, { id: 0, rc: 1 });
2419

2520
// Note: 0 is preserved for global
2621
this._heapNextKey = 1;
@@ -34,22 +29,13 @@ export class SwiftRuntimeHeap {
3429
}
3530
const id = this._heapNextKey++;
3631
this._heapValueById.set(id, value);
37-
this._heapEntryByValue.set(value, { id: id, rc: 1, released: false });
32+
this._heapEntryByValue.set(value, { id: id, rc: 1 });
3833
return id;
3934
}
4035

4136
release(ref: ref) {
4237
const value = this._heapValueById.get(ref);
4338
const entry = this._heapEntryByValue.get(value)!;
44-
if (entry.released) {
45-
console.error(
46-
"Double release detected for reference " + ref,
47-
entry
48-
);
49-
throw new ReferenceError(
50-
"Double release detected for reference " + ref
51-
);
52-
}
5339
entry.rc--;
5440
if (entry.rc != 0) return;
5541

0 commit comments

Comments
 (0)