OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "src/compiler/frame-states.h" | |
6 #include "src/compiler/js-context-relaxation.h" | |
7 #include "src/compiler/js-operator.h" | |
8 #include "src/compiler/node.h" | |
9 #include "src/compiler/node-properties.h" | |
10 | |
11 namespace v8 { | |
12 namespace internal { | |
13 namespace compiler { | |
14 | |
15 Reduction JSContextRelaxation::Reduce(Node* node) { | |
16 switch (node->opcode()) { | |
17 case IrOpcode::kJSCallFunction: | |
18 case IrOpcode::kJSToNumber: { | |
19 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | |
20 Node* outer_frame = frame_state; | |
21 Node* outer_frame_context = nullptr; | |
22 do { | |
23 FrameStateInfo frame_state_info( | |
24 OpParameter<FrameStateInfo>(outer_frame->op())); | |
25 const FrameStateFunctionInfo* function_info = | |
26 frame_state_info.function_info(); | |
27 if (function_info == nullptr || | |
28 (function_info->context_calling_mode() == | |
29 CALL_CHANGES_NATIVE_CONTEXT)) { | |
30 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
| |
31 } | |
32 outer_frame_context = outer_frame->InputAt(kFrameStateContextInput); | |
33 outer_frame = outer_frame->InputAt(kFrameStateOuterStateInput); | |
34 } while (outer_frame->opcode() == IrOpcode::kFrameState); | |
35 | |
36 while (true) { | |
37 switch (outer_frame_context->opcode()) { | |
38 case IrOpcode::kParameter: | |
39 case IrOpcode::kJSCreateModuleContext: | |
40 case IrOpcode::kJSCreateScriptContext: | |
41 NodeProperties::ReplaceContextInput(node, outer_frame_context); | |
42 return Changed(node); | |
43 case IrOpcode::kJSCreateCatchContext: | |
44 case IrOpcode::kJSCreateWithContext: | |
45 case IrOpcode::kJSCreateBlockContext: | |
46 outer_frame_context = | |
47 NodeProperties::GetContextInput(outer_frame_context); | |
48 break; | |
49 default: | |
50 return NoChange(); | |
51 } | |
52 } | |
53 } | |
54 default: | |
55 break; | |
56 } | |
57 return NoChange(); | |
58 } | |
59 | |
60 } // namespace compiler | |
61 } // namespace internal | |
62 } // namespace v8 | |
OLD | NEW |