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

Side by Side Diff: src/runtime.cc

Issue 7890028: Force lazy deoptimization and remove optimized code on deopt inside a recursively invoked function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 8211 matching lines...) Expand 10 before | Expand all | Expand 10 after
8222 NULL)->ToObjectUnchecked()); 8222 NULL)->ToObjectUnchecked());
8223 ASSERT(*arguments != isolate->heap()->null_value()); 8223 ASSERT(*arguments != isolate->heap()->null_value());
8224 ASSERT(*arguments != isolate->heap()->undefined_value()); 8224 ASSERT(*arguments != isolate->heap()->undefined_value());
8225 } 8225 }
8226 frame->SetExpression(i, *arguments); 8226 frame->SetExpression(i, *arguments);
8227 } 8227 }
8228 } 8228 }
8229 8229
8230 if (type == Deoptimizer::EAGER) { 8230 if (type == Deoptimizer::EAGER) {
8231 RUNTIME_ASSERT(function->IsOptimized()); 8231 RUNTIME_ASSERT(function->IsOptimized());
8232 } else {
8233 RUNTIME_ASSERT(!function->IsOptimized());
8234 } 8232 }
8235 8233
8236 // Avoid doing too much work when running with --always-opt and keep 8234 // Avoid doing too much work when running with --always-opt and keep
8237 // the optimized code around. 8235 // the optimized code around.
8238 if (FLAG_always_opt || type == Deoptimizer::LAZY) { 8236 if (FLAG_always_opt || type == Deoptimizer::LAZY) {
8239 return isolate->heap()->undefined_value(); 8237 return isolate->heap()->undefined_value();
8240 } 8238 }
8241 8239
8242 // Count the number of optimized activations of the function. 8240 // Count the number of optimized activations of the function.
8243 int activations = 0; 8241 int activations = 0;
8244 while (!it.done()) { 8242 while (!it.done()) {
8245 JavaScriptFrame* frame = it.frame(); 8243 JavaScriptFrame* frame = it.frame();
8246 if (frame->is_optimized() && frame->function() == *function) { 8244 if (frame->is_optimized() && frame->function() == *function) {
8247 activations++; 8245 activations++;
8248 } 8246 }
8249 it.Advance(); 8247 it.Advance();
8250 } 8248 }
8251 8249
8252 // TODO(kasperl): For now, we cannot support removing the optimized
8253 // code when we have recursive invocations of the same function.
8254 if (activations == 0) { 8250 if (activations == 0) {
8255 if (FLAG_trace_deopt) { 8251 if (FLAG_trace_deopt) {
8256 PrintF("[removing optimized code for: "); 8252 PrintF("[removing optimized code for: ");
8257 function->PrintName(); 8253 function->PrintName();
8258 PrintF("]\n"); 8254 PrintF("]\n");
8259 } 8255 }
8260 function->ReplaceCode(function->shared()->code()); 8256 function->ReplaceCode(function->shared()->code());
8257 } else {
8258 Deoptimizer::DeoptimizeFunction(*function);
8261 } 8259 }
8262 return isolate->heap()->undefined_value(); 8260 return isolate->heap()->undefined_value();
8263 } 8261 }
8264 8262
8265 8263
8266 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { 8264 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) {
8267 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8265 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8268 delete deoptimizer; 8266 delete deoptimizer;
8269 return isolate->heap()->undefined_value(); 8267 return isolate->heap()->undefined_value();
8270 } 8268 }
(...skipping 4953 matching lines...) Expand 10 before | Expand all | Expand 10 after
13224 } else { 13222 } else {
13225 // Handle last resort GC and make sure to allow future allocations 13223 // Handle last resort GC and make sure to allow future allocations
13226 // to grow the heap without causing GCs (if possible). 13224 // to grow the heap without causing GCs (if possible).
13227 isolate->counters()->gc_last_resort_from_js()->Increment(); 13225 isolate->counters()->gc_last_resort_from_js()->Increment();
13228 isolate->heap()->CollectAllGarbage(false); 13226 isolate->heap()->CollectAllGarbage(false);
13229 } 13227 }
13230 } 13228 }
13231 13229
13232 13230
13233 } } // namespace v8::internal 13231 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698