| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 global_scope_ = NULL; | 99 global_scope_ = NULL; |
| 100 extension_ = NULL; | 100 extension_ = NULL; |
| 101 pre_parse_data_ = NULL; | 101 pre_parse_data_ = NULL; |
| 102 zone_ = zone; | 102 zone_ = zone; |
| 103 deferred_handles_ = NULL; | 103 deferred_handles_ = NULL; |
| 104 code_stub_ = NULL; | 104 code_stub_ = NULL; |
| 105 prologue_offset_ = kPrologueOffsetNotSet; | 105 prologue_offset_ = kPrologueOffsetNotSet; |
| 106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 106 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
| 107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 107 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
| 108 ? new List<OffsetRange>(2) : NULL; | 108 ? new List<OffsetRange>(2) : NULL; |
| 109 for (int i = 0; i < DependentCode::kGroupCount; i++) { | |
| 110 dependent_maps_[i] = NULL; | |
| 111 } | |
| 112 if (mode == STUB) { | 109 if (mode == STUB) { |
| 113 mode_ = STUB; | 110 mode_ = STUB; |
| 114 return; | 111 return; |
| 115 } | 112 } |
| 116 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 113 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 117 if (script_->type()->value() == Script::TYPE_NATIVE) { | 114 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 118 MarkAsNative(); | 115 MarkAsNative(); |
| 119 } | 116 } |
| 120 if (!shared_info_.is_null()) { | 117 if (!shared_info_.is_null()) { |
| 121 ASSERT(language_mode() == CLASSIC_MODE); | 118 ASSERT(language_mode() == CLASSIC_MODE); |
| 122 SetLanguageMode(shared_info_->language_mode()); | 119 SetLanguageMode(shared_info_->language_mode()); |
| 123 } | 120 } |
| 124 set_bailout_reason("unknown"); | 121 set_bailout_reason("unknown"); |
| 125 } | 122 } |
| 126 | 123 |
| 127 | 124 |
| 128 CompilationInfo::~CompilationInfo() { | 125 CompilationInfo::~CompilationInfo() { |
| 129 delete deferred_handles_; | 126 delete deferred_handles_; |
| 130 delete no_frame_ranges_; | 127 delete no_frame_ranges_; |
| 131 #ifdef DEBUG | |
| 132 // Check that no dependent maps have been added or added dependent maps have | |
| 133 // been rolled back or committed. | |
| 134 for (int i = 0; i < DependentCode::kGroupCount; i++) { | |
| 135 ASSERT_EQ(NULL, dependent_maps_[i]); | |
| 136 } | |
| 137 #endif // DEBUG | |
| 138 } | 128 } |
| 139 | 129 |
| 140 | 130 |
| 141 void CompilationInfo::CommitDependentMaps(Handle<Code> code) { | |
| 142 for (int i = 0; i < DependentCode::kGroupCount; i++) { | |
| 143 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i]; | |
| 144 if (group_maps == NULL) continue; | |
| 145 ASSERT(!object_wrapper_.is_null()); | |
| 146 for (int j = 0; j < group_maps->length(); j++) { | |
| 147 group_maps->at(j)->dependent_code()->UpdateToFinishedCode( | |
| 148 static_cast<DependentCode::DependencyGroup>(i), this, *code); | |
| 149 } | |
| 150 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. | |
| 151 } | |
| 152 } | |
| 153 | |
| 154 | |
| 155 void CompilationInfo::RollbackDependentMaps() { | |
| 156 // Unregister from all dependent maps if not yet committed. | |
| 157 for (int i = 0; i < DependentCode::kGroupCount; i++) { | |
| 158 ZoneList<Handle<Map> >* group_maps = dependent_maps_[i]; | |
| 159 if (group_maps == NULL) continue; | |
| 160 for (int j = 0; j < group_maps->length(); j++) { | |
| 161 group_maps->at(j)->dependent_code()->RemoveCompilationInfo( | |
| 162 static_cast<DependentCode::DependencyGroup>(i), this); | |
| 163 } | |
| 164 dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. | |
| 165 } | |
| 166 } | |
| 167 | |
| 168 | |
| 169 int CompilationInfo::num_parameters() const { | 131 int CompilationInfo::num_parameters() const { |
| 170 ASSERT(!IsStub()); | 132 ASSERT(!IsStub()); |
| 171 return scope()->num_parameters(); | 133 return scope()->num_parameters(); |
| 172 } | 134 } |
| 173 | 135 |
| 174 | 136 |
| 175 int CompilationInfo::num_heap_slots() const { | 137 int CompilationInfo::num_heap_slots() const { |
| 176 if (IsStub()) { | 138 if (IsStub()) { |
| 177 return 0; | 139 return 0; |
| 178 } else { | 140 } else { |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 975 |
| 1014 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 976 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
| 1015 } | 977 } |
| 1016 | 978 |
| 1017 | 979 |
| 1018 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { | 980 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { |
| 1019 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); | 981 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); |
| 1020 // The function may have already been optimized by OSR. Simply continue. | 982 // The function may have already been optimized by OSR. Simply continue. |
| 1021 // Except when OSR already disabled optimization for some reason. | 983 // Except when OSR already disabled optimization for some reason. |
| 1022 if (info->shared_info()->optimization_disabled()) { | 984 if (info->shared_info()->optimization_disabled()) { |
| 1023 info->AbortOptimization(); | 985 info->SetCode(Handle<Code>(info->shared_info()->code())); |
| 1024 InstallFullCode(*info); | 986 InstallFullCode(*info); |
| 1025 if (FLAG_trace_parallel_recompilation) { | 987 if (FLAG_trace_parallel_recompilation) { |
| 1026 PrintF(" ** aborting optimization for "); | 988 PrintF(" ** aborting optimization for "); |
| 1027 info->closure()->PrintName(); | 989 info->closure()->PrintName(); |
| 1028 PrintF(" as it has been disabled.\n"); | 990 PrintF(" as it has been disabled.\n"); |
| 1029 } | 991 } |
| 1030 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); | 992 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); |
| 1031 return; | 993 return; |
| 1032 } | 994 } |
| 1033 | 995 |
| 1034 Isolate* isolate = info->isolate(); | 996 Isolate* isolate = info->isolate(); |
| 1035 VMState<COMPILER> state(isolate); | 997 VMState<COMPILER> state(isolate); |
| 1036 Logger::TimerEventScope timer( | 998 Logger::TimerEventScope timer( |
| 1037 isolate, Logger::TimerEventScope::v8_recompile_synchronous); | 999 isolate, Logger::TimerEventScope::v8_recompile_synchronous); |
| 1038 // If crankshaft succeeded, install the optimized code else install | 1000 // If crankshaft succeeded, install the optimized code else install |
| 1039 // the unoptimized code. | 1001 // the unoptimized code. |
| 1040 OptimizingCompiler::Status status = optimizing_compiler->last_status(); | 1002 OptimizingCompiler::Status status = optimizing_compiler->last_status(); |
| 1041 if (info->HasAbortedDueToDependentMap()) { | 1003 if (status != OptimizingCompiler::SUCCEEDED) { |
| 1042 info->set_bailout_reason("bailed out due to dependent map"); | 1004 optimizing_compiler->info()->set_bailout_reason( |
| 1043 status = optimizing_compiler->AbortOptimization(); | 1005 "failed/bailed out last time"); |
| 1044 } else if (status != OptimizingCompiler::SUCCEEDED) { | |
| 1045 info->set_bailout_reason("failed/bailed out last time"); | |
| 1046 status = optimizing_compiler->AbortOptimization(); | 1006 status = optimizing_compiler->AbortOptimization(); |
| 1047 } else { | 1007 } else { |
| 1048 status = optimizing_compiler->GenerateAndInstallCode(); | 1008 status = optimizing_compiler->GenerateAndInstallCode(); |
| 1049 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 1009 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
| 1050 status == OptimizingCompiler::BAILED_OUT); | 1010 status == OptimizingCompiler::BAILED_OUT); |
| 1051 } | 1011 } |
| 1052 | 1012 |
| 1053 InstallCodeCommon(*info); | 1013 InstallCodeCommon(*info); |
| 1054 if (status == OptimizingCompiler::SUCCEEDED) { | 1014 if (status == OptimizingCompiler::SUCCEEDED) { |
| 1055 Handle<Code> code = info->code(); | 1015 Handle<Code> code = info->code(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 } | 1161 } |
| 1202 } | 1162 } |
| 1203 | 1163 |
| 1204 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1164 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 1205 Handle<Script>(info->script()), | 1165 Handle<Script>(info->script()), |
| 1206 Handle<Code>(info->code()), | 1166 Handle<Code>(info->code()), |
| 1207 info)); | 1167 info)); |
| 1208 } | 1168 } |
| 1209 | 1169 |
| 1210 } } // namespace v8::internal | 1170 } } // namespace v8::internal |
| OLD | NEW |