OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/type-hint-analyzer.h" | 5 #include "src/compiler/type-hint-analyzer.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler/type-hints.h" | 9 #include "src/compiler/type-hints.h" |
10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 BinaryOperationHint ToBinaryOperationHint(BinaryOpICState::Kind kind) { | 18 BinaryOperationHint ToBinaryOperationHint(Token::Value op, |
| 19 BinaryOpICState::Kind kind) { |
19 switch (kind) { | 20 switch (kind) { |
20 case BinaryOpICState::NONE: | 21 case BinaryOpICState::NONE: |
21 return BinaryOperationHint::kNone; | 22 return BinaryOperationHint::kNone; |
22 case BinaryOpICState::SMI: | 23 case BinaryOpICState::SMI: |
23 return BinaryOperationHint::kSignedSmall; | 24 return BinaryOperationHint::kSignedSmall; |
24 case BinaryOpICState::INT32: | 25 case BinaryOpICState::INT32: |
25 return BinaryOperationHint::kSigned32; | 26 return (Token::IsTruncatingBinaryOp(op) && SmiValuesAre31Bits()) |
| 27 ? BinaryOperationHint::kNumberOrOddball |
| 28 : BinaryOperationHint::kSigned32; |
26 case BinaryOpICState::NUMBER: | 29 case BinaryOpICState::NUMBER: |
27 return BinaryOperationHint::kNumberOrOddball; | 30 return BinaryOperationHint::kNumberOrOddball; |
28 case BinaryOpICState::STRING: | 31 case BinaryOpICState::STRING: |
29 case BinaryOpICState::GENERIC: | 32 case BinaryOpICState::GENERIC: |
30 return BinaryOperationHint::kAny; | 33 return BinaryOperationHint::kAny; |
31 } | 34 } |
32 UNREACHABLE(); | 35 UNREACHABLE(); |
33 return BinaryOperationHint::kNone; | 36 return BinaryOperationHint::kNone; |
34 } | 37 } |
35 | 38 |
(...skipping 23 matching lines...) Expand all Loading... |
59 | 62 |
60 } // namespace | 63 } // namespace |
61 | 64 |
62 bool TypeHintAnalysis::GetBinaryOperationHint(TypeFeedbackId id, | 65 bool TypeHintAnalysis::GetBinaryOperationHint(TypeFeedbackId id, |
63 BinaryOperationHint* hint) const { | 66 BinaryOperationHint* hint) const { |
64 auto i = infos_.find(id); | 67 auto i = infos_.find(id); |
65 if (i == infos_.end()) return false; | 68 if (i == infos_.end()) return false; |
66 Handle<Code> code = i->second; | 69 Handle<Code> code = i->second; |
67 DCHECK_EQ(Code::BINARY_OP_IC, code->kind()); | 70 DCHECK_EQ(Code::BINARY_OP_IC, code->kind()); |
68 BinaryOpICState state(code->GetIsolate(), code->extra_ic_state()); | 71 BinaryOpICState state(code->GetIsolate(), code->extra_ic_state()); |
69 *hint = ToBinaryOperationHint(state.kind()); | 72 *hint = ToBinaryOperationHint(state.op(), state.kind()); |
70 return true; | 73 return true; |
71 } | 74 } |
72 | 75 |
73 bool TypeHintAnalysis::GetCompareOperationHint( | 76 bool TypeHintAnalysis::GetCompareOperationHint( |
74 TypeFeedbackId id, CompareOperationHint* hint) const { | 77 TypeFeedbackId id, CompareOperationHint* hint) const { |
75 auto i = infos_.find(id); | 78 auto i = infos_.find(id); |
76 if (i == infos_.end()) return false; | 79 if (i == infos_.end()) return false; |
77 Handle<Code> code = i->second; | 80 Handle<Code> code = i->second; |
78 DCHECK_EQ(Code::COMPARE_IC, code->kind()); | 81 DCHECK_EQ(Code::COMPARE_IC, code->kind()); |
79 CompareICStub stub(code->stub_key(), code->GetIsolate()); | 82 CompareICStub stub(code->stub_key(), code->GetIsolate()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 case CompareOperationFeedback::kNumber: | 158 case CompareOperationFeedback::kNumber: |
156 return CompareOperationHint::kNumber; | 159 return CompareOperationHint::kNumber; |
157 default: | 160 default: |
158 return CompareOperationHint::kAny; | 161 return CompareOperationHint::kAny; |
159 } | 162 } |
160 } | 163 } |
161 | 164 |
162 } // namespace compiler | 165 } // namespace compiler |
163 } // namespace internal | 166 } // namespace internal |
164 } // namespace v8 | 167 } // namespace v8 |
OLD | NEW |