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

Side by Side Diff: src/jsregexp.h

Issue 10380028: Limit recursion depth for gathering BoyerMoore info. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | test/mjsunit/regress/regress-126412.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 static int IrregexpNumberOfRegisters(FixedArray* re); 178 static int IrregexpNumberOfRegisters(FixedArray* re);
179 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii); 179 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii);
180 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii); 180 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii);
181 181
182 // Limit the space regexps take up on the heap. In order to limit this we 182 // Limit the space regexps take up on the heap. In order to limit this we
183 // would like to keep track of the amount of regexp code on the heap. This 183 // would like to keep track of the amount of regexp code on the heap. This
184 // is not tracked, however. As a conservative approximation we track the 184 // is not tracked, however. As a conservative approximation we track the
185 // total regexp code compiled including code that has subsequently been freed 185 // total regexp code compiled including code that has subsequently been freed
186 // and the total executable memory at any point. 186 // and the total executable memory at any point.
187 static const int kRegExpExecutableMemoryLimit = 16 * MB; 187 static const int kRegExpExecutableMemoryLimit = 16 * MB;
188 static const int kRegWxpCompiledLimit = 1 * MB; 188 static const int kRegExpCompiledLimit = 1 * MB;
189 189
190 private: 190 private:
191 static String* last_ascii_string_; 191 static String* last_ascii_string_;
192 static String* two_byte_cached_string_; 192 static String* two_byte_cached_string_;
193 193
194 static bool CompileIrregexp( 194 static bool CompileIrregexp(
195 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii); 195 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
196 static inline bool EnsureCompiledIrregexp( 196 static inline bool EnsureCompiledIrregexp(
197 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii); 197 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
198 198
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1229
1230 void SetAll(int map_number) { 1230 void SetAll(int map_number) {
1231 bitmaps_->at(map_number)->SetAll(); 1231 bitmaps_->at(map_number)->SetAll();
1232 } 1232 }
1233 1233
1234 void SetRest(int from_map) { 1234 void SetRest(int from_map) {
1235 for (int i = from_map; i < length_; i++) SetAll(i); 1235 for (int i = from_map; i < length_; i++) SetAll(i);
1236 } 1236 }
1237 bool EmitSkipInstructions(RegExpMacroAssembler* masm); 1237 bool EmitSkipInstructions(RegExpMacroAssembler* masm);
1238 1238
1239 bool MaxDepthExceeded() {
1240 return (++depth_ > kMaxFillInDepth);
1241 }
1242
1243 static const int kMaxFillInDepth = 1024;
1244
1239 private: 1245 private:
1240 // This is the value obtained by EatsAtLeast. If we do not have at least this 1246 // This is the value obtained by EatsAtLeast. If we do not have at least this
1241 // many characters left in the sample string then the match is bound to fail. 1247 // many characters left in the sample string then the match is bound to fail.
1242 // Therefore it is OK to read a character this far ahead of the current match 1248 // Therefore it is OK to read a character this far ahead of the current match
1243 // point. 1249 // point.
1244 int length_; 1250 int length_;
1245 RegExpCompiler* compiler_; 1251 RegExpCompiler* compiler_;
1252 int depth_;
1246 // 0x7f for ASCII, 0xffff for UTF-16. 1253 // 0x7f for ASCII, 0xffff for UTF-16.
1247 int max_char_; 1254 int max_char_;
1248 ZoneList<BoyerMoorePositionInfo*>* bitmaps_; 1255 ZoneList<BoyerMoorePositionInfo*>* bitmaps_;
1249 1256
1250 int GetSkipTable(int min_lookahead, 1257 int GetSkipTable(int min_lookahead,
1251 int max_lookahead, 1258 int max_lookahead,
1252 Handle<ByteArray> boolean_skip_table); 1259 Handle<ByteArray> boolean_skip_table);
1253 bool FindWorthwhileInterval(int* from, int* to); 1260 bool FindWorthwhileInterval(int* from, int* to);
1254 int FindBestInterval( 1261 int FindBestInterval(
1255 int max_number_of_chars, int old_biggest_points, int* from, int* to); 1262 int max_number_of_chars, int old_biggest_points, int* from, int* to);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 int* vector_; 1590 int* vector_;
1584 int offsets_vector_length_; 1591 int offsets_vector_length_;
1585 1592
1586 friend class ExternalReference; 1593 friend class ExternalReference;
1587 }; 1594 };
1588 1595
1589 1596
1590 } } // namespace v8::internal 1597 } } // namespace v8::internal
1591 1598
1592 #endif // V8_JSREGEXP_H_ 1599 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | test/mjsunit/regress/regress-126412.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698