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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 info()->SetCode(code); | 360 info()->SetCode(code); |
| 361 return SetLastStatus(BAILED_OUT); | 361 return SetLastStatus(BAILED_OUT); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Recompile the unoptimized version of the code if the current version | 364 // Recompile the unoptimized version of the code if the current version |
| 365 // doesn't have deoptimization support. Alternatively, we may decide to | 365 // doesn't have deoptimization support. Alternatively, we may decide to |
| 366 // run the full code generator to get a baseline for the compile-time | 366 // run the full code generator to get a baseline for the compile-time |
| 367 // performance of the hydrogen-based compiler. | 367 // performance of the hydrogen-based compiler. |
| 368 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); | 368 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); |
| 369 if (should_recompile || FLAG_hydrogen_stats) { | 369 if (should_recompile || FLAG_hydrogen_stats) { |
| 370 HPhase phase(HPhase::kFullCodeGen, isolate(), info()->zone()); | 370 int64_t start_ticks = 0; |
|
danno
2013/06/24 12:21:22
Seems like you have more than one patch in this CL
Benedikt Meurer
2013/06/24 13:04:08
Done.
| |
| 371 if (FLAG_hydrogen_stats) { | |
| 372 start_ticks = OS::Ticks(); | |
| 373 } | |
| 371 CompilationInfoWithZone unoptimized(info()->shared_info()); | 374 CompilationInfoWithZone unoptimized(info()->shared_info()); |
| 372 // Note that we use the same AST that we will use for generating the | 375 // Note that we use the same AST that we will use for generating the |
| 373 // optimized code. | 376 // optimized code. |
| 374 unoptimized.SetFunction(info()->function()); | 377 unoptimized.SetFunction(info()->function()); |
| 375 unoptimized.SetScope(info()->scope()); | 378 unoptimized.SetScope(info()->scope()); |
| 376 unoptimized.SetContext(info()->context()); | 379 unoptimized.SetContext(info()->context()); |
| 377 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); | 380 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
| 378 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); | 381 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); |
| 379 if (should_recompile) { | 382 if (should_recompile) { |
| 380 if (!succeeded) return SetLastStatus(FAILED); | 383 if (!succeeded) return SetLastStatus(FAILED); |
| 381 Handle<SharedFunctionInfo> shared = info()->shared_info(); | 384 Handle<SharedFunctionInfo> shared = info()->shared_info(); |
| 382 shared->EnableDeoptimizationSupport(*unoptimized.code()); | 385 shared->EnableDeoptimizationSupport(*unoptimized.code()); |
| 383 // The existing unoptimized code was replaced with the new one. | 386 // The existing unoptimized code was replaced with the new one. |
| 384 Compiler::RecordFunctionCompilation( | 387 Compiler::RecordFunctionCompilation( |
| 385 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); | 388 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); |
| 386 } | 389 } |
| 390 if (FLAG_hydrogen_stats) { | |
| 391 int64_t ticks = OS::Ticks() - start_ticks; | |
| 392 isolate()->GetHStatistics()->IncrementFullCodeGen(ticks); | |
| 393 } | |
| 387 } | 394 } |
| 388 | 395 |
| 389 // Check that the unoptimized, shared code is ready for | 396 // Check that the unoptimized, shared code is ready for |
| 390 // optimizations. When using the always_opt flag we disregard the | 397 // optimizations. When using the always_opt flag we disregard the |
| 391 // optimizable marker in the code object and optimize anyway. This | 398 // optimizable marker in the code object and optimize anyway. This |
| 392 // is safe as long as the unoptimized code has deoptimization | 399 // is safe as long as the unoptimized code has deoptimization |
| 393 // support. | 400 // support. |
| 394 ASSERT(FLAG_always_opt || code->optimizable()); | 401 ASSERT(FLAG_always_opt || code->optimizable()); |
| 395 ASSERT(info()->shared_info()->has_deoptimization_support()); | 402 ASSERT(info()->shared_info()->has_deoptimization_support()); |
| 396 | 403 |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 shared->DebugName())); | 1206 shared->DebugName())); |
| 1200 } | 1207 } |
| 1201 } | 1208 } |
| 1202 | 1209 |
| 1203 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1210 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 1204 Handle<Script>(info->script()), | 1211 Handle<Script>(info->script()), |
| 1205 Handle<Code>(info->code()), | 1212 Handle<Code>(info->code()), |
| 1206 info)); | 1213 info)); |
| 1207 } | 1214 } |
| 1208 | 1215 |
| 1216 | |
| 1217 CompilationPhase::CompilationPhase(const char* name, | |
| 1218 Isolate* isolate, | |
| 1219 Zone* zone) | |
| 1220 : name_(name), isolate_(isolate), zone_(zone) { | |
| 1221 if (FLAG_hydrogen_stats) { | |
| 1222 start_allocation_size_ = zone->allocation_size(); | |
| 1223 start_ticks_ = OS::Ticks(); | |
| 1224 } | |
| 1225 } | |
| 1226 | |
| 1227 | |
| 1228 CompilationPhase::~CompilationPhase() { | |
| 1229 if (FLAG_hydrogen_stats) { | |
| 1230 unsigned size = zone_->allocation_size() - start_allocation_size_; | |
| 1231 int64_t ticks = OS::Ticks() - start_ticks_; | |
| 1232 isolate_->GetHStatistics()->SaveTiming(name_, ticks, size); | |
| 1233 } | |
| 1234 } | |
| 1235 | |
| 1236 | |
| 1237 bool CompilationPhase::ShouldProduceTraceOutput() const { | |
| 1238 // Produce trace output if flag is set so that the first letter of the | |
| 1239 // phase name matches the command line parameter FLAG_trace_phase. | |
| 1240 return (FLAG_trace_hydrogen && | |
| 1241 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | |
| 1242 } | |
| 1243 | |
| 1209 } } // namespace v8::internal | 1244 } } // namespace v8::internal |
| OLD | NEW |