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

Unified Diff: src/objects.h

Issue 10990076: Short term JSON eval cache Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/objects.cc » ('j') | src/v8.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
===================================================================
--- src/objects.h (revision 12582)
+++ src/objects.h (working copy)
@@ -79,6 +79,7 @@
// - Dictionary
// - SymbolTable
// - CompilationCacheTable
+// - ShortTermJSONEvalCacheTable
// - CodeCacheHashTable
// - MapCache
// - Context
@@ -850,6 +851,7 @@
V(JSFunctionResultCache) \
V(NormalizedMapCache) \
V(CompilationCacheTable) \
+ V(ShortTermJSONEvalCacheTable) \
V(CodeCacheHashTable) \
V(PolymorphicCodeCacheHashTable) \
V(MapCache) \
@@ -5719,6 +5721,10 @@
// Indicates that code for this function cannot be cached.
DECL_BOOLEAN_ACCESSORS(dont_cache)
+ // Indicates this is an eval function which just returns an object or array
+ // literal containing no outside information.
+ DECL_BOOLEAN_ACCESSORS(is_json_eval)
+
// Indicates whether or not the code in the shared function support
// deoptimization.
inline bool has_deoptimization_support();
@@ -5952,6 +5958,7 @@
kDontOptimize,
kDontInline,
kDontCache,
+ kIsJSONEval,
kCompilerHintsCount // Pseudo entry
};
@@ -6769,12 +6776,15 @@
Context* context,
Object* value);
MUST_USE_RESULT MaybeObject* PutEval(String* src,
- Context* context,
- SharedFunctionInfo* value,
- int scope_position);
+ Context* context,
+ SharedFunctionInfo* value,
+ int scope_position);
MUST_USE_RESULT MaybeObject* PutRegExp(String* src,
JSRegExp::Flags flags,
FixedArray* value);
+ MUST_USE_RESULT MaybeObject* PutRaw(Object* key,
+ SharedFunctionInfo* value,
+ HashTableKey* hasher);
// Remove given value from cache.
void Remove(Object* value);
@@ -6786,6 +6796,78 @@
};
+class ShortTermJSONEvalCacheShape : public BaseShape<HashTableKey*> {
+ public:
+ static inline bool IsMatch(HashTableKey* key, Object* value) {
+ return key->IsMatch(value);
+ }
+
+ static inline uint32_t Hash(HashTableKey* key) {
+ return key->Hash();
+ }
+
+ static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
+ return key->HashForObject(object);
+ }
+
+ MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
+ return key->AsObject();
+ }
+
+ // This is the prefix size in the HashTable class. We don't reference it
+ // directly because clang is picky about the order constants are defined.
+ static const int kPrefixStartIndex = 3;
+ static const int kTotalSourceSizeIndex = kPrefixStartIndex;
+ static const int kAgeIndex = kTotalSourceSizeIndex + 1;
+
+ static const int kPrefixSize = kAgeIndex - kPrefixStartIndex + 1;
+ static const int kEntrySize = 3;
+};
+
+
+class ShortTermJSONEvalCacheTable
+ : public HashTable<ShortTermJSONEvalCacheShape, HashTableKey*> {
+ public:
+ MUST_USE_RESULT static MaybeObject* Allocate();
+
+ // Returns the total code size of all entries
+ int total_source_size();
+
+ // Find a cached value, otherwise return undefined.
+ Object* Lookup(String* src);
+
+ // Attempt to add a new value to the cache. The size of the value (as given
+ // by ValueSize) must be at most kMaxTotalSourceSize. This may evict
+ // older elements to make room for the new element.
+ MUST_USE_RESULT MaybeObject* Put(String* src,
+ SharedFunctionInfo* value);
+
+ // Remove given value from cache.
+ void Remove(Object* value);
+
+ // Return the code size of a value. Values must be less than kMaxTotalCodeSize
+ // to be added to this cache.
+ static int ValueSize(SharedFunctionInfo* value);
+
+ static inline ShortTermJSONEvalCacheTable* cast(Object* obj);
+
+ static int max_entries();
+ static int max_total_source_size();
+
+ private:
+ void Reserve(int size);
+ void RemoveOldest();
+
+ void set_total_source_size(int size);
+
+ int current_age();
+ void set_current_age(int age);
+ Smi* NextAge();
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ShortTermJSONEvalCacheTable);
+};
+
+
class CodeCache: public Struct {
public:
DECL_ACCESSORS(default_cache, FixedArray)
« no previous file with comments | « src/flag-definitions.h ('k') | src/objects.cc » ('j') | src/v8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698