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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/flag-definitions.h ('k') | src/objects.cc » ('j') | src/v8.cc » ('J')
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // - JSProxy 72 // - JSProxy
73 // - JSFunctionProxy 73 // - JSFunctionProxy
74 // - FixedArrayBase 74 // - FixedArrayBase
75 // - ByteArray 75 // - ByteArray
76 // - FixedArray 76 // - FixedArray
77 // - DescriptorArray 77 // - DescriptorArray
78 // - HashTable 78 // - HashTable
79 // - Dictionary 79 // - Dictionary
80 // - SymbolTable 80 // - SymbolTable
81 // - CompilationCacheTable 81 // - CompilationCacheTable
82 // - ShortTermJSONEvalCacheTable
82 // - CodeCacheHashTable 83 // - CodeCacheHashTable
83 // - MapCache 84 // - MapCache
84 // - Context 85 // - Context
85 // - JSFunctionResultCache 86 // - JSFunctionResultCache
86 // - ScopeInfo 87 // - ScopeInfo
87 // - TransitionArray 88 // - TransitionArray
88 // - FixedDoubleArray 89 // - FixedDoubleArray
89 // - ExternalArray 90 // - ExternalArray
90 // - ExternalPixelArray 91 // - ExternalPixelArray
91 // - ExternalByteArray 92 // - ExternalByteArray
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 V(JSSet) \ 844 V(JSSet) \
844 V(JSMap) \ 845 V(JSMap) \
845 V(JSWeakMap) \ 846 V(JSWeakMap) \
846 V(JSRegExp) \ 847 V(JSRegExp) \
847 V(HashTable) \ 848 V(HashTable) \
848 V(Dictionary) \ 849 V(Dictionary) \
849 V(SymbolTable) \ 850 V(SymbolTable) \
850 V(JSFunctionResultCache) \ 851 V(JSFunctionResultCache) \
851 V(NormalizedMapCache) \ 852 V(NormalizedMapCache) \
852 V(CompilationCacheTable) \ 853 V(CompilationCacheTable) \
854 V(ShortTermJSONEvalCacheTable) \
853 V(CodeCacheHashTable) \ 855 V(CodeCacheHashTable) \
854 V(PolymorphicCodeCacheHashTable) \ 856 V(PolymorphicCodeCacheHashTable) \
855 V(MapCache) \ 857 V(MapCache) \
856 V(Primitive) \ 858 V(Primitive) \
857 V(GlobalObject) \ 859 V(GlobalObject) \
858 V(JSGlobalObject) \ 860 V(JSGlobalObject) \
859 V(JSBuiltinsObject) \ 861 V(JSBuiltinsObject) \
860 V(JSGlobalProxy) \ 862 V(JSGlobalProxy) \
861 V(UndetectableObject) \ 863 V(UndetectableObject) \
862 V(AccessCheckNeeded) \ 864 V(AccessCheckNeeded) \
(...skipping 4849 matching lines...) Expand 10 before | Expand all | Expand 10 after
5712 5714
5713 // Indicates that the function cannot be optimized. 5715 // Indicates that the function cannot be optimized.
5714 DECL_BOOLEAN_ACCESSORS(dont_optimize) 5716 DECL_BOOLEAN_ACCESSORS(dont_optimize)
5715 5717
5716 // Indicates that the function cannot be inlined. 5718 // Indicates that the function cannot be inlined.
5717 DECL_BOOLEAN_ACCESSORS(dont_inline) 5719 DECL_BOOLEAN_ACCESSORS(dont_inline)
5718 5720
5719 // Indicates that code for this function cannot be cached. 5721 // Indicates that code for this function cannot be cached.
5720 DECL_BOOLEAN_ACCESSORS(dont_cache) 5722 DECL_BOOLEAN_ACCESSORS(dont_cache)
5721 5723
5724 // Indicates this is an eval function which just returns an object or array
5725 // literal containing no outside information.
5726 DECL_BOOLEAN_ACCESSORS(is_json_eval)
5727
5722 // Indicates whether or not the code in the shared function support 5728 // Indicates whether or not the code in the shared function support
5723 // deoptimization. 5729 // deoptimization.
5724 inline bool has_deoptimization_support(); 5730 inline bool has_deoptimization_support();
5725 5731
5726 // Enable deoptimization support through recompiled code. 5732 // Enable deoptimization support through recompiled code.
5727 void EnableDeoptimizationSupport(Code* recompiled); 5733 void EnableDeoptimizationSupport(Code* recompiled);
5728 5734
5729 // Disable (further) attempted optimization of all functions sharing this 5735 // Disable (further) attempted optimization of all functions sharing this
5730 // shared function info. 5736 // shared function info.
5731 void DisableOptimization(const char* reason); 5737 void DisableOptimization(const char* reason);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
5945 kUsesArguments, 5951 kUsesArguments,
5946 kHasDuplicateParameters, 5952 kHasDuplicateParameters,
5947 kNative, 5953 kNative,
5948 kBoundFunction, 5954 kBoundFunction,
5949 kIsAnonymous, 5955 kIsAnonymous,
5950 kNameShouldPrintAsAnonymous, 5956 kNameShouldPrintAsAnonymous,
5951 kIsFunction, 5957 kIsFunction,
5952 kDontOptimize, 5958 kDontOptimize,
5953 kDontInline, 5959 kDontInline,
5954 kDontCache, 5960 kDontCache,
5961 kIsJSONEval,
5955 kCompilerHintsCount // Pseudo entry 5962 kCompilerHintsCount // Pseudo entry
5956 }; 5963 };
5957 5964
5958 class DeoptCountBits: public BitField<int, 0, 4> {}; 5965 class DeoptCountBits: public BitField<int, 0, 4> {};
5959 class OptReenableTriesBits: public BitField<int, 4, 18> {}; 5966 class OptReenableTriesBits: public BitField<int, 4, 18> {};
5960 class ICAgeBits: public BitField<int, 22, 8> {}; 5967 class ICAgeBits: public BitField<int, 22, 8> {};
5961 5968
5962 private: 5969 private:
5963 #if V8_HOST_ARCH_32_BIT 5970 #if V8_HOST_ARCH_32_BIT
5964 // On 32 bit platforms, compiler hints is a smi. 5971 // On 32 bit platforms, compiler hints is a smi.
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
6762 Object* Lookup(String* src, Context* context); 6769 Object* Lookup(String* src, Context* context);
6763 Object* LookupEval(String* src, 6770 Object* LookupEval(String* src,
6764 Context* context, 6771 Context* context,
6765 LanguageMode language_mode, 6772 LanguageMode language_mode,
6766 int scope_position); 6773 int scope_position);
6767 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 6774 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
6768 MUST_USE_RESULT MaybeObject* Put(String* src, 6775 MUST_USE_RESULT MaybeObject* Put(String* src,
6769 Context* context, 6776 Context* context,
6770 Object* value); 6777 Object* value);
6771 MUST_USE_RESULT MaybeObject* PutEval(String* src, 6778 MUST_USE_RESULT MaybeObject* PutEval(String* src,
6772 Context* context, 6779 Context* context,
6773 SharedFunctionInfo* value, 6780 SharedFunctionInfo* value,
6774 int scope_position); 6781 int scope_position);
6775 MUST_USE_RESULT MaybeObject* PutRegExp(String* src, 6782 MUST_USE_RESULT MaybeObject* PutRegExp(String* src,
6776 JSRegExp::Flags flags, 6783 JSRegExp::Flags flags,
6777 FixedArray* value); 6784 FixedArray* value);
6785 MUST_USE_RESULT MaybeObject* PutRaw(Object* key,
6786 SharedFunctionInfo* value,
6787 HashTableKey* hasher);
6778 6788
6779 // Remove given value from cache. 6789 // Remove given value from cache.
6780 void Remove(Object* value); 6790 void Remove(Object* value);
6781 6791
6782 static inline CompilationCacheTable* cast(Object* obj); 6792 static inline CompilationCacheTable* cast(Object* obj);
6783 6793
6784 private: 6794 private:
6785 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 6795 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
6786 }; 6796 };
6787 6797
6788 6798
6799 class ShortTermJSONEvalCacheShape : public BaseShape<HashTableKey*> {
6800 public:
6801 static inline bool IsMatch(HashTableKey* key, Object* value) {
6802 return key->IsMatch(value);
6803 }
6804
6805 static inline uint32_t Hash(HashTableKey* key) {
6806 return key->Hash();
6807 }
6808
6809 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
6810 return key->HashForObject(object);
6811 }
6812
6813 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
6814 return key->AsObject();
6815 }
6816
6817 // This is the prefix size in the HashTable class. We don't reference it
6818 // directly because clang is picky about the order constants are defined.
6819 static const int kPrefixStartIndex = 3;
6820 static const int kTotalSourceSizeIndex = kPrefixStartIndex;
6821 static const int kAgeIndex = kTotalSourceSizeIndex + 1;
6822
6823 static const int kPrefixSize = kAgeIndex - kPrefixStartIndex + 1;
6824 static const int kEntrySize = 3;
6825 };
6826
6827
6828 class ShortTermJSONEvalCacheTable
6829 : public HashTable<ShortTermJSONEvalCacheShape, HashTableKey*> {
6830 public:
6831 MUST_USE_RESULT static MaybeObject* Allocate();
6832
6833 // Returns the total code size of all entries
6834 int total_source_size();
6835
6836 // Find a cached value, otherwise return undefined.
6837 Object* Lookup(String* src);
6838
6839 // Attempt to add a new value to the cache. The size of the value (as given
6840 // by ValueSize) must be at most kMaxTotalSourceSize. This may evict
6841 // older elements to make room for the new element.
6842 MUST_USE_RESULT MaybeObject* Put(String* src,
6843 SharedFunctionInfo* value);
6844
6845 // Remove given value from cache.
6846 void Remove(Object* value);
6847
6848 // Return the code size of a value. Values must be less than kMaxTotalCodeSize
6849 // to be added to this cache.
6850 static int ValueSize(SharedFunctionInfo* value);
6851
6852 static inline ShortTermJSONEvalCacheTable* cast(Object* obj);
6853
6854 static int max_entries();
6855 static int max_total_source_size();
6856
6857 private:
6858 void Reserve(int size);
6859 void RemoveOldest();
6860
6861 void set_total_source_size(int size);
6862
6863 int current_age();
6864 void set_current_age(int age);
6865 Smi* NextAge();
6866
6867 DISALLOW_IMPLICIT_CONSTRUCTORS(ShortTermJSONEvalCacheTable);
6868 };
6869
6870
6789 class CodeCache: public Struct { 6871 class CodeCache: public Struct {
6790 public: 6872 public:
6791 DECL_ACCESSORS(default_cache, FixedArray) 6873 DECL_ACCESSORS(default_cache, FixedArray)
6792 DECL_ACCESSORS(normal_type_cache, Object) 6874 DECL_ACCESSORS(normal_type_cache, Object)
6793 6875
6794 // Add the code object to the cache. 6876 // Add the code object to the cache.
6795 MUST_USE_RESULT MaybeObject* Update(String* name, Code* code); 6877 MUST_USE_RESULT MaybeObject* Update(String* name, Code* code);
6796 6878
6797 // Lookup code object in the cache. Returns code object if found and undefined 6879 // Lookup code object in the cache. Returns code object if found and undefined
6798 // if not. 6880 // if not.
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
9019 } else { 9101 } else {
9020 value &= ~(1 << bit_position); 9102 value &= ~(1 << bit_position);
9021 } 9103 }
9022 return value; 9104 return value;
9023 } 9105 }
9024 }; 9106 };
9025 9107
9026 } } // namespace v8::internal 9108 } } // namespace v8::internal
9027 9109
9028 #endif // V8_OBJECTS_H_ 9110 #endif // V8_OBJECTS_H_
OLDNEW
« 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