@@ -4,7 +4,6 @@ import { ref } from "./types.js";
4
4
type SwiftRuntimeHeapEntry = {
5
5
id : number ;
6
6
rc : number ;
7
- released : boolean ;
8
7
} ;
9
8
export class SwiftRuntimeHeap {
10
9
private _heapValueById : Map < number , any > ;
@@ -16,11 +15,7 @@ export class SwiftRuntimeHeap {
16
15
this . _heapValueById . set ( 0 , globalVariable ) ;
17
16
18
17
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 } ) ;
24
19
25
20
// Note: 0 is preserved for global
26
21
this . _heapNextKey = 1 ;
@@ -34,22 +29,13 @@ export class SwiftRuntimeHeap {
34
29
}
35
30
const id = this . _heapNextKey ++ ;
36
31
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 } ) ;
38
33
return id ;
39
34
}
40
35
41
36
release ( ref : ref ) {
42
37
const value = this . _heapValueById . get ( ref ) ;
43
38
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
- }
53
39
entry . rc -- ;
54
40
if ( entry . rc != 0 ) return ;
55
41
0 commit comments