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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); | 660 live_edit_tracker.RecordFunctionInfo(result, lit, info->zone()); |
661 | 661 |
662 return result; | 662 return result; |
663 } | 663 } |
664 | 664 |
665 | 665 |
666 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, | 666 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, |
667 Handle<Object> script_name, | 667 Handle<Object> script_name, |
668 int line_offset, | 668 int line_offset, |
669 int column_offset, | 669 int column_offset, |
| 670 bool is_shared_cross_origin, |
670 Handle<Context> context, | 671 Handle<Context> context, |
671 v8::Extension* extension, | 672 v8::Extension* extension, |
672 ScriptDataImpl* pre_data, | 673 ScriptDataImpl* pre_data, |
673 Handle<Object> script_data, | 674 Handle<Object> script_data, |
674 NativesFlag natives) { | 675 NativesFlag natives) { |
675 Isolate* isolate = source->GetIsolate(); | 676 Isolate* isolate = source->GetIsolate(); |
676 int source_length = source->length(); | 677 int source_length = source->length(); |
677 isolate->counters()->total_load_size()->Increment(source_length); | 678 isolate->counters()->total_load_size()->Increment(source_length); |
678 isolate->counters()->total_compile_size()->Increment(source_length); | 679 isolate->counters()->total_compile_size()->Increment(source_length); |
679 | 680 |
680 // The VM is in the COMPILER state until exiting this function. | 681 // The VM is in the COMPILER state until exiting this function. |
681 VMState<COMPILER> state(isolate); | 682 VMState<COMPILER> state(isolate); |
682 | 683 |
683 CompilationCache* compilation_cache = isolate->compilation_cache(); | 684 CompilationCache* compilation_cache = isolate->compilation_cache(); |
684 | 685 |
685 // Do a lookup in the compilation cache but not for extensions. | 686 // Do a lookup in the compilation cache but not for extensions. |
686 Handle<SharedFunctionInfo> result; | 687 Handle<SharedFunctionInfo> result; |
687 if (extension == NULL) { | 688 if (extension == NULL) { |
688 result = compilation_cache->LookupScript(source, | 689 result = compilation_cache->LookupScript(source, |
689 script_name, | 690 script_name, |
690 line_offset, | 691 line_offset, |
691 column_offset, | 692 column_offset, |
| 693 is_shared_cross_origin, |
692 context); | 694 context); |
693 } | 695 } |
694 | 696 |
695 if (result.is_null()) { | 697 if (result.is_null()) { |
696 // No cache entry found. Do pre-parsing, if it makes sense, and compile | 698 // No cache entry found. Do pre-parsing, if it makes sense, and compile |
697 // the script. | 699 // the script. |
698 // Building preparse data that is only used immediately after is only a | 700 // Building preparse data that is only used immediately after is only a |
699 // saving if we might skip building the AST for lazily compiled functions. | 701 // saving if we might skip building the AST for lazily compiled functions. |
700 // I.e., preparse data isn't relevant when the lazy flag is off, and | 702 // I.e., preparse data isn't relevant when the lazy flag is off, and |
701 // for small sources, odds are that there aren't many functions | 703 // for small sources, odds are that there aren't many functions |
702 // that would be compiled lazily anyway, so we skip the preparse step | 704 // that would be compiled lazily anyway, so we skip the preparse step |
703 // in that case too. | 705 // in that case too. |
704 | 706 |
705 // Create a script object describing the script to be compiled. | 707 // Create a script object describing the script to be compiled. |
706 Handle<Script> script = isolate->factory()->NewScript(source); | 708 Handle<Script> script = isolate->factory()->NewScript(source); |
707 if (natives == NATIVES_CODE) { | 709 if (natives == NATIVES_CODE) { |
708 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 710 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
709 } | 711 } |
710 if (!script_name.is_null()) { | 712 if (!script_name.is_null()) { |
711 script->set_name(*script_name); | 713 script->set_name(*script_name); |
712 script->set_line_offset(Smi::FromInt(line_offset)); | 714 script->set_line_offset(Smi::FromInt(line_offset)); |
713 script->set_column_offset(Smi::FromInt(column_offset)); | 715 script->set_column_offset(Smi::FromInt(column_offset)); |
714 } | 716 } |
| 717 script->set_is_shared_cross_origin(is_shared_cross_origin); |
715 | 718 |
716 script->set_data(script_data.is_null() ? HEAP->undefined_value() | 719 script->set_data(script_data.is_null() ? HEAP->undefined_value() |
717 : *script_data); | 720 : *script_data); |
718 | 721 |
719 // Compile the function and add it to the cache. | 722 // Compile the function and add it to the cache. |
720 CompilationInfoWithZone info(script); | 723 CompilationInfoWithZone info(script); |
721 info.MarkAsGlobal(); | 724 info.MarkAsGlobal(); |
722 info.SetExtension(extension); | 725 info.SetExtension(extension); |
723 info.SetPreParseData(pre_data); | 726 info.SetPreParseData(pre_data); |
724 info.SetContext(context); | 727 info.SetContext(context); |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 // Trace if the appropriate trace flag is set and the phase name's first | 1251 // Trace if the appropriate trace flag is set and the phase name's first |
1249 // character is in the FLAG_trace_phase command line parameter. | 1252 // character is in the FLAG_trace_phase command line parameter. |
1250 bool tracing_on = info()->IsStub() ? | 1253 bool tracing_on = info()->IsStub() ? |
1251 FLAG_trace_hydrogen_stubs : | 1254 FLAG_trace_hydrogen_stubs : |
1252 FLAG_trace_hydrogen; | 1255 FLAG_trace_hydrogen; |
1253 return (tracing_on && | 1256 return (tracing_on && |
1254 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1257 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1255 } | 1258 } |
1256 | 1259 |
1257 } } // namespace v8::internal | 1260 } } // namespace v8::internal |
OLD | NEW |