Reviewers: Sven Panne, Hannes Payer,
Message:
As requested. This enables both forcing and preventing of the
memory_constrained flag. PTAL.
Description:
Add flags to force or prevent setting of isolate.is_memory_constrained.
Also, add a method of prohibiting illegal flag combinations.
BUG=None.
Please review this at https://codereview.chromium.org/23890027/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+39, -2 lines):
M src/api.cc
M src/flag-definitions.h
M src/flags.h
M src/flags.cc
M src/isolate.cc
M src/v8.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
d1f6b78cc0c1d06b0d252071d8bf6c0a2573d5ee..8ef7e5fdc65ef19c8e2d81e0746873975b8a4905
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -647,7 +647,9 @@ bool SetResourceConstraints(ResourceConstraints*
constraints) {
uintptr_t limit =
reinterpret_cast<uintptr_t>(constraints->stack_limit());
isolate->stack_guard()->SetStackLimit(limit);
}
- if (constraints->is_memory_constrained().has_value) {
+ if (constraints->is_memory_constrained().has_value &&
+ !i::FLAG_force_memory_constrained &&
+ !i::FLAG_prevent_memory_constrained) {
isolate->set_is_memory_constrained(
constraints->is_memory_constrained().value);
}
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
7548c01643615a0a9b293389dc4c6206120d91f2..b894d2b14201e09604773febc6f3f586e14df6b5
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -69,6 +69,17 @@
#define DEFINE_implication(whenflag, thenflag) \
if (FLAG_##whenflag) FLAG_##thenflag = true;
+// We produce the code to un-set restricted flags when it is prohibited by
+// another flag.
+#elif defined(FLAG_MODE_DEFINE_RESTRICTIONS)
+#define DEFINE_prohibited(whenflag,
preventflag) \
+ if (FLAG_##whenflag && FLAG_##preventflag)
{ \
+
PrintF(stderr, \
+ "Warning: cannot set both --"#whenflag"
and "#preventflag".\n" \
+ " Unsetting --"#preventflag".\n"
); \
+ FLAG_##preventflag
= !FLAG_##whenflag; \
+ }
+
#else
#error No mode supplied when including flags.defs
#endif
@@ -90,6 +101,10 @@
#define DEFINE_implication(whenflag, thenflag)
#endif
+#ifndef DEFINE_prohibited
+#define DEFINE_prohibited(whenflag, preventflag)
+#endif
+
#ifdef FLAG_MODE_DECLARE
// Structure used to hold a collection of arguments to the JavaScript code.
@@ -601,6 +616,11 @@ DEFINE_int(hash_seed,
0,
"Fixed seed to use to hash property keys (0 means random)"
"(with snapshots this option cannot override the baked-in
seed)")
+DEFINE_bool(force_memory_constrained, false,
+ "force the runtime to treat the device as memory constrained.")
+DEFINE_bool(prevent_memory_constrained, false,
+ "prevent the runtime to treat the device as memory
constrained.")
+DEFINE_prohibited(force_memory_constrained, prevent_memory_constrained)
// v8.cc
DEFINE_bool(preemption, false,
@@ -840,6 +860,7 @@ DEFINE_implication(print_all_code, trace_codegen)
#undef DEFINE_float
#undef DEFINE_args
#undef DEFINE_implication
+#undef DEFINE_prohibited
#undef DEFINE_ALIAS_bool
#undef DEFINE_ALIAS_int
#undef DEFINE_ALIAS_string
@@ -851,3 +872,4 @@ DEFINE_implication(print_all_code, trace_codegen)
#undef FLAG_MODE_DEFINE_DEFAULTS
#undef FLAG_MODE_META
#undef FLAG_MODE_DEFINE_IMPLICATIONS
+#undef FLAG_MODE_DEFINE_RESTRICTIONS
Index: src/flags.cc
diff --git a/src/flags.cc b/src/flags.cc
index
4e18cc8c80832b5b1217424acecfa9e9c3578190..6c391751d7c6ad916947779a19436360a91a55f8
100644
--- a/src/flags.cc
+++ b/src/flags.cc
@@ -549,10 +549,19 @@ void FlagList::PrintHelp() {
}
+// static
void FlagList::EnforceFlagImplications() {
#define FLAG_MODE_DEFINE_IMPLICATIONS
#include "flag-definitions.h"
#undef FLAG_MODE_DEFINE_IMPLICATIONS
}
+
+// static
+void FlagList::EnforceFlagRestrictions() {
+#define FLAG_MODE_DEFINE_RESTRICTIONS
+#include "flag-definitions.h"
+#undef FLAG_MODE_DEFINE_RESTRICTIONS
+}
+
} } // namespace v8::internal
Index: src/flags.h
diff --git a/src/flags.h b/src/flags.h
index
fe182e5221cec755e4c629ffabda040e738e701a..b5dc6a2a46568f0a63907dbe7b3fc2e718e59e6e
100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -78,6 +78,9 @@ class FlagList {
// Set flags as consequence of being implied by another flag.
static void EnforceFlagImplications();
+
+ // Unset flags as a consequnce of illegal flag combinations.
+ static void EnforceFlagRestrictions();
};
} } // namespace v8::internal
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
8e581359dca1393b38efa29ab3f13d3ffce9399c..05d3fbfc3998f670e8bfacbb1774d43a43d0840e
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1776,7 +1776,7 @@ Isolate::Isolate()
// TODO(bmeurer) Initialized lazily because it depends on flags; can
// be fixed once the default isolate cleanup is done.
random_number_generator_(NULL),
- is_memory_constrained_(false),
+ is_memory_constrained_(FLAG_force_memory_constrained),
has_fatal_error_(false),
use_crankshaft_(true),
initialized_from_snapshot_(false),
Index: src/v8.cc
diff --git a/src/v8.cc b/src/v8.cc
index
e894164cd16207448befdc3c0daa93bf08c315bc..ded19b1edf49549d68804ede996bd182a0556d03
100644
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -197,6 +197,7 @@ Object* V8::FillHeapNumberWithRandom(Object*
heap_number,
void V8::InitializeOncePerProcessImpl() {
FlagList::EnforceFlagImplications();
+ FlagList::EnforceFlagRestrictions();
if (FLAG_stress_compaction) {
FLAG_force_marking_deque_overflows = true;
FLAG_gc_global = true;
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.