OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 bool allow_lazy = false) { | 611 bool allow_lazy = false) { |
612 Parser parser(info); | 612 Parser parser(info); |
613 parser.set_allow_lazy(allow_lazy); | 613 parser.set_allow_lazy(allow_lazy); |
614 return parser.Parse(); | 614 return parser.Parse(); |
615 } | 615 } |
616 bool Parse(); | 616 bool Parse(); |
617 | 617 |
618 private: | 618 private: |
619 friend class ParserTraits; | 619 friend class ParserTraits; |
620 | 620 |
621 static const int kMaxNumFunctionLocals = 131071; // 2^17-1 | 621 // Limit the allowed number of local variables in a function. The hard limit |
| 622 // is that offsets computed by FullCodeGenerator::StackOperand and similar |
| 623 // functions are ints, and they should not overflow. In addition, accessing |
| 624 // local variables creates user-controlled constants in the generated code, |
| 625 // and we don't want too much user-controlled memory inside the code (this was |
| 626 // the reason why this limit was introduced in the first place; see |
| 627 // https://codereview.chromium.org/7003030/ ). |
| 628 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
622 | 629 |
623 enum Mode { | 630 enum Mode { |
624 PARSE_LAZILY, | 631 PARSE_LAZILY, |
625 PARSE_EAGERLY | 632 PARSE_EAGERLY |
626 }; | 633 }; |
627 | 634 |
628 enum VariableDeclarationContext { | 635 enum VariableDeclarationContext { |
629 kModuleElement, | 636 kModuleElement, |
630 kBlockElement, | 637 kBlockElement, |
631 kStatement, | 638 kStatement, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 private: | 871 private: |
865 static const int kLiteralTypeSlot = 0; | 872 static const int kLiteralTypeSlot = 0; |
866 static const int kElementsSlot = 1; | 873 static const int kElementsSlot = 1; |
867 | 874 |
868 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 875 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
869 }; | 876 }; |
870 | 877 |
871 } } // namespace v8::internal | 878 } } // namespace v8::internal |
872 | 879 |
873 #endif // V8_PARSER_H_ | 880 #endif // V8_PARSER_H_ |
OLD | NEW |