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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 442253002: Add deoptimization translations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review comments. Created 6 years, 4 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/ast-graph-builder.h ('k') | src/compiler/code-generator.h » ('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/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/control-builders.h" 8 #include "src/compiler/control-builders.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder, 166 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder,
167 Scope* scope, 167 Scope* scope,
168 Node* control_dependency) 168 Node* control_dependency)
169 : StructuredGraphBuilder::Environment(builder, control_dependency), 169 : StructuredGraphBuilder::Environment(builder, control_dependency),
170 parameters_count_(scope->num_parameters() + 1), 170 parameters_count_(scope->num_parameters() + 1),
171 locals_count_(scope->num_stack_slots()), 171 locals_count_(scope->num_stack_slots()),
172 parameters_node_(NULL), 172 parameters_node_(NULL),
173 locals_node_(NULL), 173 locals_node_(NULL),
174 stack_node_(NULL), 174 stack_node_(NULL),
175 parameters_dirty_(false), 175 parameters_dirty_(true),
176 locals_dirty_(false), 176 locals_dirty_(true),
177 stack_dirty_(false) { 177 stack_dirty_(true) {
178 DCHECK_EQ(scope->num_parameters() + 1, parameters_count()); 178 DCHECK_EQ(scope->num_parameters() + 1, parameters_count());
179 179
180 // Bind the receiver variable. 180 // Bind the receiver variable.
181 Node* receiver = builder->graph()->NewNode(common()->Parameter(0), 181 Node* receiver = builder->graph()->NewNode(common()->Parameter(0),
182 builder->graph()->start()); 182 builder->graph()->start());
183 values()->push_back(receiver); 183 values()->push_back(receiver);
184 184
185 // Bind all parameter variables. The parameter indices are shifted by 1 185 // Bind all parameter variables. The parameter indices are shifted by 1
186 // (receiver is parameter index -1 but environment index 0). 186 // (receiver is parameter index -1 but environment index 0).
187 for (int i = 0; i < scope->num_parameters(); ++i) { 187 for (int i = 0; i < scope->num_parameters(); ++i) {
(...skipping 15 matching lines...) Expand all
203 locals_count_(copy.locals_count_), 203 locals_count_(copy.locals_count_),
204 parameters_node_(copy.parameters_node_), 204 parameters_node_(copy.parameters_node_),
205 locals_node_(copy.locals_node_), 205 locals_node_(copy.locals_node_),
206 stack_node_(copy.stack_node_), 206 stack_node_(copy.stack_node_),
207 parameters_dirty_(copy.parameters_dirty_), 207 parameters_dirty_(copy.parameters_dirty_),
208 locals_dirty_(copy.locals_dirty_), 208 locals_dirty_(copy.locals_dirty_),
209 stack_dirty_(copy.stack_dirty_) {} 209 stack_dirty_(copy.stack_dirty_) {}
210 210
211 211
212 Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id) { 212 Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id) {
213 UNIMPLEMENTED(); // TODO(mstarzinger): Implementation below is incomplete.
214 if (parameters_dirty_) { 213 if (parameters_dirty_) {
215 Node** parameters = &values()->front(); 214 Operator* op = common()->StateValues(parameters_count());
216 parameters_node_ = graph()->NewNode(NULL, parameters_count(), parameters); 215 if (parameters_count() != 0) {
216 Node** parameters = &values()->front();
217 parameters_node_ = graph()->NewNode(op, parameters_count(), parameters);
218 } else {
219 parameters_node_ = graph()->NewNode(op);
220 }
217 parameters_dirty_ = false; 221 parameters_dirty_ = false;
218 } 222 }
219 if (locals_dirty_) { 223 if (locals_dirty_) {
220 Node** locals = &values()->at(parameters_count_); 224 Operator* op = common()->StateValues(locals_count());
221 locals_node_ = graph()->NewNode(NULL, locals_count(), locals); 225 if (locals_count() != 0) {
226 Node** locals = &values()->at(parameters_count_);
227 locals_node_ = graph()->NewNode(op, locals_count(), locals);
228 } else {
229 locals_node_ = graph()->NewNode(op);
230 }
222 locals_dirty_ = false; 231 locals_dirty_ = false;
223 } 232 }
224 FrameStateDescriptor descriptor(ast_id); 233 if (stack_dirty_) {
225 // TODO(jarin): add environment to the node. 234 Operator* op = common()->StateValues(stack_height());
226 Operator* op = common()->FrameState(descriptor); 235 if (stack_height() != 0) {
236 Node** stack = &values()->at(parameters_count_ + locals_count_);
237 stack_node_ = graph()->NewNode(op, stack_height(), stack);
238 } else {
239 stack_node_ = graph()->NewNode(op);
240 }
241 stack_dirty_ = false;
242 }
227 243
228 return graph()->NewNode(op); 244 Operator* op = common()->FrameState(ast_id);
245
246 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_);
229 } 247 }
230 248
231 249
232 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own, 250 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own,
233 Expression::Context kind) 251 Expression::Context kind)
234 : kind_(kind), owner_(own), outer_(own->ast_context()) { 252 : kind_(kind), owner_(own), outer_(own->ast_context()) {
235 owner()->set_ast_context(this); // Push. 253 owner()->set_ast_context(this); // Push.
236 #ifdef DEBUG 254 #ifdef DEBUG
237 original_height_ = environment()->stack_height(); 255 original_height_ = environment()->stack_height();
238 #endif 256 #endif
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1974
1957 StructuredGraphBuilder::Environment* continuation_env = 1975 StructuredGraphBuilder::Environment* continuation_env =
1958 environment_internal(); 1976 environment_internal();
1959 // Create environment for the deoptimization block, and build the block. 1977 // Create environment for the deoptimization block, and build the block.
1960 StructuredGraphBuilder::Environment* deopt_env = 1978 StructuredGraphBuilder::Environment* deopt_env =
1961 CopyEnvironment(continuation_env); 1979 CopyEnvironment(continuation_env);
1962 set_environment(deopt_env); 1980 set_environment(deopt_env);
1963 1981
1964 NewNode(common()->LazyDeoptimization()); 1982 NewNode(common()->LazyDeoptimization());
1965 1983
1966 FrameStateDescriptor stateDescriptor(ast_id); 1984 Node* state_node = environment()->Checkpoint(ast_id);
1967 Node* state_node = NewNode(common()->FrameState(stateDescriptor));
1968 1985
1969 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); 1986 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node);
1970 1987
1971 UpdateControlDependencyToLeaveFunction(deoptimize_node); 1988 UpdateControlDependencyToLeaveFunction(deoptimize_node);
1972 1989
1973 // Continue with the original environment. 1990 // Continue with the original environment.
1974 set_environment(continuation_env); 1991 set_environment(continuation_env);
1975 1992
1976 NewNode(common()->Continuation()); 1993 NewNode(common()->Continuation());
1977 } 1994 }
1978 } 1995 }
1979 } 1996 }
1980 } 1997 }
1981 } // namespace v8::internal::compiler 1998 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/code-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698