| 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_JSREGEXP_H_ | 28 #ifndef V8_JSREGEXP_H_ |
| 29 #define V8_JSREGEXP_H_ | 29 #define V8_JSREGEXP_H_ |
| 30 | 30 |
| 31 #include "allocation.h" |
| 31 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
| 32 #include "zone-inl.h" | 33 #include "zone-inl.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 | 38 |
| 38 class RegExpMacroAssembler; | 39 class RegExpMacroAssembler; |
| 39 | 40 |
| 40 | 41 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 169 } |
| 169 | 170 |
| 170 // For acting on the JSRegExp data FixedArray. | 171 // For acting on the JSRegExp data FixedArray. |
| 171 static int IrregexpMaxRegisterCount(FixedArray* re); | 172 static int IrregexpMaxRegisterCount(FixedArray* re); |
| 172 static void SetIrregexpMaxRegisterCount(FixedArray* re, int value); | 173 static void SetIrregexpMaxRegisterCount(FixedArray* re, int value); |
| 173 static int IrregexpNumberOfCaptures(FixedArray* re); | 174 static int IrregexpNumberOfCaptures(FixedArray* re); |
| 174 static int IrregexpNumberOfRegisters(FixedArray* re); | 175 static int IrregexpNumberOfRegisters(FixedArray* re); |
| 175 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii); | 176 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii); |
| 176 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii); | 177 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii); |
| 177 | 178 |
| 179 // Limit the space regexps take up on the heap. In order to limit this we |
| 180 // would like to keep track of the amount of regexp code on the heap. This |
| 181 // is not tracked, however. As a conservative approximation we track the |
| 182 // total regexp code compiled including code that has subsequently been freed |
| 183 // and the total executable memory at any point. |
| 184 static const int kRegExpExecutableMemoryLimit = 16 * MB; |
| 185 static const int kRegWxpCompiledLimit = 1 * MB; |
| 186 |
| 178 private: | 187 private: |
| 179 static String* last_ascii_string_; | 188 static String* last_ascii_string_; |
| 180 static String* two_byte_cached_string_; | 189 static String* two_byte_cached_string_; |
| 181 | 190 |
| 182 static bool CompileIrregexp(Handle<JSRegExp> re, bool is_ascii); | 191 static bool CompileIrregexp(Handle<JSRegExp> re, bool is_ascii); |
| 183 static inline bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii); | 192 static inline bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii); |
| 184 | 193 |
| 185 | 194 |
| 186 // Set the subject cache. The previous string buffer is not deleted, so the | 195 // Set the subject cache. The previous string buffer is not deleted, so the |
| 187 // caller should ensure that it doesn't leak. | 196 // caller should ensure that it doesn't leak. |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 int* vector_; | 1483 int* vector_; |
| 1475 int offsets_vector_length_; | 1484 int offsets_vector_length_; |
| 1476 | 1485 |
| 1477 friend class ExternalReference; | 1486 friend class ExternalReference; |
| 1478 }; | 1487 }; |
| 1479 | 1488 |
| 1480 | 1489 |
| 1481 } } // namespace v8::internal | 1490 } } // namespace v8::internal |
| 1482 | 1491 |
| 1483 #endif // V8_JSREGEXP_H_ | 1492 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |