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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 960 |
961 // Do a lookup in the compilation cache but not for extensions. | 961 // Do a lookup in the compilation cache but not for extensions. |
962 MaybeHandle<SharedFunctionInfo> maybe_result; | 962 MaybeHandle<SharedFunctionInfo> maybe_result; |
963 Handle<SharedFunctionInfo> result; | 963 Handle<SharedFunctionInfo> result; |
964 if (extension == NULL) { | 964 if (extension == NULL) { |
965 maybe_result = compilation_cache->LookupScript( | 965 maybe_result = compilation_cache->LookupScript( |
966 source, script_name, line_offset, column_offset, | 966 source, script_name, line_offset, column_offset, |
967 is_shared_cross_origin, context); | 967 is_shared_cross_origin, context); |
968 if (maybe_result.is_null() && FLAG_serialize_toplevel && | 968 if (maybe_result.is_null() && FLAG_serialize_toplevel && |
969 cached_data_mode == CONSUME_CACHED_DATA) { | 969 cached_data_mode == CONSUME_CACHED_DATA) { |
970 Object* des = CodeSerializer::Deserialize(isolate, *cached_data); | 970 return CodeSerializer::Deserialize(isolate, *cached_data, source); |
971 return handle(SharedFunctionInfo::cast(des), isolate); | |
972 } | 971 } |
973 } | 972 } |
974 | 973 |
975 if (!maybe_result.ToHandle(&result)) { | 974 if (!maybe_result.ToHandle(&result)) { |
976 // No cache entry found. Compile the script. | 975 // No cache entry found. Compile the script. |
977 | 976 |
978 // Create a script object describing the script to be compiled. | 977 // Create a script object describing the script to be compiled. |
979 Handle<Script> script = isolate->factory()->NewScript(source); | 978 Handle<Script> script = isolate->factory()->NewScript(source); |
980 if (natives == NATIVES_CODE) { | 979 if (natives == NATIVES_CODE) { |
981 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 980 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
(...skipping 13 matching lines...) Expand all Loading... |
995 info.SetContext(context); | 994 info.SetContext(context); |
996 if (FLAG_serialize_toplevel && cached_data_mode == PRODUCE_CACHED_DATA) { | 995 if (FLAG_serialize_toplevel && cached_data_mode == PRODUCE_CACHED_DATA) { |
997 info.PrepareForSerializing(); | 996 info.PrepareForSerializing(); |
998 } | 997 } |
999 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 998 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
1000 | 999 |
1001 result = CompileToplevel(&info); | 1000 result = CompileToplevel(&info); |
1002 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 1001 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
1003 compilation_cache->PutScript(source, context, result); | 1002 compilation_cache->PutScript(source, context, result); |
1004 if (FLAG_serialize_toplevel && cached_data_mode == PRODUCE_CACHED_DATA) { | 1003 if (FLAG_serialize_toplevel && cached_data_mode == PRODUCE_CACHED_DATA) { |
1005 *cached_data = CodeSerializer::Serialize(result); | 1004 *cached_data = CodeSerializer::Serialize(isolate, result, source); |
1006 } | 1005 } |
1007 } | 1006 } |
1008 if (result.is_null()) isolate->ReportPendingMessages(); | 1007 if (result.is_null()) isolate->ReportPendingMessages(); |
1009 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 1008 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
1010 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 1009 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
1011 } | 1010 } |
1012 return result; | 1011 return result; |
1013 } | 1012 } |
1014 | 1013 |
1015 | 1014 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 AllowHandleDereference allow_deref; | 1335 AllowHandleDereference allow_deref; |
1337 bool tracing_on = info()->IsStub() | 1336 bool tracing_on = info()->IsStub() |
1338 ? FLAG_trace_hydrogen_stubs | 1337 ? FLAG_trace_hydrogen_stubs |
1339 : (FLAG_trace_hydrogen && | 1338 : (FLAG_trace_hydrogen && |
1340 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1339 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1341 return (tracing_on && | 1340 return (tracing_on && |
1342 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1341 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1343 } | 1342 } |
1344 | 1343 |
1345 } } // namespace v8::internal | 1344 } } // namespace v8::internal |
OLD | NEW |