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

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

Issue 23516010: Implement simplistic local alias analysis, which will be used in both check elimination and load el… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make AliasAnalyzer::MayAlias more conservative and add AliasAnalyzer::ActualValue. Created 7 years, 3 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 | « no previous file | tools/gyp/v8.gyp » ('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 };
Toon Verwaest 2013/09/11 09:05:55 Can we move this enum into HAliasAnalyzer?
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 // TODO(titzer): return MustAlias for two equivalent constants.
69 return kMayAlias;
70 }
71
72 // Checks whether the objects referred to by the given instructions may
73 // ever be aliases. Note that this is more conservative than checking
74 // {Query(a, b) == kMayAlias}, since this method considers kMustAlias
75 // objects to also be may-aliasing.
76 inline bool MayAlias(HValue* a, HValue* b) {
77 return Query(a, b) != kNoAlias;
78 }
79
80 inline bool MustAlias(HValue* a, HValue* b) {
81 return Query(a, b) == kMayAlias;
82 }
83
84 inline bool NoAlias(HValue* a, HValue* b) {
85 return Query(a, b) == kNoAlias;
86 }
87
88 // Returns the actual value of an instruction. In the case of a chain
89 // of informative definitions, return the root of the chain.
90 HValue* ActualValue(HValue* obj) {
Michael Starzinger 2013/09/12 20:09:08 Can we move this onto the HValue class? Pretty ple
91 while (obj->IsInformativeDefinition()) { // Walk a chain of idefs.
92 obj = obj->RedefinedOperand();
93 }
94 return obj;
95 }
96 };
97
98
99 } } // namespace v8::internal
100
101 #endif // V8_HYDROGEN_ALIAS_ANALYSIS_H_
OLDNEW
« no previous file with comments | « no previous file | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698