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

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

Issue 464033002: Refactor building of lazy bailouts in AstGraphBuilder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address 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 | « no previous file | src/compiler/ast-graph-builder.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 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_
6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/ast.h" 10 #include "src/ast.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void VisitNot(UnaryOperation* expr); 164 void VisitNot(UnaryOperation* expr);
165 165
166 // Dispatched from VisitBinaryOperation. 166 // Dispatched from VisitBinaryOperation.
167 void VisitComma(BinaryOperation* expr); 167 void VisitComma(BinaryOperation* expr);
168 void VisitLogicalExpression(BinaryOperation* expr); 168 void VisitLogicalExpression(BinaryOperation* expr);
169 void VisitArithmeticExpression(BinaryOperation* expr); 169 void VisitArithmeticExpression(BinaryOperation* expr);
170 170
171 // Dispatched from VisitForInStatement. 171 // Dispatched from VisitForInStatement.
172 void VisitForInAssignment(Expression* expr, Node* value); 172 void VisitForInAssignment(Expression* expr, Node* value);
173 173
174 void BuildLazyBailout(Node* node, BailoutId ast_id); 174 // Flag that describes how to combine the current environment with
175 void BuildLazyBailoutWithPushedNode(Node* node, BailoutId ast_id); 175 // the output of a node to obtain a framestate for lazy bailout.
176 enum OutputFrameStateCombine {
177 PUSH_OUTPUT, // Push the output on the expression stack.
178 IGNORE_OUTPUT // Use the frame state as-is.
179 };
180
181 // Builds deoptimization for a given node.
182 void PrepareFrameState(Node* node, BailoutId ast_id,
183 OutputFrameStateCombine combine = IGNORE_OUTPUT);
184
185 OutputFrameStateCombine StateCombineFromAstContext();
Michael Starzinger 2014/08/13 09:15:58 This method is no longer used or implemented, let'
176 186
177 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 187 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
178 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); 188 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder);
179 }; 189 };
180 190
181 191
182 // The abstract execution environment for generated code consists of 192 // The abstract execution environment for generated code consists of
183 // parameter variables, local variables and the operand stack. The 193 // parameter variables, local variables and the operand stack. The
184 // environment will perform proper SSA-renaming of all tracked nodes 194 // environment will perform proper SSA-renaming of all tracked nodes
185 // at split and merge points in the control flow. Internally all the 195 // at split and merge points in the control flow. Internally all the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 285
276 286
277 // Each expression in the AST is evaluated in a specific context. This context 287 // Each expression in the AST is evaluated in a specific context. This context
278 // decides how the evaluation result is passed up the visitor. 288 // decides how the evaluation result is passed up the visitor.
279 class AstGraphBuilder::AstContext BASE_EMBEDDED { 289 class AstGraphBuilder::AstContext BASE_EMBEDDED {
280 public: 290 public:
281 bool IsEffect() const { return kind_ == Expression::kEffect; } 291 bool IsEffect() const { return kind_ == Expression::kEffect; }
282 bool IsValue() const { return kind_ == Expression::kValue; } 292 bool IsValue() const { return kind_ == Expression::kValue; }
283 bool IsTest() const { return kind_ == Expression::kTest; } 293 bool IsTest() const { return kind_ == Expression::kTest; }
284 294
295 // Determines how to combine the frame state with the value
296 // that is about to be plugged into this AstContext.
297 AstGraphBuilder::OutputFrameStateCombine GetStateCombine() {
298 return IsEffect() ? IGNORE_OUTPUT : PUSH_OUTPUT;
299 }
300
285 // Plug a node into this expression context. Call this function in tail 301 // Plug a node into this expression context. Call this function in tail
286 // position in the Visit functions for expressions. 302 // position in the Visit functions for expressions.
287 virtual void ProduceValue(Node* value) = 0; 303 virtual void ProduceValue(Node* value) = 0;
288 virtual void ProduceValueWithLazyBailout(Node* value) = 0;
289 304
290 // Unplugs a node from this expression context. Call this to retrieve the 305 // Unplugs a node from this expression context. Call this to retrieve the
291 // result of another Visit function that already plugged the context. 306 // result of another Visit function that already plugged the context.
292 virtual Node* ConsumeValue() = 0; 307 virtual Node* ConsumeValue() = 0;
293 308
294 // Shortcut for "context->ProduceValue(context->ConsumeValue())". 309 // Shortcut for "context->ProduceValue(context->ConsumeValue())".
295 void ReplaceValue() { ProduceValue(ConsumeValue()); } 310 void ReplaceValue() { ProduceValue(ConsumeValue()); }
296 311
297 protected: 312 protected:
298 AstContext(AstGraphBuilder* owner, Expression::Context kind, 313 AstContext(AstGraphBuilder* owner, Expression::Context kind);
299 BailoutId bailout_id);
300 virtual ~AstContext(); 314 virtual ~AstContext();
301 315
302 AstGraphBuilder* owner() const { return owner_; } 316 AstGraphBuilder* owner() const { return owner_; }
303 Environment* environment() const { return owner_->environment(); } 317 Environment* environment() const { return owner_->environment(); }
304 318
305 // We want to be able to assert, in a context-specific way, that the stack 319 // We want to be able to assert, in a context-specific way, that the stack
306 // height makes sense when the context is filled. 320 // height makes sense when the context is filled.
307 #ifdef DEBUG 321 #ifdef DEBUG
308 int original_height_; 322 int original_height_;
309 #endif 323 #endif
310 324
311 BailoutId bailout_id_;
312
313 private: 325 private:
314 Expression::Context kind_; 326 Expression::Context kind_;
315 AstGraphBuilder* owner_; 327 AstGraphBuilder* owner_;
316 AstContext* outer_; 328 AstContext* outer_;
317 }; 329 };
318 330
319 331
320 // Context to evaluate expression for its side effects only. 332 // Context to evaluate expression for its side effects only.
321 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { 333 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext {
322 public: 334 public:
323 explicit AstEffectContext(AstGraphBuilder* owner, BailoutId bailout_id) 335 explicit AstEffectContext(AstGraphBuilder* owner)
324 : AstContext(owner, Expression::kEffect, bailout_id) {} 336 : AstContext(owner, Expression::kEffect) {}
325 virtual ~AstEffectContext(); 337 virtual ~AstEffectContext();
326 virtual void ProduceValue(Node* value) V8_OVERRIDE; 338 virtual void ProduceValue(Node* value) V8_OVERRIDE;
327 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
328 virtual Node* ConsumeValue() V8_OVERRIDE; 339 virtual Node* ConsumeValue() V8_OVERRIDE;
329 }; 340 };
330 341
331 342
332 // Context to evaluate expression for its value (and side effects). 343 // Context to evaluate expression for its value (and side effects).
333 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { 344 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext {
334 public: 345 public:
335 explicit AstValueContext(AstGraphBuilder* owner, BailoutId bailout_id) 346 explicit AstValueContext(AstGraphBuilder* owner)
336 : AstContext(owner, Expression::kValue, bailout_id) {} 347 : AstContext(owner, Expression::kValue) {}
337 virtual ~AstValueContext(); 348 virtual ~AstValueContext();
338 virtual void ProduceValue(Node* value) V8_OVERRIDE; 349 virtual void ProduceValue(Node* value) V8_OVERRIDE;
339 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
340 virtual Node* ConsumeValue() V8_OVERRIDE; 350 virtual Node* ConsumeValue() V8_OVERRIDE;
341 }; 351 };
342 352
343 353
344 // Context to evaluate expression for a condition value (and side effects). 354 // Context to evaluate expression for a condition value (and side effects).
345 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { 355 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext {
346 public: 356 public:
347 explicit AstTestContext(AstGraphBuilder* owner, BailoutId bailout_id) 357 explicit AstTestContext(AstGraphBuilder* owner)
348 : AstContext(owner, Expression::kTest, bailout_id) {} 358 : AstContext(owner, Expression::kTest) {}
349 virtual ~AstTestContext(); 359 virtual ~AstTestContext();
350 virtual void ProduceValue(Node* value) V8_OVERRIDE; 360 virtual void ProduceValue(Node* value) V8_OVERRIDE;
351 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE;
352 virtual Node* ConsumeValue() V8_OVERRIDE; 361 virtual Node* ConsumeValue() V8_OVERRIDE;
353 }; 362 };
354 363
355 364
356 // Scoped class tracking breakable statements entered by the visitor. Allows to 365 // Scoped class tracking breakable statements entered by the visitor. Allows to
357 // properly 'break' and 'continue' iteration statements as well as to 'break' 366 // properly 'break' and 'continue' iteration statements as well as to 'break'
358 // from blocks within switch statements. 367 // from blocks within switch statements.
359 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { 368 class AstGraphBuilder::BreakableScope BASE_EMBEDDED {
360 public: 369 public:
361 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, 370 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 }; 428 };
420 429
421 Scope* AstGraphBuilder::current_scope() const { 430 Scope* AstGraphBuilder::current_scope() const {
422 return execution_context_->scope(); 431 return execution_context_->scope();
423 } 432 }
424 } 433 }
425 } 434 }
426 } // namespace v8::internal::compiler 435 } // namespace v8::internal::compiler
427 436
428 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ 437 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698