Skip to content

Fixed the issue where gc was triggered during the attribute search pr… #5242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jerry-core/ecma/base/ecma-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
void
ecma_gc_run (void)
{
JERRY_CONTEXT(running_gc_count)++;
#if (JERRY_GC_MARK_LIMIT != 0)
JERRY_ASSERT (JERRY_CONTEXT (ecma_gc_mark_recursion_limit) == JERRY_GC_MARK_LIMIT);
#endif /* (JERRY_GC_MARK_LIMIT != 0) */
Expand Down Expand Up @@ -2235,6 +2236,7 @@ ecma_gc_run (void)
/* Free RegExp bytecodes stored in cache */
re_cache_gc ();
#endif /* JERRY_BUILTIN_REGEXP */
JERRY_CONTEXT(running_gc_count)--;
} /* ecma_gc_run */

/**
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
}

#if JERRY_PROPERTY_HASHMAP
if (steps >= (ECMA_PROPERTY_HASMAP_MINIMUM_SIZE / 2))
if (steps >= (ECMA_PROPERTY_HASMAP_MINIMUM_SIZE / 2) && JERRY_CONTEXT(running_gc_count) == 0)
{
ecma_property_hashmap_create (obj_p);
}
Expand Down
1 change: 1 addition & 0 deletions jerry-core/jcontext/jcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ struct jerry_context_t
jerry_external_string_free_cb_t external_string_free_callback_p; /**< free callback for external strings */
void *error_object_created_callback_user_p; /**< user pointer for error_object_update_callback_p */
jerry_error_object_created_cb_t error_object_created_callback_p; /**< decorator callback for Error objects */
uint32_t running_gc_count; /**< The current status of gc */
size_t ecma_gc_objects_number; /**< number of currently allocated objects */
size_t ecma_gc_new_objects; /**< number of newly allocated objects since last GC session */
size_t jmem_heap_allocated_size; /**< size of allocated regions */
Expand Down
1 change: 1 addition & 0 deletions jerry-core/jmem/jmem-heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jmem_heap_init (void)
JMEM_VALGRIND_NOACCESS_SPACE (JERRY_HEAP_CONTEXT (area), JMEM_HEAP_AREA_SIZE);

#endif /* !JERRY_SYSTEM_ALLOCATOR */
JERRY_CONTEXT(running_gc_count) = 0;
JMEM_HEAP_STAT_INIT ();
} /* jmem_heap_init */

Expand Down
22 changes: 22 additions & 0 deletions tests/jerry/gc-hashmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var a = [ ];
for (var v = 0; v < 256; v++)
{
var n = Object.create(null);
a.push(n, a);
n = new WeakSet(a);
n.o = 1;
}