src/cpu/zero/vm/stubGenerator_zero.cpp

Thu, 15 Apr 2010 03:13:56 -0700

author
twisti
date
Thu, 15 Apr 2010 03:13:56 -0700
changeset 1816
a9584793da0f
parent 1445
354d3184f6b2
child 1814
f9271ff9d324
permissions
-rw-r--r--

6944028: 6940701 broke Zero
Summary: The fix for 6940701 broke Zero.
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

never@1445 1 /*
never@1445 2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
never@1445 3 * Copyright 2007, 2008 Red Hat, Inc.
never@1445 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
never@1445 5 *
never@1445 6 * This code is free software; you can redistribute it and/or modify it
never@1445 7 * under the terms of the GNU General Public License version 2 only, as
never@1445 8 * published by the Free Software Foundation.
never@1445 9 *
never@1445 10 * This code is distributed in the hope that it will be useful, but WITHOUT
never@1445 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
never@1445 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
never@1445 13 * version 2 for more details (a copy is included in the LICENSE file that
never@1445 14 * accompanied this code).
never@1445 15 *
never@1445 16 * You should have received a copy of the GNU General Public License version
never@1445 17 * 2 along with this work; if not, write to the Free Software Foundation,
never@1445 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
never@1445 19 *
never@1445 20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
never@1445 21 * CA 95054 USA or visit www.sun.com if you need additional information or
never@1445 22 * have any questions.
never@1445 23 *
never@1445 24 */
never@1445 25
never@1445 26 #include "incls/_precompiled.incl"
never@1445 27 #include "incls/_stubGenerator_zero.cpp.incl"
never@1445 28
never@1445 29 // Declaration and definition of StubGenerator (no .hpp file).
never@1445 30 // For a more detailed description of the stub routine structure
never@1445 31 // see the comment in stubRoutines.hpp
never@1445 32
never@1445 33 class StubGenerator: public StubCodeGenerator {
never@1445 34 private:
never@1445 35 // The call stub is used to call Java from C
never@1445 36 static void call_stub(
never@1445 37 JavaCallWrapper *call_wrapper,
never@1445 38 intptr_t* result,
never@1445 39 BasicType result_type,
never@1445 40 methodOop method,
never@1445 41 address entry_point,
never@1445 42 intptr_t* parameters,
never@1445 43 int parameter_words,
never@1445 44 TRAPS) {
never@1445 45 JavaThread *thread = (JavaThread *) THREAD;
never@1445 46 ZeroStack *stack = thread->zero_stack();
never@1445 47
never@1445 48 // Make sure we have no pending exceptions
never@1445 49 assert(!HAS_PENDING_EXCEPTION, "call_stub called with pending exception");
never@1445 50
never@1445 51 // Set up the stack if necessary
never@1445 52 bool stack_needs_teardown = false;
never@1445 53 if (stack->needs_setup()) {
never@1445 54 size_t stack_used = thread->stack_base() - (address) &stack_used;
never@1445 55 size_t stack_free = thread->stack_size() - stack_used;
never@1445 56 size_t zero_stack_size = align_size_down(stack_free / 2, wordSize);
never@1445 57
never@1445 58 stack->setup(alloca(zero_stack_size), zero_stack_size);
never@1445 59 stack_needs_teardown = true;
never@1445 60 }
never@1445 61
never@1445 62 // Allocate and initialize our frame
never@1445 63 thread->push_zero_frame(
never@1445 64 EntryFrame::build(stack, parameters, parameter_words, call_wrapper));
never@1445 65
never@1445 66 // Make the call
never@1445 67 Interpreter::invoke_method(method, entry_point, THREAD);
never@1445 68
never@1445 69 // Store result depending on type
never@1445 70 if (!HAS_PENDING_EXCEPTION) {
never@1445 71 switch (result_type) {
never@1445 72 case T_INT:
never@1445 73 *(jint *) result = *(jint *) stack->sp();
never@1445 74 break;
never@1445 75 case T_LONG:
never@1445 76 *(jlong *) result = *(jlong *) stack->sp();
never@1445 77 break;
never@1445 78 case T_FLOAT:
never@1445 79 *(jfloat *) result = *(jfloat *) stack->sp();
never@1445 80 break;
never@1445 81 case T_DOUBLE:
never@1445 82 *(jdouble *) result = *(jdouble *) stack->sp();
never@1445 83 break;
never@1445 84 case T_OBJECT:
never@1445 85 *(oop *) result = *(oop *) stack->sp();
never@1445 86 break;
never@1445 87 default:
never@1445 88 ShouldNotReachHere();
never@1445 89 }
never@1445 90 }
never@1445 91
never@1445 92 // Unwind our frame
never@1445 93 thread->pop_zero_frame();
never@1445 94
never@1445 95 // Tear down the stack if necessary
never@1445 96 if (stack_needs_teardown)
never@1445 97 stack->teardown();
never@1445 98 }
never@1445 99
never@1445 100 // These stubs get called from some dumb test routine.
never@1445 101 // I'll write them properly when they're called from
never@1445 102 // something that's actually doing something.
never@1445 103 static void fake_arraycopy_stub(address src, address dst, int count) {
never@1445 104 assert(count == 0, "huh?");
never@1445 105 }
never@1445 106
never@1445 107 void generate_arraycopy_stubs() {
never@1445 108 // Call the conjoint generation methods immediately after
never@1445 109 // the disjoint ones so that short branches from the former
never@1445 110 // to the latter can be generated.
never@1445 111 StubRoutines::_jbyte_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 112 StubRoutines::_jbyte_arraycopy = (address) fake_arraycopy_stub;
never@1445 113
never@1445 114 StubRoutines::_jshort_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 115 StubRoutines::_jshort_arraycopy = (address) fake_arraycopy_stub;
never@1445 116
never@1445 117 StubRoutines::_jint_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 118 StubRoutines::_jint_arraycopy = (address) fake_arraycopy_stub;
never@1445 119
never@1445 120 StubRoutines::_jlong_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 121 StubRoutines::_jlong_arraycopy = (address) fake_arraycopy_stub;
never@1445 122
never@1445 123 StubRoutines::_oop_disjoint_arraycopy = ShouldNotCallThisStub();
never@1445 124 StubRoutines::_oop_arraycopy = ShouldNotCallThisStub();
never@1445 125
never@1445 126 StubRoutines::_checkcast_arraycopy = ShouldNotCallThisStub();
never@1445 127 StubRoutines::_unsafe_arraycopy = ShouldNotCallThisStub();
never@1445 128 StubRoutines::_generic_arraycopy = ShouldNotCallThisStub();
never@1445 129
never@1445 130 // We don't generate specialized code for HeapWord-aligned source
never@1445 131 // arrays, so just use the code we've already generated
never@1445 132 StubRoutines::_arrayof_jbyte_disjoint_arraycopy =
never@1445 133 StubRoutines::_jbyte_disjoint_arraycopy;
never@1445 134 StubRoutines::_arrayof_jbyte_arraycopy =
never@1445 135 StubRoutines::_jbyte_arraycopy;
never@1445 136
never@1445 137 StubRoutines::_arrayof_jshort_disjoint_arraycopy =
never@1445 138 StubRoutines::_jshort_disjoint_arraycopy;
never@1445 139 StubRoutines::_arrayof_jshort_arraycopy =
never@1445 140 StubRoutines::_jshort_arraycopy;
never@1445 141
never@1445 142 StubRoutines::_arrayof_jint_disjoint_arraycopy =
never@1445 143 StubRoutines::_jint_disjoint_arraycopy;
never@1445 144 StubRoutines::_arrayof_jint_arraycopy =
never@1445 145 StubRoutines::_jint_arraycopy;
never@1445 146
never@1445 147 StubRoutines::_arrayof_jlong_disjoint_arraycopy =
never@1445 148 StubRoutines::_jlong_disjoint_arraycopy;
never@1445 149 StubRoutines::_arrayof_jlong_arraycopy =
never@1445 150 StubRoutines::_jlong_arraycopy;
never@1445 151
never@1445 152 StubRoutines::_arrayof_oop_disjoint_arraycopy =
never@1445 153 StubRoutines::_oop_disjoint_arraycopy;
never@1445 154 StubRoutines::_arrayof_oop_arraycopy =
never@1445 155 StubRoutines::_oop_arraycopy;
never@1445 156 }
never@1445 157
never@1445 158 void generate_initial() {
never@1445 159 // Generates all stubs and initializes the entry points
never@1445 160
never@1445 161 // entry points that exist in all platforms Note: This is code
never@1445 162 // that could be shared among different platforms - however the
never@1445 163 // benefit seems to be smaller than the disadvantage of having a
never@1445 164 // much more complicated generator structure. See also comment in
never@1445 165 // stubRoutines.hpp.
never@1445 166
never@1445 167 StubRoutines::_forward_exception_entry = ShouldNotCallThisStub();
never@1445 168 StubRoutines::_call_stub_entry = (address) call_stub;
never@1445 169 StubRoutines::_catch_exception_entry = ShouldNotCallThisStub();
never@1445 170
never@1445 171 // atomic calls
never@1445 172 StubRoutines::_atomic_xchg_entry = ShouldNotCallThisStub();
never@1445 173 StubRoutines::_atomic_xchg_ptr_entry = ShouldNotCallThisStub();
never@1445 174 StubRoutines::_atomic_cmpxchg_entry = ShouldNotCallThisStub();
never@1445 175 StubRoutines::_atomic_cmpxchg_ptr_entry = ShouldNotCallThisStub();
never@1445 176 StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
never@1445 177 StubRoutines::_atomic_add_entry = ShouldNotCallThisStub();
never@1445 178 StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub();
never@1445 179 StubRoutines::_fence_entry = ShouldNotCallThisStub();
never@1445 180
never@1445 181 // amd64 does this here, sparc does it in generate_all()
never@1445 182 StubRoutines::_handler_for_unsafe_access_entry =
never@1445 183 ShouldNotCallThisStub();
never@1445 184 }
never@1445 185
never@1445 186 void generate_all() {
never@1445 187 // Generates all stubs and initializes the entry points
never@1445 188
never@1445 189 // These entry points require SharedInfo::stack0 to be set up in
never@1445 190 // non-core builds and need to be relocatable, so they each
never@1445 191 // fabricate a RuntimeStub internally.
never@1445 192 StubRoutines::_throw_AbstractMethodError_entry =
never@1445 193 ShouldNotCallThisStub();
never@1445 194
never@1445 195 StubRoutines::_throw_ArithmeticException_entry =
never@1445 196 ShouldNotCallThisStub();
never@1445 197
never@1445 198 StubRoutines::_throw_NullPointerException_entry =
never@1445 199 ShouldNotCallThisStub();
never@1445 200
never@1445 201 StubRoutines::_throw_NullPointerException_at_call_entry =
never@1445 202 ShouldNotCallThisStub();
never@1445 203
never@1445 204 StubRoutines::_throw_StackOverflowError_entry =
never@1445 205 ShouldNotCallThisStub();
never@1445 206
never@1445 207 // support for verify_oop (must happen after universe_init)
never@1445 208 StubRoutines::_verify_oop_subroutine_entry =
never@1445 209 ShouldNotCallThisStub();
never@1445 210
never@1445 211 // arraycopy stubs used by compilers
never@1445 212 generate_arraycopy_stubs();
never@1445 213 }
never@1445 214
never@1445 215 public:
never@1445 216 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
never@1445 217 if (all) {
never@1445 218 generate_all();
never@1445 219 } else {
never@1445 220 generate_initial();
never@1445 221 }
never@1445 222 }
never@1445 223 };
never@1445 224
never@1445 225 void StubGenerator_generate(CodeBuffer* code, bool all) {
never@1445 226 StubGenerator g(code, all);
never@1445 227 }
never@1445 228
never@1445 229 EntryFrame *EntryFrame::build(ZeroStack* stack,
never@1445 230 const intptr_t* parameters,
never@1445 231 int parameter_words,
never@1445 232 JavaCallWrapper* call_wrapper) {
never@1445 233 if (header_words + parameter_words > stack->available_words()) {
never@1445 234 Unimplemented();
never@1445 235 }
never@1445 236
never@1445 237 stack->push(0); // next_frame, filled in later
never@1445 238 intptr_t *fp = stack->sp();
never@1445 239 assert(fp - stack->sp() == next_frame_off, "should be");
never@1445 240
never@1445 241 stack->push(ENTRY_FRAME);
never@1445 242 assert(fp - stack->sp() == frame_type_off, "should be");
never@1445 243
never@1445 244 stack->push((intptr_t) call_wrapper);
never@1445 245 assert(fp - stack->sp() == call_wrapper_off, "should be");
never@1445 246
never@1445 247 for (int i = 0; i < parameter_words; i++)
never@1445 248 stack->push(parameters[i]);
never@1445 249
never@1445 250 return (EntryFrame *) fp;
never@1445 251 }

mercurial