Reviewers: Michael Starzinger,

Description:
The --optimize-for-size flag should imply a small semi-space

[email protected]
BUG=

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -12 lines):
  M src/flag-definitions.h
  M test/cctest/test-heap.cc


Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index c77d801413a1271f3d7050720cd615bfb1b552d0..0caca9ffeeb0897e231a7587d7e95bd6f38b7a5e 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -10,6 +10,12 @@
// which can be included multiple times in different modes. It expects to have
 // a mode defined before it's included.  The modes are FLAG_MODE_... below:

+#define DEFINE_IMPLICATION(whenflag, thenflag)              \
+  DEFINE_VALUE_IMPLICATION(whenflag, thenflag, true)
+
+#define DEFINE_NEG_IMPLICATION(whenflag, thenflag)          \
+  DEFINE_VALUE_IMPLICATION(whenflag, thenflag, false)
+
// We want to declare the names of the variables for the header file. Normally // this will just be an extern declaration, but for a readonly flag we let the
 // compiler make better optimizations by giving it the value.
@@ -45,11 +51,8 @@

 // We produce the code to set flags when it is implied by another flag.
 #elif defined(FLAG_MODE_DEFINE_IMPLICATIONS)
-#define DEFINE_IMPLICATION(whenflag, thenflag) \
-  if (FLAG_##whenflag) FLAG_##thenflag = true;
-
-#define DEFINE_NEG_IMPLICATION(whenflag, thenflag) \
-  if (FLAG_##whenflag) FLAG_##thenflag = false;
+#define DEFINE_VALUE_IMPLICATION(whenflag, thenflag, value) \
+  if (FLAG_##whenflag) FLAG_##thenflag = value;

 #else
 #error No mode supplied when including flags.defs
@@ -68,12 +71,8 @@
 #define FLAG_ALIAS(ftype, ctype, alias, nam)
 #endif

-#ifndef DEFINE_IMPLICATION
-#define DEFINE_IMPLICATION(whenflag, thenflag)
-#endif
-
-#ifndef DEFINE_NEG_IMPLICATION
-#define DEFINE_NEG_IMPLICATION(whenflag, thenflag)
+#ifndef DEFINE_VALUE_IMPLICATION
+#define DEFINE_VALUE_IMPLICATION(whenflag, thenflag, value)
 #endif

 #define COMMA ,
@@ -214,6 +213,8 @@ DEFINE_BOOL(optimize_for_size, false,
             "Enables optimizations which favor memory size over execution "
             "speed.")

+DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, 1)
+
 // Flags for data representation optimizations
DEFINE_BOOL(unbox_double_arrays, true, "automatically unbox arrays of doubles")
 DEFINE_BOOL(string_slices, true, "use string slices")
@@ -929,6 +930,7 @@ DEFINE_BOOL(enable_ool_constant_pool, V8_OOL_CONSTANT_POOL,
 #undef DEFINE_ARGS
 #undef DEFINE_IMPLICATION
 #undef DEFINE_NEG_IMPLICATION
+#undef DEFINE_VALUE_IMPLICATION
 #undef DEFINE_ALIAS_BOOL
 #undef DEFINE_ALIAS_INT
 #undef DEFINE_ALIAS_STRING
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 8852b8820ffa19573fdcd26bb4a661bdab1acc42..31d817c924c2a5d5e004e5273cb850186f2987b8 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -4360,7 +4360,7 @@ TEST(PromotionQueue) {

// In this test we will try to overwrite the promotion queue which is at the
   // end of to-space. To actually make that possible, we need at least two
-  // semi-space pages and take advantage of fragementation.
+  // semi-space pages and take advantage of fragmentation.
   // (1) Grow semi-space to two pages.
   // (2) Create a few small long living objects and call the scavenger to
   // move them to the other semi-space.
@@ -4380,6 +4380,12 @@ TEST(PromotionQueue) {
   // Grow the semi-space to two pages to make semi-space copy overwrite the
   // promotion queue, which will be at the end of the second page.
   intptr_t old_capacity = new_space->Capacity();
+
+ // If we are in a low memory config, we can't grow to two pages and we can't + // run this test. This also means the issue we are testing cannot arise, as
+  // there is no fragmentation.
+  if (new_space->IsAtMaximumCapacity()) return;
+
   new_space->Grow();
   CHECK(new_space->IsAtMaximumCapacity());
   CHECK(2 * old_capacity == new_space->Capacity());


--
--
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