Chromium Code Reviews| Index: src/compiler/js-context-relaxation.cc |
| diff --git a/src/compiler/js-context-relaxation.cc b/src/compiler/js-context-relaxation.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..433b520b413988ae86395c764cb94916d70acf83 |
| --- /dev/null |
| +++ b/src/compiler/js-context-relaxation.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "src/compiler/frame-states.h" |
| +#include "src/compiler/js-context-relaxation.h" |
| +#include "src/compiler/js-operator.h" |
| +#include "src/compiler/node.h" |
| +#include "src/compiler/node-properties.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| +namespace compiler { |
| + |
| +Reduction JSContextRelaxation::Reduce(Node* node) { |
| + switch (node->opcode()) { |
| + case IrOpcode::kJSCallFunction: |
| + case IrOpcode::kJSToNumber: { |
| + Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| + Node* outer_frame = frame_state; |
| + Node* outer_frame_context = nullptr; |
| + do { |
| + FrameStateInfo frame_state_info( |
| + OpParameter<FrameStateInfo>(outer_frame->op())); |
| + const FrameStateFunctionInfo* function_info = |
| + frame_state_info.function_info(); |
| + if (function_info == nullptr || |
| + (function_info->context_calling_mode() == |
| + CALL_CHANGES_NATIVE_CONTEXT)) { |
| + return NoChange(); |
|
Michael Starzinger
2015/07/20 08:09:49
Could we just break when we hit a context-changing
danno
2015/07/20 15:27:33
Done
|
| + } |
| + outer_frame_context = outer_frame->InputAt(kFrameStateContextInput); |
| + outer_frame = outer_frame->InputAt(kFrameStateOuterStateInput); |
| + } while (outer_frame->opcode() == IrOpcode::kFrameState); |
| + |
| + while (true) { |
| + switch (outer_frame_context->opcode()) { |
| + case IrOpcode::kParameter: |
| + case IrOpcode::kJSCreateModuleContext: |
| + case IrOpcode::kJSCreateScriptContext: |
| + NodeProperties::ReplaceContextInput(node, outer_frame_context); |
| + return Changed(node); |
| + case IrOpcode::kJSCreateCatchContext: |
| + case IrOpcode::kJSCreateWithContext: |
| + case IrOpcode::kJSCreateBlockContext: |
| + outer_frame_context = |
| + NodeProperties::GetContextInput(outer_frame_context); |
| + break; |
| + default: |
| + return NoChange(); |
| + } |
| + } |
| + } |
| + default: |
| + break; |
| + } |
| + return NoChange(); |
| +} |
| + |
| +} // namespace compiler |
| +} // namespace internal |
| +} // namespace v8 |