Reviewers: Yang,
Message:
PTAL. This flag is useful for V8 embedders and protects them from changes in
GC/compiler specific flags.
Description:
Add --single-threaded flag that disables background threads.
BUG=
Please review this at https://codereview.chromium.org/938683002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+23, -12 lines):
M src/flag-definitions.h
M src/heap/mark-compact.cc
M src/isolate.cc
M src/optimizing-compiler-thread.cc
A + test/mjsunit/single-threaded.js
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
989e19348c08d0c8ce5618fbca87127cda85640c..b9eb073a8165c1b62aceee40fac51d8b7e49b1ab
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -749,9 +749,12 @@ DEFINE_BOOL(profile_hydrogen_code_stub_compilation,
false,
"Print the time it takes to lazily compile hydrogen code
stubs.")
DEFINE_BOOL(predictable, false, "enable predictable mode")
-DEFINE_NEG_IMPLICATION(predictable, concurrent_recompilation)
-DEFINE_NEG_IMPLICATION(predictable, concurrent_osr)
-DEFINE_NEG_IMPLICATION(predictable, concurrent_sweeping)
+DEFINE_IMPLICATION(predictable, single_threaded)
+
+DEFINE_BOOL(single_threaded, false, "use a single thread to run")
+DEFINE_NEG_IMPLICATION(single_threaded, concurrent_recompilation)
+DEFINE_NEG_IMPLICATION(single_threaded, concurrent_osr)
+DEFINE_NEG_IMPLICATION(single_threaded, concurrent_sweeping)
//
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
37651e7133eb9c367b1cdff17e7a2df5b73ddadf..acedeb174cc70c116c3818da68538932002f3add
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -461,6 +461,7 @@ class MarkCompactCollector::SweeperTask : public
v8::Task {
void MarkCompactCollector::StartSweeperThreads() {
+ DCHECK(!FLAG_single_threaded);
DCHECK(free_list_old_pointer_space_.get()->IsEmpty());
DCHECK(free_list_old_data_space_.get()->IsEmpty());
V8::GetCurrentPlatform()->CallOnBackgroundThread(
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
8c3fce930ed6732c281a46ed83cd30a915a52b39..119b0758c0abf739d321692f8dbcdc96ee7499c5
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -2111,6 +2111,7 @@ bool Isolate::Init(Deserializer* des) {
// Choose the default between 1 and 4.
max_available_threads_ =
Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1);
+ if (FLAG_single_threaded) max_available_threads_ = 1;
}
if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
Index: src/optimizing-compiler-thread.cc
diff --git a/src/optimizing-compiler-thread.cc
b/src/optimizing-compiler-thread.cc
index
5999df9d6d724916c4c3d5d99f177e0e29c70a5c..c83963a32fa9bd5a9c5f0b1ce01e2bc13a35b1ae
100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -372,6 +372,7 @@ void
OptimizingCompilerThread::QueueForOptimization(OptimizedCompileJob* job) {
if (FLAG_block_concurrent_recompilation) {
blocked_jobs_++;
} else if (job_based_recompilation_) {
+ DCHECK(!FLAG_single_threaded);
base::LockGuard<base::RecursiveMutex> lock(&task_count_mutex_);
++task_count_;
V8::GetCurrentPlatform()->CallOnBackgroundThread(
@@ -390,6 +391,7 @@ void OptimizingCompilerThread::Unblock() {
}
while (blocked_jobs_ > 0) {
if (job_based_recompilation_) {
+ DCHECK(!FLAG_single_threaded);
V8::GetCurrentPlatform()->CallOnBackgroundThread(
new CompileTask(isolate_), v8::Platform::kShortRunningTask);
} else {
Index: test/mjsunit/single-threaded.js
diff --git a/test/mjsunit/regress/regress-crbug-448730.js
b/test/mjsunit/single-threaded.js
similarity index 53%
copy from test/mjsunit/regress/regress-crbug-448730.js
copy to test/mjsunit/single-threaded.js
index
31d276aa839cdf649b2da1ad54138cc4f9418b81..4602e9c450d4bcd5a06ec0d25c2727aa721e9e27
100644
--- a/test/mjsunit/regress/regress-crbug-448730.js
+++ b/test/mjsunit/single-threaded.js
@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --allow-natives-syntax --harmony-proxies
-
-function bar() {}
-bar({ a: Proxy.create({}) });
-function foo(x) { x.a.b == ""; }
-var x = {a: {b: "" }};
-foo(x);
-foo(x);
+// Flags: --allow-natives-syntax --single-threaded --expose-gc
+
+function foo() {
+ for (var i = 0; i < 100; i++) new Array(100);
+}
+
+foo();
+foo();
%OptimizeFunctionOnNextCall(foo);
-foo(x);
+foo();
+
+gc();
+gc();
+gc();
--
--
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.