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 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // Sub-cache for scripts. | 74 // Sub-cache for scripts. |
75 class CompilationCacheScript : public CompilationSubCache { | 75 class CompilationCacheScript : public CompilationSubCache { |
76 public: | 76 public: |
77 CompilationCacheScript(Isolate* isolate, int generations); | 77 CompilationCacheScript(Isolate* isolate, int generations); |
78 | 78 |
79 Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name, | 79 Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name, |
80 int line_offset, int column_offset, | 80 int line_offset, int column_offset, |
81 ScriptOriginOptions resource_options, | 81 ScriptOriginOptions resource_options, |
82 Handle<Context> context, | 82 Handle<Context> context, |
83 LanguageMode language_mode); | 83 LanguageMode language_mode, bool is_module); |
84 void Put(Handle<String> source, | 84 void Put(Handle<String> source, Handle<Context> context, |
85 Handle<Context> context, | 85 LanguageMode language_mode, bool is_module, |
86 LanguageMode language_mode, | |
87 Handle<SharedFunctionInfo> function_info); | 86 Handle<SharedFunctionInfo> function_info); |
88 | 87 |
89 private: | 88 private: |
90 bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name, | 89 bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name, |
91 int line_offset, int column_offset, | 90 int line_offset, int column_offset, |
92 ScriptOriginOptions resource_options); | 91 ScriptOriginOptions resource_options); |
93 | 92 |
94 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); | 93 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); |
95 }; | 94 }; |
96 | 95 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // the source string as the key. For regular expressions the | 145 // the source string as the key. For regular expressions the |
147 // compilation data is cached. | 146 // compilation data is cached. |
148 class CompilationCache { | 147 class CompilationCache { |
149 public: | 148 public: |
150 // Finds the script shared function info for a source | 149 // Finds the script shared function info for a source |
151 // string. Returns an empty handle if the cache doesn't contain a | 150 // string. Returns an empty handle if the cache doesn't contain a |
152 // script for the given source string with the right origin. | 151 // script for the given source string with the right origin. |
153 MaybeHandle<SharedFunctionInfo> LookupScript( | 152 MaybeHandle<SharedFunctionInfo> LookupScript( |
154 Handle<String> source, Handle<Object> name, int line_offset, | 153 Handle<String> source, Handle<Object> name, int line_offset, |
155 int column_offset, ScriptOriginOptions resource_options, | 154 int column_offset, ScriptOriginOptions resource_options, |
156 Handle<Context> context, LanguageMode language_mode); | 155 Handle<Context> context, LanguageMode language_mode, bool is_module); |
157 | 156 |
158 // Finds the shared function info for a source string for eval in a | 157 // Finds the shared function info for a source string for eval in a |
159 // given context. Returns an empty handle if the cache doesn't | 158 // given context. Returns an empty handle if the cache doesn't |
160 // contain a script for the given source string. | 159 // contain a script for the given source string. |
161 MaybeHandle<SharedFunctionInfo> LookupEval( | 160 MaybeHandle<SharedFunctionInfo> LookupEval( |
162 Handle<String> source, Handle<SharedFunctionInfo> outer_info, | 161 Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
163 Handle<Context> context, LanguageMode language_mode, int scope_position); | 162 Handle<Context> context, LanguageMode language_mode, int scope_position); |
164 | 163 |
165 // Returns the regexp data associated with the given regexp if it | 164 // Returns the regexp data associated with the given regexp if it |
166 // is in cache, otherwise an empty handle. | 165 // is in cache, otherwise an empty handle. |
167 MaybeHandle<FixedArray> LookupRegExp( | 166 MaybeHandle<FixedArray> LookupRegExp( |
168 Handle<String> source, JSRegExp::Flags flags); | 167 Handle<String> source, JSRegExp::Flags flags); |
169 | 168 |
170 // Associate the (source, kind) pair to the shared function | 169 // Associate the (source, kind) pair to the shared function |
171 // info. This may overwrite an existing mapping. | 170 // info. This may overwrite an existing mapping. |
172 void PutScript(Handle<String> source, | 171 void PutScript(Handle<String> source, Handle<Context> context, |
173 Handle<Context> context, | 172 LanguageMode language_mode, bool is_module, |
174 LanguageMode language_mode, | |
175 Handle<SharedFunctionInfo> function_info); | 173 Handle<SharedFunctionInfo> function_info); |
176 | 174 |
177 // Associate the (source, context->closure()->shared(), kind) triple | 175 // Associate the (source, context->closure()->shared(), kind) triple |
178 // with the shared function info. This may overwrite an existing mapping. | 176 // with the shared function info. This may overwrite an existing mapping. |
179 void PutEval(Handle<String> source, Handle<SharedFunctionInfo> outer_info, | 177 void PutEval(Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
180 Handle<Context> context, | 178 Handle<Context> context, |
181 Handle<SharedFunctionInfo> function_info, int scope_position); | 179 Handle<SharedFunctionInfo> function_info, int scope_position); |
182 | 180 |
183 // Associate the (source, flags) pair to the given regexp data. | 181 // Associate the (source, flags) pair to the given regexp data. |
184 // This may overwrite an existing mapping. | 182 // This may overwrite an existing mapping. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 friend class Isolate; | 231 friend class Isolate; |
234 | 232 |
235 DISALLOW_COPY_AND_ASSIGN(CompilationCache); | 233 DISALLOW_COPY_AND_ASSIGN(CompilationCache); |
236 }; | 234 }; |
237 | 235 |
238 | 236 |
239 } // namespace internal | 237 } // namespace internal |
240 } // namespace v8 | 238 } // namespace v8 |
241 | 239 |
242 #endif // V8_COMPILATION_CACHE_H_ | 240 #endif // V8_COMPILATION_CACHE_H_ |
OLD | NEW |