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

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

Issue 2802113003: [turbofan] Introduce a SpeculativeToNumber operator. (Closed)
Patch Set: Paint it green! Created 3 years, 8 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-type-hint-lowering.h ('k') | src/compiler/js-typed-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 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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-type-hint-lowering.h" 5 #include "src/compiler/js-type-hint-lowering.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/operator-properties.h" 8 #include "src/compiler/operator-properties.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/feedback-vector.h" 10 #include "src/feedback-vector.h"
11 #include "src/type-hints.h" 11 #include "src/type-hints.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 namespace {
18
19 bool BinaryOperationHintToNumberOperationHint(
20 BinaryOperationHint binop_hint, NumberOperationHint* number_hint) {
21 switch (binop_hint) {
22 case BinaryOperationHint::kSignedSmall:
23 *number_hint = NumberOperationHint::kSignedSmall;
24 return true;
25 case BinaryOperationHint::kSigned32:
26 *number_hint = NumberOperationHint::kSigned32;
27 return true;
28 case BinaryOperationHint::kNumberOrOddball:
29 *number_hint = NumberOperationHint::kNumberOrOddball;
30 return true;
31 case BinaryOperationHint::kAny:
32 case BinaryOperationHint::kNone:
33 case BinaryOperationHint::kString:
34 break;
35 }
36 return false;
37 }
38
39 } // namespace
40
17 class JSSpeculativeBinopBuilder final { 41 class JSSpeculativeBinopBuilder final {
18 public: 42 public:
19 JSSpeculativeBinopBuilder(const JSTypeHintLowering* lowering, 43 JSSpeculativeBinopBuilder(const JSTypeHintLowering* lowering,
20 const Operator* op, Node* left, Node* right, 44 const Operator* op, Node* left, Node* right,
21 Node* effect, Node* control, FeedbackSlot slot) 45 Node* effect, Node* control, FeedbackSlot slot)
22 : lowering_(lowering), 46 : lowering_(lowering),
23 op_(op), 47 op_(op),
24 left_(left), 48 left_(left),
25 right_(right), 49 right_(right),
26 effect_(effect), 50 effect_(effect),
27 control_(control), 51 control_(control),
28 slot_(slot) {} 52 slot_(slot) {}
29 53
30 BinaryOperationHint GetBinaryOperationHint() { 54 BinaryOperationHint GetBinaryOperationHint() {
31 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, feedback_vector()->GetKind(slot_)); 55 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, feedback_vector()->GetKind(slot_));
32 BinaryOpICNexus nexus(feedback_vector(), slot_); 56 BinaryOpICNexus nexus(feedback_vector(), slot_);
33 return nexus.GetBinaryOperationFeedback(); 57 return nexus.GetBinaryOperationFeedback();
34 } 58 }
35 59
36 CompareOperationHint GetCompareOperationHint() { 60 CompareOperationHint GetCompareOperationHint() {
37 DCHECK_EQ(FeedbackSlotKind::kCompareOp, feedback_vector()->GetKind(slot_)); 61 DCHECK_EQ(FeedbackSlotKind::kCompareOp, feedback_vector()->GetKind(slot_));
38 CompareICNexus nexus(feedback_vector(), slot_); 62 CompareICNexus nexus(feedback_vector(), slot_);
39 return nexus.GetCompareOperationFeedback(); 63 return nexus.GetCompareOperationFeedback();
40 } 64 }
41 65
42 bool GetBinaryNumberOperationHint(NumberOperationHint* hint) { 66 bool GetBinaryNumberOperationHint(NumberOperationHint* hint) {
43 switch (GetBinaryOperationHint()) { 67 return BinaryOperationHintToNumberOperationHint(GetBinaryOperationHint(),
44 case BinaryOperationHint::kSignedSmall: 68 hint);
45 *hint = NumberOperationHint::kSignedSmall;
46 return true;
47 case BinaryOperationHint::kSigned32:
48 *hint = NumberOperationHint::kSigned32;
49 return true;
50 case BinaryOperationHint::kNumberOrOddball:
51 *hint = NumberOperationHint::kNumberOrOddball;
52 return true;
53 case BinaryOperationHint::kAny:
54 case BinaryOperationHint::kNone:
55 case BinaryOperationHint::kString:
56 break;
57 }
58 return false;
59 } 69 }
60 70
61 bool GetCompareNumberOperationHint(NumberOperationHint* hint) { 71 bool GetCompareNumberOperationHint(NumberOperationHint* hint) {
62 switch (GetCompareOperationHint()) { 72 switch (GetCompareOperationHint()) {
63 case CompareOperationHint::kSignedSmall: 73 case CompareOperationHint::kSignedSmall:
64 *hint = NumberOperationHint::kSignedSmall; 74 *hint = NumberOperationHint::kSignedSmall;
65 return true; 75 return true;
66 case CompareOperationHint::kNumber: 76 case CompareOperationHint::kNumber:
67 *hint = NumberOperationHint::kNumber; 77 *hint = NumberOperationHint::kNumber;
68 return true; 78 return true;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 231 }
222 break; 232 break;
223 } 233 }
224 default: 234 default:
225 UNREACHABLE(); 235 UNREACHABLE();
226 break; 236 break;
227 } 237 }
228 return Reduction(); 238 return Reduction();
229 } 239 }
230 240
241 Reduction JSTypeHintLowering::ReduceToNumberOperation(Node* input, Node* effect,
242 Node* control,
243 FeedbackSlot slot) const {
244 DCHECK(!slot.IsInvalid());
245 BinaryOpICNexus nexus(feedback_vector(), slot);
246 NumberOperationHint hint;
247 if (BinaryOperationHintToNumberOperationHint(
248 nexus.GetBinaryOperationFeedback(), &hint)) {
249 Node* node = jsgraph()->graph()->NewNode(
250 jsgraph()->simplified()->SpeculativeToNumber(hint), input, effect,
251 control);
252 return Reduction(node);
253 }
254 return Reduction();
255 }
256
231 Reduction JSTypeHintLowering::ReduceLoadNamedOperation( 257 Reduction JSTypeHintLowering::ReduceLoadNamedOperation(
232 const Operator* op, Node* obj, Node* effect, Node* control, 258 const Operator* op, Node* obj, Node* effect, Node* control,
233 FeedbackSlot slot) const { 259 FeedbackSlot slot) const {
234 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); 260 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode());
235 DCHECK(!slot.IsInvalid()); 261 DCHECK(!slot.IsInvalid());
236 LoadICNexus nexus(feedback_vector(), slot); 262 LoadICNexus nexus(feedback_vector(), slot);
237 if (Node* node = TryBuildSoftDeopt( 263 if (Node* node = TryBuildSoftDeopt(
238 nexus, effect, control, 264 nexus, effect, control,
239 DeoptimizeReason::kInsufficientTypeFeedbackForGenericNamedAccess)) { 265 DeoptimizeReason::kInsufficientTypeFeedbackForGenericNamedAccess)) {
240 return Reduction(node); 266 return Reduction(node);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 Node* frame_state = NodeProperties::FindFrameStateBefore(deoptimize); 321 Node* frame_state = NodeProperties::FindFrameStateBefore(deoptimize);
296 deoptimize->ReplaceInput(0, frame_state); 322 deoptimize->ReplaceInput(0, frame_state);
297 return deoptimize; 323 return deoptimize;
298 } 324 }
299 return nullptr; 325 return nullptr;
300 } 326 }
301 327
302 } // namespace compiler 328 } // namespace compiler
303 } // namespace internal 329 } // namespace internal
304 } // namespace v8 330 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-type-hint-lowering.h ('k') | src/compiler/js-typed-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698