Support caching of next method in for-of and built-in methods. (#3939)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -153,7 +153,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
ecma_object_t *array_obj_p = ecma_get_object_from_value (array);
|
||||
|
||||
/* 6.d */
|
||||
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, NULL);
|
||||
ecma_value_t next_method;
|
||||
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, &next_method);
|
||||
ecma_free_value (using_iterator);
|
||||
|
||||
/* 6.e */
|
||||
@@ -170,7 +171,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
while (true)
|
||||
{
|
||||
/* 6.g.ii */
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator);
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
|
||||
|
||||
/* 6.g.iii */
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
@@ -196,6 +197,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
}
|
||||
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
/* 6.g.iv.3 */
|
||||
return array;
|
||||
}
|
||||
@@ -254,6 +256,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
iterator_cleanup:
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
ecma_free_value (array);
|
||||
|
||||
return ret_value;
|
||||
|
||||
@@ -126,6 +126,7 @@ ecma_builtin_promise_resolve (ecma_value_t this_arg, /**< 'this' argument */
|
||||
*/
|
||||
inline static ecma_value_t
|
||||
ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for race */
|
||||
ecma_value_t next_method, /**< next method */
|
||||
ecma_value_t capability, /**< PromiseCapability record */
|
||||
ecma_value_t ctor, /**< Constructor value */
|
||||
bool *done_p) /**< [out] iteratorRecord[[done]] */
|
||||
@@ -138,7 +139,7 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for
|
||||
while (true)
|
||||
{
|
||||
/* a. */
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator);
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
|
||||
/* b, c. */
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
{
|
||||
@@ -321,8 +322,9 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function
|
||||
*/
|
||||
inline static ecma_value_t
|
||||
ecma_builtin_promise_perform_all (ecma_value_t iterator, /**< iteratorRecord */
|
||||
ecma_value_t ctor, /**< the caller of Promise.race */
|
||||
ecma_value_t next_method, /**< next method */
|
||||
ecma_value_t capability, /**< PromiseCapability record */
|
||||
ecma_value_t ctor, /**< the caller of Promise.race */
|
||||
bool *done_p) /**< [out] iteratorRecord[[done]] */
|
||||
{
|
||||
/* 1. - 2. */
|
||||
@@ -350,7 +352,7 @@ ecma_builtin_promise_perform_all (ecma_value_t iterator, /**< iteratorRecord */
|
||||
while (true)
|
||||
{
|
||||
/* a. */
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator);
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
|
||||
/* b. - c. */
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
{
|
||||
@@ -527,9 +529,9 @@ ecma_builtin_promise_race_or_all (ecma_value_t this_arg, /**< 'this' argument */
|
||||
return capability;
|
||||
}
|
||||
|
||||
ecma_value_t iterator;
|
||||
iterator = ecma_builtin_promise_reject_abrupt (ecma_op_get_iterator (iterable, ECMA_VALUE_SYNC_ITERATOR, NULL),
|
||||
capability);
|
||||
ecma_value_t next_method;
|
||||
ecma_value_t iterator = ecma_op_get_iterator (iterable, ECMA_VALUE_SYNC_ITERATOR, &next_method);
|
||||
iterator = ecma_builtin_promise_reject_abrupt (iterator, capability);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
@@ -543,11 +545,11 @@ ecma_builtin_promise_race_or_all (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
if (is_race)
|
||||
{
|
||||
ret = ecma_builtin_promise_perform_race (iterator, capability, constructor_value, &is_done);
|
||||
ret = ecma_builtin_promise_perform_race (iterator, next_method, capability, constructor_value, &is_done);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ecma_builtin_promise_perform_all (iterator, constructor_value, capability, &is_done);
|
||||
ret = ecma_builtin_promise_perform_all (iterator, next_method, capability, constructor_value, &is_done);
|
||||
}
|
||||
|
||||
ecma_free_value (constructor_value);
|
||||
@@ -563,6 +565,7 @@ ecma_builtin_promise_race_or_all (ecma_value_t this_arg, /**< 'this' argument */
|
||||
}
|
||||
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
ecma_free_value (capability);
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user