| 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_COMPILATION_CACHE_H_ | 5 #ifndef V8_COMPILATION_CACHE_H_ |
| 6 #define V8_COMPILATION_CACHE_H_ | 6 #define V8_COMPILATION_CACHE_H_ |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 | 69 |
| 70 // Sub-cache for scripts. | 70 // Sub-cache for scripts. |
| 71 class CompilationCacheScript : public CompilationSubCache { | 71 class CompilationCacheScript : public CompilationSubCache { |
| 72 public: | 72 public: |
| 73 CompilationCacheScript(Isolate* isolate, int generations); | 73 CompilationCacheScript(Isolate* isolate, int generations); |
| 74 | 74 |
| 75 Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name, | 75 Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name, |
| 76 int line_offset, int column_offset, | 76 int line_offset, int column_offset, |
| 77 bool is_embedder_debug_script, | 77 ScriptOriginOptions resource_options, |
| 78 bool is_shared_cross_origin, | |
| 79 Handle<Context> context, | 78 Handle<Context> context, |
| 80 LanguageMode language_mode); | 79 LanguageMode language_mode); |
| 81 void Put(Handle<String> source, | 80 void Put(Handle<String> source, |
| 82 Handle<Context> context, | 81 Handle<Context> context, |
| 83 LanguageMode language_mode, | 82 LanguageMode language_mode, |
| 84 Handle<SharedFunctionInfo> function_info); | 83 Handle<SharedFunctionInfo> function_info); |
| 85 | 84 |
| 86 private: | 85 private: |
| 87 bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name, | 86 bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name, |
| 88 int line_offset, int column_offset, | 87 int line_offset, int column_offset, |
| 89 bool is_embedder_debug_script, bool is_shared_cross_origin); | 88 ScriptOriginOptions resource_options); |
| 90 | 89 |
| 91 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); | 90 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); |
| 92 }; | 91 }; |
| 93 | 92 |
| 94 | 93 |
| 95 // Sub-cache for eval scripts. Two caches for eval are used. One for eval calls | 94 // Sub-cache for eval scripts. Two caches for eval are used. One for eval calls |
| 96 // in native contexts and one for eval calls in other contexts. The cache | 95 // in native contexts and one for eval calls in other contexts. The cache |
| 97 // considers the following pieces of information when checking for matching | 96 // considers the following pieces of information when checking for matching |
| 98 // entries: | 97 // entries: |
| 99 // 1. The source string. | 98 // 1. The source string. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // scripts and evals. The shared function infos are looked up using | 141 // scripts and evals. The shared function infos are looked up using |
| 143 // the source string as the key. For regular expressions the | 142 // the source string as the key. For regular expressions the |
| 144 // compilation data is cached. | 143 // compilation data is cached. |
| 145 class CompilationCache { | 144 class CompilationCache { |
| 146 public: | 145 public: |
| 147 // Finds the script shared function info for a source | 146 // Finds the script shared function info for a source |
| 148 // string. Returns an empty handle if the cache doesn't contain a | 147 // string. Returns an empty handle if the cache doesn't contain a |
| 149 // script for the given source string with the right origin. | 148 // script for the given source string with the right origin. |
| 150 MaybeHandle<SharedFunctionInfo> LookupScript( | 149 MaybeHandle<SharedFunctionInfo> LookupScript( |
| 151 Handle<String> source, Handle<Object> name, int line_offset, | 150 Handle<String> source, Handle<Object> name, int line_offset, |
| 152 int column_offset, bool is_embedder_debug_script, | 151 int column_offset, ScriptOriginOptions resource_options, |
| 153 bool is_shared_cross_origin, Handle<Context> context, | 152 Handle<Context> context, LanguageMode language_mode); |
| 154 LanguageMode language_mode); | |
| 155 | 153 |
| 156 // Finds the shared function info for a source string for eval in a | 154 // Finds the shared function info for a source string for eval in a |
| 157 // given context. Returns an empty handle if the cache doesn't | 155 // given context. Returns an empty handle if the cache doesn't |
| 158 // contain a script for the given source string. | 156 // contain a script for the given source string. |
| 159 MaybeHandle<SharedFunctionInfo> LookupEval( | 157 MaybeHandle<SharedFunctionInfo> LookupEval( |
| 160 Handle<String> source, Handle<SharedFunctionInfo> outer_info, | 158 Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
| 161 Handle<Context> context, LanguageMode language_mode, int scope_position); | 159 Handle<Context> context, LanguageMode language_mode, int scope_position); |
| 162 | 160 |
| 163 // Returns the regexp data associated with the given regexp if it | 161 // Returns the regexp data associated with the given regexp if it |
| 164 // is in cache, otherwise an empty handle. | 162 // is in cache, otherwise an empty handle. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 228 |
| 231 friend class Isolate; | 229 friend class Isolate; |
| 232 | 230 |
| 233 DISALLOW_COPY_AND_ASSIGN(CompilationCache); | 231 DISALLOW_COPY_AND_ASSIGN(CompilationCache); |
| 234 }; | 232 }; |
| 235 | 233 |
| 236 | 234 |
| 237 } } // namespace v8::internal | 235 } } // namespace v8::internal |
| 238 | 236 |
| 239 #endif // V8_COMPILATION_CACHE_H_ | 237 #endif // V8_COMPILATION_CACHE_H_ |
| OLD | NEW |