| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 | 237 |
| 238 void AstOptimizer::VisitObjectLiteral(ObjectLiteral* node) { | 238 void AstOptimizer::VisitObjectLiteral(ObjectLiteral* node) { |
| 239 for (int i = 0; i < node->properties()->length(); i++) { | 239 for (int i = 0; i < node->properties()->length(); i++) { |
| 240 Visit(node->properties()->at(i)->key()); | 240 Visit(node->properties()->at(i)->key()); |
| 241 Visit(node->properties()->at(i)->value()); | 241 Visit(node->properties()->at(i)->value()); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 | 245 |
| 246 void AstOptimizer::VisitCatchExtensionObject(CatchExtensionObject* node) { |
| 247 Visit(node->key()); |
| 248 Visit(node->value()); |
| 249 } |
| 250 |
| 251 |
| 246 void AstOptimizer::VisitAssignment(Assignment* node) { | 252 void AstOptimizer::VisitAssignment(Assignment* node) { |
| 247 switch (node->op()) { | 253 switch (node->op()) { |
| 248 case Token::INIT_VAR: | 254 case Token::INIT_VAR: |
| 249 case Token::INIT_CONST: | 255 case Token::INIT_CONST: |
| 250 case Token::ASSIGN: | 256 case Token::ASSIGN: |
| 251 // No type can be infered from the general assignment. | 257 // No type can be infered from the general assignment. |
| 252 break; | 258 break; |
| 253 case Token::ASSIGN_BIT_OR: | 259 case Token::ASSIGN_BIT_OR: |
| 254 case Token::ASSIGN_BIT_XOR: | 260 case Token::ASSIGN_BIT_XOR: |
| 255 case Token::ASSIGN_BIT_AND: | 261 case Token::ASSIGN_BIT_AND: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 275 break; | 281 break; |
| 276 } | 282 } |
| 277 | 283 |
| 278 Visit(node->target()); | 284 Visit(node->target()); |
| 279 Visit(node->value()); | 285 Visit(node->value()); |
| 280 | 286 |
| 281 switch (node->op()) { | 287 switch (node->op()) { |
| 282 case Token::INIT_VAR: | 288 case Token::INIT_VAR: |
| 283 case Token::INIT_CONST: | 289 case Token::INIT_CONST: |
| 284 case Token::ASSIGN: | 290 case Token::ASSIGN: |
| 285 // Pure assigment copies the type from the value. | 291 // Pure assignment copies the type from the value. |
| 286 node->type()->CopyFrom(node->value()->type()); | 292 node->type()->CopyFrom(node->value()->type()); |
| 287 break; | 293 break; |
| 288 case Token::ASSIGN_BIT_OR: | 294 case Token::ASSIGN_BIT_OR: |
| 289 case Token::ASSIGN_BIT_XOR: | 295 case Token::ASSIGN_BIT_XOR: |
| 290 case Token::ASSIGN_BIT_AND: | 296 case Token::ASSIGN_BIT_AND: |
| 291 case Token::ASSIGN_SHL: | 297 case Token::ASSIGN_SHL: |
| 292 case Token::ASSIGN_SAR: | 298 case Token::ASSIGN_SAR: |
| 293 case Token::ASSIGN_SHR: | 299 case Token::ASSIGN_SHR: |
| 294 // Should have been setup above already. | 300 // Should have been setup above already. |
| 295 break; | 301 break; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 // After visiting the operand nodes we have to check if this node's type | 419 // After visiting the operand nodes we have to check if this node's type |
| 414 // can be updated. If it does, then we can push that information down | 420 // can be updated. If it does, then we can push that information down |
| 415 // towards the leafs again if the new information is an upgrade over the | 421 // towards the leafs again if the new information is an upgrade over the |
| 416 // previous type of the operand nodes. | 422 // previous type of the operand nodes. |
| 417 if (node->type()->IsUnknown()) { | 423 if (node->type()->IsUnknown()) { |
| 418 if (node->left()->type()->IsLikelySmi() || | 424 if (node->left()->type()->IsLikelySmi() || |
| 419 node->right()->type()->IsLikelySmi()) { | 425 node->right()->type()->IsLikelySmi()) { |
| 420 node->type()->SetAsLikelySmi(); | 426 node->type()->SetAsLikelySmi(); |
| 421 } | 427 } |
| 422 if (node->type()->IsLikelySmi()) { | 428 if (node->type()->IsLikelySmi()) { |
| 423 // The type of this node changed to LIKELY_SMI. Propagate this knowlege | 429 // The type of this node changed to LIKELY_SMI. Propagate this knowledge |
| 424 // down through the nodes. | 430 // down through the nodes. |
| 425 if (node->left()->type()->IsUnknown()) { | 431 if (node->left()->type()->IsUnknown()) { |
| 426 node->left()->type()->SetAsLikelySmi(); | 432 node->left()->type()->SetAsLikelySmi(); |
| 427 Visit(node->left()); | 433 Visit(node->left()); |
| 428 } | 434 } |
| 429 if (node->right()->type()->IsUnknown()) { | 435 if (node->right()->type()->IsUnknown()) { |
| 430 node->right()->type()->SetAsLikelySmi(); | 436 node->right()->type()->SetAsLikelySmi(); |
| 431 Visit(node->right()); | 437 Visit(node->right()); |
| 432 } | 438 } |
| 433 } | 439 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 448 // After visiting the operand nodes we have to check if this node's type | 454 // After visiting the operand nodes we have to check if this node's type |
| 449 // can be updated. If it does, then we can push that information down | 455 // can be updated. If it does, then we can push that information down |
| 450 // towards the leafs again if the new information is an upgrade over the | 456 // towards the leafs again if the new information is an upgrade over the |
| 451 // previous type of the operand nodes. | 457 // previous type of the operand nodes. |
| 452 if (node->type()->IsUnknown()) { | 458 if (node->type()->IsUnknown()) { |
| 453 if (node->left()->type()->IsLikelySmi() || | 459 if (node->left()->type()->IsLikelySmi() || |
| 454 node->right()->type()->IsLikelySmi()) { | 460 node->right()->type()->IsLikelySmi()) { |
| 455 node->type()->SetAsLikelySmi(); | 461 node->type()->SetAsLikelySmi(); |
| 456 } | 462 } |
| 457 if (node->type()->IsLikelySmi()) { | 463 if (node->type()->IsLikelySmi()) { |
| 458 // The type of this node changed to LIKELY_SMI. Propagate this knowlege | 464 // The type of this node changed to LIKELY_SMI. Propagate this knowledge |
| 459 // down through the nodes. | 465 // down through the nodes. |
| 460 if (node->left()->type()->IsUnknown()) { | 466 if (node->left()->type()->IsUnknown()) { |
| 461 node->left()->type()->SetAsLikelySmi(); | 467 node->left()->type()->SetAsLikelySmi(); |
| 462 Visit(node->left()); | 468 Visit(node->left()); |
| 463 } | 469 } |
| 464 if (node->right()->type()->IsUnknown()) { | 470 if (node->right()->type()->IsUnknown()) { |
| 465 node->right()->type()->SetAsLikelySmi(); | 471 node->right()->type()->SetAsLikelySmi(); |
| 466 Visit(node->right()); | 472 Visit(node->right()); |
| 467 } | 473 } |
| 468 } | 474 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 UNREACHABLE(); | 683 UNREACHABLE(); |
| 678 } | 684 } |
| 679 | 685 |
| 680 | 686 |
| 681 void Processor::VisitObjectLiteral(ObjectLiteral* node) { | 687 void Processor::VisitObjectLiteral(ObjectLiteral* node) { |
| 682 USE(node); | 688 USE(node); |
| 683 UNREACHABLE(); | 689 UNREACHABLE(); |
| 684 } | 690 } |
| 685 | 691 |
| 686 | 692 |
| 693 void Processor::VisitCatchExtensionObject(CatchExtensionObject* node) { |
| 694 USE(node); |
| 695 UNREACHABLE(); |
| 696 } |
| 697 |
| 698 |
| 687 void Processor::VisitAssignment(Assignment* node) { | 699 void Processor::VisitAssignment(Assignment* node) { |
| 688 USE(node); | 700 USE(node); |
| 689 UNREACHABLE(); | 701 UNREACHABLE(); |
| 690 } | 702 } |
| 691 | 703 |
| 692 | 704 |
| 693 void Processor::VisitThrow(Throw* node) { | 705 void Processor::VisitThrow(Throw* node) { |
| 694 USE(node); | 706 USE(node); |
| 695 UNREACHABLE(); | 707 UNREACHABLE(); |
| 696 } | 708 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 if (optimizer.HasStackOverflow()) { | 796 if (optimizer.HasStackOverflow()) { |
| 785 return false; | 797 return false; |
| 786 } | 798 } |
| 787 } | 799 } |
| 788 } | 800 } |
| 789 return true; | 801 return true; |
| 790 } | 802 } |
| 791 | 803 |
| 792 | 804 |
| 793 } } // namespace v8::internal | 805 } } // namespace v8::internal |
| OLD | NEW |