| 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 8247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8258 if (FLAG_trace_opt) { | 8258 if (FLAG_trace_opt) { |
| 8259 PrintF("[failed to optimize "); | 8259 PrintF("[failed to optimize "); |
| 8260 function->PrintName(); | 8260 function->PrintName(); |
| 8261 PrintF(": optimized compilation failed]\n"); | 8261 PrintF(": optimized compilation failed]\n"); |
| 8262 } | 8262 } |
| 8263 function->ReplaceCode(function->shared()->code()); | 8263 function->ReplaceCode(function->shared()->code()); |
| 8264 return function->code(); | 8264 return function->code(); |
| 8265 } | 8265 } |
| 8266 | 8266 |
| 8267 | 8267 |
| 8268 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) { | 8268 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { |
| 8269 HandleScope handle_scope(isolate); | 8269 HandleScope handle_scope(isolate); |
| 8270 ASSERT(args.length() == 1); | 8270 ASSERT(args.length() == 1); |
| 8271 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8271 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8272 if (!AllowOptimization(isolate, function)) { | 8272 if (!AllowOptimization(isolate, function)) { |
| 8273 function->ReplaceCode(function->shared()->code()); | 8273 function->ReplaceCode(function->shared()->code()); |
| 8274 return isolate->heap()->undefined_value(); | 8274 return isolate->heap()->undefined_value(); |
| 8275 } | 8275 } |
| 8276 function->shared()->code()->set_profiler_ticks(0); | 8276 function->shared()->code()->set_profiler_ticks(0); |
| 8277 ASSERT(FLAG_parallel_recompilation); | 8277 ASSERT(FLAG_concurrent_recompilation); |
| 8278 Compiler::RecompileParallel(function); | 8278 Compiler::RecompileConcurrent(function); |
| 8279 return isolate->heap()->undefined_value(); | 8279 return isolate->heap()->undefined_value(); |
| 8280 } | 8280 } |
| 8281 | 8281 |
| 8282 | 8282 |
| 8283 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { | 8283 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { |
| 8284 HandleScope handle_scope(isolate); | 8284 HandleScope handle_scope(isolate); |
| 8285 ASSERT(args.length() == 1); | 8285 ASSERT(args.length() == 1); |
| 8286 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8286 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8287 ASSERT(V8::UseCrankshaft() && FLAG_parallel_recompilation); | 8287 ASSERT(V8::UseCrankshaft() && FLAG_concurrent_recompilation); |
| 8288 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8288 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 8289 return function->code(); | 8289 return function->code(); |
| 8290 } | 8290 } |
| 8291 | 8291 |
| 8292 | 8292 |
| 8293 class ActivationsFinder : public ThreadVisitor { | 8293 class ActivationsFinder : public ThreadVisitor { |
| 8294 public: | 8294 public: |
| 8295 explicit ActivationsFinder(JSFunction* function) | 8295 explicit ActivationsFinder(JSFunction* function) |
| 8296 : function_(function), has_activations_(false) {} | 8296 : function_(function), has_activations_(false) {} |
| 8297 | 8297 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8428 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { | 8428 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { |
| 8429 SealHandleScope shs(isolate); | 8429 SealHandleScope shs(isolate); |
| 8430 #if defined(USE_SIMULATOR) | 8430 #if defined(USE_SIMULATOR) |
| 8431 return isolate->heap()->true_value(); | 8431 return isolate->heap()->true_value(); |
| 8432 #else | 8432 #else |
| 8433 return isolate->heap()->false_value(); | 8433 return isolate->heap()->false_value(); |
| 8434 #endif | 8434 #endif |
| 8435 } | 8435 } |
| 8436 | 8436 |
| 8437 | 8437 |
| 8438 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsParallelRecompilationSupported) { | 8438 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) { |
| 8439 HandleScope scope(isolate); | 8439 HandleScope scope(isolate); |
| 8440 return FLAG_parallel_recompilation | 8440 return FLAG_concurrent_recompilation |
| 8441 ? isolate->heap()->true_value() : isolate->heap()->false_value(); | 8441 ? isolate->heap()->true_value() : isolate->heap()->false_value(); |
| 8442 } | 8442 } |
| 8443 | 8443 |
| 8444 | 8444 |
| 8445 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { | 8445 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { |
| 8446 HandleScope scope(isolate); | 8446 HandleScope scope(isolate); |
| 8447 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8447 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
| 8448 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8448 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8449 | 8449 |
| 8450 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); | 8450 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); |
| 8451 function->MarkForLazyRecompilation(); | 8451 function->MarkForLazyRecompilation(); |
| 8452 | 8452 |
| 8453 Code* unoptimized = function->shared()->code(); | 8453 Code* unoptimized = function->shared()->code(); |
| 8454 if (args.length() == 2 && | 8454 if (args.length() == 2 && |
| 8455 unoptimized->kind() == Code::FUNCTION) { | 8455 unoptimized->kind() == Code::FUNCTION) { |
| 8456 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 8456 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
| 8457 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { | 8457 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { |
| 8458 for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) { | 8458 for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) { |
| 8459 unoptimized->set_allow_osr_at_loop_nesting_level(i); | 8459 unoptimized->set_allow_osr_at_loop_nesting_level(i); |
| 8460 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); | 8460 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); |
| 8461 } | 8461 } |
| 8462 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("parallel"))) { | 8462 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { |
| 8463 function->MarkForParallelRecompilation(); | 8463 function->MarkForConcurrentRecompilation(); |
| 8464 } | 8464 } |
| 8465 } | 8465 } |
| 8466 | 8466 |
| 8467 return isolate->heap()->undefined_value(); | 8467 return isolate->heap()->undefined_value(); |
| 8468 } | 8468 } |
| 8469 | 8469 |
| 8470 | 8470 |
| 8471 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { | 8471 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { |
| 8472 HandleScope scope(isolate); | 8472 HandleScope scope(isolate); |
| 8473 ASSERT(args.length() == 1); | 8473 ASSERT(args.length() == 1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8485 return Smi::FromInt(4); // 4 == "never". | 8485 return Smi::FromInt(4); // 4 == "never". |
| 8486 } | 8486 } |
| 8487 bool sync_with_compiler_thread = true; | 8487 bool sync_with_compiler_thread = true; |
| 8488 if (args.length() == 2) { | 8488 if (args.length() == 2) { |
| 8489 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8489 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
| 8490 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8490 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
| 8491 sync_with_compiler_thread = false; | 8491 sync_with_compiler_thread = false; |
| 8492 } | 8492 } |
| 8493 } | 8493 } |
| 8494 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8494 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8495 if (FLAG_parallel_recompilation && sync_with_compiler_thread) { | 8495 if (FLAG_concurrent_recompilation && sync_with_compiler_thread) { |
| 8496 while (function->IsInRecompileQueue() || | 8496 while (function->IsInRecompileQueue() || |
| 8497 function->IsMarkedForInstallingRecompiledCode()) { | 8497 function->IsMarkedForInstallingRecompiledCode()) { |
| 8498 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8498 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 8499 OS::Sleep(50); | 8499 OS::Sleep(50); |
| 8500 } | 8500 } |
| 8501 } | 8501 } |
| 8502 if (FLAG_always_opt) { | 8502 if (FLAG_always_opt) { |
| 8503 // We may have always opt, but that is more best-effort than a real | 8503 // We may have always opt, but that is more best-effort than a real |
| 8504 // promise, so we still say "no" if it is not optimized. | 8504 // promise, so we still say "no" if it is not optimized. |
| 8505 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8505 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
| (...skipping 6135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14641 // Handle last resort GC and make sure to allow future allocations | 14641 // Handle last resort GC and make sure to allow future allocations |
| 14642 // to grow the heap without causing GCs (if possible). | 14642 // to grow the heap without causing GCs (if possible). |
| 14643 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14643 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14644 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14644 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14645 "Runtime::PerformGC"); | 14645 "Runtime::PerformGC"); |
| 14646 } | 14646 } |
| 14647 } | 14647 } |
| 14648 | 14648 |
| 14649 | 14649 |
| 14650 } } // namespace v8::internal | 14650 } } // namespace v8::internal |
| OLD | NEW |