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

Side by Side Diff: src/runtime.cc

Issue 99013003: Fix incorrect patching for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comment Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/x64/builtins-x64.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 8389 matching lines...) Expand 10 before | Expand all | Expand 10 after
8400 8400
8401 8401
8402 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { 8402 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) {
8403 HandleScope handle_scope(isolate); 8403 HandleScope handle_scope(isolate);
8404 ASSERT(args.length() == 1); 8404 ASSERT(args.length() == 1);
8405 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8405 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8406 if (!AllowOptimization(isolate, function)) { 8406 if (!AllowOptimization(isolate, function)) {
8407 function->ReplaceCode(function->shared()->code()); 8407 function->ReplaceCode(function->shared()->code());
8408 return isolate->heap()->undefined_value(); 8408 return isolate->heap()->undefined_value();
8409 } 8409 }
8410 function->shared()->code()->set_profiler_ticks(0); 8410 Handle<Code> shared_code(function->shared()->code());
8411 shared_code->set_profiler_ticks(0);
8411 ASSERT(isolate->concurrent_recompilation_enabled()); 8412 ASSERT(isolate->concurrent_recompilation_enabled());
8412 if (!Compiler::RecompileConcurrent(function)) { 8413 if (!Compiler::RecompileConcurrent(function, shared_code)) {
8413 function->ReplaceCode(function->shared()->code()); 8414 function->ReplaceCode(*shared_code);
8414 } 8415 }
8415 return isolate->heap()->undefined_value(); 8416 return isolate->heap()->undefined_value();
8416 } 8417 }
8417 8418
8418 8419
8419 class ActivationsFinder : public ThreadVisitor { 8420 class ActivationsFinder : public ThreadVisitor {
8420 public: 8421 public:
8421 Code* code_; 8422 Code* code_;
8422 bool has_code_activations_; 8423 bool has_code_activations_;
8423 8424
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
8653 JavaScriptFrame* frame = it.frame(); 8654 JavaScriptFrame* frame = it.frame();
8654 if (frame->is_optimized() && frame->function() == *function) return false; 8655 if (frame->is_optimized() && frame->function() == *function) return false;
8655 } 8656 }
8656 8657
8657 return true; 8658 return true;
8658 } 8659 }
8659 8660
8660 8661
8661 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { 8662 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
8662 HandleScope scope(isolate); 8663 HandleScope scope(isolate);
8663 ASSERT(args.length() == 2); 8664 ASSERT(args.length() == 1);
8664 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8665 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8665 CONVERT_NUMBER_CHECKED(uint32_t, pc_offset, Uint32, args[1]);
8666 Handle<Code> unoptimized(function->shared()->code(), isolate); 8666 Handle<Code> unoptimized(function->shared()->code(), isolate);
8667 8667
8668 #ifdef DEBUG 8668 // Passing the PC in the javascript frame from the caller directly is
8669 // not GC safe, so we walk the stack to get it.
8669 JavaScriptFrameIterator it(isolate); 8670 JavaScriptFrameIterator it(isolate);
8670 JavaScriptFrame* frame = it.frame(); 8671 JavaScriptFrame* frame = it.frame();
8672 if (!unoptimized->contains(frame->pc())) {
8673 // Code on the stack may not be the code object referenced by the shared
8674 // function info. It may have been replaced to include deoptimization data.
8675 unoptimized = Handle<Code>(frame->LookupCode());
8676 }
8677
8678 uint32_t pc_offset = static_cast<uint32_t>(frame->pc() -
8679 unoptimized->instruction_start());
8680
8681 #ifdef DEBUG
8671 ASSERT_EQ(frame->function(), *function); 8682 ASSERT_EQ(frame->function(), *function);
8672 ASSERT_EQ(frame->LookupCode(), *unoptimized); 8683 ASSERT_EQ(frame->LookupCode(), *unoptimized);
8673 ASSERT(unoptimized->contains(frame->pc())); 8684 ASSERT(unoptimized->contains(frame->pc()));
8674
8675 ASSERT(pc_offset ==
8676 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start()));
8677 #endif // DEBUG 8685 #endif // DEBUG
8678 8686
8679 // We're not prepared to handle a function with arguments object. 8687 // We're not prepared to handle a function with arguments object.
8680 ASSERT(!function->shared()->uses_arguments()); 8688 ASSERT(!function->shared()->uses_arguments());
8681 8689
8682 Handle<Code> result = Handle<Code>::null(); 8690 Handle<Code> result = Handle<Code>::null();
8683 BailoutId ast_id = BailoutId::None(); 8691 BailoutId ast_id = BailoutId::None();
8684 8692
8685 if (isolate->concurrent_osr_enabled()) { 8693 if (isolate->concurrent_osr_enabled()) {
8686 if (isolate->optimizing_compiler_thread()-> 8694 if (isolate->optimizing_compiler_thread()->
8687 IsQueuedForOSR(function, pc_offset)) { 8695 IsQueuedForOSR(function, pc_offset)) {
8688 // Still waiting for the optimizing compiler thread to finish. Carry on. 8696 // Still waiting for the optimizing compiler thread to finish. Carry on.
8689 if (FLAG_trace_osr) { 8697 if (FLAG_trace_osr) {
8690 PrintF("[COSR - polling recompile tasks for "); 8698 PrintF("[COSR - polling recompile tasks for ");
8691 function->PrintName(); 8699 function->PrintName();
8692 PrintF("]\n"); 8700 PrintF("]\n");
8693 } 8701 }
8694 return NULL; 8702 return NULL;
8695 } 8703 }
8696 8704
8697 RecompileJob* job = isolate->optimizing_compiler_thread()-> 8705 RecompileJob* job = isolate->optimizing_compiler_thread()->
8698 FindReadyOSRCandidate(function, pc_offset); 8706 FindReadyOSRCandidate(function, pc_offset);
8699 8707
8700 if (job == NULL) { 8708 if (job == NULL) {
8701 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && 8709 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) &&
8702 Compiler::RecompileConcurrent(function, pc_offset)) { 8710 Compiler::RecompileConcurrent(function, unoptimized, pc_offset)) {
8703 if (function->IsMarkedForLazyRecompilation() || 8711 if (function->IsMarkedForLazyRecompilation() ||
8704 function->IsMarkedForConcurrentRecompilation()) { 8712 function->IsMarkedForConcurrentRecompilation()) {
8705 // Prevent regular recompilation if we queue this for OSR. 8713 // Prevent regular recompilation if we queue this for OSR.
8706 // TODO(yangguo): remove this as soon as OSR becomes one-shot. 8714 // TODO(yangguo): remove this as soon as OSR becomes one-shot.
8707 function->ReplaceCode(*unoptimized); 8715 function->ReplaceCode(function->shared()->code());
8708 } 8716 }
8709 return NULL; 8717 return NULL;
8710 } 8718 }
8711 // Fall through to the end in case of failure. 8719 // Fall through to the end in case of failure.
8712 } else { 8720 } else {
8713 // TODO(titzer): don't install the OSR code into the function. 8721 // TODO(titzer): don't install the OSR code into the function.
8714 ast_id = job->info()->osr_ast_id(); 8722 ast_id = job->info()->osr_ast_id();
8715 result = Compiler::InstallOptimizedCode(job); 8723 result = Compiler::InstallOptimizedCode(job);
8716 } 8724 }
8717 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { 8725 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) {
(...skipping 6197 matching lines...) Expand 10 before | Expand all | Expand 10 after
14915 // Handle last resort GC and make sure to allow future allocations 14923 // Handle last resort GC and make sure to allow future allocations
14916 // to grow the heap without causing GCs (if possible). 14924 // to grow the heap without causing GCs (if possible).
14917 isolate->counters()->gc_last_resort_from_js()->Increment(); 14925 isolate->counters()->gc_last_resort_from_js()->Increment();
14918 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14926 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14919 "Runtime::PerformGC"); 14927 "Runtime::PerformGC");
14920 } 14928 }
14921 } 14929 }
14922 14930
14923 14931
14924 } } // namespace v8::internal 14932 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698