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/ic/ic-state.h" | 9 #include "src/ic/ic-state.h" |
10 #include "src/type-hints.h" | 10 #include "src/type-hints.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 bool TypeHintAnalysis::GetToBooleanHints(TypeFeedbackId id, | 88 bool TypeHintAnalysis::GetToBooleanHints(TypeFeedbackId id, |
89 ToBooleanHints* hints) const { | 89 ToBooleanHints* hints) const { |
90 auto i = infos_.find(id); | 90 auto i = infos_.find(id); |
91 if (i == infos_.end()) return false; | 91 if (i == infos_.end()) return false; |
92 Handle<Code> code = i->second; | 92 Handle<Code> code = i->second; |
93 DCHECK_EQ(Code::TO_BOOLEAN_IC, code->kind()); | 93 DCHECK_EQ(Code::TO_BOOLEAN_IC, code->kind()); |
94 ToBooleanICStub stub(code->GetIsolate(), code->extra_ic_state()); | 94 ToBooleanICStub stub(code->GetIsolate(), code->extra_ic_state()); |
95 // TODO(bmeurer): Replace ToBooleanICStub::Types with ToBooleanHints. | 95 *hints = stub.hints(); |
96 #define ASSERT_COMPATIBLE(NAME, Name) \ | |
97 STATIC_ASSERT(1 << ToBooleanICStub::NAME == \ | |
98 static_cast<int>(ToBooleanHint::k##Name)) | |
99 ASSERT_COMPATIBLE(UNDEFINED, Undefined); | |
100 ASSERT_COMPATIBLE(BOOLEAN, Boolean); | |
101 ASSERT_COMPATIBLE(NULL_TYPE, Null); | |
102 ASSERT_COMPATIBLE(SMI, SmallInteger); | |
103 ASSERT_COMPATIBLE(SPEC_OBJECT, Receiver); | |
104 ASSERT_COMPATIBLE(STRING, String); | |
105 ASSERT_COMPATIBLE(SYMBOL, Symbol); | |
106 ASSERT_COMPATIBLE(HEAP_NUMBER, HeapNumber); | |
107 ASSERT_COMPATIBLE(SIMD_VALUE, SimdValue); | |
108 #undef ASSERT_COMPATIBLE | |
109 *hints = ToBooleanHints(stub.types().ToIntegral()); | |
110 return true; | 96 return true; |
111 } | 97 } |
112 | 98 |
113 TypeHintAnalysis* TypeHintAnalyzer::Analyze(Handle<Code> code) { | 99 TypeHintAnalysis* TypeHintAnalyzer::Analyze(Handle<Code> code) { |
114 DisallowHeapAllocation no_gc; | 100 DisallowHeapAllocation no_gc; |
115 TypeHintAnalysis::Infos infos(zone()); | 101 TypeHintAnalysis::Infos infos(zone()); |
116 Isolate* const isolate = code->GetIsolate(); | 102 Isolate* const isolate = code->GetIsolate(); |
117 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); | 103 int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
118 for (RelocIterator it(*code, mask); !it.done(); it.next()) { | 104 for (RelocIterator it(*code, mask); !it.done(); it.next()) { |
119 RelocInfo* rinfo = it.rinfo(); | 105 RelocInfo* rinfo = it.rinfo(); |
(...skipping 13 matching lines...) Expand all Loading... |
133 break; | 119 break; |
134 } | 120 } |
135 } | 121 } |
136 return new (zone()) TypeHintAnalysis(infos, zone()); | 122 return new (zone()) TypeHintAnalysis(infos, zone()); |
137 } | 123 } |
138 | 124 |
139 | 125 |
140 } // namespace compiler | 126 } // namespace compiler |
141 } // namespace internal | 127 } // namespace internal |
142 } // namespace v8 | 128 } // namespace v8 |
OLD | NEW |