< prev index next >

src/cpu/ppc/vm/sharedRuntime_ppc.cpp

Print this page
rev 9821 : 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
Reviewed-by: goetz
   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2015 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


3420 
3421 // Copy len longwords from s to d, word-swapping as we go. The
3422 // destination array is reversed.
3423 static void reverse_words(unsigned long *s, unsigned long *d, int len) {
3424   d += len;
3425   while(len-- > 0) {
3426     d--;
3427     unsigned long s_val = *s;
3428     // Swap words in a longword on little endian machines.
3429 #ifdef VM_LITTLE_ENDIAN
3430      s_val = (s_val << 32) | (s_val >> 32);
3431 #endif
3432     *d = s_val;
3433     s++;
3434   }
3435 }
3436 
3437 void SharedRuntime::montgomery_multiply(jint *a_ints, jint *b_ints, jint *n_ints,
3438                                         jint len, jlong inv,
3439                                         jint *m_ints) {

3440   assert(len % 2 == 0, "array length in montgomery_multiply must be even");
3441   int longwords = len/2;
3442   assert(longwords > 0, "unsupported");
3443 
3444   // Make very sure we don't use so much space that the stack might
3445   // overflow. 512 jints corresponds to an 16384-bit integer and
3446   // will use here a total of 8k bytes of stack space.
3447   int total_allocation = longwords * sizeof (unsigned long) * 4;
3448   guarantee(total_allocation <= 8192, "must be");
3449   unsigned long *scratch = (unsigned long *)alloca(total_allocation);
3450 
3451   // Local scratch arrays
3452   unsigned long
3453     *a = scratch + 0 * longwords,
3454     *b = scratch + 1 * longwords,
3455     *n = scratch + 2 * longwords,
3456     *m = scratch + 3 * longwords;
3457 
3458   reverse_words((unsigned long *)a_ints, a, longwords);
3459   reverse_words((unsigned long *)b_ints, b, longwords);
3460   reverse_words((unsigned long *)n_ints, n, longwords);
3461 
3462   ::montgomery_multiply(a, b, n, m, (unsigned long)inv, longwords);
3463 
3464   reverse_words(m, (unsigned long *)m_ints, longwords);
3465 }
3466 
3467 void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints,
3468                                       jint len, jlong inv,
3469                                       jint *m_ints) {

3470   assert(len % 2 == 0, "array length in montgomery_square must be even");
3471   int longwords = len/2;
3472   assert(longwords > 0, "unsupported");
3473 
3474   // Make very sure we don't use so much space that the stack might
3475   // overflow. 512 jints corresponds to an 16384-bit integer and
3476   // will use here a total of 6k bytes of stack space.
3477   int total_allocation = longwords * sizeof (unsigned long) * 3;
3478   guarantee(total_allocation <= 8192, "must be");
3479   unsigned long *scratch = (unsigned long *)alloca(total_allocation);
3480 
3481   // Local scratch arrays
3482   unsigned long
3483     *a = scratch + 0 * longwords,
3484     *n = scratch + 1 * longwords,
3485     *m = scratch + 2 * longwords;
3486 
3487   reverse_words((unsigned long *)a_ints, a, longwords);
3488   reverse_words((unsigned long *)n_ints, n, longwords);
3489 
3490   if (len >= MONTGOMERY_SQUARING_THRESHOLD) {
3491     ::montgomery_square(a, n, m, (unsigned long)inv, longwords);
3492   } else {
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2016 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


3420 
3421 // Copy len longwords from s to d, word-swapping as we go. The
3422 // destination array is reversed.
3423 static void reverse_words(unsigned long *s, unsigned long *d, int len) {
3424   d += len;
3425   while(len-- > 0) {
3426     d--;
3427     unsigned long s_val = *s;
3428     // Swap words in a longword on little endian machines.
3429 #ifdef VM_LITTLE_ENDIAN
3430      s_val = (s_val << 32) | (s_val >> 32);
3431 #endif
3432     *d = s_val;
3433     s++;
3434   }
3435 }
3436 
3437 void SharedRuntime::montgomery_multiply(jint *a_ints, jint *b_ints, jint *n_ints,
3438                                         jint len, jlong inv,
3439                                         jint *m_ints) {
3440   len = len & 0x7fffFFFF; // C2 does not respect int to long conversion for stub calls.
3441   assert(len % 2 == 0, "array length in montgomery_multiply must be even");
3442   int longwords = len/2;

3443 
3444   // Make very sure we don't use so much space that the stack might
3445   // overflow. 512 jints corresponds to an 16384-bit integer and
3446   // will use here a total of 8k bytes of stack space.
3447   int total_allocation = longwords * sizeof (unsigned long) * 4;
3448   guarantee(total_allocation <= 8192, "must be");
3449   unsigned long *scratch = (unsigned long *)alloca(total_allocation);
3450 
3451   // Local scratch arrays
3452   unsigned long
3453     *a = scratch + 0 * longwords,
3454     *b = scratch + 1 * longwords,
3455     *n = scratch + 2 * longwords,
3456     *m = scratch + 3 * longwords;
3457 
3458   reverse_words((unsigned long *)a_ints, a, longwords);
3459   reverse_words((unsigned long *)b_ints, b, longwords);
3460   reverse_words((unsigned long *)n_ints, n, longwords);
3461 
3462   ::montgomery_multiply(a, b, n, m, (unsigned long)inv, longwords);
3463 
3464   reverse_words(m, (unsigned long *)m_ints, longwords);
3465 }
3466 
3467 void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints,
3468                                       jint len, jlong inv,
3469                                       jint *m_ints) {
3470   len = len & 0x7fffFFFF; // C2 does not respect int to long conversion for stub calls.
3471   assert(len % 2 == 0, "array length in montgomery_square must be even");
3472   int longwords = len/2;

3473 
3474   // Make very sure we don't use so much space that the stack might
3475   // overflow. 512 jints corresponds to an 16384-bit integer and
3476   // will use here a total of 6k bytes of stack space.
3477   int total_allocation = longwords * sizeof (unsigned long) * 3;
3478   guarantee(total_allocation <= 8192, "must be");
3479   unsigned long *scratch = (unsigned long *)alloca(total_allocation);
3480 
3481   // Local scratch arrays
3482   unsigned long
3483     *a = scratch + 0 * longwords,
3484     *n = scratch + 1 * longwords,
3485     *m = scratch + 2 * longwords;
3486 
3487   reverse_words((unsigned long *)a_ints, a, longwords);
3488   reverse_words((unsigned long *)n_ints, n, longwords);
3489 
3490   if (len >= MONTGOMERY_SQUARING_THRESHOLD) {
3491     ::montgomery_square(a, n, m, (unsigned long)inv, longwords);
3492   } else {
< prev index next >