From d1c0d6b3cdde0960355302fc8f0f6e95df88851c Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Tue, 3 Sep 2013 08:49:44 +0000 Subject: [PATCH] Move global V8::UseCrankshaft() into the Isolate. R=jkummerow@chromium.org BUG=v8:2744 Review URL: https://codereview.chromium.org/23441029 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16494 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler.cc | 10 +++++----- src/compiler.h | 2 +- src/factory.cc | 2 +- src/isolate.cc | 5 +++++ src/isolate.h | 5 +++++ src/runtime.cc | 4 ++-- src/v8.cc | 4 ---- src/v8.h | 3 --- test/cctest/test-deoptimization.cc | 10 +++++----- test/cctest/test-heap.cc | 34 +++++++++++++++++----------------- test/cctest/test-random.cc | 2 +- 11 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index c791cb5..bc65b1f 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -119,7 +119,7 @@ void CompilationInfo::Initialize(Isolate* isolate, mode_ = STUB; return; } - mode_ = V8::UseCrankshaft() ? mode : NONOPT; + mode_ = isolate->use_crankshaft() ? mode : NONOPT; abort_due_to_dependency_ = false; if (script_->type()->value() == Script::TYPE_NATIVE) { MarkAsNative(); @@ -242,7 +242,7 @@ bool CompilationInfo::ShouldSelfOptimize() { // break points has actually been set. static bool IsDebuggerActive(Isolate* isolate) { #ifdef ENABLE_DEBUGGER_SUPPORT - return V8::UseCrankshaft() ? + return isolate->use_crankshaft() ? isolate->debug()->has_break_points() : isolate->debugger()->IsDebuggerActive(); #else @@ -310,7 +310,7 @@ static bool MakeCrankshaftCode(CompilationInfo* info) { OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { - ASSERT(V8::UseCrankshaft()); + ASSERT(isolate()->use_crankshaft()); ASSERT(info()->IsOptimizing()); ASSERT(!info()->IsCompilingForDebugging()); @@ -499,7 +499,7 @@ OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { static bool GenerateCode(CompilationInfo* info) { - bool is_optimizing = V8::UseCrankshaft() && + bool is_optimizing = info->isolate()->use_crankshaft() && !info->IsCompilingForDebugging() && info->IsOptimizing(); if (is_optimizing) { @@ -838,7 +838,7 @@ static bool InstallFullCode(CompilationInfo* info) { shared->set_dont_inline(lit->flags()->Contains(kDontInline)); shared->set_ast_node_count(lit->ast_node_count()); - if (V8::UseCrankshaft() && + if (info->isolate()->use_crankshaft() && !function.is_null() && !shared->optimization_disabled()) { // If we're asked to always optimize, we compile the optimized diff --git a/src/compiler.h b/src/compiler.h index bdb168f..4f6a472 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -335,7 +335,7 @@ class CompilationInfo { void Initialize(Isolate* isolate, Mode mode, Zone* zone); void SetMode(Mode mode) { - ASSERT(V8::UseCrankshaft()); + ASSERT(isolate()->use_crankshaft()); mode_ = mode; } diff --git a/src/factory.cc b/src/factory.cc index 8878b79..819e9f0 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -664,7 +664,7 @@ Handle Factory::NewFunctionFromSharedFunctionInfo( return result; } - if (V8::UseCrankshaft() && + if (isolate()->use_crankshaft() && FLAG_always_opt && result->is_compiled() && !function_info->is_toplevel() && diff --git a/src/isolate.cc b/src/isolate.cc index 691c6b7..b3e8a53 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1793,6 +1793,7 @@ Isolate::Isolate() regexp_stack_(NULL), date_cache_(NULL), code_stub_interface_descriptors_(NULL), + use_crankshaft_(true), initialized_from_snapshot_(false), cpu_profiler_(NULL), heap_profiler_(NULL), @@ -2148,6 +2149,10 @@ bool Isolate::Init(Deserializer* des) { stress_deopt_count_ = FLAG_deopt_every_n_times; + use_crankshaft_ = FLAG_crankshaft + && !Serializer::enabled() + && CPU::SupportsCrankshaft(); + 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 8eace12..b50ab0e 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -1059,6 +1059,8 @@ class Isolate { thread_local_top_.top_lookup_result_ = top; } + bool use_crankshaft() const { return use_crankshaft_; } + bool initialized_from_snapshot() { return initialized_from_snapshot_; } double time_millis_since_init() { @@ -1300,6 +1302,9 @@ class Isolate { unibrow::Mapping interp_canonicalize_mapping_; CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; + // True if we are using the Crankshaft optimizing compiler. + bool use_crankshaft_; + // True if this isolate was initialized from a snapshot. bool initialized_from_snapshot_; diff --git a/src/runtime.cc b/src/runtime.cc index 1e0f4cd..d183a6b 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -8352,7 +8352,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { HandleScope handle_scope(isolate); ASSERT(args.length() == 1); CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); - ASSERT(V8::UseCrankshaft() && FLAG_concurrent_recompilation); + ASSERT(isolate->use_crankshaft() && FLAG_concurrent_recompilation); isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); return function->code(); } @@ -8538,7 +8538,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { HandleScope scope(isolate); RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); - if (!V8::UseCrankshaft()) { + if (!isolate->use_crankshaft()) { return Smi::FromInt(4); // 4 == "never". } bool sync_with_compiler_thread = true; diff --git a/src/v8.cc b/src/v8.cc index a5ff145..a9d3c99 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -53,7 +53,6 @@ V8_DECLARE_ONCE(init_once); bool V8::has_been_set_up_ = false; bool V8::has_been_disposed_ = false; bool V8::has_fatal_error_ = false; -bool V8::use_crankshaft_ = true; List* V8::call_completed_callbacks_ = NULL; v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; @@ -314,9 +313,6 @@ void V8::InitializeOncePerProcessImpl() { OS::SetUp(); Sampler::SetUp(); CPU::SetUp(); - use_crankshaft_ = FLAG_crankshaft - && !Serializer::enabled() - && CPU::SupportsCrankshaft(); OS::PostSetUp(); ElementsAccessor::InitializeOncePerProcess(); LOperand::SetUpCaches(); diff --git a/src/v8.h b/src/v8.h index 73c9b75..abace93 100644 --- a/src/v8.h +++ b/src/v8.h @@ -82,7 +82,6 @@ class V8 : public AllStatic { // empty heap. static bool Initialize(Deserializer* des); static void TearDown(); - static bool UseCrankshaft() { return use_crankshaft_; } // To be dead you have to have lived // TODO(isolates): move IsDead to Isolate. static bool IsDead() { return has_fatal_error_ || has_been_disposed_; } @@ -138,8 +137,6 @@ class V8 : public AllStatic { // True if engine has been shut down // (reset if engine is restarted) static bool has_been_disposed_; - // True if we are using the crankshaft optimizing compiler. - static bool use_crankshaft_; // List of callbacks when a Call completes. static List* call_completed_callbacks_; // Allocator for external array buffers. diff --git a/test/cctest/test-deoptimization.cc b/test/cctest/test-deoptimization.cc index 10fe99c..83a6354 100644 --- a/test/cctest/test-deoptimization.cc +++ b/test/cctest/test-deoptimization.cc @@ -367,7 +367,7 @@ TEST(DeoptimizeBinaryOperationADDString) { i::FLAG_always_opt = true; CompileRun(f_source); CompileRun("f('a+', new X());"); - CHECK(!i::V8::UseCrankshaft() || + CHECK(!i::Isolate::Current()->use_crankshaft() || GetJSFunction(env->Global(), "f")->IsOptimized()); // Call f and force deoptimization while processing the binary operation. @@ -419,7 +419,7 @@ static void TestDeoptimizeBinaryOpHelper(LocalContext* env, i::FLAG_always_opt = true; CompileRun(f_source); CompileRun("f(7, new X());"); - CHECK(!i::V8::UseCrankshaft() || + CHECK(!i::Isolate::Current()->use_crankshaft() || GetJSFunction((*env)->Global(), "f")->IsOptimized()); // Call f and force deoptimization while processing the binary operation. @@ -517,7 +517,7 @@ TEST(DeoptimizeCompare) { i::FLAG_always_opt = true; CompileRun(f_source); CompileRun("f('a', new X());"); - CHECK(!i::V8::UseCrankshaft() || + CHECK(!i::Isolate::Current()->use_crankshaft() || GetJSFunction(env->Global(), "f")->IsOptimized()); // Call f and force deoptimization while processing the comparison. @@ -587,7 +587,7 @@ TEST(DeoptimizeLoadICStoreIC) { CompileRun("g1(new X());"); CompileRun("f2(new X(), 'z');"); CompileRun("g2(new X(), 'z');"); - if (i::V8::UseCrankshaft()) { + if (i::Isolate::Current()->use_crankshaft()) { CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); @@ -671,7 +671,7 @@ TEST(DeoptimizeLoadICStoreICNested) { CompileRun("g1(new X());"); CompileRun("f2(new X(), 'z');"); CompileRun("g2(new X(), 'z');"); - if (i::V8::UseCrankshaft()) { + if (i::Isolate::Current()->use_crankshaft()) { CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index c8b884b..611e6e3 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -1335,7 +1335,7 @@ TEST(TestInternalWeakLists) { isolate->compilation_cache()->Clear(); heap->CollectAllGarbage(Heap::kNoGCFlags); - bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); + bool opt = (FLAG_always_opt && isolate->use_crankshaft()); CHECK_EQ(i + 1, CountNativeContexts()); @@ -1479,7 +1479,7 @@ TEST(TestInternalWeakListsTraverseWithGC) { CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1)); } - bool opt = (FLAG_always_opt && i::V8::UseCrankshaft()); + bool opt = (FLAG_always_opt && isolate->use_crankshaft()); // Compile a number of functions the length of the weak list of optimized // functions both with and without GCs while iterating the list. @@ -1879,7 +1879,7 @@ TEST(InstanceOfStubWriteBarrier) { #endif CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft()) return; + if (!i::Isolate::Current()->use_crankshaft()) return; if (i::FLAG_force_marking_deque_overflows) return; v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); @@ -1996,7 +1996,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { #endif CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft()) return; + if (!i::Isolate::Current()->use_crankshaft()) return; v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); { @@ -2053,7 +2053,7 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { #endif CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft()) return; + if (!i::Isolate::Current()->use_crankshaft()) return; v8::HandleScope outer_scope(CcTest::isolate()); { @@ -2092,7 +2092,7 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { TEST(OptimizedAllocationAlwaysInNewSpace) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); @@ -2121,7 +2121,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { TEST(OptimizedPretenuringAllocationFolding) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2157,7 +2157,7 @@ TEST(OptimizedPretenuringAllocationFolding) { TEST(OptimizedPretenuringAllocationFoldingBlocks) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2193,7 +2193,7 @@ TEST(OptimizedPretenuringAllocationFoldingBlocks) { TEST(OptimizedPretenuringObjectArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2218,7 +2218,7 @@ TEST(OptimizedPretenuringObjectArrayLiterals) { TEST(OptimizedPretenuringMixedInObjectProperties) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2249,7 +2249,7 @@ TEST(OptimizedPretenuringMixedInObjectProperties) { TEST(OptimizedPretenuringDoubleArrayProperties) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2274,7 +2274,7 @@ TEST(OptimizedPretenuringDoubleArrayProperties) { TEST(OptimizedPretenuringdoubleArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2299,7 +2299,7 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) { TEST(OptimizedPretenuringNestedMixedArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2333,7 +2333,7 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) { TEST(OptimizedPretenuringNestedObjectLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2367,7 +2367,7 @@ TEST(OptimizedPretenuringNestedObjectLiterals) { TEST(OptimizedPretenuringNestedDoubleLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); @@ -2404,7 +2404,7 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) { TEST(OptimizedAllocationArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); @@ -2431,7 +2431,7 @@ TEST(OptimizedPretenuringCallNew) { i::FLAG_allow_natives_syntax = true; i::FLAG_pretenuring_call_new = true; CcTest::InitializeVM(); - if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); HEAP->SetNewSpaceHighPromotionModeActive(true); diff --git a/test/cctest/test-random.cc b/test/cctest/test-random.cc index 0a8594c..2f7ab7d 100644 --- a/test/cctest/test-random.cc +++ b/test/cctest/test-random.cc @@ -69,7 +69,7 @@ void TestSeeds(Handle fun, TEST(CrankshaftRandom) { v8::V8::Initialize(); // Skip test if crankshaft is disabled. - if (!V8::UseCrankshaft()) return; + if (!Isolate::Current()->use_crankshaft()) return; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); v8::Context::Scope context_scope(v8::Context::New(isolate)); -- 2.7.4