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