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

Side by Side Diff: src/objects.h

Issue 675013004: Changing the aging mechanism for script and eval caches. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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/compilation-cache.cc ('k') | src/objects.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 // 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_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 7919 matching lines...) Expand 10 before | Expand all | Expand 10 after
7930 return key->HashForObject(object); 7930 return key->HashForObject(object);
7931 } 7931 }
7932 7932
7933 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); 7933 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key);
7934 7934
7935 static const int kPrefixSize = 0; 7935 static const int kPrefixSize = 0;
7936 static const int kEntrySize = 2; 7936 static const int kEntrySize = 2;
7937 }; 7937 };
7938 7938
7939 7939
7940 // This cache is used in two different variants. For regexp caching, it simply
7941 // maps identifying info of the regexp to the cached regexp object. Scripts and
7942 // eval code only gets cached after a second probe for the code object. To do
7943 // so, on first "put" only a hash identifying the source is entered into the
7944 // cache, mapping it to a lifetime count of the hash. On each call to Age all
7945 // such lifetimes get reduced, and removed once they reach zero. If a second put
7946 // is called while such a hash is live in the cache, the hash gets replaced by
7947 // an actual cache entry. Age also removes stale live entries from the cache.
7948 // Such entries are identified by SharedFunctionInfos pointing to either the
7949 // recompilation stub, or to "old" code. This avoids memory leaks due to
7950 // premature caching of scripts and eval strings that are never needed later.
7940 class CompilationCacheTable: public HashTable<CompilationCacheTable, 7951 class CompilationCacheTable: public HashTable<CompilationCacheTable,
7941 CompilationCacheShape, 7952 CompilationCacheShape,
7942 HashTableKey*> { 7953 HashTableKey*> {
7943 public: 7954 public:
7944 // Find cached value for a string key, otherwise return null. 7955 // Find cached value for a string key, otherwise return null.
7945 Handle<Object> Lookup(Handle<String> src, Handle<Context> context); 7956 Handle<Object> Lookup(Handle<String> src, Handle<Context> context);
7946 Handle<Object> LookupEval(Handle<String> src, 7957 Handle<Object> LookupEval(Handle<String> src,
7947 Handle<SharedFunctionInfo> shared, 7958 Handle<SharedFunctionInfo> shared,
7948 StrictMode strict_mode, int scope_position); 7959 StrictMode strict_mode, int scope_position);
7949 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); 7960 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags);
7950 static Handle<CompilationCacheTable> Put( 7961 static Handle<CompilationCacheTable> Put(
7951 Handle<CompilationCacheTable> cache, Handle<String> src, 7962 Handle<CompilationCacheTable> cache, Handle<String> src,
7952 Handle<Context> context, Handle<Object> value); 7963 Handle<Context> context, Handle<Object> value);
7953 static Handle<CompilationCacheTable> PutEval( 7964 static Handle<CompilationCacheTable> PutEval(
7954 Handle<CompilationCacheTable> cache, Handle<String> src, 7965 Handle<CompilationCacheTable> cache, Handle<String> src,
7955 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, 7966 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value,
7956 int scope_position); 7967 int scope_position);
7957 static Handle<CompilationCacheTable> PutRegExp( 7968 static Handle<CompilationCacheTable> PutRegExp(
7958 Handle<CompilationCacheTable> cache, Handle<String> src, 7969 Handle<CompilationCacheTable> cache, Handle<String> src,
7959 JSRegExp::Flags flags, Handle<FixedArray> value); 7970 JSRegExp::Flags flags, Handle<FixedArray> value);
7960 void Remove(Object* value); 7971 void Remove(Object* value);
7972 void Age();
7973 static const int kHashGenerations = 10;
7961 7974
7962 DECLARE_CAST(CompilationCacheTable) 7975 DECLARE_CAST(CompilationCacheTable)
7963 7976
7964 private: 7977 private:
7965 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 7978 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
7966 }; 7979 };
7967 7980
7968 7981
7969 class CodeCache: public Struct { 7982 class CodeCache: public Struct {
7970 public: 7983 public:
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
10909 } else { 10922 } else {
10910 value &= ~(1 << bit_position); 10923 value &= ~(1 << bit_position);
10911 } 10924 }
10912 return value; 10925 return value;
10913 } 10926 }
10914 }; 10927 };
10915 10928
10916 } } // namespace v8::internal 10929 } } // namespace v8::internal
10917 10930
10918 #endif // V8_OBJECTS_H_ 10931 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698