| 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/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 | 271 |
| 272 // Control scope implementation for a BreakableStatement. | 272 // Control scope implementation for a BreakableStatement. |
| 273 class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { | 273 class AstGraphBuilder::ControlScopeForBreakable : public ControlScope { |
| 274 public: | 274 public: |
| 275 ControlScopeForBreakable(AstGraphBuilder* owner, BreakableStatement* target, | 275 ControlScopeForBreakable(AstGraphBuilder* owner, BreakableStatement* target, |
| 276 ControlBuilder* control) | 276 ControlBuilder* control) |
| 277 : ControlScope(owner), target_(target), control_(control) {} | 277 : ControlScope(owner), target_(target), control_(control) {} |
| 278 | 278 |
| 279 protected: | 279 protected: |
| 280 virtual bool Execute(Command cmd, Statement* target, Node* value) override { | 280 bool Execute(Command cmd, Statement* target, Node* value) override { |
| 281 if (target != target_) return false; // We are not the command target. | 281 if (target != target_) return false; // We are not the command target. |
| 282 switch (cmd) { | 282 switch (cmd) { |
| 283 case CMD_BREAK: | 283 case CMD_BREAK: |
| 284 control_->Break(); | 284 control_->Break(); |
| 285 return true; | 285 return true; |
| 286 case CMD_CONTINUE: | 286 case CMD_CONTINUE: |
| 287 case CMD_THROW: | 287 case CMD_THROW: |
| 288 case CMD_RETURN: | 288 case CMD_RETURN: |
| 289 break; | 289 break; |
| 290 } | 290 } |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 private: | 294 private: |
| 295 BreakableStatement* target_; | 295 BreakableStatement* target_; |
| 296 ControlBuilder* control_; | 296 ControlBuilder* control_; |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 | 299 |
| 300 // Control scope implementation for an IterationStatement. | 300 // Control scope implementation for an IterationStatement. |
| 301 class AstGraphBuilder::ControlScopeForIteration : public ControlScope { | 301 class AstGraphBuilder::ControlScopeForIteration : public ControlScope { |
| 302 public: | 302 public: |
| 303 ControlScopeForIteration(AstGraphBuilder* owner, IterationStatement* target, | 303 ControlScopeForIteration(AstGraphBuilder* owner, IterationStatement* target, |
| 304 LoopBuilder* control) | 304 LoopBuilder* control) |
| 305 : ControlScope(owner), target_(target), control_(control) {} | 305 : ControlScope(owner), target_(target), control_(control) {} |
| 306 | 306 |
| 307 protected: | 307 protected: |
| 308 virtual bool Execute(Command cmd, Statement* target, Node* value) override { | 308 bool Execute(Command cmd, Statement* target, Node* value) override { |
| 309 if (target != target_) return false; // We are not the command target. | 309 if (target != target_) return false; // We are not the command target. |
| 310 switch (cmd) { | 310 switch (cmd) { |
| 311 case CMD_BREAK: | 311 case CMD_BREAK: |
| 312 control_->Break(); | 312 control_->Break(); |
| 313 return true; | 313 return true; |
| 314 case CMD_CONTINUE: | 314 case CMD_CONTINUE: |
| 315 control_->Continue(); | 315 control_->Continue(); |
| 316 return true; | 316 return true; |
| 317 case CMD_THROW: | 317 case CMD_THROW: |
| 318 case CMD_RETURN: | 318 case CMD_RETURN: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 334 : ControlScope(owner), control_(control) { | 334 : ControlScope(owner), control_(control) { |
| 335 builder()->try_nesting_level_++; // Increment nesting. | 335 builder()->try_nesting_level_++; // Increment nesting. |
| 336 builder()->try_catch_nesting_level_++; | 336 builder()->try_catch_nesting_level_++; |
| 337 } | 337 } |
| 338 ~ControlScopeForCatch() { | 338 ~ControlScopeForCatch() { |
| 339 builder()->try_nesting_level_--; // Decrement nesting. | 339 builder()->try_nesting_level_--; // Decrement nesting. |
| 340 builder()->try_catch_nesting_level_--; | 340 builder()->try_catch_nesting_level_--; |
| 341 } | 341 } |
| 342 | 342 |
| 343 protected: | 343 protected: |
| 344 virtual bool Execute(Command cmd, Statement* target, Node* value) override { | 344 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 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 3975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4361 // Phi does not exist yet, introduce one. | 4361 // Phi does not exist yet, introduce one. |
| 4362 value = NewPhi(inputs, value, control); | 4362 value = NewPhi(inputs, value, control); |
| 4363 value->ReplaceInput(inputs - 1, other); | 4363 value->ReplaceInput(inputs - 1, other); |
| 4364 } | 4364 } |
| 4365 return value; | 4365 return value; |
| 4366 } | 4366 } |
| 4367 | 4367 |
| 4368 } // namespace compiler | 4368 } // namespace compiler |
| 4369 } // namespace internal | 4369 } // namespace internal |
| 4370 } // namespace v8 | 4370 } // namespace v8 |
| OLD | NEW |