Skip to content

Commit 7c21fb8

Browse files
authored
Reorder list of function built-in properties (#4791)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent d98ff6f commit 7c21fb8

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,19 +2173,6 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
21732173
const ecma_compiled_code_t *bytecode_data_p;
21742174
bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) object_p);
21752175

2176-
#if JERRY_ESNEXT
2177-
bool append_prototype = CBC_FUNCTION_HAS_PROTOTYPE (bytecode_data_p->status_flags);
2178-
#else /* !JERRY_ESNEXT */
2179-
bool append_prototype = true;
2180-
#endif /* JERRY_ESNEXT */
2181-
2182-
if (append_prototype)
2183-
{
2184-
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
2185-
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
2186-
prop_counter_p->string_named_props++;
2187-
}
2188-
21892176
#if JERRY_ESNEXT
21902177
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
21912178

@@ -2210,7 +2197,7 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
22102197
#endif /* JERRY_ESNEXT */
22112198

22122199
#if JERRY_ESNEXT
2213-
if (!append_prototype)
2200+
if (!CBC_FUNCTION_HAS_PROTOTYPE (bytecode_data_p->status_flags))
22142201
{
22152202
return;
22162203
}
@@ -2222,14 +2209,18 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
22222209

22232210
if (append_caller_and_arguments)
22242211
{
2225-
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
2226-
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
2227-
22282212
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
22292213
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS));
22302214

2215+
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
2216+
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
2217+
22312218
prop_counter_p->string_named_props += 2;
22322219
}
2220+
2221+
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
2222+
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
2223+
prop_counter_p->string_named_props++;
22332224
} /* ecma_op_function_list_lazy_property_names */
22342225

22352226
/**

tests/jerry/es.next/function-properties.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Object.setPrototypeOf(print, prototype_obj);
4646
assert(getProperties(print) == "dummy length caller arguments");
4747

4848
function f1() {}
49-
assert(Reflect.ownKeys(f1).toString() === "prototype,length,name,caller,arguments")
49+
assert(Reflect.ownKeys(f1).toString() === "length,name,arguments,caller,prototype")
5050

5151
async function f2() {}
5252
assert(Reflect.ownKeys(f2).toString() === "length,name")

0 commit comments

Comments
 (0)