Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: src/compiler/js-graph.cc

Issue 1314473007: [turbofan] Remove usage of Unique<T> from graph. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased and fixed. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-graph.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> object) {
15 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object); 15 return graph()->NewNode(common()->HeapConstant(object));
16 return graph()->NewNode(common()->HeapConstant(unique));
17 } 16 }
18 17
19 18
20 #define CACHED(name, expr) \ 19 #define CACHED(name, expr) \
21 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr)) 20 cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr))
22 21
23 22
24 Node* JSGraph::CEntryStubConstant(int result_size) { 23 Node* JSGraph::CEntryStubConstant(int result_size) {
25 if (result_size == 1) { 24 if (result_size == 1) {
26 return CACHED(kCEntryStubConstant, 25 return CACHED(kCEntryStubConstant,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return CACHED(kOneConstant, NumberConstant(1.0)); 66 return CACHED(kOneConstant, NumberConstant(1.0));
68 } 67 }
69 68
70 69
71 Node* JSGraph::NaNConstant() { 70 Node* JSGraph::NaNConstant() {
72 return CACHED(kNaNConstant, 71 return CACHED(kNaNConstant,
73 NumberConstant(std::numeric_limits<double>::quiet_NaN())); 72 NumberConstant(std::numeric_limits<double>::quiet_NaN()));
74 } 73 }
75 74
76 75
77 Node* JSGraph::HeapConstant(Unique<HeapObject> value) { 76 Node* JSGraph::HeapConstant(Handle<HeapObject> value) {
78 // TODO(turbofan): canonicalize heap constants using Unique<T> 77 // TODO(turbofan): canonicalize heap constants using <magic approach>.
78 // TODO(titzer): We could also match against the addresses of immortable
79 // immovables here, even without access to the heap, thus always
80 // canonicalizing references to them.
79 return graph()->NewNode(common()->HeapConstant(value)); 81 return graph()->NewNode(common()->HeapConstant(value));
80 } 82 }
81 83
82 84
83 Node* JSGraph::HeapConstant(Handle<HeapObject> value) {
84 // TODO(titzer): We could also match against the addresses of immortable
85 // immovables here, even without access to the heap, thus always
86 // canonicalizing references to them.
87 // return HeapConstant(Unique<Object>::CreateUninitialized(value));
88 // TODO(turbofan): This is a work-around to make Unique::HashCode() work for
89 // value numbering. We need some sane way to compute a unique hash code for
90 // arbitrary handles here.
91 Unique<HeapObject> unique(reinterpret_cast<Address>(*value.location()),
92 value);
93 return HeapConstant(unique);
94 }
95
96
97 Node* JSGraph::Constant(Handle<Object> value) { 85 Node* JSGraph::Constant(Handle<Object> value) {
98 // Dereference the handle to determine if a number constant or other 86 // Dereference the handle to determine if a number constant or other
99 // canonicalized node can be used. 87 // canonicalized node can be used.
100 if (value->IsNumber()) { 88 if (value->IsNumber()) {
101 return Constant(value->Number()); 89 return Constant(value->Number());
102 } else if (value->IsUndefined()) { 90 } else if (value->IsUndefined()) {
103 return UndefinedConstant(); 91 return UndefinedConstant();
104 } else if (value->IsTrue()) { 92 } else if (value->IsTrue()) {
105 return TrueConstant(); 93 return TrueConstant();
106 } else if (value->IsFalse()) { 94 } else if (value->IsFalse()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 for (size_t i = 0; i < arraysize(cached_nodes_); i++) { 201 for (size_t i = 0; i < arraysize(cached_nodes_); i++) {
214 if (Node* node = cached_nodes_[i]) { 202 if (Node* node = cached_nodes_[i]) {
215 if (!node->IsDead()) nodes->push_back(node); 203 if (!node->IsDead()) nodes->push_back(node);
216 } 204 }
217 } 205 }
218 } 206 }
219 207
220 } // namespace compiler 208 } // namespace compiler
221 } // namespace internal 209 } // namespace internal
222 } // namespace v8 210 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-graph.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698