OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ |
7 | 7 |
8 #include "src/crankshaft/hydrogen.h" | 8 #include "src/crankshaft/hydrogen.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (b->IsConstant()) return kNoAlias; | 37 if (b->IsConstant()) return kNoAlias; |
38 } | 38 } |
39 if (b->IsAllocate() || b->IsInnerAllocatedObject()) { | 39 if (b->IsAllocate() || b->IsInnerAllocatedObject()) { |
40 // An allocation can never alias a parameter or a constant. | 40 // An allocation can never alias a parameter or a constant. |
41 if (a->IsParameter()) return kNoAlias; | 41 if (a->IsParameter()) return kNoAlias; |
42 if (a->IsConstant()) return kNoAlias; | 42 if (a->IsConstant()) return kNoAlias; |
43 } | 43 } |
44 | 44 |
45 // Constant objects can be distinguished statically. | 45 // Constant objects can be distinguished statically. |
46 if (a->IsConstant()) { | 46 if (a->IsConstant()) { |
47 // TODO(titzer): DataEquals() is more efficient, but that's protected. | |
48 return a->Equals(b) ? kMustAlias : kNoAlias; | 47 return a->Equals(b) ? kMustAlias : kNoAlias; |
49 } | 48 } |
50 return kMayAlias; | 49 return kMayAlias; |
51 } | 50 } |
52 | 51 |
53 // Checks whether the objects referred to by the given instructions may | 52 // Checks whether the objects referred to by the given instructions may |
54 // ever be aliases. Note that this is more conservative than checking | 53 // ever be aliases. Note that this is more conservative than checking |
55 // {Query(a, b) == kMayAlias}, since this method considers kMustAlias | 54 // {Query(a, b) == kMayAlias}, since this method considers kMustAlias |
56 // objects to also be may-aliasing. | 55 // objects to also be may-aliasing. |
57 inline bool MayAlias(HValue* a, HValue* b) { | 56 inline bool MayAlias(HValue* a, HValue* b) { |
58 return Query(a, b) != kNoAlias; | 57 return Query(a, b) != kNoAlias; |
59 } | 58 } |
60 | 59 |
61 inline bool MustAlias(HValue* a, HValue* b) { | 60 inline bool MustAlias(HValue* a, HValue* b) { |
62 return Query(a, b) == kMustAlias; | 61 return Query(a, b) == kMustAlias; |
63 } | 62 } |
64 | 63 |
65 inline bool NoAlias(HValue* a, HValue* b) { | 64 inline bool NoAlias(HValue* a, HValue* b) { |
66 return Query(a, b) == kNoAlias; | 65 return Query(a, b) == kNoAlias; |
67 } | 66 } |
68 }; | 67 }; |
69 | 68 |
70 | 69 |
71 } // namespace internal | 70 } // namespace internal |
72 } // namespace v8 | 71 } // namespace v8 |
73 | 72 |
74 #endif // V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ | 73 #endif // V8_CRANKSHAFT_HYDROGEN_ALIAS_ANALYSIS_H_ |
OLD | NEW |