Commit 3d618949 authored by ishell's avatar ishell Committed by Commit bot

[stubs] Cleanup usages of lambdas in CodeStubAssembler and friends.

The changes are:
1) Pass lambdas as const references to avoid unnecessary copying.
2) Remove CodeStubAssembler* parameter from loop bodies and let the lambdas
   capture the right assembler instead. It makes the loop body code look
   uniform with the surrounding code and unblocks splitting of a CSA
   into different classes.

BUG=

Review-Url: https://codereview.chromium.org/2535753012
Cr-Commit-Position: refs/heads/master@{#41482}
parent 8590e8d4
......@@ -314,11 +314,10 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) {
assembler.Bind(&default_label);
{
args.ForEach(
[receiver, context, &arg_index](CodeStubAssembler* assembler,
Node* arg) {
Node* length = assembler->LoadJSArrayLength(receiver);
assembler->CallRuntime(Runtime::kSetProperty, context, receiver,
length, arg, assembler->SmiConstant(STRICT));
[&assembler, receiver, context, &arg_index](Node* arg) {
Node* length = assembler.LoadJSArrayLength(receiver);
assembler.CallRuntime(Runtime::kSetProperty, context, receiver,
length, arg, assembler.SmiConstant(STRICT));
},
arg_index.value());
args.PopAndReturn(assembler.LoadJSArrayLength(receiver));
......
......@@ -376,13 +376,12 @@ void Builtins::Generate_FastFunctionPrototypeBind(
Variable index(&assembler, MachineType::PointerRepresentation());
index.Bind(assembler.IntPtrConstant(0));
CodeStubAssembler::VariableList foreach_vars({&index}, assembler.zone());
args.ForEach(
foreach_vars,
[elements, &index](CodeStubAssembler* assembler, compiler::Node* arg) {
assembler->StoreFixedArrayElement(elements, index.value(), arg,
UPDATE_WRITE_BARRIER, 0,
args.ForEach(foreach_vars,
[&assembler, elements, &index](compiler::Node* arg) {
assembler.StoreFixedArrayElement(
elements, index.value(), arg, UPDATE_WRITE_BARRIER, 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->Increment(index);
assembler.Increment(index);
},
assembler.IntPtrConstant(1));
argument_array.Bind(elements);
......
......@@ -2159,8 +2159,8 @@ Node* ReplaceGlobalCallableFastPath(CodeStubAssembler* a, Node* context,
a->BuildFastLoop(
MachineType::PointerRepresentation(), from, to,
[res_elems, isolate, native_context, context, undefined,
replace_callable, mode](CodeStubAssembler* a, Node* index) {
[a, res_elems, isolate, native_context, context, undefined,
replace_callable, mode](Node* index) {
Node* const elem =
a->LoadFixedArrayElement(res_elems, index, 0, mode);
......
......@@ -473,27 +473,26 @@ void Builtins::Generate_StringFromCharCode(
// codes. Stop if any of the conversions generates a code that doesn't fit
// in 8 bits.
CodeStubAssembler::VariableList vars({&max_index}, assembler.zone());
arguments.ForEach(vars, [context, &two_byte, &max_index, &code16,
one_byte_result](CodeStubAssembler* assembler,
Node* arg) {
Node* code32 = assembler->TruncateTaggedToWord32(context, arg);
code16 = assembler->Word32And(
code32, assembler->Int32Constant(String::kMaxUtf16CodeUnit));
assembler->GotoIf(
assembler->Int32GreaterThan(
code16, assembler->Int32Constant(String::kMaxOneByteCharCode)),
arguments.ForEach(vars, [&assembler, context, &two_byte, &max_index,
&code16, one_byte_result](Node* arg) {
Node* code32 = assembler.TruncateTaggedToWord32(context, arg);
code16 = assembler.Word32And(
code32, assembler.Int32Constant(String::kMaxUtf16CodeUnit));
assembler.GotoIf(
assembler.Int32GreaterThan(
code16, assembler.Int32Constant(String::kMaxOneByteCharCode)),
&two_byte);
// The {code16} fits into the SeqOneByteString {one_byte_result}.
Node* offset = assembler->ElementOffsetFromIndex(
Node* offset = assembler.ElementOffsetFromIndex(
max_index.value(), UINT8_ELEMENTS,
CodeStubAssembler::INTPTR_PARAMETERS,
SeqOneByteString::kHeaderSize - kHeapObjectTag);
assembler->StoreNoWriteBarrier(MachineRepresentation::kWord8,
assembler.StoreNoWriteBarrier(MachineRepresentation::kWord8,
one_byte_result, offset, code16);
max_index.Bind(assembler->IntPtrAdd(max_index.value(),
assembler->IntPtrConstant(1)));
max_index.Bind(
assembler.IntPtrAdd(max_index.value(), assembler.IntPtrConstant(1)));
});
arguments.PopAndReturn(one_byte_result);
......@@ -527,20 +526,19 @@ void Builtins::Generate_StringFromCharCode(
// using a 16-bit representation.
arguments.ForEach(
vars,
[context, two_byte_result, &max_index](CodeStubAssembler* assembler,
Node* arg) {
Node* code32 = assembler->TruncateTaggedToWord32(context, arg);
Node* code16 = assembler->Word32And(
code32, assembler->Int32Constant(String::kMaxUtf16CodeUnit));
[&assembler, context, two_byte_result, &max_index](Node* arg) {
Node* code32 = assembler.TruncateTaggedToWord32(context, arg);
Node* code16 = assembler.Word32And(
code32, assembler.Int32Constant(String::kMaxUtf16CodeUnit));
Node* offset = assembler->ElementOffsetFromIndex(
Node* offset = assembler.ElementOffsetFromIndex(
max_index.value(), UINT16_ELEMENTS,
CodeStubAssembler::INTPTR_PARAMETERS,
SeqTwoByteString::kHeaderSize - kHeapObjectTag);
assembler->StoreNoWriteBarrier(MachineRepresentation::kWord16,
assembler.StoreNoWriteBarrier(MachineRepresentation::kWord16,
two_byte_result, offset, code16);
max_index.Bind(assembler->IntPtrAdd(max_index.value(),
assembler->IntPtrConstant(1)));
max_index.Bind(assembler.IntPtrAdd(max_index.value(),
assembler.IntPtrConstant(1)));
},
max_index.value());
......
......@@ -11,8 +11,9 @@ namespace internal {
using compiler::Node;
void CodeStubAssembler::Assert(ConditionBody codition_body, const char* message,
const char* file, int line) {
void CodeStubAssembler::Assert(const NodeGenerator& codition_body,
const char* message, const char* file,
int line) {
#if defined(DEBUG)
Label ok(this);
Label not_ok(this, Label::kDeferred);
......@@ -1446,26 +1447,24 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context,
CodeStubAssembler::VariableList push_vars({&length, &elements}, zone());
args.ForEach(
push_vars,
[kind, mode, &length, &elements, &pre_bailout](
CodeStubAssembler* assembler, Node* arg) {
[this, kind, mode, &length, &elements, &pre_bailout](Node* arg) {
if (IsFastSmiElementsKind(kind)) {
assembler->GotoIf(assembler->TaggedIsNotSmi(arg), &pre_bailout);
GotoIf(TaggedIsNotSmi(arg), &pre_bailout);
} else if (IsFastDoubleElementsKind(kind)) {
assembler->GotoIfNotNumber(arg, &pre_bailout);
GotoIfNotNumber(arg, &pre_bailout);
}
if (IsFastDoubleElementsKind(kind)) {
Node* double_value = assembler->ChangeNumberToFloat64(arg);
assembler->StoreFixedDoubleArrayElement(
elements.value(), length.value(),
assembler->Float64SilenceNaN(double_value), mode);
Node* double_value = ChangeNumberToFloat64(arg);
StoreFixedDoubleArrayElement(elements.value(), length.value(),
Float64SilenceNaN(double_value), mode);
} else {
WriteBarrierMode barrier_mode = IsFastSmiElementsKind(kind)
? SKIP_WRITE_BARRIER
: UPDATE_WRITE_BARRIER;
assembler->StoreFixedArrayElement(elements.value(), length.value(),
arg, barrier_mode, 0, mode);
StoreFixedArrayElement(elements.value(), length.value(), arg,
barrier_mode, 0, mode);
}
assembler->Increment(length, 1, mode);
Increment(length, 1, mode);
},
first, nullptr);
length.Bind(TagParameter(length.value(), mode));
......@@ -1896,8 +1895,8 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address,
CSA_ASSERT(this, WordIsWordAligned(end_address));
BuildFastLoop(
MachineType::PointerRepresentation(), start_address, end_address,
[value](CodeStubAssembler* a, Node* current) {
a->StoreNoWriteBarrier(MachineRepresentation::kTagged, current, value);
[this, value](Node* current) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, current, value);
},
kPointerSize, IndexAdvanceMode::kPost);
}
......@@ -2024,8 +2023,7 @@ void CodeStubAssembler::FillFixedArrayWithValue(
BuildFastFixedArrayForEach(
array, kind, from_node, to_node,
[value, is_double, double_hole](CodeStubAssembler* assembler, Node* array,
Node* offset) {
[this, value, is_double, double_hole](Node* array, Node* offset) {
if (is_double) {
// Don't use doubles to store the hole double, since manipulating the
// signaling NaN used for the hole in C++, e.g. with bit_cast, will
......@@ -2035,21 +2033,19 @@ void CodeStubAssembler::FillFixedArrayWithValue(
// TODO(danno): When we have a Float32/Float64 wrapper class that
// preserves double bits during manipulation, remove this code/change
// this to an indexed Float64 store.
if (assembler->Is64()) {
assembler->StoreNoWriteBarrier(MachineRepresentation::kWord64,
array, offset, double_hole);
if (Is64()) {
StoreNoWriteBarrier(MachineRepresentation::kWord64, array, offset,
double_hole);
} else {
assembler->StoreNoWriteBarrier(MachineRepresentation::kWord32,
array, offset, double_hole);
assembler->StoreNoWriteBarrier(
MachineRepresentation::kWord32, array,
assembler->IntPtrAdd(offset,
assembler->IntPtrConstant(kPointerSize)),
StoreNoWriteBarrier(MachineRepresentation::kWord32, array, offset,
double_hole);
StoreNoWriteBarrier(MachineRepresentation::kWord32, array,
IntPtrAdd(offset, IntPtrConstant(kPointerSize)),
double_hole);
}
} else {
assembler->StoreNoWriteBarrier(MachineRepresentation::kTagged, array,
offset, value);
StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset,
value);
}
},
mode);
......@@ -2237,14 +2233,14 @@ void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
to_index_smi == from_index_smi));
BuildFastLoop(vars, MachineType::PointerRepresentation(), from_offset,
limit_offset,
[from_string, to_string, &current_to_offset, to_increment, type,
rep, index_same](CodeStubAssembler* assembler, Node* offset) {
Node* value = assembler->Load(type, from_string, offset);
assembler->StoreNoWriteBarrier(
[this, from_string, to_string, &current_to_offset, to_increment,
type, rep, index_same](Node* offset) {
Node* value = Load(type, from_string, offset);
StoreNoWriteBarrier(
rep, to_string,
index_same ? offset : current_to_offset.value(), value);
if (!index_same) {
assembler->Increment(current_to_offset, to_increment);
Increment(current_to_offset, to_increment);
}
},
from_increment, IndexAdvanceMode::kPost);
......@@ -3543,19 +3539,19 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
var_result.Bind(SmiConstant(Smi::FromInt(-1)));
BuildFastLoop(MachineType::PointerRepresentation(), cursor, end,
[string, needle_char, begin, &var_result, &out](
CodeStubAssembler* csa, Node* cursor) {
Label next(csa);
Node* value = csa->Load(MachineType::Uint8(), string, cursor);
csa->GotoUnless(csa->WordEqual(value, needle_char), &next);
BuildFastLoop(
MachineType::PointerRepresentation(), cursor, end,
[this, string, needle_char, begin, &var_result, &out](Node* cursor) {
Label next(this);
Node* value = Load(MachineType::Uint8(), string, cursor);
GotoUnless(WordEqual(value, needle_char), &next);
// Found a match.
Node* index = csa->SmiTag(csa->IntPtrSub(cursor, begin));
Node* index = SmiTag(IntPtrSub(cursor, begin));
var_result.Bind(index);
csa->Goto(&out);
Goto(&out);
csa->Bind(&next);
Bind(&next);
},
1, IndexAdvanceMode::kPost);
Goto(&out);
......@@ -4601,15 +4597,14 @@ void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name,
Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize);
Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor));
BuildFastLoop(
MachineType::PointerRepresentation(), last_exclusive, first_inclusive,
[descriptors, unique_name, if_found, var_name_index](
CodeStubAssembler* assembler, Node* name_index) {
Node* candidate_name = assembler->LoadFixedArrayElement(
BuildFastLoop(MachineType::PointerRepresentation(), last_exclusive,
first_inclusive,
[this, descriptors, unique_name, if_found,
var_name_index](Node* name_index) {
Node* candidate_name = LoadFixedArrayElement(
descriptors, name_index, 0, INTPTR_PARAMETERS);
var_name_index->Bind(name_index);
assembler->GotoIf(assembler->WordEqual(candidate_name, unique_name),
if_found);
GotoIf(WordEqual(candidate_name, unique_name), if_found);
},
-DescriptorArray::kDescriptorSize, IndexAdvanceMode::kPre);
Goto(if_not_found);
......@@ -5075,8 +5070,8 @@ template void CodeStubAssembler::NumberDictionaryLookup<
UnseededNumberDictionary>(Node*, Node*, Label*, Variable*, Label*);
void CodeStubAssembler::TryPrototypeChainLookup(
Node* receiver, Node* key, LookupInHolder& lookup_property_in_holder,
LookupInHolder& lookup_element_in_holder, Label* if_end,
Node* receiver, Node* key, const LookupInHolder& lookup_property_in_holder,
const LookupInHolder& lookup_element_in_holder, Label* if_end,
Label* if_bailout) {
// Ensure receiver is JSReceiver, otherwise bailout.
Label if_objectisnotsmi(this);
......@@ -6188,8 +6183,7 @@ Node* CodeStubAssembler::CreateWeakCellInFeedbackVector(Node* feedback_vector,
void CodeStubAssembler::BuildFastLoop(
const CodeStubAssembler::VariableList& vars,
MachineRepresentation index_rep, Node* start_index, Node* end_index,
std::function<void(CodeStubAssembler* assembler, Node* index)> body,
int increment, IndexAdvanceMode mode) {
const FastLoopBody& body, int increment, IndexAdvanceMode mode) {
Variable var(this, index_rep);
VariableList vars_copy(vars, zone());
vars_copy.Add(&var, zone());
......@@ -6209,7 +6203,7 @@ void CodeStubAssembler::BuildFastLoop(
if (mode == IndexAdvanceMode::kPre) {
Increment(var, increment);
}
body(this, var.value());
body(var.value());
if (mode == IndexAdvanceMode::kPost) {
Increment(var, increment);
}
......@@ -6220,10 +6214,7 @@ void CodeStubAssembler::BuildFastLoop(
void CodeStubAssembler::BuildFastFixedArrayForEach(
Node* fixed_array, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive,
std::function<void(CodeStubAssembler* assembler, Node* fixed_array,
Node* offset)>
body,
Node* last_element_exclusive, const FastFixedArrayForEachBody& body,
ParameterMode mode, ForEachDirection direction) {
STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
int32_t first_val;
......@@ -6240,7 +6231,7 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
Node* offset =
ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS,
FixedArray::kHeaderSize - kHeapObjectTag);
body(this, fixed_array, offset);
body(fixed_array, offset);
}
} else {
for (int i = last_val - 1; i >= first_val; --i) {
......@@ -6248,7 +6239,7 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
Node* offset =
ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS,
FixedArray::kHeaderSize - kHeapObjectTag);
body(this, fixed_array, offset);
body(fixed_array, offset);
}
}
return;
......@@ -6266,9 +6257,7 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
int increment = IsFastDoubleElementsKind(kind) ? kDoubleSize : kPointerSize;
BuildFastLoop(
MachineType::PointerRepresentation(), start, limit,
[fixed_array, body](CodeStubAssembler* assembler, Node* offset) {
body(assembler, fixed_array, offset);
},
[fixed_array, &body](Node* offset) { body(fixed_array, offset); },
direction == ForEachDirection::kReverse ? -increment : increment,
direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre
: IndexAdvanceMode::kPost);
......@@ -8107,9 +8096,9 @@ Node* CodeStubArguments::AtIndex(int index) const {
return AtIndex(assembler_->IntPtrConstant(index));
}
void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
CodeStubArguments::ForEachBodyFunction body,
Node* first, Node* last,
void CodeStubArguments::ForEach(
const CodeStubAssembler::VariableList& vars,
const CodeStubArguments::ForEachBodyFunction& body, Node* first, Node* last,
CodeStubAssembler::ParameterMode mode) {
assembler_->Comment("CodeStubArguments::ForEach");
DCHECK_IMPLIES(first == nullptr || last == nullptr,
......@@ -8128,9 +8117,9 @@ void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
assembler_->BuildFastLoop(
vars, MachineType::PointerRepresentation(), start, end,
[body](CodeStubAssembler* assembler, Node* current) {
Node* arg = assembler->Load(MachineType::AnyTagged(), current);
body(assembler, arg);
[this, &body](Node* current) {
Node* arg = assembler_->Load(MachineType::AnyTagged(), current);
body(arg);
},
-kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
}
......
......@@ -164,8 +164,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* InnerAllocate(Node* previous, Node* offset);
Node* IsRegularHeapObjectSize(Node* size);
typedef std::function<Node*()> ConditionBody;
void Assert(ConditionBody condition_body, const char* string = nullptr,
typedef std::function<Node*()> NodeGenerator;
void Assert(const NodeGenerator& condition_body, const char* string = nullptr,
const char* file = nullptr, int line = 0);
// Check a value for smi-ness
......@@ -830,8 +831,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// If it can't handle the case {receiver}/{key} case then the control goes
// to {if_bailout}.
void TryPrototypeChainLookup(Node* receiver, Node* key,
LookupInHolder& lookup_property_in_holder,
LookupInHolder& lookup_element_in_holder,
const LookupInHolder& lookup_property_in_holder,
const LookupInHolder& lookup_element_in_holder,
Label* if_end, Label* if_bailout);
// Instanceof helpers.
......@@ -923,28 +924,28 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
enum class IndexAdvanceMode { kPre, kPost };
void BuildFastLoop(
const VariableList& var_list, MachineRepresentation index_rep,
Node* start_index, Node* end_index,
std::function<void(CodeStubAssembler* assembler, Node* index)> body,
int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre);
typedef std::function<void(Node* index)> FastLoopBody;
void BuildFastLoop(const VariableList& var_list,
MachineRepresentation index_rep, Node* start_index,
Node* end_index, const FastLoopBody& body, int increment,
IndexAdvanceMode mode = IndexAdvanceMode::kPre);
void BuildFastLoop(
MachineRepresentation index_rep, Node* start_index, Node* end_index,
std::function<void(CodeStubAssembler* assembler, Node* index)> body,
int increment, IndexAdvanceMode mode = IndexAdvanceMode::kPre) {
void BuildFastLoop(MachineRepresentation index_rep, Node* start_index,
Node* end_index, const FastLoopBody& body, int increment,
IndexAdvanceMode mode = IndexAdvanceMode::kPre) {
BuildFastLoop(VariableList(0, zone()), index_rep, start_index, end_index,
body, increment, mode);
}
enum class ForEachDirection { kForward, kReverse };
typedef std::function<void(Node* fixed_array, Node* offset)>
FastFixedArrayForEachBody;
void BuildFastFixedArrayForEach(
Node* fixed_array, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive,
std::function<void(CodeStubAssembler* assembler, Node* fixed_array,
Node* offset)>
body,
Node* last_element_exclusive, const FastFixedArrayForEachBody& body,
ParameterMode mode = INTPTR_PARAMETERS,
ForEachDirection direction = ForEachDirection::kReverse);
......@@ -1069,11 +1070,10 @@ class CodeStubArguments {
Node* GetLength() const { return argc_; }
typedef std::function<void(CodeStubAssembler* assembler, Node* arg)>
ForEachBodyFunction;
typedef std::function<void(Node* arg)> ForEachBodyFunction;
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
void ForEach(ForEachBodyFunction body, Node* first = nullptr,
void ForEach(const ForEachBodyFunction& body, Node* first = nullptr,
Node* last = nullptr, CodeStubAssembler::ParameterMode mode =
CodeStubAssembler::INTPTR_PARAMETERS) {
CodeStubAssembler::VariableList list(0, assembler_->zone());
......@@ -1082,7 +1082,7 @@ class CodeStubArguments {
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
void ForEach(const CodeStubAssembler::VariableList& vars,
ForEachBodyFunction body, Node* first = nullptr,
const ForEachBodyFunction& body, Node* first = nullptr,
Node* last = nullptr, CodeStubAssembler::ParameterMode mode =
CodeStubAssembler::INTPTR_PARAMETERS);
......
......@@ -2626,7 +2626,7 @@ compiler::Node* FastNewFunctionContextStub::Generate(
Node* undefined = assembler->UndefinedConstant();
assembler->BuildFastFixedArrayForEach(
function_context, FAST_ELEMENTS, min_context_slots, length,
[undefined](CodeStubAssembler* assembler, Node* context, Node* offset) {
[assembler, undefined](Node* context, Node* offset) {
assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(),
context, offset, undefined);
});
......
......@@ -79,21 +79,20 @@ void AccessorAssemblerImpl::HandlePolymorphicCase(
Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
BuildFastLoop(
MachineType::PointerRepresentation(), init, length,
[receiver_map, feedback, if_handler, var_handler](CodeStubAssembler* csa,
Node* index) {
Node* cached_map = csa->LoadWeakCellValue(
csa->LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS));
[this, receiver_map, feedback, if_handler, var_handler](Node* index) {
Node* cached_map = LoadWeakCellValue(
LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS));
Label next_entry(csa);
csa->GotoIf(csa->WordNotEqual(receiver_map, cached_map), &next_entry);
Label next_entry(this);
GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry);
// Found, now call handler.
Node* handler = csa->LoadFixedArrayElement(
feedback, index, kPointerSize, INTPTR_PARAMETERS);
Node* handler = LoadFixedArrayElement(feedback, index, kPointerSize,
INTPTR_PARAMETERS);
var_handler->Bind(handler);
csa->Goto(if_handler);
Goto(if_handler);
csa->Bind(&next_entry);
Bind(&next_entry);
},
kEntrySize, IndexAdvanceMode::kPost);
// The loop falls through if no handler was found.
......@@ -111,28 +110,26 @@ void AccessorAssemblerImpl::HandleKeyedStorePolymorphicCase(
Node* init = IntPtrConstant(0);
Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
BuildFastLoop(
MachineType::PointerRepresentation(), init, length,
[receiver_map, feedback, if_handler, var_handler, if_transition_handler,
var_transition_map_cell](CodeStubAssembler* csa, Node* index) {
Node* cached_map = csa->LoadWeakCellValue(
csa->LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS));
Label next_entry(csa);
csa->GotoIf(csa->WordNotEqual(receiver_map, cached_map), &next_entry);
Node* maybe_transition_map_cell = csa->LoadFixedArrayElement(
BuildFastLoop(MachineType::PointerRepresentation(), init, length,
[this, receiver_map, feedback, if_handler, var_handler,
if_transition_handler, var_transition_map_cell](Node* index) {
Node* cached_map = LoadWeakCellValue(LoadFixedArrayElement(
feedback, index, 0, INTPTR_PARAMETERS));
Label next_entry(this);
GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry);
Node* maybe_transition_map_cell = LoadFixedArrayElement(
feedback, index, kPointerSize, INTPTR_PARAMETERS);
var_handler->Bind(csa->LoadFixedArrayElement(
var_handler->Bind(LoadFixedArrayElement(
feedback, index, 2 * kPointerSize, INTPTR_PARAMETERS));
csa->GotoIf(
csa->WordEqual(maybe_transition_map_cell,
csa->LoadRoot(Heap::kUndefinedValueRootIndex)),
GotoIf(WordEqual(maybe_transition_map_cell,
LoadRoot(Heap::kUndefinedValueRootIndex)),
if_handler);
var_transition_map_cell->Bind(maybe_transition_map_cell);
csa->Goto(if_transition_handler);
Goto(if_transition_handler);
csa->Bind(&next_entry);
Bind(&next_entry);
},
kEntrySize, IndexAdvanceMode::kPost);
// The loop falls through if no handler was found.
......@@ -424,7 +421,7 @@ Node* AccessorAssemblerImpl::EmitLoadICProtoArrayCheck(
BuildFastLoop(
MachineType::PointerRepresentation(), start_index.value(), handler_length,
[this, p, handler, miss](CodeStubAssembler*, Node* current) {
[this, p, handler, miss](Node* current) {
Node* prototype_cell =
LoadFixedArrayElement(handler, current, 0, INTPTR_PARAMETERS);
CheckPrototype(prototype_cell, p->name, miss);
......@@ -579,7 +576,7 @@ void AccessorAssemblerImpl::HandleStoreICProtoHandler(
Node* length = SmiUntag(maybe_transition_cell);
BuildFastLoop(MachineType::PointerRepresentation(),
IntPtrConstant(StoreHandler::kFirstPrototypeIndex), length,
[this, p, handler, miss](CodeStubAssembler*, Node* current) {
[this, p, handler, miss](Node* current) {
Node* prototype_cell = LoadFixedArrayElement(
handler, current, 0, INTPTR_PARAMETERS);
CheckPrototype(prototype_cell, p->name, miss);
......
......@@ -1742,9 +1742,8 @@ TEST(ArgumentsForEach) {
sum.Bind(m.IntPtrConstant(0));
arguments.ForEach(list, [&m, &sum](CodeStubAssembler* assembler, Node* arg) {
sum.Bind(assembler->IntPtrAdd(sum.value(), arg));
});
arguments.ForEach(
list, [&m, &sum](Node* arg) { sum.Bind(m.IntPtrAdd(sum.value(), arg)); });
m.Return(sum.value());
......
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