OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, | 288 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
289 Handle<Context> context, | 289 Handle<Context> context, |
290 bool is_global, | 290 bool is_global, |
291 bool is_json) { | 291 bool is_json) { |
292 int source_length = source->length(); | 292 int source_length = source->length(); |
293 Counters::total_eval_size.Increment(source_length); | 293 Counters::total_eval_size.Increment(source_length); |
294 Counters::total_compile_size.Increment(source_length); | 294 Counters::total_compile_size.Increment(source_length); |
295 | 295 |
296 // The VM is in the COMPILER state until exiting this function. | 296 // The VM is in the COMPILER state until exiting this function. |
297 VMState state(COMPILER); | 297 VMState state(COMPILER); |
298 CompilationCache::Entry entry = is_global | |
299 ? CompilationCache::EVAL_GLOBAL | |
300 : CompilationCache::EVAL_CONTEXTUAL; | |
301 | 298 |
302 // Do a lookup in the compilation cache; if the entry is not there, | 299 // Do a lookup in the compilation cache; if the entry is not there, |
303 // invoke the compiler and add the result to the cache. | 300 // invoke the compiler and add the result to the cache. |
304 Handle<JSFunction> result = | 301 Handle<JSFunction> result = |
305 CompilationCache::LookupEval(source, context, entry); | 302 CompilationCache::LookupEval(source, context, is_global); |
306 if (result.is_null()) { | 303 if (result.is_null()) { |
307 // Create a script object describing the script to be compiled. | 304 // Create a script object describing the script to be compiled. |
308 Handle<Script> script = Factory::NewScript(source); | 305 Handle<Script> script = Factory::NewScript(source); |
309 result = MakeFunction(is_global, | 306 result = MakeFunction(is_global, |
310 true, | 307 true, |
311 is_json, | 308 is_json, |
312 script, | 309 script, |
313 context, | 310 context, |
314 NULL, | 311 NULL, |
315 NULL); | 312 NULL); |
316 if (!result.is_null()) { | 313 if (!result.is_null()) { |
317 CompilationCache::PutEval(source, context, entry, result); | 314 CompilationCache::PutEval(source, context, is_global, result); |
318 } | 315 } |
319 } | 316 } |
320 | 317 |
321 return result; | 318 return result; |
322 } | 319 } |
323 | 320 |
324 | 321 |
325 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, | 322 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, |
326 int loop_nesting) { | 323 int loop_nesting) { |
327 CompilationZoneScope zone_scope(DELETE_ON_EXIT); | 324 CompilationZoneScope zone_scope(DELETE_ON_EXIT); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // Set the expected number of properties for instances. | 400 // Set the expected number of properties for instances. |
404 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 401 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
405 | 402 |
406 // Check the function has compiled code. | 403 // Check the function has compiled code. |
407 ASSERT(shared->is_compiled()); | 404 ASSERT(shared->is_compiled()); |
408 return true; | 405 return true; |
409 } | 406 } |
410 | 407 |
411 | 408 |
412 } } // namespace v8::internal | 409 } } // namespace v8::internal |
OLD | NEW |