OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 30 matching lines...) Expand all Loading... |
41 namespace v8 { | 41 namespace v8 { |
42 namespace internal { | 42 namespace internal { |
43 | 43 |
44 | 44 |
45 class CodeGenSelector: public AstVisitor { | 45 class CodeGenSelector: public AstVisitor { |
46 public: | 46 public: |
47 enum CodeGenTag { NORMAL, FAST }; | 47 enum CodeGenTag { NORMAL, FAST }; |
48 | 48 |
49 CodeGenSelector() | 49 CodeGenSelector() |
50 : has_supported_syntax_(true), | 50 : has_supported_syntax_(true), |
51 location_(Location::Nowhere()) { | 51 location_(Location::Uninitialized()) { |
52 } | 52 } |
53 | 53 |
54 CodeGenTag Select(FunctionLiteral* fun); | 54 CodeGenTag Select(FunctionLiteral* fun); |
55 | 55 |
56 private: | 56 private: |
57 void VisitDeclarations(ZoneList<Declaration*>* decls); | 57 void VisitDeclarations(ZoneList<Declaration*>* decls); |
58 void VisitStatements(ZoneList<Statement*>* stmts); | 58 void VisitStatements(ZoneList<Statement*>* stmts); |
59 | 59 |
60 // Visit an expression in effect context with a desired location of | 60 // Visit an expression in effect context with a desired location of |
61 // nowhere. | 61 // nowhere. |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 507 |
508 void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) { | 508 void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) { |
509 for (int i = 0, len = stmts->length(); i < len; i++) { | 509 for (int i = 0, len = stmts->length(); i < len; i++) { |
510 Visit(stmts->at(i)); | 510 Visit(stmts->at(i)); |
511 CHECK_BAILOUT; | 511 CHECK_BAILOUT; |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 void CodeGenSelector::VisitAsEffect(Expression* expr) { | 516 void CodeGenSelector::VisitAsEffect(Expression* expr) { |
517 if (location_.is_nowhere()) { | 517 if (location_.is_effect()) { |
518 Visit(expr); | 518 Visit(expr); |
519 } else { | 519 } else { |
520 Location saved = location_; | 520 Location saved = location_; |
521 location_ = Location::Nowhere(); | 521 location_ = Location::Effect(); |
522 Visit(expr); | 522 Visit(expr); |
523 location_ = saved; | 523 location_ = saved; |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 | 527 |
528 void CodeGenSelector::VisitAsValue(Expression* expr) { | 528 void CodeGenSelector::VisitAsValue(Expression* expr) { |
529 if (location_.is_temporary()) { | 529 if (location_.is_value()) { |
530 Visit(expr); | 530 Visit(expr); |
531 } else { | 531 } else { |
532 Location saved = location_; | 532 Location saved = location_; |
533 location_ = Location::Temporary(); | 533 location_ = Location::Value(); |
534 Visit(expr); | 534 Visit(expr); |
535 location_ = saved; | 535 location_ = saved; |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 | 539 |
540 void CodeGenSelector::VisitDeclaration(Declaration* decl) { | 540 void CodeGenSelector::VisitDeclaration(Declaration* decl) { |
541 Variable* var = decl->proxy()->var(); | 541 Variable* var = decl->proxy()->var(); |
542 if (!var->is_global() || var->mode() == Variable::CONST) { | 542 if (!var->is_global() || var->mode() == Variable::CONST) { |
543 BAILOUT("Non-global declaration"); | 543 BAILOUT("Non-global declaration"); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 | 871 |
872 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { | 872 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { |
873 BAILOUT("ThisFunction"); | 873 BAILOUT("ThisFunction"); |
874 } | 874 } |
875 | 875 |
876 #undef BAILOUT | 876 #undef BAILOUT |
877 #undef CHECK_BAILOUT | 877 #undef CHECK_BAILOUT |
878 | 878 |
879 | 879 |
880 } } // namespace v8::internal | 880 } } // namespace v8::internal |
OLD | NEW |