Skip to content

Commit 9625fb8

Browse files
zherczegyichoi
authored andcommitted
Improve instanceof operator. (#2395)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 5398e07 commit 9625fb8

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,7 @@ ecma_op_arrow_function_get_compiled_code (ecma_arrow_function_t *arrow_function_
330330
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
331331

332332
/**
333-
* [[Call]] implementation for Function objects,
334-
* created through 13.2 (ECMA_OBJECT_TYPE_FUNCTION)
335-
* or 15.3.4.5 (ECMA_OBJECT_TYPE_BOUND_FUNCTION),
336-
* and for built-in Function objects
337-
* from section 15 (ECMA_OBJECT_TYPE_FUNCTION).
333+
* 15.3.5.3 implementation of [[HasInstance]] for Function objects
338334
*
339335
* @return ecma value
340336
* Returned value must be freed with ecma_free_value
@@ -346,19 +342,15 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object *
346342
JERRY_ASSERT (func_obj_p != NULL
347343
&& !ecma_is_lexical_environment (func_obj_p));
348344

349-
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION)
345+
while (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION)
350346
{
351347
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
352348

353-
/* 1. */
349+
/* 1. 3. */
354350
ecma_extended_object_t *ext_function_p = (ecma_extended_object_t *) func_obj_p;
355351

356-
ecma_object_t *target_func_obj_p;
357-
target_func_obj_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
358-
ext_function_p->u.bound_function.target_function);
359-
360-
/* 3. */
361-
return ecma_op_object_has_instance (target_func_obj_p, value);
352+
func_obj_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
353+
ext_function_p->u.bound_function.target_function);
362354
}
363355

364356
JERRY_ASSERT (ecma_is_normal_or_arrow_function (ecma_get_object_type (func_obj_p))

0 commit comments

Comments
 (0)