[csa] Universally use ParameterMode in BuildFastFixedArrayForEach

This allows support for tagged representations of index/loop variables which
asserted in BuildFastFixedArrayForEach's call to Increment up to this point.

Review-Url: https://codereview.chromium.org/2665143002
Cr-Commit-Position: refs/heads/master@{#42863}
This commit is contained in:
danno 2017-02-01 10:23:13 -08:00 committed by Commit bot
parent d8ab932ceb
commit c9f7f303b9
4 changed files with 68 additions and 61 deletions

View File

@ -2323,7 +2323,7 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
const int increment = 1;
BuildFastLoop(
MachineType::PointerRepresentation(), from, to,
from, to,
[this, res_elems, isolate, native_context, context, undefined,
replace_callable](Node* index) {
Node* const elem = LoadFixedArrayElement(res_elems, index);
@ -2354,7 +2354,8 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
Goto(&do_continue);
Bind(&do_continue);
},
increment, CodeStubAssembler::IndexAdvanceMode::kPost);
increment, CodeStubAssembler::INTPTR_PARAMETERS,
CodeStubAssembler::IndexAdvanceMode::kPost);
Goto(&create_result);
}

View File

@ -1997,12 +1997,12 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address,
Comment("StoreFieldsNoWriteBarrier");
CSA_ASSERT(this, WordIsWordAligned(start_address));
CSA_ASSERT(this, WordIsWordAligned(end_address));
BuildFastLoop(
MachineType::PointerRepresentation(), start_address, end_address,
[this, value](Node* current) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, current, value);
},
kPointerSize, IndexAdvanceMode::kPost);
BuildFastLoop(start_address, end_address,
[this, value](Node* current) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, current,
value);
},
kPointerSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
}
Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
@ -2342,8 +2342,7 @@ void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
(ToSmiConstant(from_index, from_index_smi) &&
ToSmiConstant(to_index, to_index_smi) &&
to_index_smi == from_index_smi));
BuildFastLoop(vars, MachineType::PointerRepresentation(), from_offset,
limit_offset,
BuildFastLoop(vars, from_offset, limit_offset,
[this, from_string, to_string, &current_to_offset, to_increment,
type, rep, index_same](Node* offset) {
Node* value = Load(type, from_string, offset);
@ -2354,7 +2353,7 @@ void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
Increment(current_to_offset, to_increment);
}
},
from_increment, IndexAdvanceMode::kPost);
from_increment, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
}
Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array,
@ -3771,7 +3770,7 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
var_result.Bind(SmiConstant(Smi::FromInt(-1)));
BuildFastLoop(
MachineType::PointerRepresentation(), cursor, end,
cursor, end,
[this, string, needle_char, begin, &var_result, &out](Node* cursor) {
Label next(this);
Node* value = Load(MachineType::Uint8(), string, cursor);
@ -3784,7 +3783,7 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
Bind(&next);
},
1, IndexAdvanceMode::kPost);
1, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
Goto(&out);
Bind(&runtime);
@ -4797,15 +4796,16 @@ 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,
[this, descriptors, unique_name, if_found,
var_name_index](Node* name_index) {
Node* candidate_name = LoadFixedArrayElement(descriptors, name_index);
var_name_index->Bind(name_index);
GotoIf(WordEqual(candidate_name, unique_name), if_found);
},
-DescriptorArray::kDescriptorSize, IndexAdvanceMode::kPre);
BuildFastLoop(last_exclusive, first_inclusive,
[this, descriptors, unique_name, if_found,
var_name_index](Node* name_index) {
Node* candidate_name =
LoadFixedArrayElement(descriptors, name_index);
var_name_index->Bind(name_index);
GotoIf(WordEqual(candidate_name, unique_name), if_found);
},
-DescriptorArray::kDescriptorSize, INTPTR_PARAMETERS,
IndexAdvanceMode::kPre);
Goto(if_not_found);
}
@ -6264,9 +6264,12 @@ Node* CodeStubAssembler::CreateWeakCellInFeedbackVector(Node* feedback_vector,
}
Node* CodeStubAssembler::BuildFastLoop(
const CodeStubAssembler::VariableList& vars,
MachineRepresentation index_rep, Node* start_index, Node* end_index,
const FastLoopBody& body, int increment, IndexAdvanceMode mode) {
const CodeStubAssembler::VariableList& vars, Node* start_index,
Node* end_index, const FastLoopBody& body, int increment,
ParameterMode parameter_mode, IndexAdvanceMode advance_mode) {
MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS)
? MachineType::PointerRepresentation()
: MachineRepresentation::kTaggedSigned;
Variable var(this, index_rep, start_index);
VariableList vars_copy(vars, zone());
vars_copy.Add(&var, zone());
@ -6282,12 +6285,12 @@ Node* CodeStubAssembler::BuildFastLoop(
Branch(WordEqual(var.value(), end_index), &after_loop, &loop);
Bind(&loop);
{
if (mode == IndexAdvanceMode::kPre) {
Increment(var, increment);
if (advance_mode == IndexAdvanceMode::kPre) {
Increment(var, increment, parameter_mode);
}
body(var.value());
if (mode == IndexAdvanceMode::kPost) {
Increment(var, increment);
if (advance_mode == IndexAdvanceMode::kPost) {
Increment(var, increment, parameter_mode);
}
Branch(WordNotEqual(var.value(), end_index), &loop, &after_loop);
}
@ -6340,9 +6343,10 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
int increment = IsFastDoubleElementsKind(kind) ? kDoubleSize : kPointerSize;
BuildFastLoop(
vars, MachineType::PointerRepresentation(), start, limit,
vars, start, limit,
[fixed_array, &body](Node* offset) { body(fixed_array, offset); },
direction == ForEachDirection::kReverse ? -increment : increment,
INTPTR_PARAMETERS,
direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre
: IndexAdvanceMode::kPost);
}
@ -6353,12 +6357,13 @@ void CodeStubAssembler::InitializeFieldsWithRoot(
start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag));
end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag));
Node* root_value = LoadRoot(root_index);
BuildFastLoop(MachineType::PointerRepresentation(), end_offset, start_offset,
BuildFastLoop(end_offset, start_offset,
[this, object, root_value](Node* current) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, object,
current, root_value);
},
-kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPre);
-kPointerSize, INTPTR_PARAMETERS,
CodeStubAssembler::IndexAdvanceMode::kPre);
}
void CodeStubAssembler::BranchIfNumericRelationalComparison(
@ -8286,13 +8291,14 @@ void CodeStubArguments::ForEach(
Node* end = assembler_->IntPtrSub(
arguments_,
assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
assembler_->BuildFastLoop(
vars, MachineType::PointerRepresentation(), start, end,
[this, &body](Node* current) {
Node* arg = assembler_->Load(MachineType::AnyTagged(), current);
body(arg);
},
-kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
assembler_->BuildFastLoop(vars, start, end,
[this, &body](Node* current) {
Node* arg = assembler_->Load(
MachineType::AnyTagged(), current);
body(arg);
},
-kPointerSize, CodeStubAssembler::INTPTR_PARAMETERS,
CodeStubAssembler::IndexAdvanceMode::kPost);
}
void CodeStubArguments::PopAndReturn(Node* value) {

View File

@ -1075,16 +1075,17 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
typedef std::function<void(Node* index)> FastLoopBody;
Node* BuildFastLoop(const VariableList& var_list,
MachineRepresentation index_rep, Node* start_index,
Node* BuildFastLoop(const VariableList& var_list, Node* start_index,
Node* end_index, const FastLoopBody& body, int increment,
IndexAdvanceMode mode = IndexAdvanceMode::kPre);
ParameterMode parameter_mode,
IndexAdvanceMode advance_mode = IndexAdvanceMode::kPre);
Node* BuildFastLoop(MachineRepresentation index_rep, Node* start_index,
Node* end_index, const FastLoopBody& body, int increment,
IndexAdvanceMode mode = IndexAdvanceMode::kPre) {
return BuildFastLoop(VariableList(0, zone()), index_rep, start_index,
end_index, body, increment, mode);
Node* BuildFastLoop(Node* start_index, Node* end_index,
const FastLoopBody& body, int increment,
ParameterMode parameter_mode,
IndexAdvanceMode advance_mode = IndexAdvanceMode::kPre) {
return BuildFastLoop(VariableList(0, zone()), start_index, end_index, body,
increment, parameter_mode, advance_mode);
}
enum class ForEachDirection { kForward, kReverse };

View File

@ -80,7 +80,7 @@ void AccessorAssembler::HandlePolymorphicCase(Node* receiver_map,
Node* init = IntPtrConstant(unroll_count * kEntrySize);
Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
BuildFastLoop(
MachineType::PointerRepresentation(), init, length,
init, length,
[this, receiver_map, feedback, if_handler, var_handler](Node* index) {
Node* cached_map =
LoadWeakCellValue(LoadFixedArrayElement(feedback, index));
@ -95,7 +95,7 @@ void AccessorAssembler::HandlePolymorphicCase(Node* receiver_map,
Bind(&next_entry);
},
kEntrySize, IndexAdvanceMode::kPost);
kEntrySize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
// The loop falls through if no handler was found.
Goto(if_miss);
}
@ -111,7 +111,7 @@ void AccessorAssembler::HandleKeyedStorePolymorphicCase(
Node* init = IntPtrConstant(0);
Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
BuildFastLoop(MachineType::PointerRepresentation(), init, length,
BuildFastLoop(init, length,
[this, receiver_map, feedback, if_handler, var_handler,
if_transition_handler, var_transition_map_cell](Node* index) {
Node* cached_map =
@ -132,7 +132,7 @@ void AccessorAssembler::HandleKeyedStorePolymorphicCase(
Bind(&next_entry);
},
kEntrySize, IndexAdvanceMode::kPost);
kEntrySize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
// The loop falls through if no handler was found.
Goto(if_miss);
}
@ -410,13 +410,13 @@ Node* AccessorAssembler::EmitLoadICProtoArrayCheck(
}
Bind(&can_access);
BuildFastLoop(
MachineType::PointerRepresentation(), start_index.value(), handler_length,
[this, p, handler, miss](Node* current) {
Node* prototype_cell = LoadFixedArrayElement(handler, current);
CheckPrototype(prototype_cell, p->name, miss);
},
1, IndexAdvanceMode::kPost);
BuildFastLoop(start_index.value(), handler_length,
[this, p, handler, miss](Node* current) {
Node* prototype_cell =
LoadFixedArrayElement(handler, current);
CheckPrototype(prototype_cell, p->name, miss);
},
1, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
Node* maybe_holder_cell =
LoadFixedArrayElement(handler, LoadHandler::kHolderCellIndex);
@ -564,14 +564,13 @@ void AccessorAssembler::HandleStoreICProtoHandler(const StoreICParameters* p,
Bind(&array_handler);
{
Node* length = SmiUntag(maybe_transition_cell);
BuildFastLoop(MachineType::PointerRepresentation(),
IntPtrConstant(StoreHandler::kFirstPrototypeIndex), length,
BuildFastLoop(IntPtrConstant(StoreHandler::kFirstPrototypeIndex), length,
[this, p, handler, miss](Node* current) {
Node* prototype_cell =
LoadFixedArrayElement(handler, current);
CheckPrototype(prototype_cell, p->name, miss);
},
1, IndexAdvanceMode::kPost);
1, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
Node* maybe_transition_cell =
LoadFixedArrayElement(handler, StoreHandler::kTransitionCellIndex);