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