Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: src/runtime.cc

Issue 10417010: Run Crankshaft on a separate thread. (Closed) Base URL: https://chromiumcodereview.appspot.com/10387157
Patch Set: Set optimize_in_parallel to false by default. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime.h ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6489 matching lines...) Expand 10 before | Expand all | Expand 10 after
6500 } 6500 }
6501 6501
6502 6502
6503 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { 6503 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
6504 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; 6504 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
6505 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); 6505 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars);
6506 return char_length == 0; 6506 return char_length == 0;
6507 } 6507 }
6508 6508
6509 6509
6510 MaybeObject* Runtime::CompileJSFunction(Isolate* isolate,
6511 Handle<JSFunction> function) {
6512 // If the function is not compiled ignore the lazy
6513 // recompilation. This can happen if the debugger is activated and
6514 // the function is returned to the not compiled state.
6515 if (!function->shared()->is_compiled()) {
6516 function->ReplaceCode(function->shared()->code());
6517 return function->code();
6518 }
6519
6520 // If the function is not optimizable or debugger is active continue using the
6521 // code from the full compiler.
6522 if (!function->shared()->code()->optimizable() ||
6523 isolate->DebuggerHasBreakPoints()) {
6524 if (FLAG_trace_opt) {
6525 PrintF("[failed to optimize ");
6526 function->PrintName();
6527 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
6528 function->shared()->code()->optimizable() ? "T" : "F",
6529 isolate->DebuggerHasBreakPoints() ? "T" : "F");
6530 }
6531 function->ReplaceCode(function->shared()->code());
6532 return function->code();
6533 }
6534 function->shared()->code()->set_profiler_ticks(0);
6535 if (JSFunction::CompileOptimized(function,
6536 AstNode::kNoNumber,
6537 CLEAR_EXCEPTION)) {
6538 return function->code();
6539 }
6540 if (FLAG_trace_opt) {
6541 PrintF("[failed to optimize ");
6542 function->PrintName();
6543 PrintF(": optimized compilation failed]\n");
6544 }
6545 function->ReplaceCode(function->shared()->code());
6546 return function->code();
6547 }
6548
6549
6510 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { 6550 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) {
6511 NoHandleAllocation ha; 6551 NoHandleAllocation ha;
6512 ASSERT(args.length() == 1); 6552 ASSERT(args.length() == 1);
6513 6553
6514 Object* number = args[0]; 6554 Object* number = args[0];
6515 RUNTIME_ASSERT(number->IsNumber()); 6555 RUNTIME_ASSERT(number->IsNumber());
6516 6556
6517 return isolate->heap()->NumberToString(number); 6557 return isolate->heap()->NumberToString(number);
6518 } 6558 }
6519 6559
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
8094 ASSERT(function->is_compiled()); 8134 ASSERT(function->is_compiled());
8095 return function->code(); 8135 return function->code();
8096 } 8136 }
8097 8137
8098 8138
8099 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { 8139 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) {
8100 HandleScope scope(isolate); 8140 HandleScope scope(isolate);
8101 ASSERT(args.length() == 1); 8141 ASSERT(args.length() == 1);
8102 Handle<JSFunction> function = args.at<JSFunction>(0); 8142 Handle<JSFunction> function = args.at<JSFunction>(0);
8103 8143
8104 // If the function is not compiled ignore the lazy 8144 return Runtime::CompileJSFunction(isolate, function);
8105 // recompilation. This can happen if the debugger is activated and
8106 // the function is returned to the not compiled state.
8107 if (!function->shared()->is_compiled()) {
8108 function->ReplaceCode(function->shared()->code());
8109 return function->code();
8110 }
8111
8112 // If the function is not optimizable or debugger is active continue using the
8113 // code from the full compiler.
8114 if (!function->shared()->code()->optimizable() ||
8115 isolate->DebuggerHasBreakPoints()) {
8116 if (FLAG_trace_opt) {
8117 PrintF("[failed to optimize ");
8118 function->PrintName();
8119 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
8120 function->shared()->code()->optimizable() ? "T" : "F",
8121 isolate->DebuggerHasBreakPoints() ? "T" : "F");
8122 }
8123 function->ReplaceCode(function->shared()->code());
8124 return function->code();
8125 }
8126 function->shared()->code()->set_profiler_ticks(0);
8127 if (JSFunction::CompileOptimized(function,
8128 AstNode::kNoNumber,
8129 CLEAR_EXCEPTION)) {
8130 return function->code();
8131 }
8132 if (FLAG_trace_opt) {
8133 PrintF("[failed to optimize ");
8134 function->PrintName();
8135 PrintF(": optimized compilation failed]\n");
8136 }
8137 function->ReplaceCode(function->shared()->code());
8138 return function->code();
8139 } 8145 }
8140 8146
8141 8147
8142 class ActivationsFinder : public ThreadVisitor { 8148 class ActivationsFinder : public ThreadVisitor {
8143 public: 8149 public:
8144 explicit ActivationsFinder(JSFunction* function) 8150 explicit ActivationsFinder(JSFunction* function)
8145 : function_(function), has_activations_(false) {} 8151 : function_(function), has_activations_(false) {}
8146 8152
8147 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { 8153 void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
8148 if (has_activations_) return; 8154 if (has_activations_) return;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
8322 8328
8323 8329
8324 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 8330 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
8325 HandleScope scope(isolate); 8331 HandleScope scope(isolate);
8326 ASSERT(args.length() == 1); 8332 ASSERT(args.length() == 1);
8327 // The least significant bit (after untagging) indicates whether the 8333 // The least significant bit (after untagging) indicates whether the
8328 // function is currently optimized, regardless of reason. 8334 // function is currently optimized, regardless of reason.
8329 if (!V8::UseCrankshaft()) { 8335 if (!V8::UseCrankshaft()) {
8330 return Smi::FromInt(4); // 4 == "never". 8336 return Smi::FromInt(4); // 4 == "never".
8331 } 8337 }
8338 if (FLAG_optimize_in_parallel) {
8339 return Smi::FromInt(5); // 5 == "indeterministic"
8340 }
8332 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8341 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8333 if (FLAG_always_opt) { 8342 if (FLAG_always_opt) {
8334 // We may have always opt, but that is more best-effort than a real 8343 // 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. 8344 // promise, so we still say "no" if it is not optimized.
8336 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". 8345 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always".
8337 : Smi::FromInt(2); // 2 == "no". 8346 : Smi::FromInt(2); // 2 == "no".
8338 } 8347 }
8339 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8348 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8340 : Smi::FromInt(2); // 2 == "no". 8349 : Smi::FromInt(2); // 2 == "no".
8341 } 8350 }
(...skipping 5133 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698