OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 int source_length = source->length(); | 953 int source_length = source->length(); |
954 isolate->counters()->total_load_size()->Increment(source_length); | 954 isolate->counters()->total_load_size()->Increment(source_length); |
955 isolate->counters()->total_compile_size()->Increment(source_length); | 955 isolate->counters()->total_compile_size()->Increment(source_length); |
956 | 956 |
957 CompilationCache* compilation_cache = isolate->compilation_cache(); | 957 CompilationCache* compilation_cache = isolate->compilation_cache(); |
958 | 958 |
959 // Do a lookup in the compilation cache but not for extensions. | 959 // Do a lookup in the compilation cache but not for extensions. |
960 MaybeHandle<SharedFunctionInfo> maybe_result; | 960 MaybeHandle<SharedFunctionInfo> maybe_result; |
961 Handle<SharedFunctionInfo> result; | 961 Handle<SharedFunctionInfo> result; |
962 if (extension == NULL) { | 962 if (extension == NULL) { |
963 maybe_result = compilation_cache->LookupScript( | 963 if (FLAG_serialize_toplevel && |
964 source, script_name, line_offset, column_offset, | |
965 is_shared_cross_origin, context); | |
966 if (maybe_result.is_null() && FLAG_serialize_toplevel && | |
967 compile_options == ScriptCompiler::kConsumeCodeCache) { | 964 compile_options == ScriptCompiler::kConsumeCodeCache) { |
968 return CodeSerializer::Deserialize(isolate, *cached_data, source); | 965 return CodeSerializer::Deserialize(isolate, *cached_data, source); |
966 } else { | |
Yang
2014/07/22 08:58:17
Without this change, --cache=code for d8 has no ef
| |
967 maybe_result = compilation_cache->LookupScript( | |
968 source, script_name, line_offset, column_offset, | |
969 is_shared_cross_origin, context); | |
969 } | 970 } |
970 } | 971 } |
971 | 972 |
973 base::ElapsedTimer timer; | |
974 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && | |
975 compile_options == ScriptCompiler::kProduceCodeCache) { | |
976 timer.Start(); | |
977 } | |
978 | |
972 if (!maybe_result.ToHandle(&result)) { | 979 if (!maybe_result.ToHandle(&result)) { |
973 // No cache entry found. Compile the script. | 980 // No cache entry found. Compile the script. |
974 | 981 |
975 // Create a script object describing the script to be compiled. | 982 // Create a script object describing the script to be compiled. |
976 Handle<Script> script = isolate->factory()->NewScript(source); | 983 Handle<Script> script = isolate->factory()->NewScript(source); |
977 if (natives == NATIVES_CODE) { | 984 if (natives == NATIVES_CODE) { |
978 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 985 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
979 } | 986 } |
980 if (!script_name.is_null()) { | 987 if (!script_name.is_null()) { |
981 script->set_name(*script_name); | 988 script->set_name(*script_name); |
(...skipping 13 matching lines...) Expand all Loading... | |
995 info.PrepareForSerializing(); | 1002 info.PrepareForSerializing(); |
996 } | 1003 } |
997 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 1004 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
998 | 1005 |
999 result = CompileToplevel(&info); | 1006 result = CompileToplevel(&info); |
1000 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 1007 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
1001 compilation_cache->PutScript(source, context, result); | 1008 compilation_cache->PutScript(source, context, result); |
1002 if (FLAG_serialize_toplevel && | 1009 if (FLAG_serialize_toplevel && |
1003 compile_options == ScriptCompiler::kProduceCodeCache) { | 1010 compile_options == ScriptCompiler::kProduceCodeCache) { |
1004 *cached_data = CodeSerializer::Serialize(isolate, result, source); | 1011 *cached_data = CodeSerializer::Serialize(isolate, result, source); |
1012 if (FLAG_profile_deserialization) { | |
1013 PrintF("[Compiling and serializing %d bytes took %0.3f ms]\n", | |
1014 (*cached_data)->length(), timer.Elapsed().InMillisecondsF()); | |
1015 } | |
1005 } | 1016 } |
1006 } | 1017 } |
1007 | 1018 |
1008 if (result.is_null()) isolate->ReportPendingMessages(); | 1019 if (result.is_null()) isolate->ReportPendingMessages(); |
1009 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 1020 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
1010 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 1021 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
1011 } | 1022 } |
1012 return result; | 1023 return result; |
1013 } | 1024 } |
1014 | 1025 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1331 AllowHandleDereference allow_deref; | 1342 AllowHandleDereference allow_deref; |
1332 bool tracing_on = info()->IsStub() | 1343 bool tracing_on = info()->IsStub() |
1333 ? FLAG_trace_hydrogen_stubs | 1344 ? FLAG_trace_hydrogen_stubs |
1334 : (FLAG_trace_hydrogen && | 1345 : (FLAG_trace_hydrogen && |
1335 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1346 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1336 return (tracing_on && | 1347 return (tracing_on && |
1337 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1348 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1338 } | 1349 } |
1339 | 1350 |
1340 } } // namespace v8::internal | 1351 } } // namespace v8::internal |
OLD | NEW |