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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 // Set the expected number of properties for instances and return | 1022 // Set the expected number of properties for instances and return |
1023 // the resulting function. | 1023 // the resulting function. |
1024 SetExpectedNofPropertiesFromEstimate(result, | 1024 SetExpectedNofPropertiesFromEstimate(result, |
1025 literal->expected_property_count()); | 1025 literal->expected_property_count()); |
1026 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1026 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
1027 return result; | 1027 return result; |
1028 } | 1028 } |
1029 | 1029 |
1030 | 1030 |
1031 static Handle<Code> GetCodeFromOptimizedCodeMap(Handle<JSFunction> function) { | 1031 static Handle<Code> GetCodeFromOptimizedCodeMap(Handle<JSFunction> function, |
| 1032 BailoutId osr_ast_id) { |
1032 if (FLAG_cache_optimized_code) { | 1033 if (FLAG_cache_optimized_code) { |
1033 Handle<SharedFunctionInfo> shared(function->shared()); | 1034 Handle<SharedFunctionInfo> shared(function->shared()); |
1034 DisallowHeapAllocation no_gc; | 1035 DisallowHeapAllocation no_gc; |
1035 int index = shared->SearchOptimizedCodeMap( | 1036 int index = shared->SearchOptimizedCodeMap( |
1036 function->context()->native_context()); | 1037 function->context()->native_context(), osr_ast_id); |
1037 if (index > 0) { | 1038 if (index > 0) { |
1038 if (FLAG_trace_opt) { | 1039 if (FLAG_trace_opt) { |
1039 PrintF("[found optimized code for "); | 1040 PrintF("[found optimized code for "); |
1040 function->ShortPrint(); | 1041 function->ShortPrint(); |
| 1042 if (!osr_ast_id.IsNone()) { |
| 1043 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
| 1044 } |
1041 PrintF("]\n"); | 1045 PrintF("]\n"); |
1042 } | 1046 } |
1043 FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index); | 1047 FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index); |
1044 if (literals != NULL) function->set_literals(literals); | 1048 if (literals != NULL) function->set_literals(literals); |
1045 return Handle<Code>(shared->GetCodeFromOptimizedCodeMap(index)); | 1049 return Handle<Code>(shared->GetCodeFromOptimizedCodeMap(index)); |
1046 } | 1050 } |
1047 } | 1051 } |
1048 return Handle<Code>::null(); | 1052 return Handle<Code>::null(); |
1049 } | 1053 } |
1050 | 1054 |
1051 | 1055 |
1052 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 1056 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
1053 Handle<Code> code = info->code(); | 1057 Handle<Code> code = info->code(); |
1054 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 1058 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
1055 | 1059 |
1056 // Cache non-OSR optimized code. | 1060 // Cache optimized code. |
1057 if (FLAG_cache_optimized_code && !info->is_osr()) { | 1061 if (FLAG_cache_optimized_code) { |
1058 Handle<JSFunction> function = info->closure(); | 1062 Handle<JSFunction> function = info->closure(); |
1059 Handle<SharedFunctionInfo> shared(function->shared()); | 1063 Handle<SharedFunctionInfo> shared(function->shared()); |
1060 Handle<FixedArray> literals(function->literals()); | 1064 Handle<FixedArray> literals(function->literals()); |
1061 Handle<Context> native_context(function->context()->native_context()); | 1065 Handle<Context> native_context(function->context()->native_context()); |
1062 SharedFunctionInfo::AddToOptimizedCodeMap( | 1066 SharedFunctionInfo::AddToOptimizedCodeMap( |
1063 shared, native_context, code, literals); | 1067 shared, native_context, code, literals, info->osr_ast_id()); |
1064 } | 1068 } |
1065 } | 1069 } |
1066 | 1070 |
1067 | 1071 |
1068 static bool CompileOptimizedPrologue(CompilationInfo* info) { | 1072 static bool CompileOptimizedPrologue(CompilationInfo* info) { |
1069 if (!Parser::Parse(info)) return false; | 1073 if (!Parser::Parse(info)) return false; |
1070 LanguageMode language_mode = info->function()->language_mode(); | 1074 LanguageMode language_mode = info->function()->language_mode(); |
1071 info->SetLanguageMode(language_mode); | 1075 info->SetLanguageMode(language_mode); |
1072 | 1076 |
1073 if (!Rewriter::Rewrite(info)) return false; | 1077 if (!Rewriter::Rewrite(info)) return false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 } | 1134 } |
1131 } | 1135 } |
1132 return true; | 1136 return true; |
1133 } | 1137 } |
1134 | 1138 |
1135 | 1139 |
1136 Handle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function, | 1140 Handle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function, |
1137 Handle<Code> current_code, | 1141 Handle<Code> current_code, |
1138 ConcurrencyMode mode, | 1142 ConcurrencyMode mode, |
1139 BailoutId osr_ast_id) { | 1143 BailoutId osr_ast_id) { |
1140 if (osr_ast_id.IsNone()) { // No cache for OSR. | 1144 Handle<Code> cached_code = GetCodeFromOptimizedCodeMap(function, osr_ast_id); |
1141 Handle<Code> cached_code = GetCodeFromOptimizedCodeMap(function); | 1145 if (!cached_code.is_null()) return cached_code; |
1142 if (!cached_code.is_null()) return cached_code; | |
1143 } | |
1144 | 1146 |
1145 SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function)); | 1147 SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function)); |
1146 Isolate* isolate = info->isolate(); | 1148 Isolate* isolate = info->isolate(); |
1147 VMState<COMPILER> state(isolate); | 1149 VMState<COMPILER> state(isolate); |
1148 ASSERT(!isolate->has_pending_exception()); | 1150 ASSERT(!isolate->has_pending_exception()); |
1149 PostponeInterruptsScope postpone(isolate); | 1151 PostponeInterruptsScope postpone(isolate); |
1150 | 1152 |
1151 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1153 Handle<SharedFunctionInfo> shared = info->shared_info(); |
1152 ASSERT_NE(ScopeInfo::Empty(isolate), shared->scope_info()); | 1154 ASSERT_NE(ScopeInfo::Empty(isolate), shared->scope_info()); |
1153 int compiled_size = shared->end_position() - shared->start_position(); | 1155 int compiled_size = shared->end_position() - shared->start_position(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 return Handle<Code>::null(); | 1205 return Handle<Code>::null(); |
1204 } | 1206 } |
1205 | 1207 |
1206 if (job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) { | 1208 if (job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) { |
1207 return Handle<Code>::null(); | 1209 return Handle<Code>::null(); |
1208 } | 1210 } |
1209 | 1211 |
1210 Compiler::RecordFunctionCompilation( | 1212 Compiler::RecordFunctionCompilation( |
1211 Logger::LAZY_COMPILE_TAG, info.get(), shared); | 1213 Logger::LAZY_COMPILE_TAG, info.get(), shared); |
1212 if (info->shared_info()->SearchOptimizedCodeMap( | 1214 if (info->shared_info()->SearchOptimizedCodeMap( |
1213 info->context()->native_context()) == -1) { | 1215 info->context()->native_context(), info->osr_ast_id()) == -1) { |
1214 InsertCodeIntoOptimizedCodeMap(info.get()); | 1216 InsertCodeIntoOptimizedCodeMap(info.get()); |
1215 } | 1217 } |
1216 | 1218 |
1217 if (FLAG_trace_concurrent_recompilation) { | 1219 if (FLAG_trace_concurrent_recompilation) { |
1218 PrintF(" ** Optimized code for "); | 1220 PrintF(" ** Optimized code for "); |
1219 info->closure()->PrintName(); | 1221 info->closure()->PrintName(); |
1220 PrintF(" generated.\n"); | 1222 PrintF(" generated.\n"); |
1221 } | 1223 } |
1222 | 1224 |
1223 return Handle<Code>(*info->code()); | 1225 return Handle<Code>(*info->code()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 AllowHandleDereference allow_deref; | 1284 AllowHandleDereference allow_deref; |
1283 bool tracing_on = info()->IsStub() | 1285 bool tracing_on = info()->IsStub() |
1284 ? FLAG_trace_hydrogen_stubs | 1286 ? FLAG_trace_hydrogen_stubs |
1285 : (FLAG_trace_hydrogen && | 1287 : (FLAG_trace_hydrogen && |
1286 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1288 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1287 return (tracing_on && | 1289 return (tracing_on && |
1288 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1290 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1289 } | 1291 } |
1290 | 1292 |
1291 } } // namespace v8::internal | 1293 } } // namespace v8::internal |
OLD | NEW |