Commit 03b85541 authored by jkummerow's avatar jkummerow Committed by Commit bot

[stubs] KeyedStoreIC: Use BuildFastLoop() helper

Bonus: CodeStubAssembler::StringIndexOfChar gets the same treatment.
Review-Url: https://chromiumcodereview.appspot.com/2435713003
Cr-Commit-Position: refs/heads/master@{#40445}
parent 9eff39ae
...@@ -3213,33 +3213,24 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, ...@@ -3213,33 +3213,24 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
Node* const cursor = IntPtrAdd(begin, SmiUntag(from)); Node* const cursor = IntPtrAdd(begin, SmiUntag(from));
Node* const end = IntPtrAdd(cursor, search_range_length); Node* const end = IntPtrAdd(cursor, search_range_length);
Variable var_cursor(this, MachineType::PointerRepresentation());
Variable* vars[] = {&var_cursor};
Label loop(this, 1, vars), loop_tail(this);
var_cursor.Bind(cursor);
var_result.Bind(SmiConstant(Smi::FromInt(-1))); var_result.Bind(SmiConstant(Smi::FromInt(-1)));
Goto(&loop); BuildFastLoop(MachineType::PointerRepresentation(), cursor, end,
Bind(&loop); [string, needle_char, begin, &var_result, &out](
{ CodeStubAssembler* csa, Node* cursor) {
Node* const cursor = var_cursor.value(); Label next(csa);
Node* value = csa->Load(MachineType::Uint8(), string, cursor);
csa->GotoUnless(csa->WordEqual(value, needle_char), &next);
Node* value = Load(MachineType::Uint8(), string, cursor); // Found a match.
GotoUnless(WordEqual(value, needle_char), &loop_tail); Node* index = csa->SmiTag(csa->IntPtrSub(cursor, begin));
var_result.Bind(index);
csa->Goto(&out);
// Found a match. csa->Bind(&next);
Node* index = SmiTag(IntPtrSub(cursor, begin)); },
var_result.Bind(index); 1, IndexAdvanceMode::kPost);
Goto(&out); Goto(&out);
Bind(&loop_tail);
{
Node* const new_cursor = IntPtrAdd(cursor, IntPtrConstant(1));
var_cursor.Bind(new_cursor);
Branch(IntPtrLessThan(new_cursor, end), &loop, &out);
}
}
Bind(&runtime); Bind(&runtime);
{ {
...@@ -3247,7 +3238,6 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, ...@@ -3247,7 +3238,6 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
Node* const result = Node* const result =
CallRuntime(Runtime::kStringIndexOf, context, string, pattern, from); CallRuntime(Runtime::kStringIndexOf, context, string, pattern, from);
var_result.Bind(result); var_result.Bind(result);
var_cursor.Bind(IntPtrConstant(0));
Goto(&out); Goto(&out);
} }
...@@ -4814,34 +4804,31 @@ void CodeStubAssembler::HandlePolymorphicCase( ...@@ -4814,34 +4804,31 @@ void CodeStubAssembler::HandlePolymorphicCase(
Bind(&next_entry); Bind(&next_entry);
} }
Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
// Loop from {unroll_count}*kEntrySize to {length}. // Loop from {unroll_count}*kEntrySize to {length}.
Variable var_index(this, MachineType::PointerRepresentation()); Node* init = IntPtrConstant(unroll_count * kEntrySize);
Label loop(this, &var_index); Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
var_index.Bind(IntPtrConstant(unroll_count * kEntrySize)); BuildFastLoop(
Goto(&loop); MachineType::PointerRepresentation(), init, length,
Bind(&loop); [receiver_map, feedback, if_handler, var_handler](CodeStubAssembler* csa,
{ Node* index) {
Node* index = var_index.value(); Node* cached_map = csa->LoadWeakCellValue(
GotoIf(UintPtrGreaterThanOrEqual(index, length), if_miss); csa->LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS));
Node* cached_map = LoadWeakCellValue( Label next_entry(csa);
LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS)); csa->GotoIf(csa->WordNotEqual(receiver_map, cached_map), &next_entry);
Label next_entry(this); // Found, now call handler.
GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry); Node* handler = csa->LoadFixedArrayElement(
feedback, index, kPointerSize, INTPTR_PARAMETERS);
// Found, now call handler. var_handler->Bind(handler);
Node* handler = csa->Goto(if_handler);
LoadFixedArrayElement(feedback, index, kPointerSize, INTPTR_PARAMETERS);
var_handler->Bind(handler); csa->Bind(&next_entry);
Goto(if_handler); },
kEntrySize, IndexAdvanceMode::kPost);
Bind(&next_entry); // The loop falls through if no handler was found.
var_index.Bind(IntPtrAdd(index, IntPtrConstant(kEntrySize))); Goto(if_miss);
Goto(&loop);
}
} }
void CodeStubAssembler::HandleKeyedStorePolymorphicCase( void CodeStubAssembler::HandleKeyedStorePolymorphicCase(
...@@ -4853,37 +4840,34 @@ void CodeStubAssembler::HandleKeyedStorePolymorphicCase( ...@@ -4853,37 +4840,34 @@ void CodeStubAssembler::HandleKeyedStorePolymorphicCase(
const int kEntrySize = 3; const int kEntrySize = 3;
Variable var_index(this, MachineType::PointerRepresentation()); Node* init = IntPtrConstant(0);
Label loop(this, &var_index);
var_index.Bind(IntPtrConstant(0));
Node* length = LoadAndUntagFixedArrayBaseLength(feedback); Node* length = LoadAndUntagFixedArrayBaseLength(feedback);
Goto(&loop); BuildFastLoop(
Bind(&loop); MachineType::PointerRepresentation(), init, length,
{ [receiver_map, feedback, if_handler, var_handler, if_transition_handler,
Node* index = var_index.value(); var_transition_map_cell](CodeStubAssembler* csa, Node* index) {
GotoIf(UintPtrGreaterThanOrEqual(index, length), if_miss); Node* cached_map = csa->LoadWeakCellValue(
csa->LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS));
Node* cached_map = LoadWeakCellValue( Label next_entry(csa);
LoadFixedArrayElement(feedback, index, 0, INTPTR_PARAMETERS)); csa->GotoIf(csa->WordNotEqual(receiver_map, cached_map), &next_entry);
Label next_entry(this); Node* maybe_transition_map_cell = csa->LoadFixedArrayElement(
GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry); feedback, index, kPointerSize, INTPTR_PARAMETERS);
Node* maybe_transition_map_cell = var_handler->Bind(csa->LoadFixedArrayElement(
LoadFixedArrayElement(feedback, index, kPointerSize, INTPTR_PARAMETERS); feedback, index, 2 * kPointerSize, INTPTR_PARAMETERS));
csa->GotoIf(
var_handler->Bind(LoadFixedArrayElement(feedback, index, 2 * kPointerSize, csa->WordEqual(maybe_transition_map_cell,
INTPTR_PARAMETERS)); csa->LoadRoot(Heap::kUndefinedValueRootIndex)),
GotoIf(WordEqual(maybe_transition_map_cell, if_handler);
LoadRoot(Heap::kUndefinedValueRootIndex)), var_transition_map_cell->Bind(maybe_transition_map_cell);
if_handler); csa->Goto(if_transition_handler);
var_transition_map_cell->Bind(maybe_transition_map_cell);
Goto(if_transition_handler); csa->Bind(&next_entry);
},
Bind(&next_entry); kEntrySize, IndexAdvanceMode::kPost);
var_index.Bind(IntPtrAdd(index, IntPtrConstant(kEntrySize))); // The loop falls through if no handler was found.
Goto(&loop); Goto(if_miss);
}
} }
compiler::Node* CodeStubAssembler::StubCachePrimaryOffset(compiler::Node* name, compiler::Node* CodeStubAssembler::StubCachePrimaryOffset(compiler::Node* name,
......
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