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 #define CACHED(name, expr) \ | 14 #define CACHED(name, expr) \ |
15 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) | 15 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) |
16 | 16 |
| 17 Node* JSGraph::AllocateInNewSpaceStubConstant() { |
| 18 return CACHED(kAllocateInNewSpaceStubConstant, |
| 19 HeapConstant(isolate()->builtins()->AllocateInNewSpace())); |
| 20 } |
| 21 |
| 22 Node* JSGraph::AllocateInOldSpaceStubConstant() { |
| 23 return CACHED(kAllocateInOldSpaceStubConstant, |
| 24 HeapConstant(isolate()->builtins()->AllocateInOldSpace())); |
| 25 } |
17 | 26 |
18 Node* JSGraph::CEntryStubConstant(int result_size) { | 27 Node* JSGraph::CEntryStubConstant(int result_size) { |
19 if (result_size == 1) { | 28 if (result_size == 1) { |
20 return CACHED(kCEntryStubConstant, | 29 return CACHED(kCEntryStubConstant, |
21 HeapConstant(CEntryStub(isolate(), 1).GetCode())); | 30 HeapConstant(CEntryStub(isolate(), 1).GetCode())); |
22 } | 31 } |
23 return HeapConstant(CEntryStub(isolate(), result_size).GetCode()); | 32 return HeapConstant(CEntryStub(isolate(), result_size).GetCode()); |
24 } | 33 } |
25 | 34 |
26 | 35 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 83 } |
75 | 84 |
76 | 85 |
77 Node* JSGraph::NaNConstant() { | 86 Node* JSGraph::NaNConstant() { |
78 return CACHED(kNaNConstant, | 87 return CACHED(kNaNConstant, |
79 NumberConstant(std::numeric_limits<double>::quiet_NaN())); | 88 NumberConstant(std::numeric_limits<double>::quiet_NaN())); |
80 } | 89 } |
81 | 90 |
82 | 91 |
83 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { | 92 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { |
84 if (value->IsConsString()) { | |
85 value = String::Flatten(Handle<String>::cast(value), TENURED); | |
86 } | |
87 Node** loc = cache_.FindHeapConstant(value); | 93 Node** loc = cache_.FindHeapConstant(value); |
88 if (*loc == nullptr) { | 94 if (*loc == nullptr) { |
89 *loc = graph()->NewNode(common()->HeapConstant(value)); | 95 *loc = graph()->NewNode(common()->HeapConstant(value)); |
90 } | 96 } |
91 return *loc; | 97 return *loc; |
92 } | 98 } |
93 | 99 |
94 | 100 |
95 Node* JSGraph::Constant(Handle<Object> value) { | 101 Node* JSGraph::Constant(Handle<Object> value) { |
96 // Dereference the handle to determine if a number constant or other | 102 // Dereference the handle to determine if a number constant or other |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 for (size_t i = 0; i < arraysize(cached_nodes_); i++) { | 239 for (size_t i = 0; i < arraysize(cached_nodes_); i++) { |
234 if (Node* node = cached_nodes_[i]) { | 240 if (Node* node = cached_nodes_[i]) { |
235 if (!node->IsDead()) nodes->push_back(node); | 241 if (!node->IsDead()) nodes->push_back(node); |
236 } | 242 } |
237 } | 243 } |
238 } | 244 } |
239 | 245 |
240 } // namespace compiler | 246 } // namespace compiler |
241 } // namespace internal | 247 } // namespace internal |
242 } // namespace v8 | 248 } // namespace v8 |
OLD | NEW |