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<Object> object) { |
14 PrintableUnique<Object> unique = | 14 Unique<Object> unique = Unique<Object>::CreateImmovable(object); |
15 PrintableUnique<Object>::CreateImmovable(zone(), object); | |
16 return NewNode(common()->HeapConstant(unique)); | 15 return NewNode(common()->HeapConstant(unique)); |
17 } | 16 } |
18 | 17 |
19 | 18 |
20 Node* JSGraph::NewNode(Operator* op) { | 19 Node* JSGraph::NewNode(Operator* op) { |
21 Node* node = graph()->NewNode(op); | 20 Node* node = graph()->NewNode(op); |
22 typer_->Init(node); | 21 typer_->Init(node); |
23 return node; | 22 return node; |
24 } | 23 } |
25 | 24 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 86 |
88 | 87 |
89 Node* JSGraph::NaNConstant() { | 88 Node* JSGraph::NaNConstant() { |
90 if (!nan_constant_.is_set()) { | 89 if (!nan_constant_.is_set()) { |
91 nan_constant_.set(NumberConstant(base::OS::nan_value())); | 90 nan_constant_.set(NumberConstant(base::OS::nan_value())); |
92 } | 91 } |
93 return nan_constant_.get(); | 92 return nan_constant_.get(); |
94 } | 93 } |
95 | 94 |
96 | 95 |
97 Node* JSGraph::HeapConstant(PrintableUnique<Object> value) { | 96 Node* JSGraph::HeapConstant(Unique<Object> value) { |
98 // TODO(turbofan): canonicalize heap constants using Unique<T> | 97 // TODO(turbofan): canonicalize heap constants using Unique<T> |
99 return NewNode(common()->HeapConstant(value)); | 98 return NewNode(common()->HeapConstant(value)); |
100 } | 99 } |
101 | 100 |
102 | 101 |
103 Node* JSGraph::HeapConstant(Handle<Object> value) { | 102 Node* JSGraph::HeapConstant(Handle<Object> value) { |
104 // TODO(titzer): We could also match against the addresses of immortable | 103 // TODO(titzer): We could also match against the addresses of immortable |
105 // immovables here, even without access to the heap, thus always | 104 // immovables here, even without access to the heap, thus always |
106 // canonicalizing references to them. | 105 // canonicalizing references to them. |
107 return HeapConstant( | 106 return HeapConstant(Unique<Object>::CreateUninitialized(value)); |
108 PrintableUnique<Object>::CreateUninitialized(zone(), value)); | |
109 } | 107 } |
110 | 108 |
111 | 109 |
112 Node* JSGraph::Constant(Handle<Object> value) { | 110 Node* JSGraph::Constant(Handle<Object> value) { |
113 // Dereference the handle to determine if a number constant or other | 111 // Dereference the handle to determine if a number constant or other |
114 // canonicalized node can be used. | 112 // canonicalized node can be used. |
115 if (value->IsNumber()) { | 113 if (value->IsNumber()) { |
116 return Constant(value->Number()); | 114 return Constant(value->Number()); |
117 } else if (value->IsUndefined()) { | 115 } else if (value->IsUndefined()) { |
118 return UndefinedConstant(); | 116 return UndefinedConstant(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 Node* JSGraph::ExternalConstant(ExternalReference reference) { | 172 Node* JSGraph::ExternalConstant(ExternalReference reference) { |
175 Node** loc = cache_.FindExternalConstant(reference); | 173 Node** loc = cache_.FindExternalConstant(reference); |
176 if (*loc == NULL) { | 174 if (*loc == NULL) { |
177 *loc = NewNode(common()->ExternalConstant(reference)); | 175 *loc = NewNode(common()->ExternalConstant(reference)); |
178 } | 176 } |
179 return *loc; | 177 return *loc; |
180 } | 178 } |
181 } // namespace compiler | 179 } // namespace compiler |
182 } // namespace internal | 180 } // namespace internal |
183 } // namespace v8 | 181 } // namespace v8 |
OLD | NEW |