Wed, 18 Sep 2013 14:34:56 -0700
8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
Summary: Some platforms, as ppc and s390x/zArch require that 32-bit ints are passed as 64-bit values to C functions. This change adds support to adapt the signature and to issue proper casts to c2-compiled stubs. The functions are used in generate_native_wrapper(). Adapt signature used by the compiler as in PhaseIdealLoop::intrinsify_fill().
Reviewed-by: kvn
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "opto/regalloc.hpp" |
duke@435 | 27 | |
duke@435 | 28 | static const int NodeRegsOverflowSize = 200; |
duke@435 | 29 | |
duke@435 | 30 | void (*PhaseRegAlloc::_alloc_statistics[MAX_REG_ALLOCATORS])(); |
duke@435 | 31 | int PhaseRegAlloc::_num_allocators = 0; |
duke@435 | 32 | #ifndef PRODUCT |
duke@435 | 33 | int PhaseRegAlloc::_total_framesize = 0; |
duke@435 | 34 | int PhaseRegAlloc::_max_framesize = 0; |
duke@435 | 35 | #endif |
duke@435 | 36 | |
duke@435 | 37 | PhaseRegAlloc::PhaseRegAlloc( uint unique, PhaseCFG &cfg, |
duke@435 | 38 | Matcher &matcher, |
duke@435 | 39 | void (*pr_stats)() ): |
duke@435 | 40 | Phase(Register_Allocation), _cfg(cfg), _matcher(matcher), |
duke@435 | 41 | _node_oops(Thread::current()->resource_area()), |
duke@435 | 42 | _node_regs(0), |
kvn@4478 | 43 | _node_regs_max_index(0), |
duke@435 | 44 | _framesize(0xdeadbeef) |
duke@435 | 45 | { |
duke@435 | 46 | int i; |
duke@435 | 47 | |
duke@435 | 48 | for (i=0; i < _num_allocators; i++) { |
duke@435 | 49 | if (_alloc_statistics[i] == pr_stats) |
duke@435 | 50 | return; |
duke@435 | 51 | } |
duke@435 | 52 | assert((_num_allocators + 1) < MAX_REG_ALLOCATORS, "too many register allocators"); |
duke@435 | 53 | _alloc_statistics[_num_allocators++] = pr_stats; |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | |
duke@435 | 57 | //------------------------------reg2offset------------------------------------- |
duke@435 | 58 | int PhaseRegAlloc::reg2offset_unchecked( OptoReg::Name reg ) const { |
duke@435 | 59 | // Slots below _max_in_arg_stack_reg are offset by the entire frame. |
duke@435 | 60 | // Slots above _max_in_arg_stack_reg are frame_slots and are not offset. |
duke@435 | 61 | int slot = (reg < _matcher._new_SP) |
duke@435 | 62 | ? reg - OptoReg::stack0() + _framesize |
duke@435 | 63 | : reg - _matcher._new_SP; |
duke@435 | 64 | // Note: We use the direct formula (reg - SharedInfo::stack0) instead of |
duke@435 | 65 | // OptoReg::reg2stack(reg), in order to avoid asserts in the latter |
duke@435 | 66 | // function. This routine must remain unchecked, so that dump_frame() |
duke@435 | 67 | // can do its work undisturbed. |
duke@435 | 68 | // %%% not really clear why reg2stack would assert here |
duke@435 | 69 | |
duke@435 | 70 | return slot*VMRegImpl::stack_slot_size; |
duke@435 | 71 | } |
duke@435 | 72 | |
duke@435 | 73 | int PhaseRegAlloc::reg2offset( OptoReg::Name reg ) const { |
duke@435 | 74 | |
duke@435 | 75 | // Not allowed in the out-preserve area. |
duke@435 | 76 | // In-preserve area is allowed so Intel can fetch the return pc out. |
duke@435 | 77 | assert( reg < _matcher._old_SP || |
duke@435 | 78 | (reg >= OptoReg::add(_matcher._old_SP,C->out_preserve_stack_slots()) && |
duke@435 | 79 | reg < _matcher._in_arg_limit) || |
duke@435 | 80 | reg >= OptoReg::add(_matcher._new_SP,C->out_preserve_stack_slots()), |
duke@435 | 81 | "register allocated in a preserve area" ); |
duke@435 | 82 | return reg2offset_unchecked( reg ); |
duke@435 | 83 | } |
duke@435 | 84 | |
duke@435 | 85 | //------------------------------offset2reg------------------------------------- |
duke@435 | 86 | OptoReg::Name PhaseRegAlloc::offset2reg(int stk_offset) const { |
duke@435 | 87 | int slot = stk_offset / jintSize; |
duke@435 | 88 | int reg = (slot < (int) _framesize) |
duke@435 | 89 | ? slot + _matcher._new_SP |
duke@435 | 90 | : OptoReg::stack2reg(slot) - _framesize; |
duke@435 | 91 | assert(stk_offset == reg2offset((OptoReg::Name) reg), |
duke@435 | 92 | "offset2reg does not invert properly"); |
duke@435 | 93 | return (OptoReg::Name) reg; |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | //------------------------------set_oop---------------------------------------- |
duke@435 | 97 | void PhaseRegAlloc::set_oop( const Node *n, bool is_an_oop ) { |
duke@435 | 98 | if( is_an_oop ) { |
duke@435 | 99 | _node_oops.set(n->_idx); |
duke@435 | 100 | } |
duke@435 | 101 | } |
duke@435 | 102 | |
duke@435 | 103 | //------------------------------is_oop----------------------------------------- |
duke@435 | 104 | bool PhaseRegAlloc::is_oop( const Node *n ) const { |
duke@435 | 105 | return _node_oops.test(n->_idx) != 0; |
duke@435 | 106 | } |
duke@435 | 107 | |
duke@435 | 108 | // Allocate _node_regs table with at least "size" elements |
duke@435 | 109 | void PhaseRegAlloc::alloc_node_regs(int size) { |
duke@435 | 110 | _node_regs_max_index = size + (size >> 1) + NodeRegsOverflowSize; |
duke@435 | 111 | _node_regs = NEW_RESOURCE_ARRAY( OptoRegPair, _node_regs_max_index ); |
duke@435 | 112 | // We assume our caller will fill in all elements up to size-1, so |
duke@435 | 113 | // only the extra space we allocate is initialized here. |
duke@435 | 114 | for( uint i = size; i < _node_regs_max_index; ++i ) |
duke@435 | 115 | _node_regs[i].set_bad(); |
duke@435 | 116 | } |
duke@435 | 117 | |
duke@435 | 118 | #ifndef PRODUCT |
duke@435 | 119 | void |
duke@435 | 120 | PhaseRegAlloc::print_statistics() { |
duke@435 | 121 | tty->print_cr("Total frameslots = %d, Max frameslots = %d", _total_framesize, _max_framesize); |
duke@435 | 122 | int i; |
duke@435 | 123 | |
duke@435 | 124 | for (i=0; i < _num_allocators; i++) { |
duke@435 | 125 | _alloc_statistics[i](); |
duke@435 | 126 | } |
duke@435 | 127 | } |
duke@435 | 128 | #endif |