Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 954431c4 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Automerger Merge Worker
Browse files

Merge changes from topic "jul15" am: 0e27faa0

parents 574659e3 0e27faa0
Loading
Loading
Loading
Loading
+53 −10
Original line number Diff line number Diff line
@@ -52,19 +52,39 @@ public class FastDataPerfTest {
        while (state.keepRunning()) {
            os.reset();
            final BufferedOutputStream bos = new BufferedOutputStream(os, BUFFER_SIZE);
            final DataOutput out = new DataOutputStream(bos);
            final DataOutputStream out = new DataOutputStream(bos);
            try {
                doWrite(out);
                out.flush();
            } finally {
                out.close();
            }
        }
    }

    @Test
    public void timeWrite_LocalUsing4ByteSequences() throws IOException {
        final ByteArrayOutputStream os = new ByteArrayOutputStream(OUTPUT_SIZE);
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            os.reset();
            final FastDataOutput out = FastDataOutput.obtainUsing4ByteSequences(os);
            try {
                doWrite(out);
            bos.flush();
                out.flush();
            } finally {
                out.release();
            }
        }
    }

    @Test
    public void timeWrite_Local() throws IOException {
    public void timeWrite_LocalUsing3ByteSequences() throws IOException {
        final ByteArrayOutputStream os = new ByteArrayOutputStream(OUTPUT_SIZE);
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            os.reset();
            final FastDataOutput out = FastDataOutput.obtain(os);
            final FastDataOutput out = FastDataOutput.obtainUsing3ByteSequences(os);
            try {
                doWrite(out);
                out.flush();
@@ -81,19 +101,42 @@ public class FastDataPerfTest {
        while (state.keepRunning()) {
            is.reset();
            final BufferedInputStream bis = new BufferedInputStream(is, BUFFER_SIZE);
            final DataInput in = new DataInputStream(bis);
            final DataInputStream in = new DataInputStream(bis);
            try {
                doRead(in);
            } finally {
                in.close();
            }
        }
    }

    @Test
    public void timeRead_LocalUsing4ByteSequences() throws Exception {
        final ByteArrayInputStream is = new ByteArrayInputStream(doWrite());
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            is.reset();
            final FastDataInput in = FastDataInput.obtainUsing4ByteSequences(is);
            try {
                doRead(in);
            } finally {
                in.release();
            }
        }
    }

    @Test
    public void timeRead_Local() throws Exception {
    public void timeRead_LocalUsing3ByteSequences() throws Exception {
        final ByteArrayInputStream is = new ByteArrayInputStream(doWrite());
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            is.reset();
            final DataInput in = new FastDataInput(is, BUFFER_SIZE);
            final FastDataInput in = FastDataInput.obtainUsing3ByteSequences(is);
            try {
                doRead(in);
            } finally {
                in.release();
            }
        }
    }

+24 −0
Original line number Diff line number Diff line
@@ -26,6 +26,12 @@ import dalvik.annotation.optimization.FastNative;
 * <p>
 * These methods purposefully accept only non-movable byte array addresses to
 * avoid extra JNI overhead.
 * <p>
 * Callers are cautioned that there is a long-standing ART bug that emits
 * non-standard 4-byte sequences, as described by {@code kUtfUse4ByteSequence}
 * in {@code art/runtime/jni/jni_internal.cc}. If precise modified UTF-8
 * encoding is required, use {@link com.android.internal.util.ModifiedUtf8}
 * instead.
 *
 * @hide
 */
@@ -33,6 +39,12 @@ public class CharsetUtils {
    /**
     * Attempt to encode the given string as modified UTF-8 into the destination
     * byte array without making any new allocations.
     * <p>
     * Callers are cautioned that there is a long-standing ART bug that emits
     * non-standard 4-byte sequences, as described by
     * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
     * If precise modified UTF-8 encoding is required, use
     * {@link com.android.internal.util.ModifiedUtf8} instead.
     *
     * @param src string value to be encoded
     * @param dest destination byte array to encode into
@@ -50,6 +62,12 @@ public class CharsetUtils {
    /**
     * Attempt to encode the given string as modified UTF-8 into the destination
     * byte array without making any new allocations.
     * <p>
     * Callers are cautioned that there is a long-standing ART bug that emits
     * non-standard 4-byte sequences, as described by
     * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
     * If precise modified UTF-8 encoding is required, use
     * {@link com.android.internal.util.ModifiedUtf8} instead.
     *
     * @param src string value to be encoded
     * @param srcLen exact length of string to be encoded
@@ -66,6 +84,12 @@ public class CharsetUtils {

    /**
     * Attempt to decode a modified UTF-8 string from the source byte array.
     * <p>
     * Callers are cautioned that there is a long-standing ART bug that emits
     * non-standard 4-byte sequences, as described by
     * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
     * If precise modified UTF-8 encoding is required, use
     * {@link com.android.internal.util.ModifiedUtf8} instead.
     *
     * @param src source byte array to decode from
     * @param srcOff offset into source where decoding should begin
+28 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "FrameworksCoreTests",
      "options": [
        {
          "include-filter": "android.util.CharsetUtilsTest"
        },
        {
          "include-filter": "com.android.internal.util.FastDataTest"
        }
      ],
      "file_patterns": ["CharsetUtils|FastData"]
    },
    {
      "name": "FrameworksCoreTests",
      "options": [
        {
          "include-filter": "android.util.XmlTest"
        },
        {
          "include-filter": "android.util.BinaryXmlTest"
        }
      ],
      "file_patterns": ["Xml"]
    }
  ]
}
+6 −7
Original line number Diff line number Diff line
@@ -73,12 +73,6 @@ import java.util.Objects;
 * </ul>
 */
public final class BinaryXmlPullParser implements TypedXmlPullParser {
    /**
     * Default buffer size, which matches {@code FastXmlSerializer}. This should
     * be kept in sync with {@link BinaryXmlPullParser}.
     */
    private static final int BUFFER_SIZE = 32_768;

    private FastDataInput mIn;

    private int mCurrentToken = START_DOCUMENT;
@@ -100,7 +94,12 @@ public final class BinaryXmlPullParser implements TypedXmlPullParser {
            throw new UnsupportedOperationException();
        }

        mIn = new FastDataInput(is, BUFFER_SIZE);
        if (mIn != null) {
            mIn.release();
            mIn = null;
        }

        mIn = FastDataInput.obtainUsing4ByteSequences(is);

        mCurrentToken = START_DOCUMENT;
        mCurrentDepth = 0;
+1 −7
Original line number Diff line number Diff line
@@ -91,12 +91,6 @@ public final class BinaryXmlSerializer implements TypedXmlSerializer {
    static final int TYPE_BOOLEAN_TRUE = 12 << 4;
    static final int TYPE_BOOLEAN_FALSE = 13 << 4;

    /**
     * Default buffer size, which matches {@code FastXmlSerializer}. This should
     * be kept in sync with {@link BinaryXmlPullParser}.
     */
    private static final int BUFFER_SIZE = 32_768;

    private FastDataOutput mOut;

    /**
@@ -124,7 +118,7 @@ public final class BinaryXmlSerializer implements TypedXmlSerializer {
            throw new UnsupportedOperationException();
        }

        mOut = FastDataOutput.obtain(os);
        mOut = FastDataOutput.obtainUsing4ByteSequences(os);
        mOut.write(PROTOCOL_MAGIC_VERSION_0);

        mTagCount = 0;
Loading