Revision: 8856
Author: [email protected]
Date: Mon Aug 8 02:58:53 2011
Log: Make experimental/gc compilable on Mac OS.
Review URL: http://codereview.chromium.org/7491089
http://code.google.com/p/v8/source/detail?r=8856
Modified:
/branches/experimental/gc/src/ia32/assembler-ia32.cc
/branches/experimental/gc/src/isolate.cc
/branches/experimental/gc/src/isolate.h
/branches/experimental/gc/src/platform-linux.cc
/branches/experimental/gc/src/platform-macos.cc
=======================================
--- /branches/experimental/gc/src/ia32/assembler-ia32.cc Tue Jul 12
16:04:25 2011
+++ /branches/experimental/gc/src/ia32/assembler-ia32.cc Mon Aug 8
02:58:53 2011
@@ -58,6 +58,7 @@
// The Probe method needs executable memory, so it uses Heap::CreateCode.
// Allocation failure is silent and leads to safe default.
void CpuFeatures::Probe() {
+ ASSERT(!initialized_);
ASSERT(supported_ == 0);
#ifdef DEBUG
initialized_ = true;
=======================================
--- /branches/experimental/gc/src/isolate.cc Wed Aug 3 09:10:10 2011
+++ /branches/experimental/gc/src/isolate.cc Mon Aug 8 02:58:53 2011
@@ -1700,12 +1700,6 @@
CpuProfiler::Setup();
HeapProfiler::Setup();
- // If the serializer is enabled we will use only the platform to
determine
- // the CPU. We can do that without generating probe code, so we don't
need
- // the heap to be set up first. We move up the detection to here so that
- // the builtins can make use of the information.
- if (Serializer::enabled()) CPU::Setup();
-
// Initialize other runtime facilities
#if defined(USE_SIMULATOR)
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS)
=======================================
--- /branches/experimental/gc/src/isolate.h Wed Aug 3 09:10:10 2011
+++ /branches/experimental/gc/src/isolate.h Mon Aug 8 02:58:53 2011
@@ -747,7 +747,7 @@
return name##_; \
} \
inline void set_##name(type value) { \
- ASSERT_EQ(OFFSET_OF(Isolate, name##_), name##_debug_offset_); \
+ ASSERT(OFFSET_OF(Isolate, name##_) == name##_debug_offset_); \
name##_ = value; \
}
ISOLATE_INIT_LIST(GLOBAL_ACCESSOR)
=======================================
--- /branches/experimental/gc/src/platform-linux.cc Wed Aug 3 09:10:10 2011
+++ /branches/experimental/gc/src/platform-linux.cc Mon Aug 8 02:58:53 2011
@@ -616,7 +616,7 @@
VirtualMemory::~VirtualMemory() {
if (IsReserved()) {
- if (0 == munmap(address(), size())) address_ = NULL;
+ if (ReleaseRegion(address(), size())) address_ = NULL;
}
}
=======================================
--- /branches/experimental/gc/src/platform-macos.cc Wed Aug 3 09:10:10 2011
+++ /branches/experimental/gc/src/platform-macos.cc Mon Aug 8 02:58:53 2011
@@ -332,21 +332,31 @@
return frames_count;
}
-
-
VirtualMemory::VirtualMemory(size_t size) {
- address_ = mmap(NULL, size, PROT_NONE,
- MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
- kMmapFd, kMmapFdOffset);
+ address_ = ReserveRegion(size);
size_ = size;
}
+
+
+void* VirtualMemory::ReserveRegion(size_t size) {
+ void* result = mmap(NULL,
+ size,
+ PROT_NONE,
+ MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
+ kMmapFd,
+ kMmapFdOffset);
+
+ if (result == MAP_FAILED) return NULL;
+
+ return result;
+}
VirtualMemory::~VirtualMemory() {
if (IsReserved()) {
- if (0 == munmap(address(), size())) address_ = MAP_FAILED;
+ if (ReleaseRegion(address_, size_)) address_ = MAP_FAILED;
}
}
@@ -357,10 +367,20 @@
bool VirtualMemory::Commit(void* address, size_t size, bool is_executable)
{
+ return CommitRegion(address, size, is_executable);
+}
+
+
+bool VirtualMemory::CommitRegion(void* address,
+ size_t size,
+ bool is_executable) {
int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
- if (MAP_FAILED == mmap(address, size, prot,
+ if (MAP_FAILED == mmap(address,
+ size,
+ prot,
MAP_PRIVATE | MAP_ANON | MAP_FIXED,
- kMmapFd, kMmapFdOffset)) {
+ kMmapFd,
+ kMmapFdOffset)) {
return false;
}
@@ -370,9 +390,22 @@
bool VirtualMemory::Uncommit(void* address, size_t size) {
- return mmap(address, size, PROT_NONE,
+ return UncommitRegion(address, size);
+}
+
+
+bool VirtualMemory::UncommitRegion(void* address, size_t size) {
+ return mmap(address,
+ size,
+ PROT_NONE,
MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_FIXED,
- kMmapFd, kMmapFdOffset) != MAP_FAILED;
+ kMmapFd,
+ kMmapFdOffset) != MAP_FAILED;
+}
+
+
+bool VirtualMemory::ReleaseRegion(void* address, size_t size) {
+ return munmap(address, size) == 0;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev