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