Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: src/platform-win32.cc

Issue 7945009: Merge experimental/gc branch to the bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-macos.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 #endif 1390 #endif
1391 } 1391 }
1392 1392
1393 1393
1394 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) { 1394 void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) {
1395 MemoryBarrier(); 1395 MemoryBarrier();
1396 *ptr = value; 1396 *ptr = value;
1397 } 1397 }
1398 1398
1399 1399
1400 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
1401
1402
1403 VirtualMemory::VirtualMemory(size_t size)
1404 : address_(ReserveRegion(size)), size_(size) { }
1405
1406
1407 VirtualMemory::VirtualMemory(size_t size, size_t alignment)
1408 : address_(NULL), size_(0) {
1409 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
1410 size_t request_size = RoundUp(size + alignment,
1411 static_cast<intptr_t>(OS::AllocateAlignment()));
1412 void* address = ReserveRegion(request_size);
1413 if (address == NULL) return;
1414 Address base = RoundUp(static_cast<Address>(address), alignment);
1415 // Try reducing the size by freeing and then reallocating a specific area.
1416 ReleaseRegion(address, request_size);
1417 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
1418 if (address != NULL) {
1419 request_size = size;
1420 ASSERT(base == static_cast<Address>(address));
1421 } else {
1422 // Resizing failed, just go with a bigger area.
1423 address = ReserveRegion(request_size);
1424 if (address == NULL) return;
1425 }
1426 address_ = address;
1427 size_ = request_size;
1428 }
1429
1430
1431 VirtualMemory::~VirtualMemory() {
1432 if (IsReserved()) {
1433 bool result = ReleaseRegion(address_, size_);
1434 ASSERT(result);
1435 USE(result);
1436 }
1437 }
1438
1439
1400 bool VirtualMemory::IsReserved() { 1440 bool VirtualMemory::IsReserved() {
1401 return address_ != NULL; 1441 return address_ != NULL;
1402 } 1442 }
1403 1443
1404 1444
1405 VirtualMemory::VirtualMemory(size_t size) { 1445 void VirtualMemory::Reset() {
1406 address_ = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); 1446 address_ = NULL;
1407 size_ = size; 1447 size_ = 0;
1408 }
1409
1410
1411 VirtualMemory::~VirtualMemory() {
1412 if (IsReserved()) {
1413 if (0 == VirtualFree(address(), 0, MEM_RELEASE)) address_ = NULL;
1414 }
1415 } 1448 }
1416 1449
1417 1450
1418 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { 1451 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
1419 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 1452 if (CommitRegion(address, size, is_executable)) {
1420 if (NULL == VirtualAlloc(address, size, MEM_COMMIT, prot)) { 1453 UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1421 return false; 1454 return true;
1422 } 1455 }
1423 1456 return false;
1424 UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1425 return true;
1426 } 1457 }
1427 1458
1428 1459
1429 bool VirtualMemory::Uncommit(void* address, size_t size) { 1460 bool VirtualMemory::Uncommit(void* address, size_t size) {
1430 ASSERT(IsReserved()); 1461 ASSERT(IsReserved());
1431 return VirtualFree(address, size, MEM_DECOMMIT) != false; 1462 return UncommitRegion(address, size);
1432 } 1463 }
1433 1464
1434 1465
1466 void* VirtualMemory::ReserveRegion(size_t size) {
1467 return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
1468 }
1469
1470
1471 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
1472 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
1473 if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
1474 return false;
1475 }
1476
1477 UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
1478 return true;
1479 }
1480
1481
1482 bool VirtualMemory::UncommitRegion(void* base, size_t size) {
1483 return VirtualFree(base, size, MEM_DECOMMIT) != 0;
1484 }
1485
1486
1487 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
1488 return VirtualFree(base, 0, MEM_RELEASE) != 0;
1489 }
1490
1491
1492
1435 // ---------------------------------------------------------------------------- 1493 // ----------------------------------------------------------------------------
1436 // Win32 thread support. 1494 // Win32 thread support.
1437 1495
1438 // Definition of invalid thread handle and id. 1496 // Definition of invalid thread handle and id.
1439 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; 1497 static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
1440 1498
1441 // Entry point for threads. The supplied argument is a pointer to the thread 1499 // Entry point for threads. The supplied argument is a pointer to the thread
1442 // object. The entry function dispatches to the run method in the thread 1500 // object. The entry function dispatches to the run method in the thread
1443 // object. It is important that this function has __stdcall calling 1501 // object. It is important that this function has __stdcall calling
1444 // convention. 1502 // convention.
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 2028
1971 2029
1972 void Sampler::Stop() { 2030 void Sampler::Stop() {
1973 ASSERT(IsActive()); 2031 ASSERT(IsActive());
1974 SamplerThread::RemoveActiveSampler(this); 2032 SamplerThread::RemoveActiveSampler(this);
1975 SetActive(false); 2033 SetActive(false);
1976 } 2034 }
1977 2035
1978 2036
1979 } } // namespace v8::internal 2037 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-macos.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698