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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> value) { | 14 Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) { |
15 if (value->IsConsString()) { | 15 return graph()->NewNode(common()->HeapConstant(object)); |
16 value = String::Flatten(Handle<String>::cast(value), TENURED); | |
17 } | |
18 return graph()->NewNode(common()->HeapConstant(value)); | |
19 } | 16 } |
20 | 17 |
21 | 18 |
22 #define CACHED(name, expr) \ | 19 #define CACHED(name, expr) \ |
23 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) | 20 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) |
24 | 21 |
25 | 22 |
26 Node* JSGraph::CEntryStubConstant(int result_size) { | 23 Node* JSGraph::CEntryStubConstant(int result_size) { |
27 if (result_size == 1) { | 24 if (result_size == 1) { |
28 return CACHED(kCEntryStubConstant, | 25 return CACHED(kCEntryStubConstant, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return CACHED(kNaNConstant, | 71 return CACHED(kNaNConstant, |
75 NumberConstant(std::numeric_limits<double>::quiet_NaN())); | 72 NumberConstant(std::numeric_limits<double>::quiet_NaN())); |
76 } | 73 } |
77 | 74 |
78 | 75 |
79 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { | 76 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { |
80 // TODO(turbofan): canonicalize heap constants using <magic approach>. | 77 // TODO(turbofan): canonicalize heap constants using <magic approach>. |
81 // TODO(titzer): We could also match against the addresses of immortable | 78 // TODO(titzer): We could also match against the addresses of immortable |
82 // immovables here, even without access to the heap, thus always | 79 // immovables here, even without access to the heap, thus always |
83 // canonicalizing references to them. | 80 // canonicalizing references to them. |
84 return ImmovableHeapConstant(value); | 81 return graph()->NewNode(common()->HeapConstant(value)); |
85 } | 82 } |
86 | 83 |
87 | 84 |
88 Node* JSGraph::Constant(Handle<Object> value) { | 85 Node* JSGraph::Constant(Handle<Object> value) { |
89 // Dereference the handle to determine if a number constant or other | 86 // Dereference the handle to determine if a number constant or other |
90 // canonicalized node can be used. | 87 // canonicalized node can be used. |
91 if (value->IsNumber()) { | 88 if (value->IsNumber()) { |
92 return Constant(value->Number()); | 89 return Constant(value->Number()); |
93 } else if (value->IsUndefined()) { | 90 } else if (value->IsUndefined()) { |
94 return UndefinedConstant(); | 91 return UndefinedConstant(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 for (size_t i = 0; i < arraysize(cached_nodes_); i++) { | 201 for (size_t i = 0; i < arraysize(cached_nodes_); i++) { |
205 if (Node* node = cached_nodes_[i]) { | 202 if (Node* node = cached_nodes_[i]) { |
206 if (!node->IsDead()) nodes->push_back(node); | 203 if (!node->IsDead()) nodes->push_back(node); |
207 } | 204 } |
208 } | 205 } |
209 } | 206 } |
210 | 207 |
211 } // namespace compiler | 208 } // namespace compiler |
212 } // namespace internal | 209 } // namespace internal |
213 } // namespace v8 | 210 } // namespace v8 |
OLD | NEW |