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/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/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #endif | 64 #endif |
65 | 65 |
66 private: | 66 private: |
67 Expression::Context kind_; | 67 Expression::Context kind_; |
68 AstGraphBuilder* owner_; | 68 AstGraphBuilder* owner_; |
69 AstContext* outer_; | 69 AstContext* outer_; |
70 }; | 70 }; |
71 | 71 |
72 | 72 |
73 // Context to evaluate expression for its side effects only. | 73 // Context to evaluate expression for its side effects only. |
74 class AstGraphBuilder::AstEffectContext FINAL : public AstContext { | 74 class AstGraphBuilder::AstEffectContext final : public AstContext { |
75 public: | 75 public: |
76 explicit AstEffectContext(AstGraphBuilder* owner) | 76 explicit AstEffectContext(AstGraphBuilder* owner) |
77 : AstContext(owner, Expression::kEffect) {} | 77 : AstContext(owner, Expression::kEffect) {} |
78 ~AstEffectContext() FINAL; | 78 ~AstEffectContext() final; |
79 void ProduceValue(Node* value) FINAL; | 79 void ProduceValue(Node* value) final; |
80 Node* ConsumeValue() FINAL; | 80 Node* ConsumeValue() final; |
81 }; | 81 }; |
82 | 82 |
83 | 83 |
84 // Context to evaluate expression for its value (and side effects). | 84 // Context to evaluate expression for its value (and side effects). |
85 class AstGraphBuilder::AstValueContext FINAL : public AstContext { | 85 class AstGraphBuilder::AstValueContext final : public AstContext { |
86 public: | 86 public: |
87 explicit AstValueContext(AstGraphBuilder* owner) | 87 explicit AstValueContext(AstGraphBuilder* owner) |
88 : AstContext(owner, Expression::kValue) {} | 88 : AstContext(owner, Expression::kValue) {} |
89 ~AstValueContext() FINAL; | 89 ~AstValueContext() final; |
90 void ProduceValue(Node* value) FINAL; | 90 void ProduceValue(Node* value) final; |
91 Node* ConsumeValue() FINAL; | 91 Node* ConsumeValue() final; |
92 }; | 92 }; |
93 | 93 |
94 | 94 |
95 // Context to evaluate expression for a condition value (and side effects). | 95 // Context to evaluate expression for a condition value (and side effects). |
96 class AstGraphBuilder::AstTestContext FINAL : public AstContext { | 96 class AstGraphBuilder::AstTestContext final : public AstContext { |
97 public: | 97 public: |
98 explicit AstTestContext(AstGraphBuilder* owner) | 98 explicit AstTestContext(AstGraphBuilder* owner) |
99 : AstContext(owner, Expression::kTest) {} | 99 : AstContext(owner, Expression::kTest) {} |
100 ~AstTestContext() FINAL; | 100 ~AstTestContext() final; |
101 void ProduceValue(Node* value) FINAL; | 101 void ProduceValue(Node* value) final; |
102 Node* ConsumeValue() FINAL; | 102 Node* ConsumeValue() final; |
103 }; | 103 }; |
104 | 104 |
105 | 105 |
106 // Scoped class tracking context objects created by the visitor. Represents | 106 // Scoped class tracking context objects created by the visitor. Represents |
107 // mutations of the context chain within the function body and allows to | 107 // mutations of the context chain within the function body and allows to |
108 // change the current {scope} and {context} during visitation. | 108 // change the current {scope} and {context} during visitation. |
109 class AstGraphBuilder::ContextScope BASE_EMBEDDED { | 109 class AstGraphBuilder::ContextScope BASE_EMBEDDED { |
110 public: | 110 public: |
111 ContextScope(AstGraphBuilder* builder, Scope* scope, Node* context) | 111 ContextScope(AstGraphBuilder* builder, Scope* scope, Node* context) |
112 : builder_(builder), | 112 : builder_(builder), |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 | 273 |
274 // Control scope implementation for a BreakableStatement. | 274 // Control scope implementation for a BreakableStatement. |
275 class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { | 275 class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { |
276 public: | 276 public: |
277 ControlScopeForBreakable(AstGraphBuilder* owner, BreakableStatement* target, | 277 ControlScopeForBreakable(AstGraphBuilder* owner, BreakableStatement* target, |
278 ControlBuilder* control) | 278 ControlBuilder* control) |
279 : ControlScope(owner), target_(target), control_(control) {} | 279 : ControlScope(owner), target_(target), control_(control) {} |
280 | 280 |
281 protected: | 281 protected: |
282 virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { | 282 virtual bool Execute(Command cmd, Statement* target, Node* value) override { |
283 if (target != target_) return false; // We are not the command target. | 283 if (target != target_) return false; // We are not the command target. |
284 switch (cmd) { | 284 switch (cmd) { |
285 case CMD_BREAK: | 285 case CMD_BREAK: |
286 control_->Break(); | 286 control_->Break(); |
287 return true; | 287 return true; |
288 case CMD_CONTINUE: | 288 case CMD_CONTINUE: |
289 case CMD_THROW: | 289 case CMD_THROW: |
290 case CMD_RETURN: | 290 case CMD_RETURN: |
291 break; | 291 break; |
292 } | 292 } |
293 return false; | 293 return false; |
294 } | 294 } |
295 | 295 |
296 private: | 296 private: |
297 BreakableStatement* target_; | 297 BreakableStatement* target_; |
298 ControlBuilder* control_; | 298 ControlBuilder* control_; |
299 }; | 299 }; |
300 | 300 |
301 | 301 |
302 // Control scope implementation for an IterationStatement. | 302 // Control scope implementation for an IterationStatement. |
303 class AstGraphBuilder::ControlScopeForIteration : public ControlScope { | 303 class AstGraphBuilder::ControlScopeForIteration : public ControlScope { |
304 public: | 304 public: |
305 ControlScopeForIteration(AstGraphBuilder* owner, IterationStatement* target, | 305 ControlScopeForIteration(AstGraphBuilder* owner, IterationStatement* target, |
306 LoopBuilder* control) | 306 LoopBuilder* control) |
307 : ControlScope(owner), target_(target), control_(control) {} | 307 : ControlScope(owner), target_(target), control_(control) {} |
308 | 308 |
309 protected: | 309 protected: |
310 virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { | 310 virtual bool Execute(Command cmd, Statement* target, Node* value) override { |
311 if (target != target_) return false; // We are not the command target. | 311 if (target != target_) return false; // We are not the command target. |
312 switch (cmd) { | 312 switch (cmd) { |
313 case CMD_BREAK: | 313 case CMD_BREAK: |
314 control_->Break(); | 314 control_->Break(); |
315 return true; | 315 return true; |
316 case CMD_CONTINUE: | 316 case CMD_CONTINUE: |
317 control_->Continue(); | 317 control_->Continue(); |
318 return true; | 318 return true; |
319 case CMD_THROW: | 319 case CMD_THROW: |
320 case CMD_RETURN: | 320 case CMD_RETURN: |
(...skipping 13 matching lines...) Expand all Loading... |
334 public: | 334 public: |
335 ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control) | 335 ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control) |
336 : ControlScope(owner), control_(control) { | 336 : ControlScope(owner), control_(control) { |
337 builder()->try_nesting_level_++; // Increment nesting. | 337 builder()->try_nesting_level_++; // Increment nesting. |
338 } | 338 } |
339 ~ControlScopeForCatch() { | 339 ~ControlScopeForCatch() { |
340 builder()->try_nesting_level_--; // Decrement nesting. | 340 builder()->try_nesting_level_--; // Decrement nesting. |
341 } | 341 } |
342 | 342 |
343 protected: | 343 protected: |
344 virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { | 344 virtual bool Execute(Command cmd, Statement* target, Node* value) override { |
345 switch (cmd) { | 345 switch (cmd) { |
346 case CMD_THROW: | 346 case CMD_THROW: |
347 control_->Throw(value); | 347 control_->Throw(value); |
348 return true; | 348 return true; |
349 case CMD_BREAK: | 349 case CMD_BREAK: |
350 case CMD_CONTINUE: | 350 case CMD_CONTINUE: |
351 case CMD_RETURN: | 351 case CMD_RETURN: |
352 break; | 352 break; |
353 } | 353 } |
354 return false; | 354 return false; |
(...skipping 10 matching lines...) Expand all Loading... |
365 ControlScopeForFinally(AstGraphBuilder* owner, DeferredCommands* commands, | 365 ControlScopeForFinally(AstGraphBuilder* owner, DeferredCommands* commands, |
366 TryFinallyBuilder* control) | 366 TryFinallyBuilder* control) |
367 : ControlScope(owner), commands_(commands), control_(control) { | 367 : ControlScope(owner), commands_(commands), control_(control) { |
368 builder()->try_nesting_level_++; // Increment nesting. | 368 builder()->try_nesting_level_++; // Increment nesting. |
369 } | 369 } |
370 ~ControlScopeForFinally() { | 370 ~ControlScopeForFinally() { |
371 builder()->try_nesting_level_--; // Decrement nesting. | 371 builder()->try_nesting_level_--; // Decrement nesting. |
372 } | 372 } |
373 | 373 |
374 protected: | 374 protected: |
375 virtual bool Execute(Command cmd, Statement* target, Node* value) OVERRIDE { | 375 virtual bool Execute(Command cmd, Statement* target, Node* value) override { |
376 Node* token = commands_->RecordCommand(cmd, target, value); | 376 Node* token = commands_->RecordCommand(cmd, target, value); |
377 control_->LeaveTry(token, value); | 377 control_->LeaveTry(token, value); |
378 return true; | 378 return true; |
379 } | 379 } |
380 | 380 |
381 private: | 381 private: |
382 DeferredCommands* commands_; | 382 DeferredCommands* commands_; |
383 TryFinallyBuilder* control_; | 383 TryFinallyBuilder* control_; |
384 }; | 384 }; |
385 | 385 |
(...skipping 3164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3550 // Phi does not exist yet, introduce one. | 3550 // Phi does not exist yet, introduce one. |
3551 value = NewPhi(inputs, value, control); | 3551 value = NewPhi(inputs, value, control); |
3552 value->ReplaceInput(inputs - 1, other); | 3552 value->ReplaceInput(inputs - 1, other); |
3553 } | 3553 } |
3554 return value; | 3554 return value; |
3555 } | 3555 } |
3556 | 3556 |
3557 } // namespace compiler | 3557 } // namespace compiler |
3558 } // namespace internal | 3558 } // namespace internal |
3559 } // namespace v8 | 3559 } // namespace v8 |
OLD | NEW |