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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 if (result.is_null()) Top::ReportPendingMessages(); | 263 if (result.is_null()) Top::ReportPendingMessages(); |
264 return result; | 264 return result; |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, | 268 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
269 Handle<Context> context, | 269 Handle<Context> context, |
270 int line_offset, | |
271 bool is_global, | 270 bool is_global, |
272 bool is_json) { | 271 bool is_json) { |
273 int source_length = source->length(); | 272 int source_length = source->length(); |
274 Counters::total_eval_size.Increment(source_length); | 273 Counters::total_eval_size.Increment(source_length); |
275 Counters::total_compile_size.Increment(source_length); | 274 Counters::total_compile_size.Increment(source_length); |
276 | 275 |
277 // The VM is in the COMPILER state until exiting this function. | 276 // The VM is in the COMPILER state until exiting this function. |
278 VMState state(COMPILER); | 277 VMState state(COMPILER); |
279 CompilationCache::Entry entry = is_global | 278 CompilationCache::Entry entry = is_global |
280 ? CompilationCache::EVAL_GLOBAL | 279 ? CompilationCache::EVAL_GLOBAL |
281 : CompilationCache::EVAL_CONTEXTUAL; | 280 : CompilationCache::EVAL_CONTEXTUAL; |
282 | 281 |
283 // Do a lookup in the compilation cache; if the entry is not there, | 282 // Do a lookup in the compilation cache; if the entry is not there, |
284 // invoke the compiler and add the result to the cache. | 283 // invoke the compiler and add the result to the cache. |
285 Handle<JSFunction> result = | 284 Handle<JSFunction> result = |
286 CompilationCache::LookupEval(source, context, entry); | 285 CompilationCache::LookupEval(source, context, entry); |
287 if (result.is_null()) { | 286 if (result.is_null()) { |
288 // Create a script object describing the script to be compiled. | 287 // Create a script object describing the script to be compiled. |
289 Handle<Script> script = Factory::NewScript(source); | 288 Handle<Script> script = Factory::NewScript(source); |
290 script->set_line_offset(Smi::FromInt(line_offset)); | |
291 result = MakeFunction(is_global, | 289 result = MakeFunction(is_global, |
292 true, | 290 true, |
293 is_json, | 291 is_json, |
294 script, | 292 script, |
295 context, | 293 context, |
296 NULL, | 294 NULL, |
297 NULL); | 295 NULL); |
298 if (!result.is_null()) { | 296 if (!result.is_null()) { |
299 CompilationCache::PutEval(source, context, entry, result); | 297 CompilationCache::PutEval(source, context, entry, result); |
300 } | 298 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // Set the expected number of properties for instances. | 384 // Set the expected number of properties for instances. |
387 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 385 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
388 | 386 |
389 // Check the function has compiled code. | 387 // Check the function has compiled code. |
390 ASSERT(shared->is_compiled()); | 388 ASSERT(shared->is_compiled()); |
391 return true; | 389 return true; |
392 } | 390 } |
393 | 391 |
394 | 392 |
395 } } // namespace v8::internal | 393 } } // namespace v8::internal |
OLD | NEW |