OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_REGEXP_JSREGEXP_H_ | 5 #ifndef V8_REGEXP_JSREGEXP_H_ |
6 #define V8_REGEXP_JSREGEXP_H_ | 6 #define V8_REGEXP_JSREGEXP_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 | 10 |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 }; | 1659 }; |
1660 | 1660 |
1661 | 1661 |
1662 class RegExpResultsCache : public AllStatic { | 1662 class RegExpResultsCache : public AllStatic { |
1663 public: | 1663 public: |
1664 enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; | 1664 enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; |
1665 | 1665 |
1666 // Attempt to retrieve a cached result. On failure, 0 is returned as a Smi. | 1666 // Attempt to retrieve a cached result. On failure, 0 is returned as a Smi. |
1667 // On success, the returned result is guaranteed to be a COW-array. | 1667 // On success, the returned result is guaranteed to be a COW-array. |
1668 static Object* Lookup(Heap* heap, String* key_string, Object* key_pattern, | 1668 static Object* Lookup(Heap* heap, String* key_string, Object* key_pattern, |
1669 ResultsCacheType type); | 1669 FixedArray** last_match_out, ResultsCacheType type); |
1670 // Attempt to add value_array to the cache specified by type. On success, | 1670 // Attempt to add value_array to the cache specified by type. On success, |
1671 // value_array is turned into a COW-array. | 1671 // value_array is turned into a COW-array. |
1672 static void Enter(Isolate* isolate, Handle<String> key_string, | 1672 static void Enter(Isolate* isolate, Handle<String> key_string, |
1673 Handle<Object> key_pattern, Handle<FixedArray> value_array, | 1673 Handle<Object> key_pattern, Handle<FixedArray> value_array, |
1674 ResultsCacheType type); | 1674 Handle<FixedArray> last_match_cache, ResultsCacheType type); |
1675 static void Clear(FixedArray* cache); | 1675 static void Clear(FixedArray* cache); |
1676 static const int kRegExpResultsCacheSize = 0x100; | 1676 static const int kRegExpResultsCacheSize = 0x100; |
1677 | 1677 |
1678 private: | 1678 private: |
1679 static const int kArrayEntriesPerCacheEntry = 4; | 1679 static const int kArrayEntriesPerCacheEntry = 4; |
1680 static const int kStringOffset = 0; | 1680 static const int kStringOffset = 0; |
1681 static const int kPatternOffset = 1; | 1681 static const int kPatternOffset = 1; |
1682 static const int kArrayOffset = 2; | 1682 static const int kArrayOffset = 2; |
| 1683 static const int kLastMatchOffset = 3; |
1683 }; | 1684 }; |
1684 | 1685 |
1685 } // namespace internal | 1686 } // namespace internal |
1686 } // namespace v8 | 1687 } // namespace v8 |
1687 | 1688 |
1688 #endif // V8_REGEXP_JSREGEXP_H_ | 1689 #endif // V8_REGEXP_JSREGEXP_H_ |
OLD | NEW |