hotspot/src/share/vm/opto/generateOptoStub.cpp
author kvn
Tue, 05 Nov 2013 17:38:04 -0800
changeset 22838 82c7497fbad4
parent 22834 3e2df6a4a28c
parent 19708 64e8c91f5f3e
child 22845 d8812d0ff387
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 13895
diff changeset
     2
 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "opto/addnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/callnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/cfgnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/compile.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/connode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "opto/locknode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "opto/memnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "opto/mulnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "opto/node.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "opto/parse.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "opto/rootnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "opto/type.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//--------------------gen_stub-------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
void GraphKit::gen_stub(address C_function,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
                        const char *name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
                        int is_fancy_jump,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
                        bool pass_tls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
                        bool return_pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  const TypeTuple *jdomain = C->tf()->domain();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  const TypeTuple *jrange  = C->tf()->range();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // The procedure start
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
    53
  StartNode* start = new (C) StartNode(root(), jdomain);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _gvn.set_type_bottom(start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Make a map, with JVM state
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  uint parm_cnt = jdomain->cnt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  uint max_map = MAX2(2*parm_cnt+1, jrange->cnt());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  assert(SynchronizationEntryBCI == InvocationEntryBci, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  JVMState* jvms = new (C) JVMState(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  jvms->set_bci(InvocationEntryBci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  jvms->set_monoff(max_map);
19708
64e8c91f5f3e 8012972: Incremental Inlining should support scalar replaced object in debug info
kvn
parents: 15475
diff changeset
    64
  jvms->set_scloff(max_map);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  jvms->set_endoff(max_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
    67
    SafePointNode *map = new (C) SafePointNode( max_map, jvms );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    jvms->set_map(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    set_jvms(jvms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    assert(map == this->map(), "kit.map is set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Make up the parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  uint i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  for( i = 0; i < parm_cnt; i++ )
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
    76
    map()->init_req(i, _gvn.transform(new (C) ParmNode(start, i)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  for( ; i<map()->req(); i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    map()->init_req(i, top());      // For nicer debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // GraphKit requires memory to be a MergeMemNode:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  set_all_memory(map()->memory());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // Get base of thread-local storage area
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
    84
  Node* thread = _gvn.transform( new (C) ThreadLocalNode() );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  const int NoAlias = Compile::AliasIdxBot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  Node* adr_last_Java_pc = basic_plus_adr(top(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
                                            thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                                            in_bytes(JavaThread::frame_anchor_offset()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                                            in_bytes(JavaFrameAnchor::last_Java_pc_offset()));
15475
73896d91270c 6518907: cleanup IA64 specific code in Hotspot
morris
parents: 13963
diff changeset
    92
#if defined(SPARC)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  Node* adr_flags = basic_plus_adr(top(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                   thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                                   in_bytes(JavaThread::frame_anchor_offset()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                                   in_bytes(JavaFrameAnchor::flags_offset()));
15475
73896d91270c 6518907: cleanup IA64 specific code in Hotspot
morris
parents: 13963
diff changeset
    97
#endif /* defined(SPARC) */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Drop in the last_Java_sp.  last_Java_fp is not touched.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Always do this after the other "last_Java_frame" fields are set since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // as soon as last_Java_sp != NULL the has_last_Java_frame is true and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // users will look at the other fields.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  Node *adr_sp = basic_plus_adr(top(), thread, in_bytes(JavaThread::last_Java_sp_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  Node *last_sp = basic_plus_adr(top(), frameptr(), (intptr_t) STACK_BIAS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  store_to_memory(NULL, adr_sp, last_sp, T_ADDRESS, NoAlias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // Set _thread_in_native
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // The order of stores into TLS is critical!  Setting _thread_in_native MUST
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // be last, because a GC is allowed at any time after setting it and the GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // will require last_Java_pc and last_Java_sp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  Node* adr_state = basic_plus_adr(top(), thread, in_bytes(JavaThread::thread_state_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // Compute signature for C call.  Varies from the Java signature!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  const Type **fields = TypeTuple::fields(2*parm_cnt+2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  uint cnt = TypeFunc::Parms;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // The C routines gets the base of thread-local storage passed in as an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // extra argument.  Not all calls need it, but its cheap to add here.
22834
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   121
  for (uint pcnt = cnt; pcnt < parm_cnt; pcnt++, cnt++) {
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   122
    // Convert ints to longs if required.
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   123
    if (CCallingConventionRequiresIntsAsLongs && jdomain->field_at(pcnt)->isa_int()) {
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   124
      fields[cnt++] = TypeLong::LONG;
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   125
      fields[cnt]   = Type::HALF; // must add an additional half for a long
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   126
    } else {
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   127
      fields[cnt] = jdomain->field_at(pcnt);
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   128
    }
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   129
  }
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   130
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  fields[cnt++] = TypeRawPtr::BOTTOM; // Thread-local storage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // Also pass in the caller's PC, if asked for.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  if( return_pc )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    fields[cnt++] = TypeRawPtr::BOTTOM; // Return PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  const TypeTuple* domain = TypeTuple::make(cnt,fields);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // The C routine we are about to call cannot return an oop; it can block on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // exit and a GC will trash the oop while it sits in C-land.  Instead, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // return the oop through TLS for runtime calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // Also, C routines returning integer subword values leave the high
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // order bits dirty; these must be cleaned up by explicit sign extension.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  const Type* retval = (jrange->cnt() == TypeFunc::Parms) ? Type::TOP : jrange->field_at(TypeFunc::Parms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // Make a private copy of jrange->fields();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  const Type **rfields = TypeTuple::fields(jrange->cnt() - TypeFunc::Parms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // Fixup oop returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  int retval_ptr = retval->isa_oop_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  if( retval_ptr ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    assert( pass_tls, "Oop must be returned thru TLS" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    // Fancy-jumps return address; others return void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    rfields[TypeFunc::Parms] = is_fancy_jump ? TypeRawPtr::BOTTOM : Type::TOP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  } else if( retval->isa_int() ) { // Returning any integer subtype?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    // "Fatten" byte, char & short return types to 'int' to show that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    // the native C code can return values with junk high order bits.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    // We'll sign-extend it below later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    rfields[TypeFunc::Parms] = TypeInt::INT; // It's "dirty" and needs sign-ext
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  } else if( jrange->cnt() >= TypeFunc::Parms+1 ) { // Else copy other types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    rfields[TypeFunc::Parms] = jrange->field_at(TypeFunc::Parms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    if( jrange->cnt() == TypeFunc::Parms+2 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      rfields[TypeFunc::Parms+1] = jrange->field_at(TypeFunc::Parms+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  const TypeTuple* range = TypeTuple::make(jrange->cnt(),rfields);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Final C signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  const TypeFunc *c_sig = TypeFunc::make(domain,range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Make the call node
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   170
  CallRuntimeNode *call = new (C)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // Fix-up the debug info for the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  call->set_jvms( new (C) JVMState(0) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  call->jvms()->set_bci(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  call->jvms()->set_offsets(cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Set fixed predefined input arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  cnt = 0;
22834
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   181
  for (i = 0; i < TypeFunc::Parms; i++)
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   182
    call->init_req(cnt++, map()->in(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // A little too aggressive on the parm copy; return address is not an input
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  call->set_req(TypeFunc::ReturnAdr, top());
22834
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   185
  for (; i < parm_cnt; i++) { // Regular input arguments
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   186
    // Convert ints to longs if required.
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   187
    if (CCallingConventionRequiresIntsAsLongs && jdomain->field_at(i)->isa_int()) {
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   188
      Node* int_as_long = _gvn.transform(new (C) ConvI2LNode(map()->in(i)));
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   189
      call->init_req(cnt++, int_as_long); // long
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   190
      call->init_req(cnt++, top());       // half
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   191
    } else {
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   192
      call->init_req(cnt++, map()->in(i));
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   193
    }
3e2df6a4a28c 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
goetz
parents: 22819
diff changeset
   194
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  call->init_req( cnt++, thread );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  if( return_pc )             // Return PC, if asked for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    call->init_req( cnt++, returnadr() );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  _gvn.transform_no_reclaim(call);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // Now set up the return results
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   204
  set_control( _gvn.transform( new (C) ProjNode(call,TypeFunc::Control)) );
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   205
  set_i_o(     _gvn.transform( new (C) ProjNode(call,TypeFunc::I_O    )) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  set_all_memory_call(call);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  if (range->cnt() > TypeFunc::Parms) {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   208
    Node* retnode = _gvn.transform( new (C) ProjNode(call,TypeFunc::Parms) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    // C-land is allowed to return sub-word values.  Convert to integer type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    assert( retval != Type::TOP, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    if (retval == TypeInt::BOOL) {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   212
      retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFF)) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    } else if (retval == TypeInt::CHAR) {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   214
      retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFFFF)) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    } else if (retval == TypeInt::BYTE) {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   216
      retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(24)) );
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   217
      retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(24)) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    } else if (retval == TypeInt::SHORT) {
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   219
      retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(16)) );
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   220
      retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(16)) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    map()->set_req( TypeFunc::Parms, retnode );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // Clear last_Java_sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  store_to_memory(NULL, adr_sp, null(), T_ADDRESS, NoAlias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // Clear last_Java_pc and (optionally)_flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  store_to_memory(NULL, adr_last_Java_pc, null(), T_ADDRESS, NoAlias);
15475
73896d91270c 6518907: cleanup IA64 specific code in Hotspot
morris
parents: 13963
diff changeset
   231
#if defined(SPARC)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  store_to_memory(NULL, adr_flags, intcon(0), T_INT, NoAlias);
15475
73896d91270c 6518907: cleanup IA64 specific code in Hotspot
morris
parents: 13963
diff changeset
   233
#endif /* defined(SPARC) */
22819
f88b9c394e42 8019973: PPC64 (part 11): Fix IA64 preprocessor conditionals on AIX.
goetz
parents: 15475
diff changeset
   234
#if (defined(IA64) && !defined(AIX))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  Node* adr_last_Java_fp = basic_plus_adr(top(), thread, in_bytes(JavaThread::last_Java_fp_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  if( os::is_MP() ) insert_mem_bar(Op_MemBarRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  store_to_memory(NULL, adr_last_Java_fp,    null(),    T_ADDRESS, NoAlias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // For is-fancy-jump, the C-return value is also the branch target
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  Node* target = map()->in(TypeFunc::Parms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // Runtime call returning oop in TLS?  Fetch it out
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  if( pass_tls ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    Node* adr = basic_plus_adr(top(), thread, in_bytes(JavaThread::vm_result_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    Node* vm_result = make_load(NULL, adr, TypeOopPtr::BOTTOM, T_OBJECT, NoAlias, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    map()->set_req(TypeFunc::Parms, vm_result); // vm_result passed as result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    // clear thread-local-storage(tls)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    store_to_memory(NULL, adr, null(), T_ADDRESS, NoAlias);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // check exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  Node* adr = basic_plus_adr(top(), thread, in_bytes(Thread::pending_exception_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  Node* pending = make_load(NULL, adr, TypeOopPtr::BOTTOM, T_OBJECT, NoAlias, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  Node* exit_memory = reset_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   258
  Node* cmp = _gvn.transform( new (C) CmpPNode(pending, null()) );
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   259
  Node* bo  = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ne) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  IfNode   *iff = create_and_map_if(control(), bo, PROB_MIN, COUNT_UNKNOWN);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   262
  Node* if_null     = _gvn.transform( new (C) IfFalseNode(iff) );
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   263
  Node* if_not_null = _gvn.transform( new (C) IfTrueNode(iff)  );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  Node *exc_target = makecon(TypeRawPtr::make( StubRoutines::forward_exception_entry() ));
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   267
  Node *to_exc = new (C) TailCallNode(if_not_null,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   268
                                      i_o(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   269
                                      exit_memory,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   270
                                      frameptr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   271
                                      returnadr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   272
                                      exc_target, null());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  root()->add_req(_gvn.transform(to_exc));  // bind to root to keep live
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  C->init_start(start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  //-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // If this is a normal subroutine return, issue the return and be done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  Node *ret;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  switch( is_fancy_jump ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  case 0:                       // Make a return instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    // Return to caller, free any space for return address
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   282
    ret = new (C) ReturnNode(TypeFunc::Parms, if_null,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   283
                             i_o(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   284
                             exit_memory,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   285
                             frameptr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   286
                             returnadr());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    if (C->tf()->range()->cnt() > TypeFunc::Parms)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      ret->add_req( map()->in(TypeFunc::Parms) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  case 1:    // This is a fancy tail-call jump.  Jump to computed address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    // Jump to new callee; leave old return address alone.
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   292
    ret = new (C) TailCallNode(if_null,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   293
                               i_o(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   294
                               exit_memory,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   295
                               frameptr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   296
                               returnadr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   297
                               target, map()->in(TypeFunc::Parms));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  case 2:                       // Pop return address & jump
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    // Throw away old return address; jump to new computed address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    //assert(C_function == CAST_FROM_FN_PTR(address, OptoRuntime::rethrow_C), "fancy_jump==2 only for rethrow");
13895
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   302
    ret = new (C) TailJumpNode(if_null,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   303
                               i_o(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   304
                               exit_memory,
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   305
                               frameptr(),
f6dfe4123709 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 7397
diff changeset
   306
                               target, map()->in(TypeFunc::Parms));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  root()->add_req(_gvn.transform(ret));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
}