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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 1824993002: [builtins] Add support for JS builtins written in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 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-builtin-reducer.h ('k') | src/compiler/js-intrinsic-lowering.h » ('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/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 common()->Select(MachineRepresentation::kFloat64), 161 common()->Select(MachineRepresentation::kFloat64),
162 graph()->NewNode(machine()->Float64LessThan(), 162 graph()->NewNode(machine()->Float64LessThan(),
163 jsgraph()->Float64Constant(0.5), real), 163 jsgraph()->Float64Constant(0.5), real),
164 graph()->NewNode(machine()->Float64Sub(), integer, 164 graph()->NewNode(machine()->Float64Sub(), integer,
165 jsgraph()->Float64Constant(1.0)), 165 jsgraph()->Float64Constant(1.0)),
166 integer)); 166 integer));
167 } 167 }
168 return NoChange(); 168 return NoChange();
169 } 169 }
170 170
171 // ES6 section 20.2.2.32 Math.sqrt ( x )
172 Reduction JSBuiltinReducer::ReduceMathSqrt(Node* node) {
173 JSCallReduction r(node);
174 if (r.InputsMatchOne(Type::Number())) {
175 // Math.sqrt(a:number) -> Float64Sqrt(a)
176 Node* value = graph()->NewNode(machine()->Float64Sqrt(), r.left());
177 return Replace(value);
178 }
179 return NoChange();
180 }
181
171 Reduction JSBuiltinReducer::Reduce(Node* node) { 182 Reduction JSBuiltinReducer::Reduce(Node* node) {
172 Reduction reduction = NoChange(); 183 Reduction reduction = NoChange();
173 JSCallReduction r(node); 184 JSCallReduction r(node);
174 185
175 // Dispatch according to the BuiltinFunctionId if present. 186 // Dispatch according to the BuiltinFunctionId if present.
176 if (!r.HasBuiltinFunctionId()) return NoChange(); 187 if (!r.HasBuiltinFunctionId()) return NoChange();
177 switch (r.GetBuiltinFunctionId()) { 188 switch (r.GetBuiltinFunctionId()) {
178 case kMathMax: 189 case kMathMax:
179 reduction = ReduceMathMax(node); 190 reduction = ReduceMathMax(node);
180 break; 191 break;
181 case kMathImul: 192 case kMathImul:
182 reduction = ReduceMathImul(node); 193 reduction = ReduceMathImul(node);
183 break; 194 break;
184 case kMathFround: 195 case kMathFround:
185 reduction = ReduceMathFround(node); 196 reduction = ReduceMathFround(node);
186 break; 197 break;
187 case kMathRound: 198 case kMathRound:
188 reduction = ReduceMathRound(node); 199 reduction = ReduceMathRound(node);
189 break; 200 break;
201 case kMathSqrt:
202 reduction = ReduceMathSqrt(node);
203 break;
190 default: 204 default:
191 break; 205 break;
192 } 206 }
193 207
194 // Replace builtin call assuming replacement nodes are pure values that don't 208 // Replace builtin call assuming replacement nodes are pure values that don't
195 // produce an effect. Replaces {node} with {reduction} and relaxes effects. 209 // produce an effect. Replaces {node} with {reduction} and relaxes effects.
196 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement()); 210 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement());
197 211
198 return reduction; 212 return reduction;
199 } 213 }
(...skipping 15 matching lines...) Expand all
215 } 229 }
216 230
217 231
218 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 232 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
219 return jsgraph()->simplified(); 233 return jsgraph()->simplified();
220 } 234 }
221 235
222 } // namespace compiler 236 } // namespace compiler
223 } // namespace internal 237 } // namespace internal
224 } // namespace v8 238 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698