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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "ast.h" | 30 #include "ast.h" |
31 #include "scopes.h" | 31 #include "scopes.h" |
32 #include "rewriter.h" | 32 #include "rewriter.h" |
33 | 33 |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 | |
38 class AstOptimizer: public AstVisitor { | 37 class AstOptimizer: public AstVisitor { |
39 public: | 38 public: |
40 explicit AstOptimizer() : has_function_literal_(false) {} | 39 explicit AstOptimizer() : has_function_literal_(false) {} |
41 | 40 |
42 void Optimize(ZoneList<Statement*>* statements); | 41 void Optimize(ZoneList<Statement*>* statements); |
43 | 42 |
44 private: | 43 private: |
45 // Used for loop condition analysis. Cleared before visiting a loop | 44 // Used for loop condition analysis. Cleared before visiting a loop |
46 // condition, set when a function literal is visited. | 45 // condition, set when a function literal is visited. |
47 bool has_function_literal_; | 46 bool has_function_literal_; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 default: | 428 default: |
430 UNREACHABLE(); | 429 UNREACHABLE(); |
431 break; | 430 break; |
432 } | 431 } |
433 } else if (node->op() == Token::BIT_NOT) { | 432 } else if (node->op() == Token::BIT_NOT) { |
434 node->expression()->set_to_int32(true); | 433 node->expression()->set_to_int32(true); |
435 } | 434 } |
436 } | 435 } |
437 | 436 |
438 | 437 |
| 438 void AstOptimizer::VisitIncrementOperation(IncrementOperation* node) { |
| 439 UNREACHABLE(); |
| 440 } |
| 441 |
| 442 |
439 void AstOptimizer::VisitCountOperation(CountOperation* node) { | 443 void AstOptimizer::VisitCountOperation(CountOperation* node) { |
440 // Count operations assume that they work on Smis. | 444 // Count operations assume that they work on Smis. |
441 node->expression()->set_no_negative_zero(node->is_prefix() ? | 445 node->expression()->set_no_negative_zero(node->is_prefix() ? |
442 true : | 446 true : |
443 node->no_negative_zero()); | 447 node->no_negative_zero()); |
444 node->type()->SetAsLikelySmiIfUnknown(); | 448 node->type()->SetAsLikelySmiIfUnknown(); |
445 node->expression()->type()->SetAsLikelySmiIfUnknown(); | 449 node->expression()->type()->SetAsLikelySmiIfUnknown(); |
446 Visit(node->expression()); | 450 Visit(node->expression()); |
447 } | 451 } |
448 | 452 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 UNREACHABLE(); | 944 UNREACHABLE(); |
941 } | 945 } |
942 | 946 |
943 | 947 |
944 void Processor::VisitUnaryOperation(UnaryOperation* node) { | 948 void Processor::VisitUnaryOperation(UnaryOperation* node) { |
945 USE(node); | 949 USE(node); |
946 UNREACHABLE(); | 950 UNREACHABLE(); |
947 } | 951 } |
948 | 952 |
949 | 953 |
| 954 void Processor::VisitIncrementOperation(IncrementOperation* node) { |
| 955 UNREACHABLE(); |
| 956 } |
| 957 |
| 958 |
950 void Processor::VisitCountOperation(CountOperation* node) { | 959 void Processor::VisitCountOperation(CountOperation* node) { |
951 USE(node); | 960 USE(node); |
952 UNREACHABLE(); | 961 UNREACHABLE(); |
953 } | 962 } |
954 | 963 |
955 | 964 |
956 void Processor::VisitBinaryOperation(BinaryOperation* node) { | 965 void Processor::VisitBinaryOperation(BinaryOperation* node) { |
957 USE(node); | 966 USE(node); |
958 UNREACHABLE(); | 967 UNREACHABLE(); |
959 } | 968 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 optimizer.Optimize(body); | 1013 optimizer.Optimize(body); |
1005 if (optimizer.HasStackOverflow()) { | 1014 if (optimizer.HasStackOverflow()) { |
1006 return false; | 1015 return false; |
1007 } | 1016 } |
1008 } | 1017 } |
1009 return true; | 1018 return true; |
1010 } | 1019 } |
1011 | 1020 |
1012 | 1021 |
1013 } } // namespace v8::internal | 1022 } } // namespace v8::internal |
OLD | NEW |