@@ -51,6 +51,7 @@ pub struct ObjectEntity<'a> {
51
51
pub consumable : bool ,
52
52
pub consumed : Cell < bool > ,
53
53
pub consumed_as_prototype : Cell < bool > ,
54
+ pub pending_clear : Cell < bool > ,
54
55
// deps: RefCell<ConsumableCollector<'a>>,
55
56
/// Where the object is created
56
57
pub cf_scope : CfScopeId ,
@@ -79,8 +80,13 @@ impl<'a> EntityTrait<'a> for ObjectEntity<'a> {
79
80
80
81
self . consume_as_prototype ( analyzer) ;
81
82
82
- self . string_keyed . take ( ) ;
83
- self . unknown_keyed . take ( ) ;
83
+ // FIXME: Need a better way to do this
84
+ if let Ok ( mut string_keyed) = self . string_keyed . try_borrow_mut ( ) {
85
+ string_keyed. clear ( ) ;
86
+ self . unknown_keyed . take ( ) ;
87
+ } else {
88
+ self . pending_clear . set ( true ) ;
89
+ }
84
90
85
91
analyzer. mark_object_consumed ( self . cf_scope , self . object_id ) ;
86
92
}
@@ -247,14 +253,19 @@ impl<'a> ObjectEntity<'a> {
247
253
return ;
248
254
}
249
255
256
+ self . disable_mangling ( analyzer) ;
257
+
250
258
self . prototype . get ( ) . consume ( analyzer) ;
251
259
252
260
for property in self . string_keyed . borrow ( ) . values ( ) {
253
261
property. consume ( analyzer) ;
254
262
}
255
263
self . unknown_keyed . borrow ( ) . consume ( analyzer) ;
256
264
257
- self . disable_mangling ( analyzer) ;
265
+ if self . pending_clear . replace ( false ) {
266
+ self . string_keyed . borrow_mut ( ) . clear ( ) ;
267
+ self . unknown_keyed . take ( ) ;
268
+ }
258
269
}
259
270
260
271
pub fn is_mangable ( & self ) -> bool {
@@ -301,6 +312,7 @@ impl<'a> Analyzer<'a> {
301
312
consumable : true ,
302
313
consumed : Cell :: new ( false ) ,
303
314
consumed_as_prototype : Cell :: new ( false ) ,
315
+ pending_clear : Cell :: new ( false ) ,
304
316
// deps: Default::default(),
305
317
cf_scope : self . scoping . cf . current_id ( ) ,
306
318
object_id : self . scoping . alloc_object_id ( ) ,
0 commit comments