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

Unified Diff: src/interpreter/interpreter-assembler.cc

Issue 2336643002: [Interpreter] Move context chain search loop to handler (Closed)
Patch Set: Fix documentation nits Created 4 years, 3 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-assembler.cc
diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc
index 94b6b554f32062d3ef0a5daa538f6ed9717b1b2d..89164af28d803cabac64ee5ec839b31f832807f2 100644
--- a/src/interpreter/interpreter-assembler.cc
+++ b/src/interpreter/interpreter-assembler.cc
@@ -84,6 +84,36 @@ void InterpreterAssembler::SetContext(Node* value) {
StoreRegister(value, Register::current_context());
}
+Node* InterpreterAssembler::GetContextAtDepth(Node* context, Node* depth) {
+ Variable cur_context(this, MachineRepresentation::kTaggedPointer);
+ cur_context.Bind(context);
+
+ Variable cur_depth(this, MachineRepresentation::kWord32);
+ cur_depth.Bind(depth);
+
+ Label context_found(this);
+
+ Variable* context_search_loop_variables[2] = {&cur_depth, &cur_context};
+ Label context_search(this, 2, context_search_loop_variables);
+
+ // Fast path if the depth is 0.
+ BranchIfWord32Equal(depth, Int32Constant(0), &context_found, &context_search);
+
+ // Loop until the depth is 0.
+ Bind(&context_search);
+ {
+ cur_depth.Bind(Int32Sub(cur_depth.value(), Int32Constant(1)));
+ cur_context.Bind(
+ LoadContextSlot(cur_context.value(), Context::PREVIOUS_INDEX));
+
+ BranchIfWord32Equal(cur_depth.value(), Int32Constant(0), &context_found,
+ &context_search);
+ }
+
+ Bind(&context_found);
+ return cur_context.value();
+}
+
Node* InterpreterAssembler::BytecodeOffset() {
return bytecode_offset_.value();
}
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | test/cctest/interpreter/bytecode_expectations/BasicLoops.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698