File tree 4 files changed +35
-2
lines changed
4 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -906,7 +906,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
906
906
/**
907
907
* Free properties of an object
908
908
*/
909
- static void
909
+ void
910
910
ecma_gc_free_properties (ecma_object_t * object_p ) /**< object */
911
911
{
912
912
jmem_cpointer_t prop_iter_cp = object_p -> u1 .property_list_cp ;
Original file line number Diff line number Diff line change 29
29
void ecma_init_gc_info (ecma_object_t * object_p );
30
30
void ecma_ref_object (ecma_object_t * object_p );
31
31
void ecma_deref_object (ecma_object_t * object_p );
32
+ void ecma_gc_free_properties (ecma_object_t * object_p );
32
33
void ecma_gc_run (void );
33
34
void ecma_free_unused_memory (jmem_pressure_t pressure );
34
35
Original file line number Diff line number Diff line change @@ -539,7 +539,22 @@ ecma_finalize_builtins (void)
539
539
{
540
540
if (JERRY_CONTEXT (ecma_builtin_objects )[id ] != JMEM_CP_NULL )
541
541
{
542
- ecma_deref_object (ECMA_GET_NON_NULL_POINTER (ecma_object_t , JERRY_CONTEXT (ecma_builtin_objects )[id ]));
542
+ ecma_object_t * obj_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t , JERRY_CONTEXT (ecma_builtin_objects )[id ]);
543
+ ecma_deref_object (obj_p );
544
+
545
+ #if ENABLED (JERRY_ES2015 )
546
+ /* Note: In ES2015 a function object may contain tagged template literal collection. Whenever
547
+ this function is assigned to a builtin function or function routine during the GC it may cause unresolvable
548
+ circle since one part of the circle is a weak reference (marked by GC) and the other part is hard reference
549
+ (reference count). In this case when the function which contains the tagged template literal collection
550
+ is getting GC marked the arrays in the collection are still holding weak references to properties/prototypes
551
+ which prevents these objects from getting freed. Releasing the property list and the prototype reference
552
+ manually eliminates the existence of the unresolvable circle described above. */
553
+ ecma_gc_free_properties (obj_p );
554
+ obj_p -> u1 .property_list_cp = JMEM_CP_NULL ;
555
+ obj_p -> u2 .prototype_cp = JMEM_CP_NULL ;
556
+ #endif /* ENABLED (JERRY_ES2015) */
557
+
543
558
JERRY_CONTEXT (ecma_builtin_objects )[id ] = JMEM_CP_NULL ;
544
559
}
545
560
}
Original file line number Diff line number Diff line change
1
+ // Copyright JS Foundation and other contributors, http://js.foundation
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ Object . prototype . toString = function ( ) {
16
+ return a `` ;
17
+ } ;
You can’t perform that action at this time.
0 commit comments