OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/js-graph.h" | 5 #include "src/compiler/js-graph.h" |
6 #include "src/compiler/node-properties-inl.h" | 6 #include "src/compiler/node-properties-inl.h" |
7 #include "src/compiler/typer.h" | 7 #include "src/compiler/typer.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
13 Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) { | 13 Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) { |
14 Unique<Object> unique = Unique<Object>::CreateImmovable(object); | 14 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object); |
15 return NewNode(common()->HeapConstant(unique)); | 15 return NewNode(common()->HeapConstant(unique)); |
16 } | 16 } |
17 | 17 |
18 | 18 |
19 Node* JSGraph::NewNode(const Operator* op) { | 19 Node* JSGraph::NewNode(const Operator* op) { |
20 Node* node = graph()->NewNode(op); | 20 Node* node = graph()->NewNode(op); |
21 typer_->Init(node); | 21 typer_->Init(node); |
22 return node; | 22 return node; |
23 } | 23 } |
24 | 24 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 | 87 |
88 Node* JSGraph::NaNConstant() { | 88 Node* JSGraph::NaNConstant() { |
89 if (!nan_constant_.is_set()) { | 89 if (!nan_constant_.is_set()) { |
90 nan_constant_.set(NumberConstant(base::OS::nan_value())); | 90 nan_constant_.set(NumberConstant(base::OS::nan_value())); |
91 } | 91 } |
92 return nan_constant_.get(); | 92 return nan_constant_.get(); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 Node* JSGraph::HeapConstant(Unique<Object> value) { | 96 Node* JSGraph::HeapConstant(Unique<HeapObject> value) { |
97 // TODO(turbofan): canonicalize heap constants using Unique<T> | 97 // TODO(turbofan): canonicalize heap constants using Unique<T> |
98 return NewNode(common()->HeapConstant(value)); | 98 return NewNode(common()->HeapConstant(value)); |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 Node* JSGraph::HeapConstant(Handle<Object> value) { | 102 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { |
103 // TODO(titzer): We could also match against the addresses of immortable | 103 // TODO(titzer): We could also match against the addresses of immortable |
104 // immovables here, even without access to the heap, thus always | 104 // immovables here, even without access to the heap, thus always |
105 // canonicalizing references to them. | 105 // canonicalizing references to them. |
106 // return HeapConstant(Unique<Object>::CreateUninitialized(value)); | 106 // return HeapConstant(Unique<Object>::CreateUninitialized(value)); |
107 // TODO(turbofan): This is a work-around to make Unique::HashCode() work for | 107 // TODO(turbofan): This is a work-around to make Unique::HashCode() work for |
108 // value numbering. We need some sane way to compute a unique hash code for | 108 // value numbering. We need some sane way to compute a unique hash code for |
109 // arbitrary handles here. | 109 // arbitrary handles here. |
110 Unique<Object> unique(reinterpret_cast<Address>(*value.location()), value); | 110 Unique<HeapObject> unique(reinterpret_cast<Address>(*value.location()), |
| 111 value); |
111 return HeapConstant(unique); | 112 return HeapConstant(unique); |
112 } | 113 } |
113 | 114 |
114 | 115 |
115 Node* JSGraph::Constant(Handle<Object> value) { | 116 Node* JSGraph::Constant(Handle<Object> value) { |
116 // Dereference the handle to determine if a number constant or other | 117 // Dereference the handle to determine if a number constant or other |
117 // canonicalized node can be used. | 118 // canonicalized node can be used. |
118 if (value->IsNumber()) { | 119 if (value->IsNumber()) { |
119 return Constant(value->Number()); | 120 return Constant(value->Number()); |
120 } else if (value->IsUndefined()) { | 121 } else if (value->IsUndefined()) { |
121 return UndefinedConstant(); | 122 return UndefinedConstant(); |
122 } else if (value->IsTrue()) { | 123 } else if (value->IsTrue()) { |
123 return TrueConstant(); | 124 return TrueConstant(); |
124 } else if (value->IsFalse()) { | 125 } else if (value->IsFalse()) { |
125 return FalseConstant(); | 126 return FalseConstant(); |
126 } else if (value->IsNull()) { | 127 } else if (value->IsNull()) { |
127 return NullConstant(); | 128 return NullConstant(); |
128 } else if (value->IsTheHole()) { | 129 } else if (value->IsTheHole()) { |
129 return TheHoleConstant(); | 130 return TheHoleConstant(); |
130 } else { | 131 } else { |
131 return HeapConstant(value); | 132 return HeapConstant(Handle<HeapObject>::cast(value)); |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 | 136 |
136 Node* JSGraph::Constant(double value) { | 137 Node* JSGraph::Constant(double value) { |
137 if (bit_cast<int64_t>(value) == bit_cast<int64_t>(0.0)) return ZeroConstant(); | 138 if (bit_cast<int64_t>(value) == bit_cast<int64_t>(0.0)) return ZeroConstant(); |
138 if (bit_cast<int64_t>(value) == bit_cast<int64_t>(1.0)) return OneConstant(); | 139 if (bit_cast<int64_t>(value) == bit_cast<int64_t>(1.0)) return OneConstant(); |
139 return NumberConstant(value); | 140 return NumberConstant(value); |
140 } | 141 } |
141 | 142 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 Node* JSGraph::ExternalConstant(ExternalReference reference) { | 184 Node* JSGraph::ExternalConstant(ExternalReference reference) { |
184 Node** loc = cache_.FindExternalConstant(reference); | 185 Node** loc = cache_.FindExternalConstant(reference); |
185 if (*loc == NULL) { | 186 if (*loc == NULL) { |
186 *loc = NewNode(common()->ExternalConstant(reference)); | 187 *loc = NewNode(common()->ExternalConstant(reference)); |
187 } | 188 } |
188 return *loc; | 189 return *loc; |
189 } | 190 } |
190 } // namespace compiler | 191 } // namespace compiler |
191 } // namespace internal | 192 } // namespace internal |
192 } // namespace v8 | 193 } // namespace v8 |
OLD | NEW |