| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); | 525 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); |
| 526 | 526 |
| 527 return result; | 527 return result; |
| 528 } | 528 } |
| 529 | 529 |
| 530 | 530 |
| 531 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, | 531 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, |
| 532 Handle<Object> script_name, | 532 Handle<Object> script_name, |
| 533 int line_offset, | 533 int line_offset, |
| 534 int column_offset, | 534 int column_offset, |
| 535 Handle<Context> context, |
| 535 v8::Extension* extension, | 536 v8::Extension* extension, |
| 536 ScriptDataImpl* pre_data, | 537 ScriptDataImpl* pre_data, |
| 537 Handle<Object> script_data, | 538 Handle<Object> script_data, |
| 538 NativesFlag natives) { | 539 NativesFlag natives) { |
| 539 Isolate* isolate = source->GetIsolate(); | 540 Isolate* isolate = source->GetIsolate(); |
| 540 int source_length = source->length(); | 541 int source_length = source->length(); |
| 541 isolate->counters()->total_load_size()->Increment(source_length); | 542 isolate->counters()->total_load_size()->Increment(source_length); |
| 542 isolate->counters()->total_compile_size()->Increment(source_length); | 543 isolate->counters()->total_compile_size()->Increment(source_length); |
| 543 | 544 |
| 544 // The VM is in the COMPILER state until exiting this function. | 545 // The VM is in the COMPILER state until exiting this function. |
| 545 VMState state(isolate, COMPILER); | 546 VMState state(isolate, COMPILER); |
| 546 | 547 |
| 547 CompilationCache* compilation_cache = isolate->compilation_cache(); | 548 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 548 | 549 |
| 549 // Do a lookup in the compilation cache but not for extensions. | 550 // Do a lookup in the compilation cache but not for extensions. |
| 550 Handle<SharedFunctionInfo> result; | 551 Handle<SharedFunctionInfo> result; |
| 551 if (extension == NULL) { | 552 if (extension == NULL) { |
| 552 result = compilation_cache->LookupScript(source, | 553 result = compilation_cache->LookupScript(source, |
| 553 script_name, | 554 script_name, |
| 554 line_offset, | 555 line_offset, |
| 555 column_offset); | 556 column_offset, |
| 557 context); |
| 556 } | 558 } |
| 557 | 559 |
| 558 if (result.is_null()) { | 560 if (result.is_null()) { |
| 559 // No cache entry found. Do pre-parsing, if it makes sense, and compile | 561 // No cache entry found. Do pre-parsing, if it makes sense, and compile |
| 560 // the script. | 562 // the script. |
| 561 // Building preparse data that is only used immediately after is only a | 563 // Building preparse data that is only used immediately after is only a |
| 562 // saving if we might skip building the AST for lazily compiled functions. | 564 // saving if we might skip building the AST for lazily compiled functions. |
| 563 // I.e., preparse data isn't relevant when the lazy flag is off, and | 565 // I.e., preparse data isn't relevant when the lazy flag is off, and |
| 564 // for small sources, odds are that there aren't many functions | 566 // for small sources, odds are that there aren't many functions |
| 565 // that would be compiled lazily anyway, so we skip the preparse step | 567 // that would be compiled lazily anyway, so we skip the preparse step |
| (...skipping 16 matching lines...) Expand all Loading... |
| 582 // Compile the function and add it to the cache. | 584 // Compile the function and add it to the cache. |
| 583 CompilationInfoWithZone info(script); | 585 CompilationInfoWithZone info(script); |
| 584 info.MarkAsGlobal(); | 586 info.MarkAsGlobal(); |
| 585 info.SetExtension(extension); | 587 info.SetExtension(extension); |
| 586 info.SetPreParseData(pre_data); | 588 info.SetPreParseData(pre_data); |
| 587 if (FLAG_use_strict) { | 589 if (FLAG_use_strict) { |
| 588 info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE); | 590 info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE); |
| 589 } | 591 } |
| 590 result = MakeFunctionInfo(&info); | 592 result = MakeFunctionInfo(&info); |
| 591 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 593 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
| 592 compilation_cache->PutScript(source, result); | 594 compilation_cache->PutScript(source, context, result); |
| 593 } | 595 } |
| 594 } else { | 596 } else { |
| 595 if (result->ic_age() != HEAP->global_ic_age()) { | 597 if (result->ic_age() != HEAP->global_ic_age()) { |
| 596 result->ResetForNewContext(HEAP->global_ic_age()); | 598 result->ResetForNewContext(HEAP->global_ic_age()); |
| 597 } | 599 } |
| 598 } | 600 } |
| 599 | 601 |
| 600 if (result.is_null()) isolate->ReportPendingMessages(); | 602 if (result.is_null()) isolate->ReportPendingMessages(); |
| 601 return result; | 603 return result; |
| 602 } | 604 } |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 } | 1029 } |
| 1028 } | 1030 } |
| 1029 | 1031 |
| 1030 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1032 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 1031 Handle<Script>(info->script()), | 1033 Handle<Script>(info->script()), |
| 1032 Handle<Code>(info->code()), | 1034 Handle<Code>(info->code()), |
| 1033 info)); | 1035 info)); |
| 1034 } | 1036 } |
| 1035 | 1037 |
| 1036 } } // namespace v8::internal | 1038 } } // namespace v8::internal |
| OLD | NEW |