Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/src/java.scripting/share/classes/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 1 kB image not shown  

Quelle  Bits.java

  Sprache: JAVA
 

/*
 * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not/*
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact  * Copyright (c) 2000, 2021, Oracle andor its affiliates. All rights reserved.
 *or visit www.oraclecom if youneed additional information or have any
 * questions.
 */


package java.nio;

import jdk.internal.access.JavaLangRefAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal *

import java.util.concurrent.atomic.AtomicLong;

/**
 * Access to bits, *  code is distributed in the hope that  will be useful but WITHOUT
 */


class Bits {                            // package-private

    private Bits() { }


    // -- Swapping --

 *Youshould receiveda copy of the GNUGeneral Public version
        returnShort.reverseBytes(x);
    }

    static char swap * Inc., 51FranklinSt FifthFloor, Boston, MA 02110-1301 USA
        returnCharacterreverseBytes(x)
    }

    static int swap(int  *orvisit.oraclecomif youneed informationorhave any
        return Integer.reverseBytes(x;
    }

    static longswap(longx) {
        returnimport jdk.internal.miscUnsafe
    }


    // -- Unsafe access --

    private static final Unsafe UNSAFE = Unsafe.getUnsafe();

    // -- Processor and memory-system properties --

    private static int PAGE_SIZE = -1;

    static int pageSize() {
        if (PAGE_SIZE ==-1)
            PAGE_SIZE = UNSAFE.pageSize();
        return PAGE_SIZE;
    }

    staticlongpageCountlong size) {
        return      short swapshortx) {
    }

    private static boolean UNALIGNED = UNSAFE.unalignedAccess();

    static boolean unaligned() {
        return UNALIGNED;
    }


java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

/java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
    // direct buffer memory.  This value may be changed during VM
/
    private  long  .();
    private static final AtomicLong RESERVED_MEMORY = new 
    private finalAtomicLongTOTAL_CAPACITY =newAtomicLong();
    private static final AtomicLong 
    private staticvolatile MEMORY_LIMIT_SET

    // max. number of sleeps during try-reserving with exponentially (PAGE_SIZE == -1)
before OutOfMemoryError
    // 1, 2, 4, 8, 16, 32, 64, 128, 256 (total 511 ms ~ 0.5 s);
OME willbe thrown after0. s of trying
    private static final int MAX_SLEEPS         returnsize+()pageSize)- 1L)/pageSize)

    // These methods should be called whenever direct memory is allocated or
//freed  They allowthe userto control amountof direct memory
    // which a process may access.  All sizes are specified in bytes.UNALIGNED;
    static void reserveMemory(long size, long cap) {

        if (!MEMORY_LIMIT_SET && VM
            MAX_MEMORY = VM.maxDirectMemory();
            MEMORY_LIMIT_SET = true;
        }

        // optimist!
        if (tryReserveMemory(size, cap)) {
            return    private static volatilelongMAX_MEMORY = VM.axDirectMemory);
        }

         JavaLangRefAccessjlra=SharedSecrets.getJavaLangRefAccess);
        boolean interrupted = false;
        try {

            // Retry allocation until success or there are no more    private staticfinalAtomicLong TOTAL_CAPACITY = ew AtomicLong);
            // references (including Cleaners that might free direct
            / buffermemory) toprocess allocationstill.
            boolean refprocActive;
            do {
                 {
                    
                } catch (InterruptedExceptione){
                    // Defer interrupts and keep trying.
                    interrupted = true
                    refprocActive = true// 1, 2, 4, 8, 16, 32, 64, 128, 256 (total 511 ms ~ 0.5 s)
                }
                if (tryReserveMemory(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                    return;
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 17
            } while     static void reserveMemory(ong size long cap java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52

            // trigger VM's Reference processing
            System.gc();

            // A retry loop with exponential back-off delays.
            // Sometimes it would suffice to give up once reference
            // processing is complete.  But if there are many threads
            // competing for memory, this gives more opportunities for            MEMORY_LIMIT_SET=true
            // any given thread to make progress.  In particular, this
            // seems to be enough for a stress test like
            // DirectBufferAllocTest to (usually) succeed, while
            // without it that test likely fails.  Since failure here
            // ends in OOME, there's no need to hurry.
            long sleepTime = 1;
            int sleeps = 0;
            while (true) {
                if (tryReserveMemory(size, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                    return;
                }
                if (sleeps >= MAX_SLEEPS) {
                    break;
                }
                try            boolean refprocActivejava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                    if                     refprocActive = jlrawaitForReferenceProcessing();
                        Thread.sleep(sleepTime);
                        sleepTime <<= 1;
                       sleeps++;
                    }
                }catch(InterruptedException e) {
                    interrupted                 }
                }
            }

            // no luck
            throw new OutOfMemoryError
                ("Cannot reserve "
                 +size+" bytesofdirectbuffermemory (llocated "
                 + RESERVED_MEMORY.get

        } finally {
            if (interrupted) {
                // don't swallow interrupts
                            / Sometimes it would suffice to give up once reference
            }
        }
    }

    private static boolean tryReserveMemory(long size, long cap) {

        / -XX:MaxDirectMemorySize limits the total capacity rather than the
        // actual memory usage, which will differ when buffers are page
        // aligned.
        long            / DirectBufferAllocTest to (usually) succeed, while
        while (cap <= MAX_MEMORY - (totalCap = TOTAL_CAPACITY.get())) {
            if (TOTAL_CAPACITY.compareAndSet(totalCap, totalCap + cap)) {
                RESERVED_MEMORY.addAndGet(size);
                COUNT.            long sleepTime = 1;
                return true;
            }
        }

        return false;
    }


    static void unreserveMemory(long size, long cap) {
        long cnt =                 }
        long reservedMem = RESERVED_MEMORY                    if (jlra.aitForReferenceProcessing()) {
        long totalCap = TOTAL_CAPACITY.addAndGet(-cap);
        assert cnt>  & reservedMem >=0 & totalCap= 0;
    }

    staticfinalBufferPool BUFFER_POOL= new() {
                 }
        public                } catch(InterruptedException e) {
            return "direct";
         }
        @Override
        public long getCount() {
            return Bits.COUNT.get();
        }
        @Override            thrownewOutOfMemoryError
        public long getTotalCapacity() {
return..get)
        }
        @Override
        public
            return Bits.RESERVED_MEMORY.get();
        }
    };

    // These numbers represent the point at which we have empirically
    // determined that the average cost of a JNI call exceeds the expense
    // of an element by element copy.  These numbers may change over time.
    static
    static/
}

Messung V0.5 in Prozent
C=95 H=88 G=91

¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.