Commit 6e0496b2 authored by danno's avatar danno Committed by Commit bot

[builtins] (Re-)implement Array.prototype.every/some with the CSA

In the process, re-factor the implementation of Array.prototype.forEach so that
the bulk of the implementation can be re-used, since much of the spec is
identical. The refactor should also make it more straight-forward to implement
map and filter. The re-factored version only have a single slow path for processing
elements which is used for both the overall slow path and for the bailout from the
FAST_ELEMENTS case.

Review-Url: https://codereview.chromium.org/2709773002
Cr-Commit-Position: refs/heads/master@{#43745}
parent 09de9969
......@@ -3708,6 +3708,26 @@ void Genesis::InitializeGlobal_enable_fast_array_builtins() {
Handle<JSFunction>::cast(for_each_function)
->shared()
->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach));
LookupIterator it4(array_prototype,
factory->NewStringFromAsciiChecked("every"),
LookupIterator::OWN_SKIP_INTERCEPTOR);
Handle<Object> every_function = Object::GetProperty(&it4).ToHandleChecked();
Handle<JSFunction>::cast(every_function)
->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery));
Handle<JSFunction>::cast(every_function)
->shared()
->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery));
LookupIterator it5(array_prototype,
factory->NewStringFromAsciiChecked("some"),
LookupIterator::OWN_SKIP_INTERCEPTOR);
Handle<Object> some_function = Object::GetProperty(&it5).ToHandleChecked();
Handle<JSFunction>::cast(some_function)
->set_code(isolate->builtins()->builtin(Builtins::kArraySome));
Handle<JSFunction>::cast(some_function)
->shared()
->set_code(isolate->builtins()->builtin(Builtins::kArraySome));
}
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
......
This diff is collapsed.
......@@ -275,6 +275,8 @@ class Isolate;
CPP(ArraySplice) \
CPP(ArrayUnshift) \
TFJ(ArrayForEach, 2) \
TFJ(ArrayEvery, 2) \
TFJ(ArraySome, 2) \
/* ES6 #sec-array.prototype.entries */ \
TFJ(ArrayPrototypeEntries, 0) \
/* ES6 #sec-array.prototype.keys */ \
......
......@@ -414,6 +414,8 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kArrayPrototypeEntries:
case Builtins::kArrayPrototypeKeys:
case Builtins::kArrayForEach:
case Builtins::kArrayEvery:
case Builtins::kArraySome:
// Math builtins.
case Builtins::kMathAbs:
case Builtins::kMathAcos:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment