| 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...) Expand 10 before | Expand all | Expand 10 after 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 zone_ = zone; | 119 zone_ = zone; |
| 120 deferred_handles_ = NULL; | 120 deferred_handles_ = NULL; |
| 121 code_stub_ = NULL; | 121 code_stub_ = NULL; |
| 122 prologue_offset_ = Code::kPrologueOffsetNotSet; | 122 prologue_offset_ = Code::kPrologueOffsetNotSet; |
| 123 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 123 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
| 124 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 124 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
| 125 ? new List<OffsetRange>(2) : NULL; | 125 ? new List<OffsetRange>(2) : NULL; |
| 126 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 126 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| 127 dependencies_[i] = NULL; | 127 dependencies_[i] = NULL; |
| 128 } | 128 } |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 FixedArray* array = isolate->native_context()->embedder_data(); | 800 FixedArray* array = isolate->native_context()->embedder_data(); |
| 801 script->set_context_data(array->get(0)); | 801 script->set_context_data(array->get(0)); |
| 802 | 802 |
| 803 #ifdef ENABLE_DEBUGGER_SUPPORT | 803 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 804 isolate->debugger()->OnBeforeCompile(script); | 804 isolate->debugger()->OnBeforeCompile(script); |
| 805 #endif | 805 #endif |
| 806 | 806 |
| 807 ASSERT(info->is_eval() || info->is_global()); | 807 ASSERT(info->is_eval() || info->is_global()); |
| 808 | 808 |
| 809 bool parse_allow_lazy = | 809 bool parse_allow_lazy = |
| 810 (info->pre_parse_data() != NULL || | 810 (info->cached_data() != NULL || |
| 811 String::cast(script->source())->length() > FLAG_min_preparse_length) && | 811 String::cast(script->source())->length() > FLAG_min_preparse_length) && |
| 812 !DebuggerWantsEagerCompilation(info); | 812 !DebuggerWantsEagerCompilation(info); |
| 813 | 813 |
| 814 if (!parse_allow_lazy && info->pre_parse_data() != NULL) { | 814 if (!parse_allow_lazy && info->cached_data() != NULL) { |
| 815 // We are going to parse eagerly, but we have preparse data produced by lazy | 815 // We are going to parse eagerly, but we either 1) have cached data produced |
| 816 // preparsing. We cannot use it, since it won't contain all the symbols we | 816 // by lazy parsing or 2) are asked to generate cached data. We cannot use |
| 817 // need for eager parsing. | 817 // the existing data, since it won't contain all the symbols we need for |
| 818 info->SetPreParseData(NULL); | 818 // eager parsing. In addition, it doesn't make sense to generate the data |
| 819 // when parsing eagerly. That data would contain all symbols, but no |
| 820 // functions, so it couldn't be used to aid lazy parsing later. |
| 821 info->SetCachedData(NULL); |
| 819 } | 822 } |
| 820 | 823 |
| 821 Handle<SharedFunctionInfo> result; | 824 Handle<SharedFunctionInfo> result; |
| 822 | 825 |
| 823 { VMState<COMPILER> state(info->isolate()); | 826 { VMState<COMPILER> state(info->isolate()); |
| 824 if (!Parser::Parse(info, parse_allow_lazy)) { | 827 if (!Parser::Parse(info, parse_allow_lazy)) { |
| 825 return Handle<SharedFunctionInfo>::null(); | 828 return Handle<SharedFunctionInfo>::null(); |
| 826 } | 829 } |
| 827 | 830 |
| 828 FunctionLiteral* lit = info->function(); | 831 FunctionLiteral* lit = info->function(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 } | 939 } |
| 937 | 940 |
| 938 | 941 |
| 939 Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source, | 942 Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source, |
| 940 Handle<Object> script_name, | 943 Handle<Object> script_name, |
| 941 int line_offset, | 944 int line_offset, |
| 942 int column_offset, | 945 int column_offset, |
| 943 bool is_shared_cross_origin, | 946 bool is_shared_cross_origin, |
| 944 Handle<Context> context, | 947 Handle<Context> context, |
| 945 v8::Extension* extension, | 948 v8::Extension* extension, |
| 946 ScriptDataImpl* pre_data, | 949 ScriptDataImpl** cached_data, |
| 947 NativesFlag natives) { | 950 NativesFlag natives) { |
| 948 Isolate* isolate = source->GetIsolate(); | 951 Isolate* isolate = source->GetIsolate(); |
| 949 int source_length = source->length(); | 952 int source_length = source->length(); |
| 950 isolate->counters()->total_load_size()->Increment(source_length); | 953 isolate->counters()->total_load_size()->Increment(source_length); |
| 951 isolate->counters()->total_compile_size()->Increment(source_length); | 954 isolate->counters()->total_compile_size()->Increment(source_length); |
| 952 | 955 |
| 953 CompilationCache* compilation_cache = isolate->compilation_cache(); | 956 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 954 | 957 |
| 955 // Do a lookup in the compilation cache but not for extensions. | 958 // Do a lookup in the compilation cache but not for extensions. |
| 956 Handle<SharedFunctionInfo> result; | 959 Handle<SharedFunctionInfo> result; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 982 script->set_name(*script_name); | 985 script->set_name(*script_name); |
| 983 script->set_line_offset(Smi::FromInt(line_offset)); | 986 script->set_line_offset(Smi::FromInt(line_offset)); |
| 984 script->set_column_offset(Smi::FromInt(column_offset)); | 987 script->set_column_offset(Smi::FromInt(column_offset)); |
| 985 } | 988 } |
| 986 script->set_is_shared_cross_origin(is_shared_cross_origin); | 989 script->set_is_shared_cross_origin(is_shared_cross_origin); |
| 987 | 990 |
| 988 // Compile the function and add it to the cache. | 991 // Compile the function and add it to the cache. |
| 989 CompilationInfoWithZone info(script); | 992 CompilationInfoWithZone info(script); |
| 990 info.MarkAsGlobal(); | 993 info.MarkAsGlobal(); |
| 991 info.SetExtension(extension); | 994 info.SetExtension(extension); |
| 992 info.SetPreParseData(pre_data); | 995 info.SetCachedData(cached_data); |
| 993 info.SetContext(context); | 996 info.SetContext(context); |
| 994 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 997 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
| 995 result = CompileToplevel(&info); | 998 result = CompileToplevel(&info); |
| 996 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 999 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
| 997 compilation_cache->PutScript(source, context, result); | 1000 compilation_cache->PutScript(source, context, result); |
| 998 } | 1001 } |
| 999 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 1002 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
| 1000 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 1003 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
| 1001 } | 1004 } |
| 1002 | 1005 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 AllowHandleDereference allow_deref; | 1322 AllowHandleDereference allow_deref; |
| 1320 bool tracing_on = info()->IsStub() | 1323 bool tracing_on = info()->IsStub() |
| 1321 ? FLAG_trace_hydrogen_stubs | 1324 ? FLAG_trace_hydrogen_stubs |
| 1322 : (FLAG_trace_hydrogen && | 1325 : (FLAG_trace_hydrogen && |
| 1323 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1326 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1324 return (tracing_on && | 1327 return (tracing_on && |
| 1325 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1328 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1326 } | 1329 } |
| 1327 | 1330 |
| 1328 } } // namespace v8::internal | 1331 } } // namespace v8::internal |
| OLD | NEW |