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

Side by Side Diff: src/runtime.cc

Issue 10908194: Fix arguments object materialization during deopt. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improved test coverage and fixed bug. Created 8 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 | « src/mips/lithium-mips.cc ('k') | src/x64/lithium-codegen-x64.h » ('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 7952 matching lines...) Expand 10 before | Expand all | Expand 10 after
7963 } 7963 }
7964 7964
7965 bool has_activations() { return has_activations_; } 7965 bool has_activations() { return has_activations_; }
7966 7966
7967 private: 7967 private:
7968 JSFunction* function_; 7968 JSFunction* function_;
7969 bool has_activations_; 7969 bool has_activations_;
7970 }; 7970 };
7971 7971
7972 7972
7973 static void MaterializeArgumentsObjectInFrame(Isolate* isolate,
7974 JavaScriptFrame* frame) {
7975 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
7976 Handle<Object> arguments;
7977 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
7978 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
7979 if (arguments.is_null()) {
7980 // FunctionGetArguments can't throw an exception, so cast away the
7981 // doubt with an assert.
7982 arguments = Handle<Object>(
7983 Accessors::FunctionGetArguments(*function,
7984 NULL)->ToObjectUnchecked());
7985 ASSERT(*arguments != isolate->heap()->null_value());
7986 ASSERT(*arguments != isolate->heap()->undefined_value());
7987 }
7988 frame->SetExpression(i, *arguments);
7989 if (FLAG_trace_deopt) {
7990 PrintF("Materializing arguments object for frame %p - %p: %p ",
7991 reinterpret_cast<void*>(frame->sp()),
7992 reinterpret_cast<void*>(frame->fp()),
7993 reinterpret_cast<void*>(*arguments));
7994 arguments->ShortPrint();
7995 PrintF("\n");
7996 }
7997 }
7998 }
7999 }
8000
8001
8002 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { 7973 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
8003 HandleScope scope(isolate); 7974 HandleScope scope(isolate);
8004 ASSERT(args.length() == 1); 7975 ASSERT(args.length() == 1);
8005 RUNTIME_ASSERT(args[0]->IsSmi()); 7976 RUNTIME_ASSERT(args[0]->IsSmi());
8006 Deoptimizer::BailoutType type = 7977 Deoptimizer::BailoutType type =
8007 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); 7978 static_cast<Deoptimizer::BailoutType>(args.smi_at(0));
8008 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 7979 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8009 ASSERT(isolate->heap()->IsAllocationAllowed()); 7980 ASSERT(isolate->heap()->IsAllocationAllowed());
8010 int jsframes = deoptimizer->jsframe_count(); 7981 JavaScriptFrameIterator it(isolate);
8011 7982
8012 deoptimizer->MaterializeHeapNumbers(); 7983 // Make sure to materialize objects before causing any allocation.
7984 deoptimizer->MaterializeHeapObjects(&it);
8013 delete deoptimizer; 7985 delete deoptimizer;
8014 7986
8015 JavaScriptFrameIterator it(isolate);
8016 for (int i = 0; i < jsframes - 1; i++) {
8017 MaterializeArgumentsObjectInFrame(isolate, it.frame());
8018 it.Advance();
8019 }
8020
8021 JavaScriptFrame* frame = it.frame(); 7987 JavaScriptFrame* frame = it.frame();
8022 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 7988 RUNTIME_ASSERT(frame->function()->IsJSFunction());
8023 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); 7989 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
8024 MaterializeArgumentsObjectInFrame(isolate, frame); 7990 RUNTIME_ASSERT(type != Deoptimizer::EAGER || function->IsOptimized());
8025
8026 if (type == Deoptimizer::EAGER) {
8027 RUNTIME_ASSERT(function->IsOptimized());
8028 }
8029 7991
8030 // Avoid doing too much work when running with --always-opt and keep 7992 // Avoid doing too much work when running with --always-opt and keep
8031 // the optimized code around. 7993 // the optimized code around.
8032 if (FLAG_always_opt || type == Deoptimizer::LAZY) { 7994 if (FLAG_always_opt || type == Deoptimizer::LAZY) {
8033 return isolate->heap()->undefined_value(); 7995 return isolate->heap()->undefined_value();
8034 } 7996 }
8035 7997
8036 // Find other optimized activations of the function or functions that 7998 // Find other optimized activations of the function or functions that
8037 // share the same optimized code. 7999 // share the same optimized code.
8038 bool has_other_activations = false; 8000 bool has_other_activations = false;
(...skipping 5260 matching lines...) Expand 10 before | Expand all | Expand 10 after
13299 // Handle last resort GC and make sure to allow future allocations 13261 // Handle last resort GC and make sure to allow future allocations
13300 // to grow the heap without causing GCs (if possible). 13262 // to grow the heap without causing GCs (if possible).
13301 isolate->counters()->gc_last_resort_from_js()->Increment(); 13263 isolate->counters()->gc_last_resort_from_js()->Increment();
13302 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13264 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13303 "Runtime::PerformGC"); 13265 "Runtime::PerformGC");
13304 } 13266 }
13305 } 13267 }
13306 13268
13307 13269
13308 } } // namespace v8::internal 13270 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-mips.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698