Reviewers: Jakob,

Description:
Refactor use of Isolate::use_crankshaft.

[email protected]

Please review this at https://codereview.chromium.org/755883003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+12, -24 lines):
  M src/compiler.cc
  M src/objects.h
  M src/objects.cc
  M src/objects-debug.cc
  M src/runtime-profiler.cc
  M src/runtime/runtime-compiler.cc
  M src/runtime/runtime-test.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 82412a3b16a0b5ba30672d08adbab1dc805e0f20..3d81219fddc84fa2b4bbea104a70f54cdff22cdb 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1382,6 +1382,7 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
   Isolate* isolate = info->isolate();
   DCHECK(AllowCompilation::IsAllowed(isolate));
   VMState<COMPILER> state(isolate);
+  DCHECK(isolate->use_crankshaft());
   DCHECK(!isolate->has_pending_exception());
   PostponeInterruptsScope postpone(isolate);

Index: src/objects-debug.cc
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 0e670993e0d965f2624f6cff9b581bfe5bcacda8..a28010961f353d5dc9564b2961a1d32f3096fb82 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -656,6 +656,7 @@ void Code::CodeVerify() {
   relocation_info()->ObjectVerify();
   Address last_gc_pc = NULL;
   Isolate* isolate = GetIsolate();
+  CHECK(!is_optimized_code() || isolate->use_crankshaft());
   for (RelocIterator it(this); !it.done(); it.next()) {
     it.rinfo()->Verify(isolate);
     // Ensure that GC will not iterate twice over the same pointer.
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 958c08243b4fbe13bb16ed6b083adcd2d7d9182b..e2ced69d6264d092315fb5a55e21bac06d800af9 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9409,12 +9409,14 @@ void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) {


 void JSFunction::MarkForOptimization() {
+  Isolate* isolate = GetIsolate();
+  DCHECK(isolate->use_crankshaft());
   DCHECK(!IsOptimized());
   DCHECK(shared()->allows_lazy_compilation() ||
          code()->optimizable());
   DCHECK(!shared()->is_generator());
   set_code_no_write_barrier(
-      GetIsolate()->builtins()->builtin(Builtins::kCompileOptimized));
+      isolate->builtins()->builtin(Builtins::kCompileOptimized));
   // No write barrier required, since the builtin is part of the root set.
 }

@@ -9434,6 +9436,7 @@ void JSFunction::AttemptConcurrentOptimization() {
     // recompilation race.  This goes away as soon as OSR becomes one-shot.
     return;
   }
+  DCHECK(isolate->use_crankshaft());
   DCHECK(!IsInOptimizationQueue());
   DCHECK(is_compiled() || isolate->DebuggerHasBreakPoints());
   DCHECK(!IsOptimized());
@@ -9451,24 +9454,6 @@ void JSFunction::AttemptConcurrentOptimization() {
 }


-void JSFunction::MarkInOptimizationQueue() {
-  // We can only arrive here via the concurrent-recompilation builtin.  If
- // break points were set, the code would point to the lazy-compile builtin.
-  DCHECK(!GetIsolate()->DebuggerHasBreakPoints());
-  DCHECK(IsMarkedForConcurrentOptimization() && !IsOptimized());
-  DCHECK(shared()->allows_lazy_compilation() || code()->optimizable());
-  DCHECK(GetIsolate()->concurrent_recompilation_enabled());
-  if (FLAG_trace_concurrent_recompilation) {
-    PrintF("  ** Queueing ");
-    ShortPrint();
-    PrintF(" for concurrent recompilation.\n");
-  }
-  set_code_no_write_barrier(
-      GetIsolate()->builtins()->builtin(Builtins::kInOptimizationQueue));
-  // No write barrier required, since the builtin is part of the root set.
-}
-
-
 Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
   Isolate* isolate = function->GetIsolate();
   Handle<Map> map(function->map());
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 911458c3cb68d47532640e8fac6e0d88034350c8..8ab652a740735dbb92ddb7998bcd194990d10f5a 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7335,7 +7335,6 @@ class JSFunction: public JSObject {
   // recompiled the next time it is executed.
   void MarkForOptimization();
   void AttemptConcurrentOptimization();
-  void MarkInOptimizationQueue();

   // Tells whether or not the function is already marked for lazy
   // recompilation.
Index: src/runtime-profiler.cc
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index 7330262e234c2ee1ea65465a3ffb7f81618bb288..db9d76a1a5cb116aec132e820a56d8bc0bd098ad 100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -148,7 +148,7 @@ void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function,
 void RuntimeProfiler::OptimizeNow() {
   HandleScope scope(isolate_);

-  if (isolate_->DebuggerHasBreakPoints()) return;
+ if (!isolate_->use_crankshaft() || isolate_->DebuggerHasBreakPoints()) return;

   DisallowHeapAllocation no_gc;

Index: src/runtime/runtime-compiler.cc
diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc index 88c771890e8bd55f1ef5cf73c1ca95aeef97c662..ebd0c13f0f9b1ef2e2bb44d5bfcb4d017d5e041c 100644
--- a/src/runtime/runtime-compiler.cc
+++ b/src/runtime/runtime-compiler.cc
@@ -47,10 +47,10 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized) {
   DCHECK(args.length() == 2);
   CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
   CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
+  DCHECK(isolate->use_crankshaft());

   Handle<Code> unoptimized(function->shared()->code());
-  if (!isolate->use_crankshaft() ||
-      function->shared()->optimization_disabled() ||
+  if (function->shared()->optimization_disabled() ||
       isolate->DebuggerHasBreakPoints()) {
     // If the function is not optimizable or debugger is active continue
     // using the code from the full compiler.
@@ -176,7 +176,7 @@ static bool IsSuitableForOnStackReplacement(Isolate* isolate,
                                             Handle<JSFunction> function,
                                             Handle<Code> current_code) {
   // Keep track of whether we've succeeded in optimizing.
- if (!isolate->use_crankshaft() || !current_code->optimizable()) return false;
+  if (!current_code->optimizable()) return false;
   // If we are trying to do OSR when there are already optimized
   // activations of the function, it means (a) the function is directly or
   // indirectly recursive and (b) an optimized invocation has been
Index: src/runtime/runtime-test.cc
diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc
index 0a7221344baebf3b6f8c57824aaf3446af301bda..bd6182a93d54035feb54bd35f4636203abd0e692 100644
--- a/src/runtime/runtime-test.cc
+++ b/src/runtime/runtime-test.cc
@@ -60,6 +60,8 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
                  (function->code()->kind() == Code::FUNCTION &&
                   function->code()->optimizable()));

+ if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value();
+
   // If the function is optimized, just return.
   if (function->IsOptimized()) return isolate->heap()->undefined_value();



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to