| 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 8077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8088 ASSERT(!function->is_compiled()); | 8088 ASSERT(!function->is_compiled()); |
| 8089 if (!JSFunction::CompileLazy(function, KEEP_EXCEPTION)) { | 8089 if (!JSFunction::CompileLazy(function, KEEP_EXCEPTION)) { |
| 8090 return Failure::Exception(); | 8090 return Failure::Exception(); |
| 8091 } | 8091 } |
| 8092 | 8092 |
| 8093 // All done. Return the compiled code. | 8093 // All done. Return the compiled code. |
| 8094 ASSERT(function->is_compiled()); | 8094 ASSERT(function->is_compiled()); |
| 8095 return function->code(); | 8095 return function->code(); |
| 8096 } | 8096 } |
| 8097 | 8097 |
| 8098 | 8098 // Compile function using CrankShaft and return a pointer to its code. |
| 8099 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { | 8099 MaybeObject *CompileJSFunction(Isolate *isolate, |
| 8100 HandleScope scope(isolate); | 8100 Handle<JSFunction> function) { |
| 8101 ASSERT(args.length() == 1); | |
| 8102 Handle<JSFunction> function = args.at<JSFunction>(0); | |
| 8103 | |
| 8104 // If the function is not compiled ignore the lazy | 8101 // If the function is not compiled ignore the lazy |
| 8105 // recompilation. This can happen if the debugger is activated and | 8102 // recompilation. This can happen if the debugger is activated and |
| 8106 // the function is returned to the not compiled state. | 8103 // the function is returned to the not compiled state. |
| 8107 if (!function->shared()->is_compiled()) { | 8104 if (!function->shared()->is_compiled()) { |
| 8108 function->ReplaceCode(function->shared()->code()); | 8105 function->ReplaceCode(function->shared()->code()); |
| 8109 return function->code(); | 8106 return function->code(); |
| 8110 } | 8107 } |
| 8111 | 8108 |
| 8112 // If the function is not optimizable or debugger is active continue using the | 8109 // If the function is not optimizable or debugger is active continue using the |
| 8113 // code from the full compiler. | 8110 // code from the full compiler. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 8132 if (FLAG_trace_opt) { | 8129 if (FLAG_trace_opt) { |
| 8133 PrintF("[failed to optimize "); | 8130 PrintF("[failed to optimize "); |
| 8134 function->PrintName(); | 8131 function->PrintName(); |
| 8135 PrintF(": optimized compilation failed]\n"); | 8132 PrintF(": optimized compilation failed]\n"); |
| 8136 } | 8133 } |
| 8137 function->ReplaceCode(function->shared()->code()); | 8134 function->ReplaceCode(function->shared()->code()); |
| 8138 return function->code(); | 8135 return function->code(); |
| 8139 } | 8136 } |
| 8140 | 8137 |
| 8141 | 8138 |
| 8139 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { |
| 8140 HandleScope scope(isolate); |
| 8141 ASSERT(args.length() == 1); |
| 8142 return CompileJSFunction(isolate, args.at<JSFunction>(0)); |
| 8143 } |
| 8144 |
| 8145 |
| 8142 class ActivationsFinder : public ThreadVisitor { | 8146 class ActivationsFinder : public ThreadVisitor { |
| 8143 public: | 8147 public: |
| 8144 explicit ActivationsFinder(JSFunction* function) | 8148 explicit ActivationsFinder(JSFunction* function) |
| 8145 : function_(function), has_activations_(false) {} | 8149 : function_(function), has_activations_(false) {} |
| 8146 | 8150 |
| 8147 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { | 8151 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { |
| 8148 if (has_activations_) return; | 8152 if (has_activations_) return; |
| 8149 | 8153 |
| 8150 for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) { | 8154 for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) { |
| 8151 JavaScriptFrame* frame = it.frame(); | 8155 JavaScriptFrame* frame = it.frame(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8322 | 8326 |
| 8323 | 8327 |
| 8324 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { | 8328 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { |
| 8325 HandleScope scope(isolate); | 8329 HandleScope scope(isolate); |
| 8326 ASSERT(args.length() == 1); | 8330 ASSERT(args.length() == 1); |
| 8327 // The least significant bit (after untagging) indicates whether the | 8331 // The least significant bit (after untagging) indicates whether the |
| 8328 // function is currently optimized, regardless of reason. | 8332 // function is currently optimized, regardless of reason. |
| 8329 if (!V8::UseCrankshaft()) { | 8333 if (!V8::UseCrankshaft()) { |
| 8330 return Smi::FromInt(4); // 4 == "never". | 8334 return Smi::FromInt(4); // 4 == "never". |
| 8331 } | 8335 } |
| 8336 if (FLAG_concurrent_crankshaft) { |
| 8337 return Smi::FromInt(5); // 5 == "concurrent" |
| 8338 } |
| 8332 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8339 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8333 if (FLAG_always_opt) { | 8340 if (FLAG_always_opt) { |
| 8334 // We may have always opt, but that is more best-effort than a real | 8341 // We may have always opt, but that is more best-effort than a real |
| 8335 // promise, so we still say "no" if it is not optimized. | 8342 // promise, so we still say "no" if it is not optimized. |
| 8336 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8343 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
| 8337 : Smi::FromInt(2); // 2 == "no". | 8344 : Smi::FromInt(2); // 2 == "no". |
| 8338 } | 8345 } |
| 8339 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8346 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
| 8340 : Smi::FromInt(2); // 2 == "no". | 8347 : Smi::FromInt(2); // 2 == "no". |
| 8341 } | 8348 } |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9020 NoHandleAllocation na; | 9027 NoHandleAllocation na; |
| 9021 return isolate->StackOverflow(); | 9028 return isolate->StackOverflow(); |
| 9022 } | 9029 } |
| 9023 | 9030 |
| 9024 return Execution::HandleStackGuardInterrupt(isolate); | 9031 return Execution::HandleStackGuardInterrupt(isolate); |
| 9025 } | 9032 } |
| 9026 | 9033 |
| 9027 | 9034 |
| 9028 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { | 9035 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { |
| 9029 ASSERT(args.length() == 0); | 9036 ASSERT(args.length() == 0); |
| 9037 ASSERT(!FLAG_concurrent_crankshaft || |
| 9038 isolate->thread_manager()->IsLockedByCurrentThread()); |
| 9030 return Execution::HandleStackGuardInterrupt(isolate); | 9039 return Execution::HandleStackGuardInterrupt(isolate); |
| 9031 } | 9040 } |
| 9032 | 9041 |
| 9033 | 9042 |
| 9034 static int StackSize() { | 9043 static int StackSize() { |
| 9035 int n = 0; | 9044 int n = 0; |
| 9036 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; | 9045 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; |
| 9037 return n; | 9046 return n; |
| 9038 } | 9047 } |
| 9039 | 9048 |
| (...skipping 4435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13475 // Handle last resort GC and make sure to allow future allocations | 13484 // Handle last resort GC and make sure to allow future allocations |
| 13476 // to grow the heap without causing GCs (if possible). | 13485 // to grow the heap without causing GCs (if possible). |
| 13477 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13486 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13478 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13487 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13479 "Runtime::PerformGC"); | 13488 "Runtime::PerformGC"); |
| 13480 } | 13489 } |
| 13481 } | 13490 } |
| 13482 | 13491 |
| 13483 | 13492 |
| 13484 } } // namespace v8::internal | 13493 } } // namespace v8::internal |
| OLD | NEW |