Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: src/interpreter/interpreter.cc

Issue 1422033002: [Interpreter] Add support for for..in. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes for 32-bit. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index f3f6be8a49a78b68b3547de3aa82cd8278d2c9c9..eac36de475ec7b2687f012b57abff6a5e6e37d89 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -1071,6 +1071,55 @@ void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
}
+// ForInPrepare
+//
+// Returns state for for..in loop execution based on the JSObject in
+// the accumulator.
+void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) {
+ Node* js_object = __ GetAccumulator();
+ Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, js_object);
+ __ SetAccumulator(result);
+ __ Dispatch();
+}
+
+
+// ForInNext <for_in_prepared>
rmcilroy 2015/10/26 14:04:01 /s/for_in_prepared/for_in_state
oth 2015/10/28 11:53:12 Done.
+//
+// Returns the next key in a for..in loop. The accumulator contains the current
+// zero-based iteration count and <for_in_prepared> is the state returned by
+// earlier
+// invocation of ForInPrepare.
rmcilroy 2015/10/26 14:04:01 remove extra newline
oth 2015/10/28 11:53:12 Done.
+void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) {
+ Node* index = __ GetAccumulator();
+ Node* for_in_state_reg = __ BytecodeOperandReg8(0);
+ Node* for_in_state = __ LoadRegister(for_in_state_reg);
+ Node* receiver = __ LoadFixedArrayElement(for_in_state, 0);
+ Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1);
+ Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2);
+ Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array,
+ cache_type, index);
+ __ SetAccumulator(result);
+ __ Dispatch();
+}
+
+
+// ForInDone <for_in_prepared>
+//
+// Returns the next key in a for..in loop. The accumulator contains the current
+// zero-based iteration count and <for_in_prepared> is the state returned by
+// earlier
+// invocation of ForInPrepare.
rmcilroy 2015/10/26 14:04:01 ditto
oth 2015/10/28 11:53:12 Done.
+void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) {
+ Node* index = __ GetAccumulator();
+ Node* for_in_state_reg = __ BytecodeOperandReg8(0);
+ Node* for_in_state = __ LoadRegister(for_in_state_reg);
+ Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3);
+ Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length);
+ __ SetAccumulator(result);
+ __ Dispatch();
+}
+
+
} // namespace interpreter
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698