Chromium Code Reviews| 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 int source_length = source->length(); | 941 int source_length = source->length(); |
| 942 isolate->counters()->total_load_size()->Increment(source_length); | 942 isolate->counters()->total_load_size()->Increment(source_length); |
| 943 isolate->counters()->total_compile_size()->Increment(source_length); | 943 isolate->counters()->total_compile_size()->Increment(source_length); |
| 944 | 944 |
| 945 CompilationCache* compilation_cache = isolate->compilation_cache(); | 945 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 946 | 946 |
| 947 // Do a lookup in the compilation cache but not for extensions. | 947 // Do a lookup in the compilation cache but not for extensions. |
| 948 MaybeHandle<SharedFunctionInfo> maybe_result; | 948 MaybeHandle<SharedFunctionInfo> maybe_result; |
| 949 Handle<SharedFunctionInfo> result; | 949 Handle<SharedFunctionInfo> result; |
| 950 if (extension == NULL) { | 950 if (extension == NULL) { |
| 951 if (FLAG_serialize_toplevel && cached_data_mode == CONSUME_CACHED_DATA) { | |
| 952 Object* des = CodeSerializer::Deserialize(isolate, *cached_data); | |
| 953 return handle(SharedFunctionInfo::cast(des), isolate); | |
| 954 } | |
|
vogelheim
2014/07/07 15:20:00
[For my understanding; not criticism:]
Why is thi
Yang
2014/07/08 09:01:05
You got a point. I reordered this. However, I thin
| |
| 951 maybe_result = compilation_cache->LookupScript( | 955 maybe_result = compilation_cache->LookupScript( |
| 952 source, script_name, line_offset, column_offset, | 956 source, script_name, line_offset, column_offset, |
| 953 is_shared_cross_origin, context); | 957 is_shared_cross_origin, context); |
| 954 } | 958 } |
| 955 | 959 |
| 956 if (!maybe_result.ToHandle(&result)) { | 960 if (!maybe_result.ToHandle(&result)) { |
| 957 // No cache entry found. Compile the script. | 961 // No cache entry found. Compile the script. |
| 958 | 962 |
| 959 // Create a script object describing the script to be compiled. | 963 // Create a script object describing the script to be compiled. |
| 960 Handle<Script> script = isolate->factory()->NewScript(source); | 964 Handle<Script> script = isolate->factory()->NewScript(source); |
| 961 if (natives == NATIVES_CODE) { | 965 if (natives == NATIVES_CODE) { |
| 962 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 966 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 963 } | 967 } |
| 964 if (!script_name.is_null()) { | 968 if (!script_name.is_null()) { |
| 965 script->set_name(*script_name); | 969 script->set_name(*script_name); |
| 966 script->set_line_offset(Smi::FromInt(line_offset)); | 970 script->set_line_offset(Smi::FromInt(line_offset)); |
| 967 script->set_column_offset(Smi::FromInt(column_offset)); | 971 script->set_column_offset(Smi::FromInt(column_offset)); |
| 968 } | 972 } |
| 969 script->set_is_shared_cross_origin(is_shared_cross_origin); | 973 script->set_is_shared_cross_origin(is_shared_cross_origin); |
| 970 | 974 |
| 971 // Compile the function and add it to the cache. | 975 // Compile the function and add it to the cache. |
| 972 CompilationInfoWithZone info(script); | 976 CompilationInfoWithZone info(script); |
| 973 info.MarkAsGlobal(); | 977 info.MarkAsGlobal(); |
| 978 info.SetCachedData(cached_data, cached_data_mode); | |
| 974 info.SetExtension(extension); | 979 info.SetExtension(extension); |
| 975 info.SetCachedData(cached_data, cached_data_mode); | |
| 976 info.SetContext(context); | 980 info.SetContext(context); |
| 977 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 981 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
| 982 | |
| 978 result = CompileToplevel(&info); | 983 result = CompileToplevel(&info); |
| 979 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 984 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
| 980 compilation_cache->PutScript(source, context, result); | 985 compilation_cache->PutScript(source, context, result); |
| 986 if (FLAG_serialize_toplevel && cached_data_mode == PRODUCE_CACHED_DATA) { | |
| 987 *cached_data = CodeSerializer::Serialize(result); | |
| 988 } | |
| 981 } | 989 } |
| 982 if (result.is_null()) isolate->ReportPendingMessages(); | 990 if (result.is_null()) isolate->ReportPendingMessages(); |
| 983 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 991 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
| 984 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 992 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
| 985 } | 993 } |
| 986 return result; | 994 return result; |
| 987 } | 995 } |
| 988 | 996 |
| 989 | 997 |
| 990 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 998 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
| 991 Handle<Script> script) { | 999 Handle<Script> script) { |
| 992 // Precondition: code has been parsed and scopes have been analyzed. | 1000 // Precondition: code has been parsed and scopes have been analyzed. |
| 993 CompilationInfoWithZone info(script); | 1001 CompilationInfoWithZone info(script); |
| 994 info.SetFunction(literal); | 1002 info.SetFunction(literal); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1310 AllowHandleDereference allow_deref; | 1318 AllowHandleDereference allow_deref; |
| 1311 bool tracing_on = info()->IsStub() | 1319 bool tracing_on = info()->IsStub() |
| 1312 ? FLAG_trace_hydrogen_stubs | 1320 ? FLAG_trace_hydrogen_stubs |
| 1313 : (FLAG_trace_hydrogen && | 1321 : (FLAG_trace_hydrogen && |
| 1314 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1322 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1315 return (tracing_on && | 1323 return (tracing_on && |
| 1316 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1324 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1317 } | 1325 } |
| 1318 | 1326 |
| 1319 } } // namespace v8::internal | 1327 } } // namespace v8::internal |
| OLD | NEW |