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