changeset 9895:c20f9b278918

8035974: Refactor DigestBase.engineUpdate() method for better code generation by JIT compiler Summary: Move the lopp from DigestBase.engineUpdate() to new private method implCompressMultiBlock() which can be intrinsified. Reviewed-by: psandoz, ascarpino, forax Contributed-by: james.cheng@oracle.com
author kvn
date Mon, 26 May 2014 18:34:26 -0700
parents 9f242c8434b0
children 4797cd0713b4 08fa623138dc
files src/share/classes/sun/security/provider/DigestBase.java
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/provider/DigestBase.java	Tue Aug 12 18:05:11 2014 +0400
+++ b/src/share/classes/sun/security/provider/DigestBase.java	Mon May 26 18:34:26 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, 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
@@ -122,10 +122,10 @@
             }
         }
         // compress complete blocks
-        while (len >= blockSize) {
-            implCompress(b, ofs);
-            len -= blockSize;
-            ofs += blockSize;
+        if (len >= blockSize) {
+            int limit = ofs + len;
+            ofs = implCompressMultiBlock(b, ofs, limit - blockSize);
+            len = limit - ofs;
         }
         // copy remainder to buffer
         if (len > 0) {
@@ -134,6 +134,14 @@
         }
     }
 
+    // compress complete blocks
+    private int implCompressMultiBlock(byte[] b, int ofs, int limit) {
+        for (; ofs <= limit; ofs += blockSize) {
+            implCompress(b, ofs);
+        }
+        return ofs;
+    }
+
     // reset this object. See JCA doc.
     protected final void engineReset() {
         if (bytesProcessed == 0) {