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

Side by Side Diff: src/runtime.cc

Issue 14604007: Only flush SharedFunctionInfo optimized code cache when necessary (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix bug Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | src/x64/deoptimizer-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 7955 matching lines...) Expand 10 before | Expand all | Expand 10 after
7966 ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION); 7966 ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION);
7967 7967
7968 // Make sure to materialize objects before causing any allocation. 7968 // Make sure to materialize objects before causing any allocation.
7969 JavaScriptFrameIterator it(isolate); 7969 JavaScriptFrameIterator it(isolate);
7970 deoptimizer->MaterializeHeapObjects(&it); 7970 deoptimizer->MaterializeHeapObjects(&it);
7971 delete deoptimizer; 7971 delete deoptimizer;
7972 7972
7973 JavaScriptFrame* frame = it.frame(); 7973 JavaScriptFrame* frame = it.frame();
7974 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 7974 RUNTIME_ASSERT(frame->function()->IsJSFunction());
7975 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); 7975 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
7976 Handle<Code> optimized_code(function->code());
7976 RUNTIME_ASSERT(type != Deoptimizer::EAGER || function->IsOptimized()); 7977 RUNTIME_ASSERT(type != Deoptimizer::EAGER || function->IsOptimized());
7977 7978
7978 // Avoid doing too much work when running with --always-opt and keep 7979 // Avoid doing too much work when running with --always-opt and keep
7979 // the optimized code around. 7980 // the optimized code around.
7980 if (FLAG_always_opt || type == Deoptimizer::LAZY) { 7981 if (FLAG_always_opt || type == Deoptimizer::LAZY) {
7981 return isolate->heap()->undefined_value(); 7982 return isolate->heap()->undefined_value();
7982 } 7983 }
7983 7984
7984 // Find other optimized activations of the function or functions that 7985 // Find other optimized activations of the function or functions that
7985 // share the same optimized code. 7986 // share the same optimized code.
(...skipping 17 matching lines...) Expand all
8003 if (!has_other_activations) { 8004 if (!has_other_activations) {
8004 if (FLAG_trace_deopt) { 8005 if (FLAG_trace_deopt) {
8005 PrintF("[removing optimized code for: "); 8006 PrintF("[removing optimized code for: ");
8006 function->PrintName(); 8007 function->PrintName();
8007 PrintF("]\n"); 8008 PrintF("]\n");
8008 } 8009 }
8009 function->ReplaceCode(function->shared()->code()); 8010 function->ReplaceCode(function->shared()->code());
8010 } else { 8011 } else {
8011 Deoptimizer::DeoptimizeFunction(*function); 8012 Deoptimizer::DeoptimizeFunction(*function);
8012 } 8013 }
8013 // Flush optimized code cache for this function. 8014 // Evict optimized code for this function from the cache so that it doesn't
8014 function->shared()->ClearOptimizedCodeMap("notify deoptimized"); 8015 // get used for new closures.
8016 function->shared()->EvictFromOptimizedCodeMap(*optimized_code,
8017 "notify deoptimized");
8015 8018
8016 return isolate->heap()->undefined_value(); 8019 return isolate->heap()->undefined_value();
8017 } 8020 }
8018 8021
8019 8022
8020 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { 8023 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) {
8021 NoHandleAllocation ha(isolate); 8024 NoHandleAllocation ha(isolate);
8022 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8025 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8023 delete deoptimizer; 8026 delete deoptimizer;
8024 return isolate->heap()->undefined_value(); 8027 return isolate->heap()->undefined_value();
(...skipping 5479 matching lines...) Expand 10 before | Expand all | Expand 10 after
13504 // Handle last resort GC and make sure to allow future allocations 13507 // Handle last resort GC and make sure to allow future allocations
13505 // to grow the heap without causing GCs (if possible). 13508 // to grow the heap without causing GCs (if possible).
13506 isolate->counters()->gc_last_resort_from_js()->Increment(); 13509 isolate->counters()->gc_last_resort_from_js()->Increment();
13507 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13510 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13508 "Runtime::PerformGC"); 13511 "Runtime::PerformGC");
13509 } 13512 }
13510 } 13513 }
13511 13514
13512 13515
13513 } } // namespace v8::internal 13516 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/deoptimizer-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698