| 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; |
| 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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 1209 } } // namespace v8::internal | 1216 } } // namespace v8::internal |
| OLD | NEW |