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

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

Issue 658543002: Better typing and type verification (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 2 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 | Annotate | Revision Log
« 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/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<HeapObject> object) { 13 Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) {
14 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object); 14 Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object);
15 return NewNode(common()->HeapConstant(unique)); 15 return graph()->NewNode(common()->HeapConstant(unique));
16 } 16 }
17 17
18 18
19 Node* JSGraph::NewNode(const Operator* op) {
20 Node* node = graph()->NewNode(op);
21 typer_->Init(node);
22 return node;
23 }
24
25
26 Node* JSGraph::CEntryStubConstant() { 19 Node* JSGraph::CEntryStubConstant() {
27 if (!c_entry_stub_constant_.is_set()) { 20 if (!c_entry_stub_constant_.is_set()) {
28 c_entry_stub_constant_.set( 21 c_entry_stub_constant_.set(
29 ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode())); 22 ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode()));
30 } 23 }
31 return c_entry_stub_constant_.get(); 24 return c_entry_stub_constant_.get();
32 } 25 }
33 26
34 27
35 Node* JSGraph::UndefinedConstant() { 28 Node* JSGraph::UndefinedConstant() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 Node* JSGraph::NaNConstant() { 81 Node* JSGraph::NaNConstant() {
89 if (!nan_constant_.is_set()) { 82 if (!nan_constant_.is_set()) {
90 nan_constant_.set(NumberConstant(base::OS::nan_value())); 83 nan_constant_.set(NumberConstant(base::OS::nan_value()));
91 } 84 }
92 return nan_constant_.get(); 85 return nan_constant_.get();
93 } 86 }
94 87
95 88
96 Node* JSGraph::HeapConstant(Unique<HeapObject> value) { 89 Node* JSGraph::HeapConstant(Unique<HeapObject> value) {
97 // TODO(turbofan): canonicalize heap constants using Unique<T> 90 // TODO(turbofan): canonicalize heap constants using Unique<T>
98 return NewNode(common()->HeapConstant(value)); 91 return graph()->NewNode(common()->HeapConstant(value));
99 } 92 }
100 93
101 94
102 Node* JSGraph::HeapConstant(Handle<HeapObject> value) { 95 Node* JSGraph::HeapConstant(Handle<HeapObject> value) {
103 // TODO(titzer): We could also match against the addresses of immortable 96 // TODO(titzer): We could also match against the addresses of immortable
104 // immovables here, even without access to the heap, thus always 97 // immovables here, even without access to the heap, thus always
105 // canonicalizing references to them. 98 // canonicalizing references to them.
106 // return HeapConstant(Unique<Object>::CreateUninitialized(value)); 99 // return HeapConstant(Unique<Object>::CreateUninitialized(value));
107 // TODO(turbofan): This is a work-around to make Unique::HashCode() work for 100 // TODO(turbofan): This is a work-around to make Unique::HashCode() work for
108 // value numbering. We need some sane way to compute a unique hash code for 101 // value numbering. We need some sane way to compute a unique hash code for
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 Node* JSGraph::Constant(int32_t value) { 137 Node* JSGraph::Constant(int32_t value) {
145 if (value == 0) return ZeroConstant(); 138 if (value == 0) return ZeroConstant();
146 if (value == 1) return OneConstant(); 139 if (value == 1) return OneConstant();
147 return NumberConstant(value); 140 return NumberConstant(value);
148 } 141 }
149 142
150 143
151 Node* JSGraph::Int32Constant(int32_t value) { 144 Node* JSGraph::Int32Constant(int32_t value) {
152 Node** loc = cache_.FindInt32Constant(value); 145 Node** loc = cache_.FindInt32Constant(value);
153 if (*loc == NULL) { 146 if (*loc == NULL) {
154 *loc = NewNode(common()->Int32Constant(value)); 147 *loc = graph()->NewNode(common()->Int32Constant(value));
155 } 148 }
156 return *loc; 149 return *loc;
157 } 150 }
158 151
159 152
160 Node* JSGraph::Int64Constant(int64_t value) { 153 Node* JSGraph::Int64Constant(int64_t value) {
161 Node** loc = cache_.FindInt64Constant(value); 154 Node** loc = cache_.FindInt64Constant(value);
162 if (*loc == NULL) { 155 if (*loc == NULL) {
163 *loc = NewNode(common()->Int64Constant(value)); 156 *loc = graph()->NewNode(common()->Int64Constant(value));
164 } 157 }
165 return *loc; 158 return *loc;
166 } 159 }
167 160
168 161
169 Node* JSGraph::NumberConstant(double value) { 162 Node* JSGraph::NumberConstant(double value) {
170 Node** loc = cache_.FindNumberConstant(value); 163 Node** loc = cache_.FindNumberConstant(value);
171 if (*loc == NULL) { 164 if (*loc == NULL) {
172 *loc = NewNode(common()->NumberConstant(value)); 165 *loc = graph()->NewNode(common()->NumberConstant(value));
173 } 166 }
174 return *loc; 167 return *loc;
175 } 168 }
176 169
177 170
178 Node* JSGraph::Float32Constant(float value) { 171 Node* JSGraph::Float32Constant(float value) {
179 // TODO(turbofan): cache float32 constants. 172 // TODO(turbofan): cache float32 constants.
180 return NewNode(common()->Float32Constant(value)); 173 return graph()->NewNode(common()->Float32Constant(value));
181 } 174 }
182 175
183 176
184 Node* JSGraph::Float64Constant(double value) { 177 Node* JSGraph::Float64Constant(double value) {
185 Node** loc = cache_.FindFloat64Constant(value); 178 Node** loc = cache_.FindFloat64Constant(value);
186 if (*loc == NULL) { 179 if (*loc == NULL) {
187 *loc = NewNode(common()->Float64Constant(value)); 180 *loc = graph()->NewNode(common()->Float64Constant(value));
188 } 181 }
189 return *loc; 182 return *loc;
190 } 183 }
191 184
192 185
193 Node* JSGraph::ExternalConstant(ExternalReference reference) { 186 Node* JSGraph::ExternalConstant(ExternalReference reference) {
194 Node** loc = cache_.FindExternalConstant(reference); 187 Node** loc = cache_.FindExternalConstant(reference);
195 if (*loc == NULL) { 188 if (*loc == NULL) {
196 *loc = NewNode(common()->ExternalConstant(reference)); 189 *loc = graph()->NewNode(common()->ExternalConstant(reference));
197 } 190 }
198 return *loc; 191 return *loc;
199 } 192 }
200 193
201 } // namespace compiler 194 } // namespace compiler
202 } // namespace internal 195 } // namespace internal
203 } // namespace v8 196 } // 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