Add fast array support for property name enumeration (#3053)
Since fast access mode arrays can be part of the prototype chain these objects must be handed separately. This patch fixes #3050. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -1812,6 +1812,60 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
|||||||
|
|
||||||
jmem_cpointer_t prop_iter_cp = prototype_chain_iter_p->u1.property_list_cp;
|
jmem_cpointer_t prop_iter_cp = prototype_chain_iter_p->u1.property_list_cp;
|
||||||
|
|
||||||
|
if (ecma_get_object_type (prototype_chain_iter_p) == ECMA_OBJECT_TYPE_ARRAY
|
||||||
|
&& ((ecma_extended_object_t *) prototype_chain_iter_p)->u.array.is_fast_mode
|
||||||
|
&& prop_iter_cp != JMEM_CP_NULL)
|
||||||
|
{
|
||||||
|
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) prototype_chain_iter_p;
|
||||||
|
|
||||||
|
uint32_t length = ext_obj_p->u.array.length;
|
||||||
|
|
||||||
|
ecma_value_t *values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, prop_iter_cp);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if (ecma_is_value_array_hole (values_p[i]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (i);
|
||||||
|
|
||||||
|
uint8_t hash = (uint8_t) ecma_string_hash (index_str_p);
|
||||||
|
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
|
||||||
|
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
|
||||||
|
|
||||||
|
bool is_add = true;
|
||||||
|
|
||||||
|
if ((own_names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0)
|
||||||
|
{
|
||||||
|
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||||
|
|
||||||
|
while (ecma_value_p != NULL)
|
||||||
|
{
|
||||||
|
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||||
|
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||||
|
|
||||||
|
if (ecma_compare_ecma_strings (index_str_p, current_name_p))
|
||||||
|
{
|
||||||
|
is_add = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_add)
|
||||||
|
{
|
||||||
|
own_names_hashes_bitmap[bitmap_row] |= (1u << bitmap_column);
|
||||||
|
|
||||||
|
ecma_append_to_values_collection (prop_names_p,
|
||||||
|
ecma_make_string_value (index_str_p),
|
||||||
|
ECMA_COLLECTION_NO_COPY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
||||||
if (prop_iter_cp != JMEM_CP_NULL)
|
if (prop_iter_cp != JMEM_CP_NULL)
|
||||||
{
|
{
|
||||||
@@ -1911,6 +1965,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
|||||||
|
|
||||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// 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 counter = 0;
|
||||||
|
var expected = [0];
|
||||||
|
|
||||||
|
var b = [$];
|
||||||
|
function dConstr () { }
|
||||||
|
dConstr.prototype = b;
|
||||||
|
var d = new dConstr()
|
||||||
|
for (var $ in d) {
|
||||||
|
counter++;
|
||||||
|
assert($ in expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(counter === 1);
|
||||||
Reference in New Issue
Block a user