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

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

Issue 2037453003: [turbofan] Add new StringFromCharCode simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mitigate verifier blowup after early optimization. Created 4 years, 6 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/opcodes.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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) { 209 Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) {
210 JSCallReduction r(node); 210 JSCallReduction r(node);
211 if (r.InputsMatchOne(Type::Number())) { 211 if (r.InputsMatchOne(Type::Number())) {
212 // Math.trunc(a:number) -> NumberTrunc(a) 212 // Math.trunc(a:number) -> NumberTrunc(a)
213 Node* value = graph()->NewNode(simplified()->NumberTrunc(), r.left()); 213 Node* value = graph()->NewNode(simplified()->NumberTrunc(), r.left());
214 return Replace(value); 214 return Replace(value);
215 } 215 }
216 return NoChange(); 216 return NoChange();
217 } 217 }
218 218
219 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
220 Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) {
221 JSCallReduction r(node);
222 if (r.InputsMatchOne(Type::Number())) {
223 // String.fromCharCode(a:number) -> StringFromCharCode(a)
224 Node* value =
225 graph()->NewNode(simplified()->StringFromCharCode(), r.left());
226 return Replace(value);
227 }
228 return NoChange();
229 }
230
219 Reduction JSBuiltinReducer::Reduce(Node* node) { 231 Reduction JSBuiltinReducer::Reduce(Node* node) {
220 Reduction reduction = NoChange(); 232 Reduction reduction = NoChange();
221 JSCallReduction r(node); 233 JSCallReduction r(node);
222 234
223 // Dispatch according to the BuiltinFunctionId if present. 235 // Dispatch according to the BuiltinFunctionId if present.
224 if (!r.HasBuiltinFunctionId()) return NoChange(); 236 if (!r.HasBuiltinFunctionId()) return NoChange();
225 switch (r.GetBuiltinFunctionId()) { 237 switch (r.GetBuiltinFunctionId()) {
226 case kMathMax: 238 case kMathMax:
227 reduction = ReduceMathMax(node); 239 reduction = ReduceMathMax(node);
228 break; 240 break;
(...skipping 14 matching lines...) Expand all
243 break; 255 break;
244 case kMathRound: 256 case kMathRound:
245 reduction = ReduceMathRound(node); 257 reduction = ReduceMathRound(node);
246 break; 258 break;
247 case kMathSqrt: 259 case kMathSqrt:
248 reduction = ReduceMathSqrt(node); 260 reduction = ReduceMathSqrt(node);
249 break; 261 break;
250 case kMathTrunc: 262 case kMathTrunc:
251 reduction = ReduceMathTrunc(node); 263 reduction = ReduceMathTrunc(node);
252 break; 264 break;
265 case kStringFromCharCode:
266 reduction = ReduceStringFromCharCode(node);
267 break;
253 default: 268 default:
254 break; 269 break;
255 } 270 }
256 271
257 // Replace builtin call assuming replacement nodes are pure values that don't 272 // Replace builtin call assuming replacement nodes are pure values that don't
258 // produce an effect. Replaces {node} with {reduction} and relaxes effects. 273 // produce an effect. Replaces {node} with {reduction} and relaxes effects.
259 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement()); 274 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement());
260 275
261 return reduction; 276 return reduction;
262 } 277 }
(...skipping 15 matching lines...) Expand all
278 } 293 }
279 294
280 295
281 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 296 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
282 return jsgraph()->simplified(); 297 return jsgraph()->simplified();
283 } 298 }
284 299
285 } // namespace compiler 300 } // namespace compiler
286 } // namespace internal 301 } // namespace internal
287 } // namespace v8 302 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698