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/objects.cc

Issue 9207002: Add a deoptimization count to each function to limit number of re-compilations. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 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
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 7349 matching lines...) Expand 10 before | Expand all | Expand 10 after
7360 return this; 7360 return this;
7361 } 7361 }
7362 7362
7363 7363
7364 Object* JSFunction::SetInstanceClassName(String* name) { 7364 Object* JSFunction::SetInstanceClassName(String* name) {
7365 shared()->set_instance_class_name(name); 7365 shared()->set_instance_class_name(name);
7366 return this; 7366 return this;
7367 } 7367 }
7368 7368
7369 7369
7370 void JSFunction::PrintName(FILE* out) {
7371 SmartArrayPointer<char> name = shared()->DebugName()->ToCString();
7372 PrintF(out, "%s", *name);
7373 }
7374
7375
7376 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { 7370 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) {
7377 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); 7371 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex));
7378 } 7372 }
7379 7373
7380 7374
7381 MaybeObject* Oddball::Initialize(const char* to_string, 7375 MaybeObject* Oddball::Initialize(const char* to_string,
7382 Object* to_number, 7376 Object* to_number,
7383 byte kind) { 7377 byte kind) {
7384 Object* symbol; 7378 Object* symbol;
7385 { MaybeObject* maybe_symbol = 7379 { MaybeObject* maybe_symbol =
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
7602 // TODO(3025757): In case the recompiled isn't equivalent to the 7596 // TODO(3025757): In case the recompiled isn't equivalent to the
7603 // old code, we have to replace it. We should try to avoid this 7597 // old code, we have to replace it. We should try to avoid this
7604 // altogether because it flushes valuable type feedback by 7598 // altogether because it flushes valuable type feedback by
7605 // effectively resetting all IC state. 7599 // effectively resetting all IC state.
7606 set_code(recompiled); 7600 set_code(recompiled);
7607 } 7601 }
7608 ASSERT(has_deoptimization_support()); 7602 ASSERT(has_deoptimization_support());
7609 } 7603 }
7610 7604
7611 7605
7612 void SharedFunctionInfo::DisableOptimization(JSFunction* function) { 7606 void SharedFunctionInfo::IncrementAndCheckDeoptCount() {
7607 set_deopt_count(deopt_count() + 1);
7608 const int kMaxDeoptCount = FLAG_deopt_every_n_times == 0
7609 ? Compiler::kDefaultMaxDeoptCount
7610 : 1000;
7611 if (deopt_count() > kMaxDeoptCount) DisableOptimization();
7612 }
7613
7614
7615 void SharedFunctionInfo::DisableOptimization() {
7613 // Disable optimization for the shared function info and mark the 7616 // Disable optimization for the shared function info and mark the
7614 // code as non-optimizable. The marker on the shared function info 7617 // code as non-optimizable. The marker on the shared function info
7615 // is there because we flush non-optimized code thereby loosing the 7618 // is there because we flush non-optimized code thereby loosing the
7616 // non-optimizable information for the code. When the code is 7619 // non-optimizable information for the code. When the code is
7617 // regenerated and set on the shared function info it is marked as 7620 // regenerated and set on the shared function info it is marked as
7618 // non-optimizable if optimization is disabled for the shared 7621 // non-optimizable if optimization is disabled for the shared
7619 // function info. 7622 // function info.
7620 set_optimization_disabled(true); 7623 set_optimization_disabled(true);
7621 // Code should be the lazy compilation stub or else unoptimized. If the 7624 // Code should be the lazy compilation stub or else unoptimized. If the
7622 // latter, disable optimization for the code too. 7625 // latter, disable optimization for the code too.
7623 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); 7626 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN);
7624 if (code()->kind() == Code::FUNCTION) { 7627 if (code()->kind() == Code::FUNCTION) {
7625 code()->set_optimizable(false); 7628 code()->set_optimizable(false);
7626 } 7629 }
7627 if (FLAG_trace_opt) { 7630 if (FLAG_trace_opt) {
7628 PrintF("[disabled optimization for: "); 7631 PrintF("[disabled optimization for: ");
7629 function->PrintName(); 7632 PrintName();
7630 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(function)); 7633 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(this));
7631 } 7634 }
7632 } 7635 }
7633 7636
7634 7637
7638 void SharedFunctionInfo::PrintName(FILE* out) {
7639 SmartArrayPointer<char> name = DebugName()->ToCString();
7640 PrintF(out, "%s", *name);
7641 }
7642
7643
7635 bool SharedFunctionInfo::VerifyBailoutId(int id) { 7644 bool SharedFunctionInfo::VerifyBailoutId(int id) {
7636 // TODO(srdjan): debugging ARM crashes in hydrogen. OK to disable while 7645 // TODO(srdjan): debugging ARM crashes in hydrogen. OK to disable while
7637 // we are always bailing out on ARM. 7646 // we are always bailing out on ARM.
7638 7647
7639 ASSERT(id != AstNode::kNoNumber); 7648 ASSERT(id != AstNode::kNoNumber);
7640 Code* unoptimized = code(); 7649 Code* unoptimized = code();
7641 DeoptimizationOutputData* data = 7650 DeoptimizationOutputData* data =
7642 DeoptimizationOutputData::cast(unoptimized->deoptimization_data()); 7651 DeoptimizationOutputData::cast(unoptimized->deoptimization_data());
7643 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this); 7652 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this);
7644 USE(ignore); 7653 USE(ignore);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
8001 UNREACHABLE(); 8010 UNREACHABLE();
8002 break; 8011 break;
8003 8012
8004 case Translation::FRAME: { 8013 case Translation::FRAME: {
8005 int ast_id = iterator.Next(); 8014 int ast_id = iterator.Next();
8006 int function_id = iterator.Next(); 8015 int function_id = iterator.Next();
8007 JSFunction* function = 8016 JSFunction* function =
8008 JSFunction::cast(LiteralArray()->get(function_id)); 8017 JSFunction::cast(LiteralArray()->get(function_id));
8009 unsigned height = iterator.Next(); 8018 unsigned height = iterator.Next();
8010 PrintF(out, "{ast_id=%d, function=", ast_id); 8019 PrintF(out, "{ast_id=%d, function=", ast_id);
8011 function->PrintName(out); 8020 function->shared()->PrintName(out);
Jakob Kummerow 2012/01/16 11:41:25 nit: since you defined JSFunction::PrintName(...),
fschneider 2012/01/19 10:26:11 Done.
8012 PrintF(out, ", height=%u}", height); 8021 PrintF(out, ", height=%u}", height);
8013 break; 8022 break;
8014 } 8023 }
8015 8024
8016 case Translation::DUPLICATE: 8025 case Translation::DUPLICATE:
8017 break; 8026 break;
8018 8027
8019 case Translation::REGISTER: { 8028 case Translation::REGISTER: {
8020 int reg_code = iterator.Next(); 8029 int reg_code = iterator.Next();
8021 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code)); 8030 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
(...skipping 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after
12743 if (break_point_objects()->IsUndefined()) return 0; 12752 if (break_point_objects()->IsUndefined()) return 0;
12744 // Single break point. 12753 // Single break point.
12745 if (!break_point_objects()->IsFixedArray()) return 1; 12754 if (!break_point_objects()->IsFixedArray()) return 1;
12746 // Multiple break points. 12755 // Multiple break points.
12747 return FixedArray::cast(break_point_objects())->length(); 12756 return FixedArray::cast(break_point_objects())->length();
12748 } 12757 }
12749 #endif // ENABLE_DEBUGGER_SUPPORT 12758 #endif // ENABLE_DEBUGGER_SUPPORT
12750 12759
12751 12760
12752 } } // namespace v8::internal 12761 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698