From f24997c1c79238a02003b5fa3bf27918149011e4 Mon Sep 17 00:00:00 2001 From: "machenbach@chromium.org" Date: Thu, 18 Jul 2013 08:12:01 +0000 Subject: [PATCH] Make deoptimization stress count global. Store the deopt stress counter per isolate instead of per shared function info. The old field is removed. Enable output of the counter value with a new flag. R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/19383002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15739 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/assembler.cc | 5 +++++ src/assembler.h | 2 ++ src/flag-definitions.h | 1 + src/heap.cc | 1 - src/ia32/lithium-codegen-ia32.cc | 20 ++++++-------------- src/isolate.cc | 9 ++++++++- src/isolate.h | 5 +++++ src/objects-inl.h | 8 ++------ src/objects.h | 11 ++--------- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/assembler.cc b/src/assembler.cc index 82c3c83..d472143 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -1073,6 +1073,11 @@ ExternalReference ExternalReference::date_cache_stamp(Isolate* isolate) { } +ExternalReference ExternalReference::stress_deopt_count(Isolate* isolate) { + return ExternalReference(isolate->stress_deopt_count_address()); +} + + ExternalReference ExternalReference::transcendental_cache_array_address( Isolate* isolate) { return ExternalReference( diff --git a/src/assembler.h b/src/assembler.h index 5cdddeb..481add5 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -866,6 +866,8 @@ class ExternalReference BASE_EMBEDDED { reinterpret_cast(redirector)); } + static ExternalReference stress_deopt_count(Isolate* isolate); + private: explicit ExternalReference(void* address) : address_(address) {} diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 397e63e..6ba2d08 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -254,6 +254,7 @@ DEFINE_int(deopt_every_n_times, DEFINE_int(deopt_every_n_garbage_collections, 0, "deoptimize every n garbage collections") +DEFINE_bool(print_deopt_stress, false, "print number of possible deopt points") DEFINE_bool(trap_on_deopt, false, "put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true, "deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true, "polymorphic inlining") diff --git a/src/heap.cc b/src/heap.cc index 97c1d41..c5d5159 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -3623,7 +3623,6 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) { share->set_inferred_name(empty_string(), SKIP_WRITE_BARRIER); share->set_initial_map(undefined_value(), SKIP_WRITE_BARRIER); share->set_ast_node_count(0); - share->set_stress_deopt_counter(FLAG_deopt_every_n_times); share->set_counters(0); // Set integer fields (smi or int, depending on the architecture). diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 8b7a494..54fb187 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -932,30 +932,22 @@ void LCodeGen::DeoptimizeIf(Condition cc, } if (FLAG_deopt_every_n_times != 0 && !info()->IsStub()) { - Handle shared(info()->shared_info()); + ExternalReference count = ExternalReference::stress_deopt_count(isolate()); Label no_deopt; __ pushfd(); __ push(eax); - __ push(ebx); - __ mov(ebx, shared); - __ mov(eax, - FieldOperand(ebx, SharedFunctionInfo::kStressDeoptCounterOffset)); - __ sub(Operand(eax), Immediate(Smi::FromInt(1))); + __ mov(eax, Operand::StaticVariable(count)); + __ sub(eax, Immediate(1)); __ j(not_zero, &no_deopt, Label::kNear); if (FLAG_trap_on_deopt) __ int3(); - __ mov(eax, Immediate(Smi::FromInt(FLAG_deopt_every_n_times))); - __ mov(FieldOperand(ebx, SharedFunctionInfo::kStressDeoptCounterOffset), - eax); - __ pop(ebx); + __ mov(eax, Immediate(FLAG_deopt_every_n_times)); + __ mov(Operand::StaticVariable(count), eax); __ pop(eax); __ popfd(); ASSERT(frame_is_built_); __ call(entry, RelocInfo::RUNTIME_ENTRY); - __ bind(&no_deopt); - __ mov(FieldOperand(ebx, SharedFunctionInfo::kStressDeoptCounterOffset), - eax); - __ pop(ebx); + __ mov(Operand::StaticVariable(count), eax); __ pop(eax); __ popfd(); } diff --git a/src/isolate.cc b/src/isolate.cc index f0ad02d..ece024c 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1786,7 +1786,8 @@ Isolate::Isolate() optimizing_compiler_thread_(this), marking_thread_(NULL), sweeper_thread_(NULL), - callback_table_(NULL) { + callback_table_(NULL), + stress_deopt_count_(0) { id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); TRACE_ISOLATE(constructor); @@ -1898,6 +1899,10 @@ void Isolate::Deinit() { if (FLAG_hydrogen_stats) GetHStatistics()->Print(); + if (FLAG_print_deopt_stress) { + PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); + } + // We must stop the logger before we tear down other components. Sampler* sampler = logger_->sampler(); if (sampler && sampler->IsActive()) sampler->Stop(); @@ -2132,6 +2137,8 @@ bool Isolate::Init(Deserializer* des) { ASSERT(Isolate::Current() == this); TRACE_ISOLATE(init); + stress_deopt_count_ = FLAG_deopt_every_n_times; + if (function_entry_hook() != NULL) { // When function entry hooking is in effect, we have to create the code // stubs from scratch to get entry hooks, rather than loading the previously diff --git a/src/isolate.h b/src/isolate.h index c0ea772..b3651e1 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -1130,6 +1130,8 @@ class Isolate { function_entry_hook_ = function_entry_hook; } + void* stress_deopt_count_address() { return &stress_deopt_count_; } + private: Isolate(); @@ -1365,6 +1367,9 @@ class Isolate { SweeperThread** sweeper_thread_; CallbackTable* callback_table_; + // Counts deopt points if deopt_every_n_times is enabled. + unsigned int stress_deopt_count_; + friend class ExecutionAccess; friend class HandleScopeImplementer; friend class IsolateInitializer; diff --git a/src/objects-inl.h b/src/objects-inl.h index ca3486f..ea21460 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4542,9 +4542,7 @@ SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, kCompilerHintsOffset) SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) -SMI_ACCESSORS(SharedFunctionInfo, - stress_deopt_counter, - kStressDeoptCounterOffset) + #else #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ @@ -4594,9 +4592,7 @@ PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, opt_count, kOptCountOffset) PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, counters, kCountersOffset) -PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, - stress_deopt_counter, - kStressDeoptCounterOffset) + #endif diff --git a/src/objects.h b/src/objects.h index 08b1e10..5d5945e 100644 --- a/src/objects.h +++ b/src/objects.h @@ -6157,11 +6157,6 @@ class SharedFunctionInfo: public HeapObject { inline int ast_node_count(); inline void set_ast_node_count(int count); - // A counter used to determine when to stress the deoptimizer with a - // deopt. - inline int stress_deopt_counter(); - inline void set_stress_deopt_counter(int counter); - inline int profiler_ticks(); // Inline cache age is used to infer whether the function survived a context @@ -6353,10 +6348,9 @@ class SharedFunctionInfo: public HeapObject { kFunctionTokenPositionOffset + kPointerSize; static const int kOptCountOffset = kCompilerHintsOffset + kPointerSize; static const int kCountersOffset = kOptCountOffset + kPointerSize; - static const int kStressDeoptCounterOffset = kCountersOffset + kPointerSize; // Total size. - static const int kSize = kStressDeoptCounterOffset + kPointerSize; + static const int kSize = kCountersOffset + kPointerSize; #else // The only reason to use smi fields instead of int fields // is to allow iteration without maps decoding during @@ -6390,10 +6384,9 @@ class SharedFunctionInfo: public HeapObject { static const int kOptCountOffset = kCompilerHintsOffset + kIntSize; static const int kCountersOffset = kOptCountOffset + kIntSize; - static const int kStressDeoptCounterOffset = kCountersOffset + kIntSize; // Total size. - static const int kSize = kStressDeoptCounterOffset + kIntSize; + static const int kSize = kCountersOffset + kIntSize; #endif -- 2.7.4