OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
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 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 // Compile the function and add it to the cache. | 205 // Compile the function and add it to the cache. |
206 result = MakeFunction(true, | 206 result = MakeFunction(true, |
207 false, | 207 false, |
208 script, | 208 script, |
209 Handle<Context>::null(), | 209 Handle<Context>::null(), |
210 extension, | 210 extension, |
211 pre_data); | 211 pre_data); |
212 if (extension == NULL && !result.is_null()) { | 212 if (extension == NULL && !result.is_null()) { |
213 CompilationCache::PutFunction(source, CompilationCache::SCRIPT, result); | 213 CompilationCache::PutScript(source, CompilationCache::SCRIPT, result); |
214 } | 214 } |
215 | 215 |
216 // Get rid of the pre-parsing data (if necessary). | 216 // Get rid of the pre-parsing data (if necessary). |
217 if (input_pre_data == NULL && pre_data != NULL) { | 217 if (input_pre_data == NULL && pre_data != NULL) { |
218 delete pre_data; | 218 delete pre_data; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 if (result.is_null()) Top::ReportPendingMessages(); | 222 if (result.is_null()) Top::ReportPendingMessages(); |
223 | |
224 return result; | 223 return result; |
225 } | 224 } |
226 | 225 |
227 | 226 |
228 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, | 227 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
229 Handle<Context> context, | 228 Handle<Context> context, |
230 int line_offset, | 229 int line_offset, |
231 bool is_global) { | 230 bool is_global) { |
232 int source_length = source->length(); | 231 int source_length = source->length(); |
233 Counters::total_eval_size.Increment(source_length); | 232 Counters::total_eval_size.Increment(source_length); |
234 Counters::total_compile_size.Increment(source_length); | 233 Counters::total_compile_size.Increment(source_length); |
235 | 234 |
236 // The VM is in the COMPILER state until exiting this function. | 235 // The VM is in the COMPILER state until exiting this function. |
237 VMState state(COMPILER); | 236 VMState state(COMPILER); |
238 CompilationCache::Entry entry = is_global | 237 CompilationCache::Entry entry = is_global |
239 ? CompilationCache::EVAL_GLOBAL | 238 ? CompilationCache::EVAL_GLOBAL |
240 : CompilationCache::EVAL_CONTEXTUAL; | 239 : CompilationCache::EVAL_CONTEXTUAL; |
241 | 240 |
242 // Do a lookup in the compilation cache; if the entry is not there, | 241 // Do a lookup in the compilation cache; if the entry is not there, |
243 // invoke the compiler and add the result to the cache. | 242 // invoke the compiler and add the result to the cache. |
244 Handle<JSFunction> result = | 243 Handle<JSFunction> result = |
245 CompilationCache::LookupEval(source, context, entry); | 244 CompilationCache::LookupEval(source, context, entry); |
246 if (result.is_null()) { | 245 if (result.is_null()) { |
247 // Create a script object describing the script to be compiled. | 246 // Create a script object describing the script to be compiled. |
248 Handle<Script> script = Factory::NewScript(source); | 247 Handle<Script> script = Factory::NewScript(source); |
249 script->set_line_offset(Smi::FromInt(line_offset)); | 248 script->set_line_offset(Smi::FromInt(line_offset)); |
250 result = MakeFunction(is_global, true, script, context, NULL, NULL); | 249 result = MakeFunction(is_global, true, script, context, NULL, NULL); |
251 if (!result.is_null()) { | 250 if (!result.is_null()) { |
252 CompilationCache::PutEvalFunction(source, context, entry, result); | 251 CompilationCache::PutEval(source, context, entry, result); |
253 } | 252 } |
254 } | 253 } |
255 | 254 |
256 return result; | 255 return result; |
257 } | 256 } |
258 | 257 |
259 | 258 |
260 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, | 259 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, |
261 int loop_nesting) { | 260 int loop_nesting) { |
262 ZoneScope zone_scope(DELETE_ON_EXIT); | 261 ZoneScope zone_scope(DELETE_ON_EXIT); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // Set the expected number of properties for instances. | 330 // Set the expected number of properties for instances. |
332 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 331 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
333 | 332 |
334 // Check the function has compiled code. | 333 // Check the function has compiled code. |
335 ASSERT(shared->is_compiled()); | 334 ASSERT(shared->is_compiled()); |
336 return true; | 335 return true; |
337 } | 336 } |
338 | 337 |
339 | 338 |
340 } } // namespace v8::internal | 339 } } // namespace v8::internal |
OLD | NEW |