Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/preparser.cc

Issue 6311005: Don't lazily compile functions that are immediately receded by '('. (Closed)
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
1 // Copyright 2010 the V8 project authors. All rights reserved. 2 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
4 // met: 5 // met:
5 // 6 //
6 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 11 // disclaimer in the documentation and/or other materials provided
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 case i::Token::LBRACK: 888 case i::Token::LBRACK:
888 result = ParseArrayLiteral(CHECK_OK); 889 result = ParseArrayLiteral(CHECK_OK);
889 break; 890 break;
890 891
891 case i::Token::LBRACE: 892 case i::Token::LBRACE:
892 result = ParseObjectLiteral(CHECK_OK); 893 result = ParseObjectLiteral(CHECK_OK);
893 break; 894 break;
894 895
895 case i::Token::LPAREN: 896 case i::Token::LPAREN:
896 Consume(i::Token::LPAREN); 897 Consume(i::Token::LPAREN);
898 parenthesized_function_ = (peek() == i::Token::FUNCTION);
897 result = ParseExpression(true, CHECK_OK); 899 result = ParseExpression(true, CHECK_OK);
898 Expect(i::Token::RPAREN, CHECK_OK); 900 Expect(i::Token::RPAREN, CHECK_OK);
899 if (result == kIdentifierExpression) result = kUnknownExpression; 901 if (result == kIdentifierExpression) result = kUnknownExpression;
900 break; 902 break;
901 903
902 case i::Token::MOD: 904 case i::Token::MOD:
903 result = ParseV8Intrinsic(CHECK_OK); 905 result = ParseV8Intrinsic(CHECK_OK);
904 break; 906 break;
905 907
906 default: { 908 default: {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1066 }
1065 } 1067 }
1066 Expect(i::Token::RPAREN, CHECK_OK); 1068 Expect(i::Token::RPAREN, CHECK_OK);
1067 1069
1068 Expect(i::Token::LBRACE, CHECK_OK); 1070 Expect(i::Token::LBRACE, CHECK_OK);
1069 int function_block_pos = scanner_->location().beg_pos; 1071 int function_block_pos = scanner_->location().beg_pos;
1070 1072
1071 // Determine if the function will be lazily compiled. 1073 // Determine if the function will be lazily compiled.
1072 // Currently only happens to top-level functions. 1074 // Currently only happens to top-level functions.
1073 // Optimistically assume that all top-level functions are lazily compiled. 1075 // Optimistically assume that all top-level functions are lazily compiled.
1074 bool is_lazily_compiled = 1076 bool is_lazily_compiled = (outer_scope_type == kTopLevelScope &&
1075 (outer_scope_type == kTopLevelScope && !inside_with && allow_lazy_); 1077 !inside_with && allow_lazy_ &&
1078 !parenthesized_function_);
1079 parenthesized_function_ = false;
1076 1080
1077 if (is_lazily_compiled) { 1081 if (is_lazily_compiled) {
1078 log_->PauseRecording(); 1082 log_->PauseRecording();
1079 ParseSourceElements(i::Token::RBRACE, ok); 1083 ParseSourceElements(i::Token::RBRACE, ok);
1080 log_->ResumeRecording(); 1084 log_->ResumeRecording();
1081 if (!*ok) return kUnknownExpression; 1085 if (!*ok) return kUnknownExpression;
1082 1086
1083 Expect(i::Token::RBRACE, CHECK_OK); 1087 Expect(i::Token::RBRACE, CHECK_OK);
1084 1088
1085 // Position right after terminal '}'. 1089 // Position right after terminal '}'.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 if (scanner_->is_literal_ascii() && scanner_->literal_length() == 3) { 1185 if (scanner_->is_literal_ascii() && scanner_->literal_length() == 3) {
1182 const char* token = scanner_->literal_ascii_string().start(); 1186 const char* token = scanner_->literal_ascii_string().start();
1183 *is_get = strncmp(token, "get", 3) == 0; 1187 *is_get = strncmp(token, "get", 3) == 0;
1184 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 1188 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1185 } 1189 }
1186 return GetIdentifierSymbol(); 1190 return GetIdentifierSymbol();
1187 } 1191 }
1188 1192
1189 #undef CHECK_OK 1193 #undef CHECK_OK
1190 } } // v8::preparser 1194 } } // v8::preparser
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698