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_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 }; | 2636 }; |
2637 | 2637 |
2638 Key keys_[kLength]; | 2638 Key keys_[kLength]; |
2639 int results_[kLength]; | 2639 int results_[kLength]; |
2640 | 2640 |
2641 friend class Isolate; | 2641 friend class Isolate; |
2642 DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache); | 2642 DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache); |
2643 }; | 2643 }; |
2644 | 2644 |
2645 | 2645 |
2646 class RegExpResultsCache { | |
2647 public: | |
2648 enum ResultsCacheType { REGEXP_MULTIPLE_INDICES, STRING_SPLIT_SUBSTRINGS }; | |
2649 | |
2650 // Attempt to retrieve a cached result. On failure, 0 is returned as a Smi. | |
2651 // On success, the returned result is guaranteed to be a COW-array. | |
2652 static Object* Lookup(Heap* heap, String* key_string, Object* key_pattern, | |
2653 ResultsCacheType type); | |
2654 // Attempt to add value_array to the cache specified by type. On success, | |
2655 // value_array is turned into a COW-array. | |
2656 static void Enter(Isolate* isolate, Handle<String> key_string, | |
2657 Handle<Object> key_pattern, Handle<FixedArray> value_array, | |
2658 ResultsCacheType type); | |
2659 static void Clear(FixedArray* cache); | |
2660 static const int kRegExpResultsCacheSize = 0x100; | |
2661 | |
2662 private: | |
2663 static const int kArrayEntriesPerCacheEntry = 4; | |
2664 static const int kStringOffset = 0; | |
2665 static const int kPatternOffset = 1; | |
2666 static const int kArrayOffset = 2; | |
2667 }; | |
2668 | |
2669 | |
2670 // Abstract base class for checking whether a weak object should be retained. | 2646 // Abstract base class for checking whether a weak object should be retained. |
2671 class WeakObjectRetainer { | 2647 class WeakObjectRetainer { |
2672 public: | 2648 public: |
2673 virtual ~WeakObjectRetainer() {} | 2649 virtual ~WeakObjectRetainer() {} |
2674 | 2650 |
2675 // Return whether this object should be retained. If NULL is returned the | 2651 // Return whether this object should be retained. If NULL is returned the |
2676 // object has no references. Otherwise the address of the retained object | 2652 // object has no references. Otherwise the address of the retained object |
2677 // should be returned as in some GC situations the object has been moved. | 2653 // should be returned as in some GC situations the object has been moved. |
2678 virtual Object* RetainAs(Object* object) = 0; | 2654 virtual Object* RetainAs(Object* object) = 0; |
2679 }; | 2655 }; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2733 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2709 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2734 | 2710 |
2735 private: | 2711 private: |
2736 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2712 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2737 }; | 2713 }; |
2738 #endif // DEBUG | 2714 #endif // DEBUG |
2739 } | 2715 } |
2740 } // namespace v8::internal | 2716 } // namespace v8::internal |
2741 | 2717 |
2742 #endif // V8_HEAP_HEAP_H_ | 2718 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |