Version 3.4.6

Lowered limit on code space for systems with low memory supply.

Allowed compiling v8_shell with the 'host' toolset (issue 82437).

Extended setBreakpoint API to accept partial script name (issue 1418).

Made multi-line comments not count when deciding whether the '-->'
comment starter is first on a line. This matches Safari.

Made handling of non-array recievers in Array length setter correct (issue 1491).

Added ability to heap profiler to iterate over snapshot's node (issue 1481).

Review URL: http://codereview.chromium.org/7232010

git-svn-id: http://v8.googlecode.com/svn/trunk@8386 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/heap.cc b/src/heap.cc
index 90847cf..58ad372 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -153,6 +153,15 @@
   max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
 #endif
 
+  intptr_t max_virtual = OS::MaxVirtualMemory();
+
+  if (max_virtual > 0) {
+    if (code_range_size_ > 0) {
+      // Reserve no more than 1/8 of the memory for the code range.
+      code_range_size_ = Min(code_range_size_, max_virtual >> 3);
+    }
+  }
+
   memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
   global_contexts_list_ = NULL;
   mark_compact_collector_.heap_ = this;