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

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

Issue 2599683002: [turbofan] Introduce a dedicated StringCharAt operator. (Closed)
Patch Set: Created 3 years, 12 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
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 6
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 Node* receiver_length = effect = graph()->NewNode( 1528 Node* receiver_length = effect = graph()->NewNode(
1529 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver, 1529 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver,
1530 effect, control); 1530 effect, control);
1531 1531
1532 // Check if {index} is less than {receiver} length. 1532 // Check if {index} is less than {receiver} length.
1533 Node* check = graph()->NewNode(simplified()->NumberLessThan(), index, 1533 Node* check = graph()->NewNode(simplified()->NumberLessThan(), index,
1534 receiver_length); 1534 receiver_length);
1535 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), 1535 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1536 check, control); 1536 check, control);
1537 1537
1538 // Return the character from the {receiver} as single character string.
1538 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 1539 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
1539 Node* vtrue; 1540 Node* vtrue = graph()->NewNode(simplified()->StringCharAt(), receiver,
1540 { 1541 index, if_true);
1541 // Load the character from the {receiver}.
1542 vtrue = graph()->NewNode(simplified()->StringCharCodeAt(), receiver,
1543 index, if_true);
1544
1545 // Return it as single character string.
1546 vtrue = graph()->NewNode(simplified()->StringFromCharCode(), vtrue);
1547 }
1548 1542
1549 // Return the empty string otherwise. 1543 // Return the empty string otherwise.
1550 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 1544 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
1551 Node* vfalse = jsgraph()->EmptyStringConstant(); 1545 Node* vfalse = jsgraph()->EmptyStringConstant();
1552 1546
1553 control = graph()->NewNode(common()->Merge(2), if_true, if_false); 1547 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
1554 Node* value = 1548 Node* value =
1555 graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 1549 graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
1556 vtrue, vfalse, control); 1550 vtrue, vfalse, control);
1557 1551
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 return jsgraph()->simplified(); 2037 return jsgraph()->simplified();
2044 } 2038 }
2045 2039
2046 JSOperatorBuilder* JSBuiltinReducer::javascript() const { 2040 JSOperatorBuilder* JSBuiltinReducer::javascript() const {
2047 return jsgraph()->javascript(); 2041 return jsgraph()->javascript();
2048 } 2042 }
2049 2043
2050 } // namespace compiler 2044 } // namespace compiler
2051 } // namespace internal 2045 } // namespace internal
2052 } // namespace v8 2046 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/effect-control-linearizer.cc ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698