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

Side by Side Diff: src/compiler/js-intrinsic-lowering.cc

Issue 961973002: [turbofan] First shot at eager deoptimization in Turbofan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix 2 Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) 15 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph)
16 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} 16 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
17 17
18 18
19 Reduction JSIntrinsicLowering::Reduce(Node* node) { 19 Reduction JSIntrinsicLowering::Reduce(Node* node) {
20 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); 20 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange();
21 const Runtime::Function* const f = 21 const Runtime::Function* const f =
22 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); 22 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id());
23 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange();
24 switch (f->function_id) { 23 switch (f->function_id) {
24 case Runtime::kDeoptimizeNow:
Michael Starzinger 2015/03/04 23:36:42 Would it be possible to move the function to INLIN
Jarin 2015/03/05 06:32:15 It would be possible, but we would also have to im
25 return ReduceDeoptimizeNow(node);
25 case Runtime::kInlineIsSmi: 26 case Runtime::kInlineIsSmi:
26 return ReduceInlineIsSmi(node); 27 return ReduceInlineIsSmi(node);
27 case Runtime::kInlineIsNonNegativeSmi: 28 case Runtime::kInlineIsNonNegativeSmi:
28 return ReduceInlineIsNonNegativeSmi(node); 29 return ReduceInlineIsNonNegativeSmi(node);
29 case Runtime::kInlineIsArray: 30 case Runtime::kInlineIsArray:
30 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); 31 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE);
31 case Runtime::kInlineIsFunction: 32 case Runtime::kInlineIsFunction:
32 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); 33 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE);
33 case Runtime::kInlineIsRegExp: 34 case Runtime::kInlineIsRegExp:
34 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); 35 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE);
35 case Runtime::kInlineValueOf: 36 case Runtime::kInlineValueOf:
36 return ReduceInlineValueOf(node); 37 return ReduceInlineValueOf(node);
37 default: 38 default:
38 break; 39 break;
39 } 40 }
40 return NoChange(); 41 return NoChange();
41 } 42 }
42 43
43 44
45 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
46 if (!FLAG_turbo_deoptimization) return NoChange();
47
48 Node* frame_state = NodeProperties::GetFrameStateInput(node);
49 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState);
50
51 Node* effect = NodeProperties::GetEffectInput(node);
52 Node* control = NodeProperties::GetControlInput(node);
53
54 // We are making the continuation after the call dead. To
55 // model this, we generate if (true) statement with deopt
56 // in the true branch and continuation in the false branch.
57 Node* branch =
58 graph()->NewNode(common()->Branch(), jsgraph()->TrueConstant(), control);
59
60 // False branch - the original continuation.
61 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
62 NodeProperties::ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect,
63 if_false);
64
65 // True branch: deopt.
66 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
67 Node* deopt =
68 graph()->NewNode(common()->Deoptimize(), frame_state, effect, if_true);
69
70 // Connect the deopt to the merge exiting the graph.
71 Node* end_pred = NodeProperties::GetControlInput(graph()->end());
72 if (end_pred->opcode() == IrOpcode::kMerge) {
73 int inputs = end_pred->op()->ControlInputCount() + 1;
74 end_pred->AppendInput(graph()->zone(), deopt);
75 end_pred->set_op(common()->Merge(inputs));
76 } else {
77 Node* merge = graph()->NewNode(common()->Merge(2), end_pred, deopt);
78 NodeProperties::ReplaceControlInput(graph()->end(), merge);
79 }
80
81 return Changed(deopt);
82 }
83
84
44 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { 85 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) {
45 return Change(node, simplified()->ObjectIsSmi()); 86 return Change(node, simplified()->ObjectIsSmi());
46 } 87 }
47 88
48 89
49 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { 90 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) {
50 return Change(node, simplified()->ObjectIsNonNegativeSmi()); 91 return Change(node, simplified()->ObjectIsNonNegativeSmi());
51 } 92 }
52 93
53 94
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 225 }
185 226
186 227
187 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { 228 MachineOperatorBuilder* JSIntrinsicLowering::machine() const {
188 return jsgraph()->machine(); 229 return jsgraph()->machine();
189 } 230 }
190 231
191 } // namespace compiler 232 } // namespace compiler
192 } // namespace internal 233 } // namespace internal
193 } // namespace v8 234 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698