Chromium Code Reviews| Index: src/interpreter/interpreter-assembler.cc |
| diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc |
| index 94b6b554f32062d3ef0a5daa538f6ed9717b1b2d..7836f80fd55e6778caecc3b87f021b1b6af58712 100644 |
| --- a/src/interpreter/interpreter-assembler.cc |
| +++ b/src/interpreter/interpreter-assembler.cc |
| @@ -84,6 +84,35 @@ void InterpreterAssembler::SetContext(Node* value) { |
| StoreRegister(value, Register::current_context()); |
| } |
| +Node* InterpreterAssembler::GetContextAtDepth(Node* root_context, Node* depth) { |
|
Michael Starzinger
2016/09/13 09:53:08
nit: Likewise about "root_context" vs "context" he
Leszek Swirski
2016/09/13 10:17:51
Done.
|
| + Variable context(this, MachineRepresentation::kTaggedPointer); |
| + context.Bind(root_context); |
| + |
| + Variable cur_depth(this, MachineRepresentation::kWord32); |
| + cur_depth.Bind(depth); |
| + |
| + Label context_found(this); |
| + |
| + Variable* context_search_loop_variables[2] = {&cur_depth, &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))); |
| + context.Bind(LoadContextSlot(context.value(), Context::PREVIOUS_INDEX)); |
| + |
| + BranchIfWord32Equal(cur_depth.value(), Int32Constant(0), &context_found, |
| + &context_search); |
| + } |
| + |
| + Bind(&context_found); |
| + return context.value(); |
| +} |
| + |
| Node* InterpreterAssembler::BytecodeOffset() { |
| return bytecode_offset_.value(); |
| } |