Commit 5b7b0ce8 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Limit the size of the space reserved for code on systems that

are short of virtual memory.  This should make V8 work in 64 bit
on OpenBSD in its default configuration.  It is a simplified
version of the reverted 8133 which also lowered the non-code
heap size, causing test failures in Chromium on MacOS.
Review URL: http://codereview.chromium.org/7234004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8363 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e378829b
...@@ -153,6 +153,15 @@ Heap::Heap() ...@@ -153,6 +153,15 @@ Heap::Heap()
max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
#endif #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); memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
global_contexts_list_ = NULL; global_contexts_list_ = NULL;
mark_compact_collector_.heap_ = this; mark_compact_collector_.heap_ = this;
......
...@@ -54,6 +54,18 @@ ...@@ -54,6 +54,18 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// Maximum size of the virtual memory. 0 means there is no artificial
// limit.
intptr_t OS::MaxVirtualMemory() {
struct rlimit limit;
int result = getrlimit(RLIMIT_DATA, &limit);
if (result != 0) return 0;
return limit.rlim_cur;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Math functions // Math functions
......
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
intptr_t OS::MaxVirtualMemory() {
return 0;
}
// Test for finite value - usually defined in math.h // Test for finite value - usually defined in math.h
int isfinite(double x) { int isfinite(double x) {
return _finite(x); return _finite(x);
......
...@@ -288,6 +288,10 @@ class OS { ...@@ -288,6 +288,10 @@ class OS {
// positions indicated by the members of the CpuFeature enum from globals.h // positions indicated by the members of the CpuFeature enum from globals.h
static uint64_t CpuFeaturesImpliedByPlatform(); static uint64_t CpuFeaturesImpliedByPlatform();
// Maximum size of the virtual memory. 0 means there is no artificial
// limit.
static intptr_t MaxVirtualMemory();
// Returns the double constant NAN // Returns the double constant NAN
static double nan_value(); static double nan_value();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment