Reviewers: Lasse Reichstein,
Description:
Make experimental/gc compilable on Mac OS.
Please review this at http://codereview.chromium.org/7491089/
SVN Base: http://v8.googlecode.com/svn/branches/experimental/gc/
Affected files:
M src/ia32/assembler-ia32.cc
M src/isolate.h
M src/isolate.cc
M src/platform-linux.cc
M src/platform-macos.cc
Index: src/ia32/assembler-ia32.cc
===================================================================
--- src/ia32/assembler-ia32.cc (revision 8847)
+++ src/ia32/assembler-ia32.cc (working copy)
@@ -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;
Index: src/isolate.cc
===================================================================
--- src/isolate.cc (revision 8847)
+++ src/isolate.cc (working copy)
@@ -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)
Index: src/isolate.h
===================================================================
--- src/isolate.h (revision 8847)
+++ src/isolate.h (working copy)
@@ -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)
Index: src/platform-linux.cc
===================================================================
--- src/platform-linux.cc (revision 8847)
+++ src/platform-linux.cc (working copy)
@@ -616,7 +616,7 @@
VirtualMemory::~VirtualMemory() {
if (IsReserved()) {
- if (0 == munmap(address(), size())) address_ = NULL;
+ if (ReleaseRegion(address(), size())) address_ = NULL;
}
}
Index: src/platform-macos.cc
===================================================================
--- src/platform-macos.cc (revision 8847)
+++ src/platform-macos.cc (working copy)
@@ -334,19 +334,29 @@
}
-
-
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,12 +390,25 @@
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;
+}
+
+
class Thread::PlatformData : public Malloced {
public:
PlatformData() : thread_(kNoThread) {}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev