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

Side by Side Diff: src/heap.h

Issue 113343003: Remove the last remnants of the TranscendentalCache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years 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 | « src/codegen.h ('k') | src/heap.cc » ('j') | no next file with comments »
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 2876 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 static const int kRegExpResultsCacheSize = 0x100; 2887 static const int kRegExpResultsCacheSize = 0x100;
2888 2888
2889 private: 2889 private:
2890 static const int kArrayEntriesPerCacheEntry = 4; 2890 static const int kArrayEntriesPerCacheEntry = 4;
2891 static const int kStringOffset = 0; 2891 static const int kStringOffset = 0;
2892 static const int kPatternOffset = 1; 2892 static const int kPatternOffset = 1;
2893 static const int kArrayOffset = 2; 2893 static const int kArrayOffset = 2;
2894 }; 2894 };
2895 2895
2896 2896
2897 class TranscendentalCache {
2898 public:
2899 enum Type { LOG, kNumberOfCaches};
2900 static const int kTranscendentalTypeBits = 3;
2901 STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches);
2902
2903 // Returns a heap number with f(input), where f is a math function specified
2904 // by the 'type' argument.
2905 MUST_USE_RESULT inline MaybeObject* Get(Type type, double input);
2906
2907 // The cache contains raw Object pointers. This method disposes of
2908 // them before a garbage collection.
2909 void Clear();
2910
2911 private:
2912 class SubCache {
2913 static const int kCacheSize = 512;
2914
2915 explicit SubCache(Isolate* isolate, Type t);
2916
2917 MUST_USE_RESULT inline MaybeObject* Get(double input);
2918
2919 inline double Calculate(double input);
2920
2921 struct Element {
2922 uint32_t in[2];
2923 Object* output;
2924 };
2925
2926 union Converter {
2927 double dbl;
2928 uint32_t integers[2];
2929 };
2930
2931 inline static int Hash(const Converter& c) {
2932 uint32_t hash = (c.integers[0] ^ c.integers[1]);
2933 hash ^= static_cast<int32_t>(hash) >> 16;
2934 hash ^= static_cast<int32_t>(hash) >> 8;
2935 return (hash & (kCacheSize - 1));
2936 }
2937
2938 Element elements_[kCacheSize];
2939 Type type_;
2940 Isolate* isolate_;
2941
2942 // Allow access to the caches_ array as an ExternalReference.
2943 friend class ExternalReference;
2944 // Inline implementation of the cache.
2945 friend class TranscendentalCacheStub;
2946 // For evaluating value.
2947 friend class TranscendentalCache;
2948
2949 DISALLOW_COPY_AND_ASSIGN(SubCache);
2950 };
2951
2952 explicit TranscendentalCache(Isolate* isolate) : isolate_(isolate) {
2953 for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL;
2954 }
2955
2956 ~TranscendentalCache() {
2957 for (int i = 0; i < kNumberOfCaches; ++i) delete caches_[i];
2958 }
2959
2960 // Used to create an external reference.
2961 inline Address cache_array_address();
2962
2963 // Instantiation
2964 friend class Isolate;
2965 // Inline implementation of the caching.
2966 friend class TranscendentalCacheStub;
2967 // Allow access to the caches_ array as an ExternalReference.
2968 friend class ExternalReference;
2969
2970 Isolate* isolate_;
2971 SubCache* caches_[kNumberOfCaches];
2972 DISALLOW_COPY_AND_ASSIGN(TranscendentalCache);
2973 };
2974
2975
2976 // Abstract base class for checking whether a weak object should be retained. 2897 // Abstract base class for checking whether a weak object should be retained.
2977 class WeakObjectRetainer { 2898 class WeakObjectRetainer {
2978 public: 2899 public:
2979 virtual ~WeakObjectRetainer() {} 2900 virtual ~WeakObjectRetainer() {}
2980 2901
2981 // Return whether this object should be retained. If NULL is returned the 2902 // Return whether this object should be retained. If NULL is returned the
2982 // object has no references. Otherwise the address of the retained object 2903 // object has no references. Otherwise the address of the retained object
2983 // should be returned as in some GC situations the object has been moved. 2904 // should be returned as in some GC situations the object has been moved.
2984 virtual Object* RetainAs(Object* object) = 0; 2905 virtual Object* RetainAs(Object* object) = 0;
2985 }; 2906 };
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 3001 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
3081 3002
3082 private: 3003 private:
3083 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 3004 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
3084 }; 3005 };
3085 #endif // DEBUG 3006 #endif // DEBUG
3086 3007
3087 } } // namespace v8::internal 3008 } } // namespace v8::internal
3088 3009
3089 #endif // V8_HEAP_H_ 3010 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698