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

Side by Side Diff: src/hydrogen-alias-analysis.h

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_HYDROGEN_ALIAS_ANALYSIS_H_
29 #define V8_HYDROGEN_ALIAS_ANALYSIS_H_
30
31 #include "hydrogen.h"
32
33 namespace v8 {
34 namespace internal {
35
36 enum HAliasing {
37 kMustAlias,
38 kMayAlias,
39 kNoAlias
40 };
41
42
43 // Defines the interface to alias analysis for the rest of the compiler.
44 // A simple implementation can use only local reasoning, but a more powerful
45 // analysis might employ points-to analysis.
46 class HAliasAnalyzer : public ZoneObject {
47 public:
48 // Simple alias analysis distinguishes allocations, parameters,
49 // and constants using only local reasoning.
50 HAliasing Query(HValue* a, HValue* b) {
51 // The same SSA value always references the same object.
52 if (a == b) return kMustAlias;
53
54 if (a->IsAllocate() || a->IsInnerAllocatedObject()) {
55 // Two non-identical allocations can never be aliases.
56 if (b->IsAllocate()) return kNoAlias;
57 if (b->IsInnerAllocatedObject()) return kNoAlias;
58 // An allocation can never alias a parameter or a constant.
59 if (b->IsParameter()) return kNoAlias;
60 if (b->IsConstant()) return kNoAlias;
61 }
62 if (b->IsAllocate() || b->IsInnerAllocatedObject()) {
63 // An allocation can never alias a parameter or a constant.
64 if (a->IsParameter()) return kNoAlias;
65 if (a->IsConstant()) return kNoAlias;
66 }
67
68 // Constant objects can be distinguished statically.
69 if (a->IsConstant()) {
70 // TODO(titzer): DataEquals() is more efficient, but that's protected.
71 return a->Equals(b) ? kMustAlias : kNoAlias;
72 }
73 return kMayAlias;
74 }
75
76 // Checks whether the objects referred to by the given instructions may
77 // ever be aliases. Note that this is more conservative than checking
78 // {Query(a, b) == kMayAlias}, since this method considers kMustAlias
79 // objects to also be may-aliasing.
80 inline bool MayAlias(HValue* a, HValue* b) {
81 return Query(a, b) != kNoAlias;
82 }
83
84 inline bool MustAlias(HValue* a, HValue* b) {
85 return Query(a, b) == kMustAlias;
86 }
87
88 inline bool NoAlias(HValue* a, HValue* b) {
89 return Query(a, b) == kNoAlias;
90 }
91
92 // Returns the actual value of an instruction. In the case of a chain
93 // of informative definitions, return the root of the chain.
94 HValue* ActualValue(HValue* obj) {
95 while (obj->IsInformativeDefinition()) { // Walk a chain of idefs.
96 obj = obj->RedefinedOperand();
97 }
98 return obj;
99 }
100 };
101
102
103 } } // namespace v8::internal
104
105 #endif // V8_HYDROGEN_ALIAS_ANALYSIS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698