Reviewers: Toon Verwaest, Sven Panne,

Message:
Changed the code_range_size's type from int to size_t as Sven suggested.

Description:
Reland "Rename kIs64BitArch with kRequiresCodeRange."

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

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

Affected files (+25, -20 lines):
  M include/v8.h
  M src/api.cc
  M src/globals.h
  M src/heap.h
  M src/heap.cc
  M src/spaces.cc
  M test/cctest/test-alloc.cc
  M test/cctest/test-spaces.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index e037ca77f4fb2fa42d08c58326fcd85253793f87..c959632f9780f8b7a5914ac5b7c8edba11305fae 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3865,8 +3865,8 @@ class V8_EXPORT ResourceConstraints {
   void set_max_available_threads(int value) {
     max_available_threads_ = value;
   }
-  int code_range_size() const { return code_range_size_; }
-  void set_code_range_size(int value) {
+  size_t code_range_size() const { return code_range_size_; }
+  void set_code_range_size(size_t value) {
     code_range_size_ = value;
   }

@@ -3876,7 +3876,7 @@ class V8_EXPORT ResourceConstraints {
   int max_executable_size_;
   uint32_t* stack_limit_;
   int max_available_threads_;
-  int code_range_size_;
+  size_t code_range_size_;
 };


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0c978516675fbe46b349cb50da8e15b722dc25c7..4a526f595a7db0e0621c3548048c0d15ad8d8ddb 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -465,11 +465,12 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,

   set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));

-  if (virtual_memory_limit > 0 && i::kIs64BitArch) {
+  if (virtual_memory_limit > 0 && i::kRequiresCodeRange) {
// Reserve no more than 1/8 of the memory for the code range, but at most
-    // 512 MB.
+    // kMaximalCodeRangeSize.
     set_code_range_size(
- i::Min(512, static_cast<int>((virtual_memory_limit >> 3) / i::MB)));
+        i::Min(i::kMaximalCodeRangeSize / i::MB,
+               static_cast<size_t>((virtual_memory_limit >> 3) / i::MB)));
   }
 }

@@ -480,7 +481,7 @@ bool SetResourceConstraints(Isolate* v8_isolate,
   int semi_space_size = constraints->max_semi_space_size();
   int old_space_size = constraints->max_old_space_size();
   int max_executable_size = constraints->max_executable_size();
-  int code_range_size = constraints->code_range_size();
+  size_t code_range_size = constraints->code_range_size();
   if (semi_space_size != 0 || old_space_size != 0 ||
       max_executable_size != 0 || code_range_size != 0) {
     // After initialization it's too late to change Heap constraints.
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index 0c24c6e59dea386a4fbbd82f1fccf6315e0d69a4..8f319fdad6a38c4e068e4b20824d1c100c80e562 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -153,12 +153,14 @@ const int kDoubleSizeLog2 = 3;
 const int kPointerSizeLog2 = 3;
 const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
 const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
-const bool kIs64BitArch = true;
+const bool kRequiresCodeRange = true;
+const size_t kMaximalCodeRangeSize = 512 * MB;
 #else
 const int kPointerSizeLog2 = 2;
 const intptr_t kIntptrSignBit = 0x80000000;
 const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
-const bool kIs64BitArch = false;
+const bool kRequiresCodeRange = false;
+const size_t kMaximalCodeRangeSize = 0 * MB;
 #endif

 const int kBitsPerByte = 8;
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 9e28d012fb71b28a93606ad1e6d08c596f323f18..26edf080b62b9b56333fd5e0d33d2a7e32318e2d 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4934,7 +4934,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
 bool Heap::ConfigureHeap(int max_semi_space_size,
                          int max_old_space_size,
                          int max_executable_size,
-                         int code_range_size) {
+                         size_t code_range_size) {
   if (HasBeenSetUp()) return false;

   // Overwrite default configuration.
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index 7d9233b30af6de7d2f21cb0d4ad4460d635c9ded..91ae36e049295cf0a44877a495d18273840961c0 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -550,7 +550,7 @@ class Heap {
   bool ConfigureHeap(int max_semi_space_size,
                      int max_old_space_size,
                      int max_executable_size,
-                     int code_range_size);
+                     size_t code_range_size);
   bool ConfigureHeapDefault();

// Prepares the heap, setting up memory areas that are needed in the isolate
@@ -1504,7 +1504,7 @@ class Heap {

   Object* roots_[kRootListLength];

-  intptr_t code_range_size_;
+  size_t code_range_size_;
   int reserved_semispace_size_;
   int max_semi_space_size_;
   int initial_semispace_size_;
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 7966a04728c6291e83142eeeda1acf2039c68c77..9d2152970881694e46f0d5f6eecbef971f3894a8 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -115,15 +115,17 @@ bool CodeRange::SetUp(size_t requested) {
   ASSERT(code_range_ == NULL);

   if (requested == 0) {
-    // On 64-bit platform(s), we put all code objects in a 512 MB range of
- // virtual address space, so that they can call each other with near calls.
-    if (kIs64BitArch) {
-      requested = 512 * MB;
+ // When a target requires the code range feature, we put all code objects
+    // in a kMaximalCodeRangeSize range of virtual address space, so that
+    // they can call each other with near calls.
+    if (kRequiresCodeRange) {
+      requested = kMaximalCodeRangeSize;
     } else {
       return true;
     }
   }

+  ASSERT(requested <= kMaximalCodeRangeSize);
   code_range_ = new VirtualMemory(requested);
   CHECK(code_range_ != NULL);
   if (!code_range_->IsReserved()) {
Index: test/cctest/test-alloc.cc
diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc
index a0a993d70a421f7f4ecaa995baf9397434e2f9c9..4520c20b4e0d8d4eb550ad0e15c690fd6f6e17df 100644
--- a/test/cctest/test-alloc.cc
+++ b/test/cctest/test-alloc.cc
@@ -196,12 +196,12 @@ class Block {


 TEST(CodeRange) {
-  const int code_range_size = 32*MB;
+  const size_t code_range_size = 32*MB;
   CcTest::InitializeVM();
   CodeRange code_range(reinterpret_cast<Isolate*>(CcTest::isolate()));
   code_range.SetUp(code_range_size);
-  int current_allocated = 0;
-  int total_allocated = 0;
+  size_t current_allocated = 0;
+  size_t total_allocated = 0;
   List<Block> blocks(1000);

   while (total_allocated < 5 * code_range_size) {
Index: test/cctest/test-spaces.cc
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
index 16ba98f2fba1bc77ab32cc8f1388476357b60f94..982f8cba64e3ce3f95347110c3f00ab44c6b0861 100644
--- a/test/cctest/test-spaces.cc
+++ b/test/cctest/test-spaces.cc
@@ -221,7 +221,7 @@ TEST(MemoryChunk) {

     // With CodeRange.
     CodeRange* code_range = new CodeRange(isolate);
-    const int code_range_size = 32 * MB;
+    const size_t code_range_size = 32 * MB;
     if (!code_range->SetUp(code_range_size)) return;

     VerifyMemoryChunk(isolate,


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