OLD | NEW |
---|---|
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
Jakob Kummerow
2011/11/10 11:53:23
2011
Steven
2011/11/14 08:57:21
Done.
| |
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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 int line_offset, | 116 int line_offset, |
117 int column_offset); | 117 int column_offset); |
118 | 118 |
119 void* script_histogram_; | 119 void* script_histogram_; |
120 bool script_histogram_initialized_; | 120 bool script_histogram_initialized_; |
121 | 121 |
122 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); |
123 }; | 123 }; |
124 | 124 |
125 | 125 |
126 // Sub-cache for eval scripts. | 126 // Sub-cache for eval scripts. Two caches for eval are used. One for eval calls |
127 // in global contexts and one for eval calls in other contexts. The cache | |
128 // considers the following pieces of information when checking for matching | |
129 // entries: | |
130 // 1. The source string. | |
131 // 2. The shared function info of the calling function. | |
132 // 3. Whether the source should be compiled as strict code or as non-strict | |
133 // code. | |
134 // Note: Currently there are clients of CompileEval that always compile | |
135 // non-strict code even if the calling function is a strict mode function. | |
136 // More specifically these are the CompileString, DebugEvaluate and | |
137 // DebugEvaluateGlobal runtime functions. | |
138 // 4. The start position of the calling scope. | |
127 class CompilationCacheEval: public CompilationSubCache { | 139 class CompilationCacheEval: public CompilationSubCache { |
128 public: | 140 public: |
129 CompilationCacheEval(Isolate* isolate, int generations) | 141 CompilationCacheEval(Isolate* isolate, int generations) |
130 : CompilationSubCache(isolate, generations) { } | 142 : CompilationSubCache(isolate, generations) { } |
131 | 143 |
132 Handle<SharedFunctionInfo> Lookup(Handle<String> source, | 144 Handle<SharedFunctionInfo> Lookup(Handle<String> source, |
133 Handle<Context> context, | 145 Handle<Context> context, |
134 StrictModeFlag strict_mode); | 146 StrictModeFlag strict_mode, |
147 int scope_position); | |
135 | 148 |
136 void Put(Handle<String> source, | 149 void Put(Handle<String> source, |
137 Handle<Context> context, | 150 Handle<Context> context, |
138 Handle<SharedFunctionInfo> function_info); | 151 Handle<SharedFunctionInfo> function_info, |
152 int scope_position); | |
139 | 153 |
140 private: | 154 private: |
141 MUST_USE_RESULT MaybeObject* TryTablePut( | 155 MUST_USE_RESULT MaybeObject* TryTablePut( |
142 Handle<String> source, | 156 Handle<String> source, |
143 Handle<Context> context, | 157 Handle<Context> context, |
144 Handle<SharedFunctionInfo> function_info); | 158 Handle<SharedFunctionInfo> function_info, |
159 int scope_position); | |
145 | 160 |
146 // Note: Returns a new hash table if operation results in expansion. | 161 // Note: Returns a new hash table if operation results in expansion. |
147 Handle<CompilationCacheTable> TablePut( | 162 Handle<CompilationCacheTable> TablePut( |
148 Handle<String> source, | 163 Handle<String> source, |
149 Handle<Context> context, | 164 Handle<Context> context, |
150 Handle<SharedFunctionInfo> function_info); | 165 Handle<SharedFunctionInfo> function_info, |
166 int scope_position); | |
151 | 167 |
152 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval); | 168 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval); |
153 }; | 169 }; |
154 | 170 |
155 | 171 |
156 // Sub-cache for regular expressions. | 172 // Sub-cache for regular expressions. |
157 class CompilationCacheRegExp: public CompilationSubCache { | 173 class CompilationCacheRegExp: public CompilationSubCache { |
158 public: | 174 public: |
159 CompilationCacheRegExp(Isolate* isolate, int generations) | 175 CompilationCacheRegExp(Isolate* isolate, int generations) |
160 : CompilationSubCache(isolate, generations) { } | 176 : CompilationSubCache(isolate, generations) { } |
(...skipping 30 matching lines...) Expand all Loading... | |
191 Handle<Object> name, | 207 Handle<Object> name, |
192 int line_offset, | 208 int line_offset, |
193 int column_offset); | 209 int column_offset); |
194 | 210 |
195 // Finds the shared function info for a source string for eval in a | 211 // Finds the shared function info for a source string for eval in a |
196 // given context. Returns an empty handle if the cache doesn't | 212 // given context. Returns an empty handle if the cache doesn't |
197 // contain a script for the given source string. | 213 // contain a script for the given source string. |
198 Handle<SharedFunctionInfo> LookupEval(Handle<String> source, | 214 Handle<SharedFunctionInfo> LookupEval(Handle<String> source, |
199 Handle<Context> context, | 215 Handle<Context> context, |
200 bool is_global, | 216 bool is_global, |
201 StrictModeFlag strict_mode); | 217 StrictModeFlag strict_mode, |
218 int scope_position); | |
202 | 219 |
203 // Returns the regexp data associated with the given regexp if it | 220 // Returns the regexp data associated with the given regexp if it |
204 // is in cache, otherwise an empty handle. | 221 // is in cache, otherwise an empty handle. |
205 Handle<FixedArray> LookupRegExp(Handle<String> source, | 222 Handle<FixedArray> LookupRegExp(Handle<String> source, |
206 JSRegExp::Flags flags); | 223 JSRegExp::Flags flags); |
207 | 224 |
208 // Associate the (source, kind) pair to the shared function | 225 // Associate the (source, kind) pair to the shared function |
209 // info. This may overwrite an existing mapping. | 226 // info. This may overwrite an existing mapping. |
210 void PutScript(Handle<String> source, | 227 void PutScript(Handle<String> source, |
211 Handle<SharedFunctionInfo> function_info); | 228 Handle<SharedFunctionInfo> function_info); |
212 | 229 |
213 // Associate the (source, context->closure()->shared(), kind) triple | 230 // Associate the (source, context->closure()->shared(), kind) triple |
214 // with the shared function info. This may overwrite an existing mapping. | 231 // with the shared function info. This may overwrite an existing mapping. |
215 void PutEval(Handle<String> source, | 232 void PutEval(Handle<String> source, |
216 Handle<Context> context, | 233 Handle<Context> context, |
217 bool is_global, | 234 bool is_global, |
218 Handle<SharedFunctionInfo> function_info); | 235 Handle<SharedFunctionInfo> function_info, |
236 int scope_position); | |
219 | 237 |
220 // Associate the (source, flags) pair to the given regexp data. | 238 // Associate the (source, flags) pair to the given regexp data. |
221 // This may overwrite an existing mapping. | 239 // This may overwrite an existing mapping. |
222 void PutRegExp(Handle<String> source, | 240 void PutRegExp(Handle<String> source, |
223 JSRegExp::Flags flags, | 241 JSRegExp::Flags flags, |
224 Handle<FixedArray> data); | 242 Handle<FixedArray> data); |
225 | 243 |
226 // Clear the cache - also used to initialize the cache at startup. | 244 // Clear the cache - also used to initialize the cache at startup. |
227 void Clear(); | 245 void Clear(); |
228 | 246 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 | 287 |
270 friend class Isolate; | 288 friend class Isolate; |
271 | 289 |
272 DISALLOW_COPY_AND_ASSIGN(CompilationCache); | 290 DISALLOW_COPY_AND_ASSIGN(CompilationCache); |
273 }; | 291 }; |
274 | 292 |
275 | 293 |
276 } } // namespace v8::internal | 294 } } // namespace v8::internal |
277 | 295 |
278 #endif // V8_COMPILATION_CACHE_H_ | 296 #endif // V8_COMPILATION_CACHE_H_ |
OLD | NEW |