Reviewers: Vyacheslav Egorov,
Description:
Make gc branch compile on Win32.
Just compile, there are still crashes.
And not even close to compiling successfully on Win64.
Please review this at http://codereview.chromium.org/7277038/
SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc
Affected files:
M src/compiler-intrinsics.h
M src/heap.h
M src/heap.cc
M src/platform-win32.cc
M src/spaces.h
M src/x64/assembler-x64-inl.h
M src/x64/macro-assembler-x64.h
Index: src/compiler-intrinsics.h
diff --git a/src/compiler-intrinsics.h b/src/compiler-intrinsics.h
index
bce5d56e25ef91a2b8af5dcf6b68e0596548609e..79ddac8720664af9986e441c177068955e7ddd04
100644
--- a/src/compiler-intrinsics.h
+++ b/src/compiler-intrinsics.h
@@ -50,6 +50,24 @@ int CompilerIntrinsics::CountTrailingZeros(uint32_t
value) {
int CompilerIntrinsics::CountLeadingZeros(uint32_t value) {
return __builtin_clz(value);
}
+
+#elif defined(_MSC_VER)
+
+#pragma intrinsic(_BitScanForward)
+#pragma intrinsic(_BitScanReverse)
+
+int CompilerIntrinsics::CountTrailingZeros(uint32_t value) {
+ unsigned long result;
+ _BitScanForward(&result, static_cast<long>(value));
+ return static_cast<int>(result);
+}
+
+int CompilerIntrinsics::CountLeadingZeros(uint32_t value) {
+ unsigned long result;
+ _BitScanReverse(&result, static_cast<long>(value));
+ return 31 - static_cast<int>(result);
+}
+
#else
#error Unsupported compiler
#endif
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
e383112c49402f1f486059e95d772101126efbeb..b96103f775a825f4ae216971097852e4331c1322
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4477,9 +4477,9 @@ static bool heap_configured = false;
// TODO(1236194): Since the heap size is configurable on the command line
// and through the API, we should gracefully handle the case that the heap
// size is not big enough to fit all the initial objects.
-bool Heap::ConfigureHeap(intptr_t max_semispace_size,
- intptr_t max_old_gen_size,
- intptr_t max_executable_size) {
+bool Heap::ConfigureHeap(int max_semispace_size,
+ int max_old_gen_size,
+ int max_executable_size) {
if (HasBeenSetup()) return false;
if (max_semispace_size > 0) max_semispace_size_ = max_semispace_size;
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
f9146c325a2c2e3cca492631ce363453a818d59f..bd0a0e66c3b0a1b6fcdb99261f9ba6594fb721ea
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -238,9 +238,9 @@ class Heap : public AllStatic {
public:
// Configure heap size before setup. Return false if the heap has been
// setup already.
- static bool ConfigureHeap(intptr_t max_semispace_size,
- intptr_t max_old_gen_size,
- intptr_t max_executable_size);
+ static bool ConfigureHeap(int max_semispace_size,
+ int max_old_gen_size,
+ int max_executable_size);
static bool ConfigureHeapDefault();
// Initializes the global object heap. If create_heap_objects is true,
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index
b5a85f6689fadbe961efff0ca30d62dbfdd6d896..1eb83432236c632e10dab1052d40ea5869380f2d
100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -1416,6 +1416,33 @@ bool VirtualMemory::Uncommit(void* address, size_t
size) {
}
+void* VirtualMemory::ReserveRegion(size_t size) {
+ return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
+}
+
+
+bool VirtualMemory::CommitRegion(void* base, size_t size, bool
is_executable) {
+ int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
+ if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
+ return false;
+ }
+
+ UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
+ return true;
+}
+
+
+bool VirtualMemory::UncommitRegion(void* base, size_t size) {
+ return VirtualFree(base, size, MEM_DECOMMIT) != false;
+}
+
+
+bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
+ return VirtualFree(base, size, MEM_DECOMMIT) != false;
+}
+
+
+
//
----------------------------------------------------------------------------
// Win32 thread support.
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index
b16d26024ca6af19efa5af9feb74eba10089b872..24aaaa03045f8f7ab0c71f4abade04907af3de9b
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -303,7 +303,7 @@ class MemoryChunk {
Address body() { return address() + kBodyOffset; }
- int body_size() { return size() - kBodyOffset; }
+ int body_size() { return static_cast<int>(size() - kBodyOffset); }
enum MemoryChunkFlags {
IS_EXECUTABLE,
@@ -311,18 +311,19 @@ class MemoryChunk {
};
void SetFlag(int flag) {
- flags_ |= 1 << flag;
+ flags_ |= static_cast<uintptr_t>(1) << flag;
}
void ClearFlag(int flag) {
- flags_ &= ~(1 << flag);
+ flags_ &= ~(static_cast<uintptr_t>(1) << flag);
}
bool IsFlagSet(int flag) {
- return (flags_ & (1 << flag)) != 0;
+ return (flags_ & (static_cast<uintptr_t>(1) << flag)) != 0;
}
- static const intptr_t kAlignment = (1 << kPageSizeBits);
+ static const intptr_t kAlignment =
+ (static_cast<uintptr_t>(1) << kPageSizeBits);
static const intptr_t kAlignmentMask = kAlignment - 1;
Index: src/x64/assembler-x64-inl.h
diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h
index
285c07812fd555aeb280a6507609440edb0687b2..0b3f470abb6107a8749e6df67763c0692f3491f2
100644
--- a/src/x64/assembler-x64-inl.h
+++ b/src/x64/assembler-x64-inl.h
@@ -232,14 +232,13 @@ int RelocInfo::target_address_size() {
}
-void RelocInfo::set_target_address(Address target) {
+ void RelocInfo::set_target_address(Address target, Code* code) {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
- if (IsCodeTarget(rmode_)) {
- Assembler::set_target_address_at(pc_, target);
- } else {
- Memory::Address_at(pc_) = target;
- CPU::FlushICache(pc_, sizeof(Address));
+ if (code != NULL && IsCodeTarget(rmode_)) {
+ Object* target_code = Code::GetCodeFromTargetAddress(target);
+ IncrementalMarking::RecordWrite(code, HeapObject::cast(target_code));
}
+ Assembler::set_target_address_at(pc_, target);
}
@@ -271,10 +270,13 @@ Address* RelocInfo::target_reference_address() {
}
-void RelocInfo::set_target_object(Object* target) {
+void RelocInfo::set_target_object(Object* target, Code* code) {
ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
*reinterpret_cast<Object**>(pc_) = target;
CPU::FlushICache(pc_, sizeof(Address));
+ if (code != NULL && target->IsHeapObject()) {
+ IncrementalMarking::RecordWrite(code, HeapObject::cast(target));
+ }
}
@@ -295,11 +297,12 @@ JSGlobalPropertyCell* RelocInfo::target_cell() {
}
-void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) {
+ void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell, Code* code) {
ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
Address address = cell->address() + JSGlobalPropertyCell::kValueOffset;
Memory::Address_at(pc_) = address;
CPU::FlushICache(pc_, sizeof(Address));
+ if (code != NULL) IncrementalMarking::RecordWrite(code, cell);
}
Index: src/x64/macro-assembler-x64.h
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index
daa071e14941779f45130b29b8d4cc57b8892618..2365abdeb2865a0b38803b1843f426d05d156637
100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -78,8 +78,9 @@ class MacroAssembler: public Assembler {
void PushRoot(Heap::RootListIndex index);
void StoreRoot(Register source, Heap::RootListIndex index);
- //
---------------------------------------------------------------------------
- // GC Support
+//
---------------------------------------------------------------------------
+// GC Support
+
// For page containing |object| mark region covering |addr| dirty.
// RecordWriteHelper only works if the object is not in new
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev