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 97 matching lines...) Loading... |
108 | 108 |
109 | 109 |
110 void CompilationInfo::Initialize(Isolate* isolate, | 110 void CompilationInfo::Initialize(Isolate* isolate, |
111 Mode mode, | 111 Mode mode, |
112 Zone* zone) { | 112 Zone* zone) { |
113 isolate_ = isolate; | 113 isolate_ = isolate; |
114 function_ = NULL; | 114 function_ = NULL; |
115 scope_ = NULL; | 115 scope_ = NULL; |
116 global_scope_ = NULL; | 116 global_scope_ = NULL; |
117 extension_ = NULL; | 117 extension_ = NULL; |
118 pre_parse_data_ = NULL; | 118 cached_data_ = NULL; |
| 119 cached_data_mode_ = NO_CACHED_DATA; |
119 zone_ = zone; | 120 zone_ = zone; |
120 deferred_handles_ = NULL; | 121 deferred_handles_ = NULL; |
121 code_stub_ = NULL; | 122 code_stub_ = NULL; |
122 prologue_offset_ = Code::kPrologueOffsetNotSet; | 123 prologue_offset_ = Code::kPrologueOffsetNotSet; |
123 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 124 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
124 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 125 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
125 ? new List<OffsetRange>(2) : NULL; | 126 ? new List<OffsetRange>(2) : NULL; |
126 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 127 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
127 dependencies_[i] = NULL; | 128 dependencies_[i] = NULL; |
128 } | 129 } |
(...skipping 646 matching lines...) Loading... |
775 FixedArray* array = isolate->native_context()->embedder_data(); | 776 FixedArray* array = isolate->native_context()->embedder_data(); |
776 script->set_context_data(array->get(0)); | 777 script->set_context_data(array->get(0)); |
777 | 778 |
778 #ifdef ENABLE_DEBUGGER_SUPPORT | 779 #ifdef ENABLE_DEBUGGER_SUPPORT |
779 isolate->debugger()->OnBeforeCompile(script); | 780 isolate->debugger()->OnBeforeCompile(script); |
780 #endif | 781 #endif |
781 | 782 |
782 ASSERT(info->is_eval() || info->is_global()); | 783 ASSERT(info->is_eval() || info->is_global()); |
783 | 784 |
784 bool parse_allow_lazy = | 785 bool parse_allow_lazy = |
785 (info->pre_parse_data() != NULL || | 786 (info->cached_data_mode() == CONSUME_CACHED_DATA || |
786 String::cast(script->source())->length() > FLAG_min_preparse_length) && | 787 String::cast(script->source())->length() > FLAG_min_preparse_length) && |
787 !DebuggerWantsEagerCompilation(info); | 788 !DebuggerWantsEagerCompilation(info); |
788 | 789 |
789 if (!parse_allow_lazy && info->pre_parse_data() != NULL) { | 790 if (!parse_allow_lazy && info->cached_data_mode() != NO_CACHED_DATA) { |
790 // We are going to parse eagerly, but we have preparse data produced by lazy | 791 // We are going to parse eagerly, but we either 1) have cached data produced |
791 // preparsing. We cannot use it, since it won't contain all the symbols we | 792 // by lazy parsing or 2) are asked to generate cached data. We cannot use |
792 // need for eager parsing. | 793 // the existing data, since it won't contain all the symbols we need for |
793 info->SetPreParseData(NULL); | 794 // eager parsing. In addition, it doesn't make sense to produce the data |
| 795 // when parsing eagerly. That data would contain all symbols, but no |
| 796 // functions, so it cannot be used to aid lazy parsing later. |
| 797 info->SetCachedData(NULL, NO_CACHED_DATA); |
794 } | 798 } |
795 | 799 |
796 Handle<SharedFunctionInfo> result; | 800 Handle<SharedFunctionInfo> result; |
797 | 801 |
798 { VMState<COMPILER> state(info->isolate()); | 802 { VMState<COMPILER> state(info->isolate()); |
799 if (!Parser::Parse(info, parse_allow_lazy)) { | 803 if (!Parser::Parse(info, parse_allow_lazy)) { |
800 return Handle<SharedFunctionInfo>::null(); | 804 return Handle<SharedFunctionInfo>::null(); |
801 } | 805 } |
802 | 806 |
803 FunctionLiteral* lit = info->function(); | 807 FunctionLiteral* lit = info->function(); |
(...skipping 99 matching lines...) Loading... |
903 } | 907 } |
904 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { | 908 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { |
905 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); | 909 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); |
906 } | 910 } |
907 | 911 |
908 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 912 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
909 shared_info, context, NOT_TENURED); | 913 shared_info, context, NOT_TENURED); |
910 } | 914 } |
911 | 915 |
912 | 916 |
913 Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source, | 917 Handle<SharedFunctionInfo> Compiler::CompileScript( |
914 Handle<Object> script_name, | 918 Handle<String> source, |
915 int line_offset, | 919 Handle<Object> script_name, |
916 int column_offset, | 920 int line_offset, |
917 bool is_shared_cross_origin, | 921 int column_offset, |
918 Handle<Context> context, | 922 bool is_shared_cross_origin, |
919 v8::Extension* extension, | 923 Handle<Context> context, |
920 ScriptDataImpl* pre_data, | 924 v8::Extension* extension, |
921 NativesFlag natives) { | 925 ScriptDataImpl** cached_data, |
| 926 CachedDataMode cached_data_mode, |
| 927 NativesFlag natives) { |
| 928 if (cached_data_mode == NO_CACHED_DATA) { |
| 929 cached_data = NULL; |
| 930 } else if (cached_data_mode == PRODUCE_CACHED_DATA) { |
| 931 ASSERT(cached_data && !*cached_data); |
| 932 } else { |
| 933 ASSERT(cached_data_mode == CONSUME_CACHED_DATA); |
| 934 ASSERT(cached_data && *cached_data); |
| 935 } |
922 Isolate* isolate = source->GetIsolate(); | 936 Isolate* isolate = source->GetIsolate(); |
923 int source_length = source->length(); | 937 int source_length = source->length(); |
924 isolate->counters()->total_load_size()->Increment(source_length); | 938 isolate->counters()->total_load_size()->Increment(source_length); |
925 isolate->counters()->total_compile_size()->Increment(source_length); | 939 isolate->counters()->total_compile_size()->Increment(source_length); |
926 | 940 |
927 CompilationCache* compilation_cache = isolate->compilation_cache(); | 941 CompilationCache* compilation_cache = isolate->compilation_cache(); |
928 | 942 |
929 // Do a lookup in the compilation cache but not for extensions. | 943 // Do a lookup in the compilation cache but not for extensions. |
930 Handle<SharedFunctionInfo> result; | 944 Handle<SharedFunctionInfo> result; |
931 if (extension == NULL) { | 945 if (extension == NULL) { |
(...skipping 24 matching lines...) Loading... |
956 script->set_name(*script_name); | 970 script->set_name(*script_name); |
957 script->set_line_offset(Smi::FromInt(line_offset)); | 971 script->set_line_offset(Smi::FromInt(line_offset)); |
958 script->set_column_offset(Smi::FromInt(column_offset)); | 972 script->set_column_offset(Smi::FromInt(column_offset)); |
959 } | 973 } |
960 script->set_is_shared_cross_origin(is_shared_cross_origin); | 974 script->set_is_shared_cross_origin(is_shared_cross_origin); |
961 | 975 |
962 // Compile the function and add it to the cache. | 976 // Compile the function and add it to the cache. |
963 CompilationInfoWithZone info(script); | 977 CompilationInfoWithZone info(script); |
964 info.MarkAsGlobal(); | 978 info.MarkAsGlobal(); |
965 info.SetExtension(extension); | 979 info.SetExtension(extension); |
966 info.SetPreParseData(pre_data); | 980 info.SetCachedData(cached_data, cached_data_mode); |
967 info.SetContext(context); | 981 info.SetContext(context); |
968 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 982 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
969 result = CompileToplevel(&info); | 983 result = CompileToplevel(&info); |
970 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 984 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
971 compilation_cache->PutScript(source, context, result); | 985 compilation_cache->PutScript(source, context, result); |
972 } | 986 } |
973 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 987 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
974 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 988 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
975 } | 989 } |
976 | 990 |
(...skipping 315 matching lines...) Loading... |
1292 AllowHandleDereference allow_deref; | 1306 AllowHandleDereference allow_deref; |
1293 bool tracing_on = info()->IsStub() | 1307 bool tracing_on = info()->IsStub() |
1294 ? FLAG_trace_hydrogen_stubs | 1308 ? FLAG_trace_hydrogen_stubs |
1295 : (FLAG_trace_hydrogen && | 1309 : (FLAG_trace_hydrogen && |
1296 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1310 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1297 return (tracing_on && | 1311 return (tracing_on && |
1298 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1312 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1299 } | 1313 } |
1300 | 1314 |
1301 } } // namespace v8::internal | 1315 } } // namespace v8::internal |
OLD | NEW |