Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 31209 invoked from network); 20 Jul 2006 09:32:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jul 2006 09:32:08 -0000 Received: (qmail 20532 invoked by uid 500); 20 Jul 2006 09:32:08 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 20435 invoked by uid 500); 20 Jul 2006 09:32:07 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 20424 invoked by uid 99); 20 Jul 2006 09:32:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 02:32:07 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jul 2006 02:32:07 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id E39B41A981F; Thu, 20 Jul 2006 02:31:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r423852 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java: java/nio/DirectByteBuffer.java java/nio/MappedByteBuffer.java java/nio/MappedByteBufferAdapter.java org/apache/harmony/nio/internal/FileChannelImpl.java Date: Thu, 20 Jul 2006 09:31:45 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060720093146.E39B41A981F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: pyang Date: Thu Jul 20 02:31:44 2006 New Revision: 423852 URL: http://svn.apache.org/viewvc?rev=423852&view=rev Log: Refactor the mmap related functions: 1. add MappedPlatformAddress as subclass of PlatformAddress, which is used by MappedByteBuffer, move the mmap related functions out of PlatformAddress to MappedPlatformAddress 2. add size parameter to IMemorySystem.unmap(), fix the memory leak problem on Linux 3. add size field to PlatformAddress to simplify AbstractMemorySpy 3. refactor the parameter of IMemorySystem's mmap related functions, change PlatformAddress to primitive long to keep consistency with other functions 4. other minor changes to fix some potential bugs Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java?rev=423852&r1=423851&r2=423852&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DirectByteBuffer.java Thu Jul 20 02:31:44 2006 @@ -16,6 +16,7 @@ package java.nio; import org.apache.harmony.luni.platform.PlatformAddress; +import org.apache.harmony.luni.platform.PlatformAddressFactory; import org.apache.harmony.nio.internal.DirectBuffer; @@ -60,7 +61,7 @@ * encouraged to explicitly free the memory where possible. */ DirectByteBuffer(int capacity) { - this(new SafeAddress(PlatformAddress.alloc(capacity, (byte)0)), capacity, 0); + this(new SafeAddress(PlatformAddressFactory.alloc(capacity, (byte)0)), capacity, 0); safeAddress.address.autoFree(); } Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java?rev=423852&r1=423851&r2=423852&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBuffer.java Thu Jul 20 02:31:44 2006 @@ -16,6 +16,7 @@ package java.nio; import org.apache.harmony.luni.platform.IMemorySystem; +import org.apache.harmony.luni.platform.MappedPlatformAddress; import org.apache.harmony.luni.platform.PlatformAddress; import org.apache.harmony.nio.internal.DirectBuffer; @@ -75,8 +76,7 @@ * @return True if this buffer's content is loaded. */ public final boolean isLoaded() { - return ((DirectBuffer) wrapped).getEffectiveAddress().mmapIsLoaded( - wrapped.capacity()); + return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded(); } /** @@ -85,8 +85,7 @@ * @return This buffer */ public final MappedByteBuffer load() { - ((DirectBuffer) wrapped).getEffectiveAddress().mmapLoad( - wrapped.capacity()); + ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad(); return this; } @@ -100,8 +99,7 @@ */ public final MappedByteBuffer force() { if (mapMode == IMemorySystem.MMAP_READ_WRITE) { - ((DirectBuffer) wrapped).getEffectiveAddress().mmapFlush( - wrapped.capacity()); + ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapFlush(); } return this; } Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java?rev=423852&r1=423851&r2=423852&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/MappedByteBufferAdapter.java Thu Jul 20 02:31:44 2006 @@ -15,6 +15,7 @@ package java.nio; +import org.apache.harmony.luni.platform.MappedPlatformAddress; import org.apache.harmony.luni.platform.PlatformAddress; import org.apache.harmony.nio.internal.DirectBuffer; @@ -354,7 +355,7 @@ } public void free() { - this.wrapped.getBaseAddress().unmap(); + ((MappedPlatformAddress)this.wrapped.getBaseAddress()).free(); this.wrapped.free(); } } Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=423852&r1=423851&r2=423852&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java Thu Jul 20 02:31:44 2006 @@ -23,15 +23,14 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.nio.channels.NonReadableChannelException; import java.nio.channels.NonWritableChannelException; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import org.apache.harmony.luni.platform.IFileSystem; -import org.apache.harmony.luni.platform.IMemorySystem; import org.apache.harmony.luni.platform.Platform; import org.apache.harmony.luni.platform.PlatformAddress; +import org.apache.harmony.luni.platform.PlatformAddressFactory; /* * The file channel impl class is the bridge between the logical channels @@ -46,9 +45,6 @@ // Reference to the portable file system code. private static final IFileSystem fileSystem = Platform.getFileSystem(); - private static final IMemorySystem memorySystem = Platform - .getMemorySystem(); - private static final int NATIVE_PAGE_SIZE; static { @@ -195,7 +191,7 @@ } long alignment = position - position % NATIVE_PAGE_SIZE; int offset = (int) (position - alignment); - PlatformAddress address = memorySystem.mmap(handle, alignment, size + PlatformAddress address = PlatformAddressFactory.allocMap(handle, alignment, size + offset, mapMode); MappedByteBuffer buffer = null; try {