| 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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 Handle<Context> context, | 870 Handle<Context> context, |
| 871 StrictMode strict_mode, | 871 StrictMode strict_mode, |
| 872 ParseRestriction restriction, | 872 ParseRestriction restriction, |
| 873 int scope_position) { | 873 int scope_position) { |
| 874 Isolate* isolate = source->GetIsolate(); | 874 Isolate* isolate = source->GetIsolate(); |
| 875 int source_length = source->length(); | 875 int source_length = source->length(); |
| 876 isolate->counters()->total_eval_size()->Increment(source_length); | 876 isolate->counters()->total_eval_size()->Increment(source_length); |
| 877 isolate->counters()->total_compile_size()->Increment(source_length); | 877 isolate->counters()->total_compile_size()->Increment(source_length); |
| 878 | 878 |
| 879 CompilationCache* compilation_cache = isolate->compilation_cache(); | 879 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 880 Handle<SharedFunctionInfo> shared_info = compilation_cache->LookupEval( | 880 MaybeHandle<SharedFunctionInfo> maybe_shared_info = |
| 881 source, context, strict_mode, scope_position); | 881 compilation_cache->LookupEval(source, context, strict_mode, |
| 882 scope_position); |
| 883 Handle<SharedFunctionInfo> shared_info; |
| 882 | 884 |
| 883 if (shared_info.is_null()) { | 885 if (!maybe_shared_info.ToHandle(&shared_info)) { |
| 884 Handle<Script> script = isolate->factory()->NewScript(source); | 886 Handle<Script> script = isolate->factory()->NewScript(source); |
| 885 CompilationInfoWithZone info(script); | 887 CompilationInfoWithZone info(script); |
| 886 info.MarkAsEval(); | 888 info.MarkAsEval(); |
| 887 if (context->IsNativeContext()) info.MarkAsGlobal(); | 889 if (context->IsNativeContext()) info.MarkAsGlobal(); |
| 888 info.SetStrictMode(strict_mode); | 890 info.SetStrictMode(strict_mode); |
| 889 info.SetParseRestriction(restriction); | 891 info.SetParseRestriction(restriction); |
| 890 info.SetContext(context); | 892 info.SetContext(context); |
| 891 | 893 |
| 892 #if ENABLE_DEBUGGER_SUPPORT | 894 #if ENABLE_DEBUGGER_SUPPORT |
| 893 Debug::RecordEvalCaller(script); | 895 Debug::RecordEvalCaller(script); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 ASSERT(cached_data && *cached_data); | 940 ASSERT(cached_data && *cached_data); |
| 939 } | 941 } |
| 940 Isolate* isolate = source->GetIsolate(); | 942 Isolate* isolate = source->GetIsolate(); |
| 941 int source_length = source->length(); | 943 int source_length = source->length(); |
| 942 isolate->counters()->total_load_size()->Increment(source_length); | 944 isolate->counters()->total_load_size()->Increment(source_length); |
| 943 isolate->counters()->total_compile_size()->Increment(source_length); | 945 isolate->counters()->total_compile_size()->Increment(source_length); |
| 944 | 946 |
| 945 CompilationCache* compilation_cache = isolate->compilation_cache(); | 947 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 946 | 948 |
| 947 // Do a lookup in the compilation cache but not for extensions. | 949 // Do a lookup in the compilation cache but not for extensions. |
| 950 MaybeHandle<SharedFunctionInfo> maybe_result; |
| 948 Handle<SharedFunctionInfo> result; | 951 Handle<SharedFunctionInfo> result; |
| 949 if (extension == NULL) { | 952 if (extension == NULL) { |
| 950 result = compilation_cache->LookupScript(source, | 953 maybe_result = compilation_cache->LookupScript( |
| 951 script_name, | 954 source, script_name, line_offset, column_offset, |
| 952 line_offset, | 955 is_shared_cross_origin, context); |
| 953 column_offset, | |
| 954 is_shared_cross_origin, | |
| 955 context); | |
| 956 } | 956 } |
| 957 | 957 |
| 958 if (result.is_null()) { | 958 if (!maybe_result.ToHandle(&result)) { |
| 959 // No cache entry found. Compile the script. | 959 // No cache entry found. Compile the script. |
| 960 | 960 |
| 961 // Create a script object describing the script to be compiled. | 961 // Create a script object describing the script to be compiled. |
| 962 Handle<Script> script = isolate->factory()->NewScript(source); | 962 Handle<Script> script = isolate->factory()->NewScript(source); |
| 963 if (natives == NATIVES_CODE) { | 963 if (natives == NATIVES_CODE) { |
| 964 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 964 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 965 } | 965 } |
| 966 if (!script_name.is_null()) { | 966 if (!script_name.is_null()) { |
| 967 script->set_name(*script_name); | 967 script->set_name(*script_name); |
| 968 script->set_line_offset(Smi::FromInt(line_offset)); | 968 script->set_line_offset(Smi::FromInt(line_offset)); |
| 969 script->set_column_offset(Smi::FromInt(column_offset)); | 969 script->set_column_offset(Smi::FromInt(column_offset)); |
| 970 } | 970 } |
| 971 script->set_is_shared_cross_origin(is_shared_cross_origin); | 971 script->set_is_shared_cross_origin(is_shared_cross_origin); |
| 972 | 972 |
| 973 // Compile the function and add it to the cache. | 973 // Compile the function and add it to the cache. |
| 974 CompilationInfoWithZone info(script); | 974 CompilationInfoWithZone info(script); |
| 975 info.MarkAsGlobal(); | 975 info.MarkAsGlobal(); |
| 976 info.SetExtension(extension); | 976 info.SetExtension(extension); |
| 977 info.SetCachedData(cached_data, cached_data_mode); | 977 info.SetCachedData(cached_data, cached_data_mode); |
| 978 info.SetContext(context); | 978 info.SetContext(context); |
| 979 if (FLAG_use_strict) info.SetStrictMode(STRICT); | 979 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
| 980 result = CompileToplevel(&info); | 980 result = CompileToplevel(&info); |
| 981 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 981 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
| 982 compilation_cache->PutScript(source, context, result); | 982 compilation_cache->PutScript(source, context, result); |
| 983 } | 983 } |
| 984 if (result.is_null()) isolate->ReportPendingMessages(); |
| 984 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 985 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
| 985 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 986 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
| 986 } | 987 } |
| 987 | |
| 988 if (result.is_null()) isolate->ReportPendingMessages(); | |
| 989 return result; | 988 return result; |
| 990 } | 989 } |
| 991 | 990 |
| 992 | 991 |
| 993 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 992 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
| 994 Handle<Script> script) { | 993 Handle<Script> script) { |
| 995 // Precondition: code has been parsed and scopes have been analyzed. | 994 // Precondition: code has been parsed and scopes have been analyzed. |
| 996 CompilationInfoWithZone info(script); | 995 CompilationInfoWithZone info(script); |
| 997 info.SetFunction(literal); | 996 info.SetFunction(literal); |
| 998 info.PrepareForCompilation(literal->scope()); | 997 info.PrepareForCompilation(literal->scope()); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 AllowHandleDereference allow_deref; | 1302 AllowHandleDereference allow_deref; |
| 1304 bool tracing_on = info()->IsStub() | 1303 bool tracing_on = info()->IsStub() |
| 1305 ? FLAG_trace_hydrogen_stubs | 1304 ? FLAG_trace_hydrogen_stubs |
| 1306 : (FLAG_trace_hydrogen && | 1305 : (FLAG_trace_hydrogen && |
| 1307 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1306 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1308 return (tracing_on && | 1307 return (tracing_on && |
| 1309 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1308 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1310 } | 1309 } |
| 1311 | 1310 |
| 1312 } } // namespace v8::internal | 1311 } } // namespace v8::internal |
| OLD | NEW |