hotspot/src/cpu/sparc/vm/runtime_sparc.cpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5702 201c5cde25bb
child 9976 6fef34e63df1
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5702
jrose
parents: 5547 5690
diff changeset
     2
 * Copyright (c) 1998, 2010, 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: 2571
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2571
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: 2571
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: 5702
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    26
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    27
#include "asm/assembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    28
#include "assembler_sparc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    29
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    30
#include "code/vmreg.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    31
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    32
#include "nativeInst_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    33
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    34
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    35
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    36
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    37
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    38
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    39
#include "vmreg_sparc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5702
diff changeset
    40
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#define __ masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
ExceptionBlob      *OptoRuntime::_exception_blob;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//------------------------------ generate_exception_blob ---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// creates exception blob at the end
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// Using exception blob, this code is jumped from a compiled method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// (see emit_exception_handler in sparc.ad file)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// Given an exception pc at a call we call into the runtime for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// handler in this method. This handler might merely restore state
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// (i.e. callee save registers) unwind the frame and jump to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// exception handler for the nmethod if there is no Java level handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// for the nmethod.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// This code is entered with a jmp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
//   O0: exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//   O1: exception pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// Results:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//   O0: exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//   O1: exception pc in caller or ???
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//   destination: exception handler of caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// Note: the exception pc MUST be at a call (precise debug information)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
void OptoRuntime::generate_exception_blob() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // allocate space for code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  int pad = VerifyThread ? 256 : 0;// Extra slop space for more verify code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // setup code generation tools
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Measured 8/7/03 at 256 in 32bit debug build (no VerifyThread)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Measured 8/7/03 at 528 in 32bit debug build (VerifyThread)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  CodeBuffer buffer("exception_blob", 600+pad, 512);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  MacroAssembler* masm     = new MacroAssembler(&buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  int framesize_in_bytes = __ total_frame_size_in_bytes(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  int framesize_in_words = framesize_in_bytes / wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  int framesize_in_slots = framesize_in_bytes / sizeof(jint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int start = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  __ verify_thread();
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
    91
  __ st_ptr(Oexception,  G2_thread, JavaThread::exception_oop_offset());
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
    92
  __ st_ptr(Oissuing_pc, G2_thread, JavaThread::exception_pc_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // This call does all the hard work. It checks if an exception catch
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // exists in the method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // If so, it returns the handler address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // If the nmethod has been deoptimized and it had a handler the handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // address is the deopt blob unpack_with_exception entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // If no handler exists it prepares for stack-unwinding, restoring the callee-save
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // registers of the frame being removed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  __ save_frame(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  __ mov(G2_thread, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  __ set_last_Java_frame(SP, noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  __ save_thread(L7_thread_cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // This call can block at exit and nmethod can be deoptimized at that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // point. If the nmethod had a catch point we would jump to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // now deoptimized catch point and fall thru the vanilla deopt
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // path and lose the exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Sure would be simpler if this call didn't block!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  __ call(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  __ delayed()->mov(L7_thread_cache, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Set an oopmap for the call site.  This oopmap will only be used if we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // are unwinding the stack.  Hence, all locations will be dead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // Callee-saved registers will be the same as the frame above (i.e.,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // handle_exception_stub), since they were restored when we got the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  OopMapSet *oop_maps = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  oop_maps->add_gc_map( __ offset()-start, new OopMap(framesize_in_slots, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  __ restore_thread(L7_thread_cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  __ reset_last_Java_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  __ mov(O0, G3_scratch);             // Move handler address to temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  __ restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
5690
796ff3814b23 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 2571
diff changeset
   133
  // Restore SP from L7 if the exception PC is a MethodHandle call site.
796ff3814b23 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 2571
diff changeset
   134
  __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), O7);
796ff3814b23 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 2571
diff changeset
   135
  __ tst(O7);
796ff3814b23 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 2571
diff changeset
   136
  __ movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP);
796ff3814b23 6934104: JSR 292 needs to support SPARC C2
twisti
parents: 2571
diff changeset
   137
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // G3_scratch contains handler address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Since this may be the deopt blob we must set O7 to look like we returned
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // from the original pc that threw the exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   142
  __ ld_ptr(G2_thread, JavaThread::exception_pc_offset(), O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  __ sub(O7, frame::pc_return_offset, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  assert(Assembler::is_simm13(in_bytes(JavaThread::exception_oop_offset())), "exception offset overflows simm13, following ld instruction cannot be in delay slot");
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   147
  __ ld_ptr(G2_thread, JavaThread::exception_oop_offset(), Oexception); // O0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
#ifdef ASSERT
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   149
  __ st_ptr(G0, G2_thread, JavaThread::exception_handler_pc_offset());
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   150
  __ st_ptr(G0, G2_thread, JavaThread::exception_pc_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Clear the exception oop so GC no longer processes it as a root.
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 1
diff changeset
   154
  __ delayed()->st_ptr(G0, G2_thread, JavaThread::exception_oop_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // make sure all code is generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  masm->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize_in_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
}