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

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

Issue 694063005: Introduce Diamond, a helper for building diamond-shaped control patterns. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: newline Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | src/compiler/machine-operator-reducer.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 2014 the V8 project authors. All rights reserved. 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 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/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
7 #include "src/compiler/diamond.h"
7 #include "src/compiler/generic-node-inl.h" 8 #include "src/compiler/generic-node-inl.h"
8 #include "src/compiler/js-intrinsic-builder.h" 9 #include "src/compiler/js-intrinsic-builder.h"
9 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
10 #include "src/compiler/simplified-operator.h" 11 #include "src/compiler/simplified-operator.h"
11 12
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 namespace compiler { 16 namespace compiler {
16 17
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 * return false 62 * return false
62 * } else { 63 * } else {
63 * return %_GetMapInstanceType(object) == map_type 64 * return %_GetMapInstanceType(object) == map_type
64 * } 65 * }
65 */ 66 */
66 ResultAndEffect JSIntrinsicBuilder::BuildMapCheck(Node* object, Node* effect, 67 ResultAndEffect JSIntrinsicBuilder::BuildMapCheck(Node* object, Node* effect,
67 InstanceType map_type) { 68 InstanceType map_type) {
68 SimplifiedOperatorBuilder simplified(jsgraph_->zone()); 69 SimplifiedOperatorBuilder simplified(jsgraph_->zone());
69 70
70 Node* is_smi = graph()->NewNode(simplified.ObjectIsSmi(), object); 71 Node* is_smi = graph()->NewNode(simplified.ObjectIsSmi(), object);
71 Node* branch = graph()->NewNode(common()->Branch(), is_smi, graph()->start()); 72 Diamond d(graph(), common(), is_smi);
72 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
73 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
74 73
75 Node* map = graph()->NewNode(simplified.LoadField(AccessBuilder::ForMap()), 74 Node* map = graph()->NewNode(simplified.LoadField(AccessBuilder::ForMap()),
76 object, effect, if_false); 75 object, effect, d.if_false);
77 76
78 Node* instance_type = graph()->NewNode( 77 Node* instance_type = graph()->NewNode(
79 simplified.LoadField(AccessBuilder::ForMapInstanceType()), map, map, 78 simplified.LoadField(AccessBuilder::ForMapInstanceType()), map, map,
80 if_false); 79 d.if_false);
81 80
82 Node* has_map_type = 81 Node* has_map_type =
83 graph()->NewNode(jsgraph_->machine()->Word32Equal(), instance_type, 82 graph()->NewNode(jsgraph_->machine()->Word32Equal(), instance_type,
84 jsgraph_->Int32Constant(map_type)); 83 jsgraph_->Int32Constant(map_type));
85 84
86 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); 85 Node* phi = d.Phi(static_cast<MachineType>(kTypeBool | kRepTagged),
86 jsgraph_->FalseConstant(), has_map_type);
87 87
88 Node* phi = 88 Node* ephi = d.EffectPhi(effect, instance_type);
89 graph()->NewNode(common()->Phi((MachineType)(kTypeBool | kRepTagged), 2),
90 jsgraph_->FalseConstant(), has_map_type, merge);
91
92 Node* ephi =
93 graph()->NewNode(common()->EffectPhi(2), effect, instance_type, merge);
94 89
95 return ResultAndEffect(phi, ephi); 90 return ResultAndEffect(phi, ephi);
96 } 91 }
97 92
98 93
99 /* 94 /*
100 * if (%_isSmi(object)) { 95 * if (%_isSmi(object)) {
101 * return object; 96 * return object;
102 * } else if (%_GetMapInstanceType(object) == JS_VALUE_TYPE) { 97 * } else if (%_GetMapInstanceType(object) == JS_VALUE_TYPE) {
103 * return %_LoadValueField(object); 98 * return %_LoadValueField(object);
104 * } else { 99 * } else {
105 * return object; 100 * return object;
106 * } 101 * }
107 */ 102 */
108 ResultAndEffect JSIntrinsicBuilder::BuildGraphFor_ValueOf( 103 ResultAndEffect JSIntrinsicBuilder::BuildGraphFor_ValueOf(
109 const NodeVector& arguments) { 104 const NodeVector& arguments) {
110 Node* object = arguments[0]; 105 Node* object = arguments[0];
111 Node* effect = arguments[2]; 106 Node* effect = arguments[2];
112 SimplifiedOperatorBuilder simplified(jsgraph_->zone()); 107 SimplifiedOperatorBuilder simplified(jsgraph_->zone());
113 108
114 Node* is_smi = graph()->NewNode(simplified.ObjectIsSmi(), object); 109 Node* is_smi = graph()->NewNode(simplified.ObjectIsSmi(), object);
115 Node* branch = graph()->NewNode(common()->Branch(), is_smi, graph()->start()); 110
116 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 111 Diamond if_is_smi(graph(), common(), is_smi);
117 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
118 112
119 Node* map = graph()->NewNode(simplified.LoadField(AccessBuilder::ForMap()), 113 Node* map = graph()->NewNode(simplified.LoadField(AccessBuilder::ForMap()),
120 object, effect, if_false); 114 object, effect, if_is_smi.if_false);
121 115
122 Node* instance_type = graph()->NewNode( 116 Node* instance_type = graph()->NewNode(
123 simplified.LoadField(AccessBuilder::ForMapInstanceType()), map, map, 117 simplified.LoadField(AccessBuilder::ForMapInstanceType()), map, map,
124 if_false); 118 if_is_smi.if_false);
125 119
126 Node* is_value = 120 Node* is_value =
127 graph()->NewNode(jsgraph_->machine()->Word32Equal(), instance_type, 121 graph()->NewNode(jsgraph_->machine()->Word32Equal(), instance_type,
128 jsgraph_->Constant(JS_VALUE_TYPE)); 122 jsgraph_->Constant(JS_VALUE_TYPE));
129 123
130 Node* branch_is_value = 124 Diamond if_is_value(graph(), common(), is_value);
131 graph()->NewNode(common()->Branch(), is_value, if_false); 125 if_is_value.Nest(if_is_smi, false);
132 Node* is_value_true = graph()->NewNode(common()->IfTrue(), branch_is_value);
133 Node* is_value_false = graph()->NewNode(common()->IfFalse(), branch_is_value);
134 126
135 Node* value = 127 Node* value =
136 graph()->NewNode(simplified.LoadField(AccessBuilder::ForValue()), object, 128 graph()->NewNode(simplified.LoadField(AccessBuilder::ForValue()), object,
137 instance_type, is_value_true); 129 instance_type, if_is_value.if_true);
138 130
139 Node* merge_is_value = 131 Node* phi_is_value = if_is_value.Phi(kTypeAny, value, object);
140 graph()->NewNode(common()->Merge(2), is_value_true, is_value_false);
141 132
142 Node* phi_is_value = graph()->NewNode(common()->Phi((MachineType)kTypeAny, 2), 133 Node* phi = if_is_smi.Phi(kTypeAny, object, phi_is_value);
143 value, object, merge_is_value);
144 134
145 135 Node* ephi = if_is_smi.EffectPhi(effect, instance_type);
146 Node* merge = graph()->NewNode(common()->Merge(2), if_true, merge_is_value);
147
148 Node* phi = graph()->NewNode(common()->Phi((MachineType)kTypeAny, 2), object,
149 phi_is_value, merge);
150
151 Node* ephi =
152 graph()->NewNode(common()->EffectPhi(2), effect, instance_type, merge);
153 136
154 return ResultAndEffect(phi, ephi); 137 return ResultAndEffect(phi, ephi);
155 } 138 }
156 } 139 }
157 } 140 }
158 } // namespace v8::internal::compiler 141 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | src/compiler/machine-operator-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698