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 // 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 } | 901 } |
| 902 // Caching of optimized code enabled and optimized code found. | 902 // Caching of optimized code enabled and optimized code found. |
| 903 shared->InstallFromOptimizedCodeMap(*function, index); | 903 shared->InstallFromOptimizedCodeMap(*function, index); |
| 904 return true; | 904 return true; |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 return false; | 907 return false; |
| 908 } | 908 } |
| 909 | 909 |
| 910 | 910 |
| 911 bool Compiler::CompileLazy(CompilationInfo* info) { | 911 bool Compiler::CompileLazy(CompilationInfo* info, bool install) { |
| 912 Isolate* isolate = info->isolate(); | 912 Isolate* isolate = info->isolate(); |
| 913 | 913 |
| 914 // The VM is in the COMPILER state until exiting this function. | 914 // The VM is in the COMPILER state until exiting this function. |
| 915 VMState<COMPILER> state(isolate); | 915 VMState<COMPILER> state(isolate); |
| 916 | 916 |
| 917 PostponeInterruptsScope postpone(isolate); | 917 PostponeInterruptsScope postpone(isolate); |
| 918 | 918 |
| 919 Handle<SharedFunctionInfo> shared = info->shared_info(); | 919 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 920 int compiled_size = shared->end_position() - shared->start_position(); | 920 int compiled_size = shared->end_position() - shared->start_position(); |
| 921 isolate->counters()->total_compile_size()->Increment(compiled_size); | 921 isolate->counters()->total_compile_size()->Increment(compiled_size); |
| 922 | 922 |
| 923 if (InstallCodeFromOptimizedCodeMap(info)) return true; | 923 if (install && InstallCodeFromOptimizedCodeMap(info)) return true; |
|
Michael Starzinger
2013/07/31 14:55:50
Both InsertCodeIntoOptimizedCodeMap() and InstallC
| |
| 924 | 924 |
| 925 // Generate the AST for the lazily compiled function. | 925 // Generate the AST for the lazily compiled function. |
| 926 if (Parser::Parse(info)) { | 926 if (Parser::Parse(info)) { |
| 927 // Measure how long it takes to do the lazy compilation; only take the | 927 // Measure how long it takes to do the lazy compilation; only take the |
| 928 // rest of the function into account to avoid overlap with the lazy | 928 // rest of the function into account to avoid overlap with the lazy |
| 929 // parsing statistics. | 929 // parsing statistics. |
| 930 HistogramTimerScope timer(isolate->counters()->compile_lazy()); | 930 HistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 931 | 931 |
| 932 // After parsing we know the function's language mode. Remember it. | 932 // After parsing we know the function's language mode. Remember it. |
| 933 LanguageMode language_mode = info->function()->language_mode(); | 933 LanguageMode language_mode = info->function()->language_mode(); |
| 934 info->SetLanguageMode(language_mode); | 934 info->SetLanguageMode(language_mode); |
| 935 shared->set_language_mode(language_mode); | 935 shared->set_language_mode(language_mode); |
| 936 | 936 |
| 937 // Compile the code. | 937 // Compile the code. |
| 938 if (!MakeCode(info)) { | 938 if (!MakeCode(info)) { |
| 939 if (!isolate->has_pending_exception()) { | 939 if (!isolate->has_pending_exception()) { |
| 940 isolate->StackOverflow(); | 940 isolate->StackOverflow(); |
| 941 } | 941 } |
| 942 } else { | 942 } else { |
| 943 InstallCodeCommon(info); | 943 if (install) InstallCodeCommon(info); |
| 944 | 944 |
| 945 if (info->IsOptimizing()) { | 945 if (info->IsOptimizing()) { |
| 946 Handle<Code> code = info->code(); | 946 Handle<Code> code = info->code(); |
| 947 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); | 947 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); |
| 948 info->closure()->ReplaceCode(*code); | 948 if (install) { |
|
Michael Starzinger
2013/07/31 14:55:50
Instead of passing the "install" boolean flag we c
| |
| 949 InsertCodeIntoOptimizedCodeMap(info); | 949 info->closure()->ReplaceCode(*code); |
| 950 InsertCodeIntoOptimizedCodeMap(info); | |
| 951 } | |
| 950 return true; | 952 return true; |
| 951 } else { | 953 } else if (install) { |
| 952 return InstallFullCode(info); | 954 return InstallFullCode(info); |
| 953 } | 955 } |
| 954 } | 956 } |
| 955 } | 957 } |
| 956 | 958 |
| 957 ASSERT(info->code().is_null()); | 959 ASSERT(info->code().is_null()); |
| 958 return false; | 960 return false; |
| 959 } | 961 } |
| 960 | 962 |
| 961 | 963 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1251 // Trace if the appropriate trace flag is set and the phase name's first | 1253 // Trace if the appropriate trace flag is set and the phase name's first |
| 1252 // character is in the FLAG_trace_phase command line parameter. | 1254 // character is in the FLAG_trace_phase command line parameter. |
| 1253 bool tracing_on = info()->IsStub() ? | 1255 bool tracing_on = info()->IsStub() ? |
| 1254 FLAG_trace_hydrogen_stubs : | 1256 FLAG_trace_hydrogen_stubs : |
| 1255 FLAG_trace_hydrogen; | 1257 FLAG_trace_hydrogen; |
| 1256 return (tracing_on && | 1258 return (tracing_on && |
| 1257 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1259 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1258 } | 1260 } |
| 1259 | 1261 |
| 1260 } } // namespace v8::internal | 1262 } } // namespace v8::internal |
| OLD | NEW |