Commit 40bf2d7e authored by bmeurer's avatar bmeurer Committed by Commit bot

[Interpreter] Implement ForInStep directly.

The ForInStep bytecode is essentially a (guaranteed) Smi increment
operation. We can do not need to go to the runtime for this operation.

R=oth@chromium.org

Review URL: https://codereview.chromium.org/1738823002

Cr-Commit-Position: refs/heads/master@{#34289}
parent 7ef9b6b8
......@@ -72,6 +72,9 @@ Node* CodeStubAssembler::NumberConstant(double value) {
return raw_assembler_->NumberConstant(value);
}
Node* CodeStubAssembler::SmiConstant(Smi* value) {
return IntPtrConstant(bit_cast<intptr_t>(value));
}
Node* CodeStubAssembler::HeapConstant(Handle<HeapObject> object) {
return raw_assembler_->HeapConstant(object);
......@@ -125,6 +128,8 @@ Node* CodeStubAssembler::SmiUntag(Node* value) {
return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
}
Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { return IntPtrAdd(a, b); }
#define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
Node* CodeStubAssembler::name(Node* a, Node* b) { \
return raw_assembler_->name(a, b); \
......
......@@ -103,6 +103,7 @@ class CodeStubAssembler {
Node* Int32Constant(int value);
Node* IntPtrConstant(intptr_t value);
Node* NumberConstant(double value);
Node* SmiConstant(Smi* value);
Node* HeapConstant(Handle<HeapObject> object);
Node* BooleanConstant(bool value);
Node* ExternalConstant(ExternalReference address);
......@@ -195,6 +196,9 @@ class CodeStubAssembler {
Node* SmiTag(Node* value);
Node* SmiUntag(Node* value);
// Smi operations.
Node* SmiAdd(Node* lhs, Node* rhs);
// Load a value from the root array.
Node* LoadRoot(Heap::RootListIndex root_index);
......
......@@ -1833,11 +1833,10 @@ void Interpreter::DoForInDone(InterpreterAssembler* assembler) {
// Increments the loop counter in register |index| and stores the result
// in the accumulator.
void Interpreter::DoForInStep(InterpreterAssembler* assembler) {
// TODO(oth): Implement directly rather than making a runtime call.
Node* index_reg = __ BytecodeOperandReg(0);
Node* index = __ LoadRegister(index_reg);
Node* context = __ GetContext();
Node* result = __ CallRuntime(Runtime::kForInStep, context, index);
Node* one = __ SmiConstant(Smi::FromInt(1));
Node* result = __ SmiAdd(index, one);
__ SetAccumulator(result);
__ Dispatch();
}
......
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