| Index: src/platform-win32.cc
|
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc
|
| index 199ed2da4442ae48a11adf52f8077dd8f795085b..c98489f5b14c8d5a93970db6e1c90dc73ed9689a 100644
|
| --- a/src/platform-win32.cc
|
| +++ b/src/platform-win32.cc
|
| @@ -144,8 +144,6 @@ double ceiling(double x) {
|
| }
|
|
|
|
|
| -static Mutex* limit_mutex = NULL;
|
| -
|
| #if V8_TARGET_ARCH_IA32
|
| static void MemMoveWrapper(void* dest, const void* src, size_t size) {
|
| memmove(dest, src, size);
|
| @@ -750,35 +748,6 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
| #undef _TRUNCATE
|
| #undef STRUNCATE
|
|
|
| -// We keep the lowest and highest addresses mapped as a quick way of
|
| -// determining that pointers are outside the heap (used mostly in assertions
|
| -// and verification). The estimate is conservative, i.e., not all addresses in
|
| -// 'allocated' space are actually allocated to our heap. The range is
|
| -// [lowest, highest), inclusive on the low and and exclusive on the high end.
|
| -static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
|
| -static void* highest_ever_allocated = reinterpret_cast<void*>(0);
|
| -
|
| -
|
| -static void UpdateAllocatedSpaceLimits(void* address, int size) {
|
| - ASSERT(limit_mutex != NULL);
|
| - LockGuard<Mutex> lock_guard(limit_mutex);
|
| -
|
| - lowest_ever_allocated = Min(lowest_ever_allocated, address);
|
| - highest_ever_allocated =
|
| - Max(highest_ever_allocated,
|
| - reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size));
|
| -}
|
| -
|
| -
|
| -bool OS::IsOutsideAllocatedSpace(void* pointer) {
|
| - if (pointer < lowest_ever_allocated || pointer >= highest_ever_allocated)
|
| - return true;
|
| - // Ask the Windows API
|
| - if (IsBadWritePtr(pointer, 1))
|
| - return true;
|
| - return false;
|
| -}
|
| -
|
|
|
| // Get the system's page size used by VirtualAlloc() or the next power
|
| // of two. The reason for always returning a power of two is that the
|
| @@ -872,7 +841,6 @@ void* OS::Allocate(const size_t requested,
|
| ASSERT(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment()));
|
|
|
| *allocated = msize;
|
| - UpdateAllocatedSpaceLimits(mbase, static_cast<int>(msize));
|
| return mbase;
|
| }
|
|
|
| @@ -1490,8 +1458,6 @@ bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
|
| if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
|
| return false;
|
| }
|
| -
|
| - UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
|
| return true;
|
| }
|
|
|
| @@ -1615,198 +1581,6 @@ void Thread::YieldCPU() {
|
| }
|
|
|
|
|
| -// ----------------------------------------------------------------------------
|
| -// Win32 socket support.
|
| -//
|
| -
|
| -class Win32Socket : public Socket {
|
| - public:
|
| - explicit Win32Socket() {
|
| - // Create the socket.
|
| - socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
| - }
|
| - explicit Win32Socket(SOCKET socket): socket_(socket) { }
|
| - virtual ~Win32Socket() { Shutdown(); }
|
| -
|
| - // Server initialization.
|
| - bool Bind(const int port);
|
| - bool Listen(int backlog) const;
|
| - Socket* Accept() const;
|
| -
|
| - // Client initialization.
|
| - bool Connect(const char* host, const char* port);
|
| -
|
| - // Shutdown socket for both read and write.
|
| - bool Shutdown();
|
| -
|
| - // Data Transimission
|
| - int Send(const char* data, int len) const;
|
| - int Receive(char* data, int len) const;
|
| -
|
| - bool SetReuseAddress(bool reuse_address);
|
| -
|
| - bool IsValid() const { return socket_ != INVALID_SOCKET; }
|
| -
|
| - private:
|
| - SOCKET socket_;
|
| -};
|
| -
|
| -
|
| -bool Win32Socket::Bind(const int port) {
|
| - if (!IsValid()) {
|
| - return false;
|
| - }
|
| -
|
| - sockaddr_in addr;
|
| - memset(&addr, 0, sizeof(addr));
|
| - addr.sin_family = AF_INET;
|
| - addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
| - addr.sin_port = htons(port);
|
| - int status = bind(socket_,
|
| - reinterpret_cast<struct sockaddr *>(&addr),
|
| - sizeof(addr));
|
| - return status == 0;
|
| -}
|
| -
|
| -
|
| -bool Win32Socket::Listen(int backlog) const {
|
| - if (!IsValid()) {
|
| - return false;
|
| - }
|
| -
|
| - int status = listen(socket_, backlog);
|
| - return status == 0;
|
| -}
|
| -
|
| -
|
| -Socket* Win32Socket::Accept() const {
|
| - if (!IsValid()) {
|
| - return NULL;
|
| - }
|
| -
|
| - SOCKET socket = accept(socket_, NULL, NULL);
|
| - if (socket == INVALID_SOCKET) {
|
| - return NULL;
|
| - } else {
|
| - return new Win32Socket(socket);
|
| - }
|
| -}
|
| -
|
| -
|
| -bool Win32Socket::Connect(const char* host, const char* port) {
|
| - if (!IsValid()) {
|
| - return false;
|
| - }
|
| -
|
| - // Lookup host and port.
|
| - struct addrinfo *result = NULL;
|
| - struct addrinfo hints;
|
| - memset(&hints, 0, sizeof(addrinfo));
|
| - hints.ai_family = AF_INET;
|
| - hints.ai_socktype = SOCK_STREAM;
|
| - hints.ai_protocol = IPPROTO_TCP;
|
| - int status = getaddrinfo(host, port, &hints, &result);
|
| - if (status != 0) {
|
| - return false;
|
| - }
|
| -
|
| - // Connect.
|
| - status = connect(socket_,
|
| - result->ai_addr,
|
| - static_cast<int>(result->ai_addrlen));
|
| - freeaddrinfo(result);
|
| - return status == 0;
|
| -}
|
| -
|
| -
|
| -bool Win32Socket::Shutdown() {
|
| - if (IsValid()) {
|
| - // Shutdown socket for both read and write.
|
| - int status = shutdown(socket_, SD_BOTH);
|
| - closesocket(socket_);
|
| - socket_ = INVALID_SOCKET;
|
| - return status == SOCKET_ERROR;
|
| - }
|
| - return true;
|
| -}
|
| -
|
| -
|
| -int Win32Socket::Send(const char* data, int len) const {
|
| - if (len <= 0) return 0;
|
| - int written = 0;
|
| - while (written < len) {
|
| - int status = send(socket_, data + written, len - written, 0);
|
| - if (status == 0) {
|
| - break;
|
| - } else if (status > 0) {
|
| - written += status;
|
| - } else {
|
| - return 0;
|
| - }
|
| - }
|
| - return written;
|
| -}
|
| -
|
| -
|
| -int Win32Socket::Receive(char* data, int len) const {
|
| - if (len <= 0) return 0;
|
| - int status = recv(socket_, data, len, 0);
|
| - return (status == SOCKET_ERROR) ? 0 : status;
|
| -}
|
| -
|
| -
|
| -bool Win32Socket::SetReuseAddress(bool reuse_address) {
|
| - BOOL on = reuse_address ? true : false;
|
| - int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
|
| - reinterpret_cast<char*>(&on), sizeof(on));
|
| - return status == SOCKET_ERROR;
|
| -}
|
| -
|
| -
|
| -bool Socket::SetUp() {
|
| - // Initialize Winsock32
|
| - int err;
|
| - WSADATA winsock_data;
|
| - WORD version_requested = MAKEWORD(1, 0);
|
| - err = WSAStartup(version_requested, &winsock_data);
|
| - if (err != 0) {
|
| - PrintF("Unable to initialize Winsock, err = %d\n", Socket::LastError());
|
| - }
|
| -
|
| - return err == 0;
|
| -}
|
| -
|
| -
|
| -int Socket::LastError() {
|
| - return WSAGetLastError();
|
| -}
|
| -
|
| -
|
| -uint16_t Socket::HToN(uint16_t value) {
|
| - return htons(value);
|
| -}
|
| -
|
| -
|
| -uint16_t Socket::NToH(uint16_t value) {
|
| - return ntohs(value);
|
| -}
|
| -
|
| -
|
| -uint32_t Socket::HToN(uint32_t value) {
|
| - return htonl(value);
|
| -}
|
| -
|
| -
|
| -uint32_t Socket::NToH(uint32_t value) {
|
| - return ntohl(value);
|
| -}
|
| -
|
| -
|
| -Socket* OS::CreateSocket() {
|
| - return new Win32Socket();
|
| -}
|
| -
|
| -
|
| void OS::SetUp() {
|
| // Seed the random number generator.
|
| // Convert the current time to a 64-bit integer first, before converting it
|
| @@ -1815,13 +1589,6 @@ void OS::SetUp() {
|
| // call this setup code within the same millisecond.
|
| uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
|
| srand(static_cast<unsigned int>(seed));
|
| - limit_mutex = new Mutex();
|
| -}
|
| -
|
| -
|
| -void OS::TearDown() {
|
| - delete limit_mutex;
|
| }
|
|
|
| -
|
| } } // namespace v8::internal
|
|
|