mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Seperate NULL and unused values. (#1572)
Fixes #1552. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
638b753135
commit
be720b2238
@ -138,6 +138,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
hashmap_p->header.next_property_cp = object_p->property_list_or_bound_object_cp;
|
||||
hashmap_p->max_property_count = max_property_count;
|
||||
hashmap_p->null_count = max_property_count - named_property_count;
|
||||
hashmap_p->unused_count = max_property_count - named_property_count;
|
||||
|
||||
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
|
||||
uint8_t *bits_p = (uint8_t *) (pair_list_p + max_property_count);
|
||||
@ -312,6 +313,9 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
hashmap_p->null_count--;
|
||||
JERRY_ASSERT (hashmap_p->null_count > 0);
|
||||
|
||||
hashmap_p->unused_count--;
|
||||
JERRY_ASSERT (hashmap_p->unused_count > 0);
|
||||
|
||||
if (property_index == 0)
|
||||
{
|
||||
*bits_p = (uint8_t) ((*bits_p) & ~mask);
|
||||
@ -345,10 +349,10 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
hashmap_p->null_count++;
|
||||
hashmap_p->unused_count++;
|
||||
|
||||
/* The NULLs are above 3/4 of the hashmap. */
|
||||
if (hashmap_p->null_count > ((hashmap_p->max_property_count * 3) >> 2))
|
||||
if (hashmap_p->unused_count > ((hashmap_p->max_property_count * 3) >> 2))
|
||||
{
|
||||
return ECMA_PROPERTY_HASHMAP_DELETE_RECREATE_HASHMAP;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ typedef struct
|
||||
ecma_property_header_t header; /**< header of the property */
|
||||
uint32_t max_property_count; /**< maximum property count (power of 2) */
|
||||
uint32_t null_count; /**< number of NULLs in the map */
|
||||
uint32_t unused_count; /**< number of unused entires in the map */
|
||||
|
||||
/*
|
||||
* The hash is followed by max_property_count ecma_cpointer_t
|
||||
|
||||
26
tests/jerry/regression-test-issue-1552.js
Normal file
26
tests/jerry/regression-test-issue-1552.js
Normal file
@ -0,0 +1,26 @@
|
||||
// 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 o = []
|
||||
|
||||
function add(i)
|
||||
{
|
||||
delete o[i & 31];
|
||||
o[i] = 0;
|
||||
}
|
||||
|
||||
for (var i = 0; i < 130; i++)
|
||||
{
|
||||
add(i)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user