src/cpu/zero/vm/stubGenerator_zero.cpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3156
f08d439fab8c
child 4299
f34d701e952e
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

never@1445 1 /*
coleenp@4037 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
twisti@1814 3 * Copyright 2007, 2008, 2010 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 *
trims@1907 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 21 * or visit www.oracle.com if you need additional information or have any
trims@1907 22 * questions.
never@1445 23 *
never@1445 24 */
never@1445 25
stefank@2314 26 #include "precompiled.hpp"
stefank@2314 27 #include "asm/assembler.hpp"
stefank@2314 28 #include "assembler_zero.inline.hpp"
stefank@2314 29 #include "interpreter/interpreter.hpp"
stefank@2314 30 #include "nativeInst_zero.hpp"
stefank@2314 31 #include "oops/instanceOop.hpp"
coleenp@4037 32 #include "oops/method.hpp"
stefank@2314 33 #include "oops/objArrayKlass.hpp"
stefank@2314 34 #include "oops/oop.inline.hpp"
stefank@2314 35 #include "prims/methodHandles.hpp"
stefank@2314 36 #include "runtime/frame.inline.hpp"
stefank@2314 37 #include "runtime/handles.inline.hpp"
stefank@2314 38 #include "runtime/sharedRuntime.hpp"
stefank@2314 39 #include "runtime/stubCodeGenerator.hpp"
stefank@2314 40 #include "runtime/stubRoutines.hpp"
stefank@2314 41 #include "stack_zero.inline.hpp"
stefank@2314 42 #include "utilities/top.hpp"
stefank@2314 43 #ifdef TARGET_OS_FAMILY_linux
stefank@2314 44 # include "thread_linux.inline.hpp"
stefank@2314 45 #endif
never@3156 46 #ifdef TARGET_OS_FAMILY_bsd
never@3156 47 # include "thread_bsd.inline.hpp"
never@3156 48 #endif
stefank@2314 49 #ifdef COMPILER2
stefank@2314 50 #include "opto/runtime.hpp"
stefank@2314 51 #endif
never@1445 52
never@1445 53 // Declaration and definition of StubGenerator (no .hpp file).
never@1445 54 // For a more detailed description of the stub routine structure
never@1445 55 // see the comment in stubRoutines.hpp
never@1445 56
never@1445 57 class StubGenerator: public StubCodeGenerator {
never@1445 58 private:
never@1445 59 // The call stub is used to call Java from C
never@1445 60 static void call_stub(
never@1445 61 JavaCallWrapper *call_wrapper,
never@1445 62 intptr_t* result,
never@1445 63 BasicType result_type,
coleenp@4037 64 Method* method,
never@1445 65 address entry_point,
never@1445 66 intptr_t* parameters,
never@1445 67 int parameter_words,
never@1445 68 TRAPS) {
never@1445 69 JavaThread *thread = (JavaThread *) THREAD;
never@1445 70 ZeroStack *stack = thread->zero_stack();
never@1445 71
never@1445 72 // Make sure we have no pending exceptions
never@1445 73 assert(!HAS_PENDING_EXCEPTION, "call_stub called with pending exception");
never@1445 74
never@1445 75 // Set up the stack if necessary
never@1445 76 bool stack_needs_teardown = false;
never@1445 77 if (stack->needs_setup()) {
twisti@1866 78 size_t zero_stack_size = stack->suggest_size(thread);
never@1445 79 stack->setup(alloca(zero_stack_size), zero_stack_size);
never@1445 80 stack_needs_teardown = true;
never@1445 81 }
never@1445 82
never@1445 83 // Allocate and initialize our frame
twisti@1814 84 EntryFrame *frame =
twisti@1814 85 EntryFrame::build(parameters, parameter_words, call_wrapper, THREAD);
never@1445 86
twisti@1814 87 if (!HAS_PENDING_EXCEPTION) {
twisti@1814 88 // Push the frame
twisti@1814 89 thread->push_zero_frame(frame);
never@1445 90
twisti@1814 91 // Make the call
twisti@1814 92 Interpreter::invoke_method(method, entry_point, THREAD);
twisti@1814 93
twisti@1814 94 // Store the result
twisti@1814 95 if (!HAS_PENDING_EXCEPTION) {
twisti@1814 96 switch (result_type) {
twisti@1814 97 case T_INT:
twisti@1814 98 *(jint *) result = *(jint *) stack->sp();
twisti@1814 99 break;
twisti@1814 100 case T_LONG:
twisti@1814 101 *(jlong *) result = *(jlong *) stack->sp();
twisti@1814 102 break;
twisti@1814 103 case T_FLOAT:
twisti@1814 104 *(jfloat *) result = *(jfloat *) stack->sp();
twisti@1814 105 break;
twisti@1814 106 case T_DOUBLE:
twisti@1814 107 *(jdouble *) result = *(jdouble *) stack->sp();
twisti@1814 108 break;
twisti@1814 109 case T_OBJECT:
twisti@1814 110 *(oop *) result = *(oop *) stack->sp();
twisti@1814 111 break;
twisti@1814 112 default:
twisti@1814 113 ShouldNotReachHere();
twisti@1814 114 }
never@1445 115 }
twisti@1814 116
twisti@1814 117 // Unwind the frame
twisti@1814 118 thread->pop_zero_frame();
never@1445 119 }
never@1445 120
never@1445 121 // Tear down the stack if necessary
never@1445 122 if (stack_needs_teardown)
never@1445 123 stack->teardown();
never@1445 124 }
never@1445 125
never@1445 126 // These stubs get called from some dumb test routine.
never@1445 127 // I'll write them properly when they're called from
never@1445 128 // something that's actually doing something.
never@1445 129 static void fake_arraycopy_stub(address src, address dst, int count) {
never@1445 130 assert(count == 0, "huh?");
never@1445 131 }
never@1445 132
never@1445 133 void generate_arraycopy_stubs() {
never@1445 134 // Call the conjoint generation methods immediately after
never@1445 135 // the disjoint ones so that short branches from the former
never@1445 136 // to the latter can be generated.
never@1445 137 StubRoutines::_jbyte_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 138 StubRoutines::_jbyte_arraycopy = (address) fake_arraycopy_stub;
never@1445 139
never@1445 140 StubRoutines::_jshort_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 141 StubRoutines::_jshort_arraycopy = (address) fake_arraycopy_stub;
never@1445 142
never@1445 143 StubRoutines::_jint_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 144 StubRoutines::_jint_arraycopy = (address) fake_arraycopy_stub;
never@1445 145
never@1445 146 StubRoutines::_jlong_disjoint_arraycopy = (address) fake_arraycopy_stub;
never@1445 147 StubRoutines::_jlong_arraycopy = (address) fake_arraycopy_stub;
never@1445 148
never@1445 149 StubRoutines::_oop_disjoint_arraycopy = ShouldNotCallThisStub();
never@1445 150 StubRoutines::_oop_arraycopy = ShouldNotCallThisStub();
never@1445 151
never@1445 152 StubRoutines::_checkcast_arraycopy = ShouldNotCallThisStub();
never@1445 153 StubRoutines::_unsafe_arraycopy = ShouldNotCallThisStub();
never@1445 154 StubRoutines::_generic_arraycopy = ShouldNotCallThisStub();
never@1445 155
never@1445 156 // We don't generate specialized code for HeapWord-aligned source
never@1445 157 // arrays, so just use the code we've already generated
never@1445 158 StubRoutines::_arrayof_jbyte_disjoint_arraycopy =
never@1445 159 StubRoutines::_jbyte_disjoint_arraycopy;
never@1445 160 StubRoutines::_arrayof_jbyte_arraycopy =
never@1445 161 StubRoutines::_jbyte_arraycopy;
never@1445 162
never@1445 163 StubRoutines::_arrayof_jshort_disjoint_arraycopy =
never@1445 164 StubRoutines::_jshort_disjoint_arraycopy;
never@1445 165 StubRoutines::_arrayof_jshort_arraycopy =
never@1445 166 StubRoutines::_jshort_arraycopy;
never@1445 167
never@1445 168 StubRoutines::_arrayof_jint_disjoint_arraycopy =
never@1445 169 StubRoutines::_jint_disjoint_arraycopy;
never@1445 170 StubRoutines::_arrayof_jint_arraycopy =
never@1445 171 StubRoutines::_jint_arraycopy;
never@1445 172
never@1445 173 StubRoutines::_arrayof_jlong_disjoint_arraycopy =
never@1445 174 StubRoutines::_jlong_disjoint_arraycopy;
never@1445 175 StubRoutines::_arrayof_jlong_arraycopy =
never@1445 176 StubRoutines::_jlong_arraycopy;
never@1445 177
never@1445 178 StubRoutines::_arrayof_oop_disjoint_arraycopy =
never@1445 179 StubRoutines::_oop_disjoint_arraycopy;
never@1445 180 StubRoutines::_arrayof_oop_arraycopy =
never@1445 181 StubRoutines::_oop_arraycopy;
never@1445 182 }
never@1445 183
never@1445 184 void generate_initial() {
never@1445 185 // Generates all stubs and initializes the entry points
never@1445 186
never@1445 187 // entry points that exist in all platforms Note: This is code
never@1445 188 // that could be shared among different platforms - however the
never@1445 189 // benefit seems to be smaller than the disadvantage of having a
never@1445 190 // much more complicated generator structure. See also comment in
never@1445 191 // stubRoutines.hpp.
never@1445 192
never@1445 193 StubRoutines::_forward_exception_entry = ShouldNotCallThisStub();
never@1445 194 StubRoutines::_call_stub_entry = (address) call_stub;
never@1445 195 StubRoutines::_catch_exception_entry = ShouldNotCallThisStub();
never@1445 196
never@1445 197 // atomic calls
never@1445 198 StubRoutines::_atomic_xchg_entry = ShouldNotCallThisStub();
never@1445 199 StubRoutines::_atomic_xchg_ptr_entry = ShouldNotCallThisStub();
never@1445 200 StubRoutines::_atomic_cmpxchg_entry = ShouldNotCallThisStub();
never@1445 201 StubRoutines::_atomic_cmpxchg_ptr_entry = ShouldNotCallThisStub();
never@1445 202 StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
never@1445 203 StubRoutines::_atomic_add_entry = ShouldNotCallThisStub();
never@1445 204 StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub();
never@1445 205 StubRoutines::_fence_entry = ShouldNotCallThisStub();
never@1445 206
never@1445 207 // amd64 does this here, sparc does it in generate_all()
never@1445 208 StubRoutines::_handler_for_unsafe_access_entry =
never@1445 209 ShouldNotCallThisStub();
never@1445 210 }
never@1445 211
never@1445 212 void generate_all() {
never@1445 213 // Generates all stubs and initializes the entry points
never@1445 214
never@1445 215 // These entry points require SharedInfo::stack0 to be set up in
never@1445 216 // non-core builds and need to be relocatable, so they each
never@1445 217 // fabricate a RuntimeStub internally.
never@1445 218 StubRoutines::_throw_AbstractMethodError_entry =
never@1445 219 ShouldNotCallThisStub();
never@1445 220
never@1445 221 StubRoutines::_throw_NullPointerException_at_call_entry =
never@1445 222 ShouldNotCallThisStub();
never@1445 223
never@1445 224 StubRoutines::_throw_StackOverflowError_entry =
never@1445 225 ShouldNotCallThisStub();
never@1445 226
never@1445 227 // support for verify_oop (must happen after universe_init)
never@1445 228 StubRoutines::_verify_oop_subroutine_entry =
never@1445 229 ShouldNotCallThisStub();
never@1445 230
never@1445 231 // arraycopy stubs used by compilers
never@1445 232 generate_arraycopy_stubs();
never@1445 233 }
never@1445 234
never@1445 235 public:
never@1445 236 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
never@1445 237 if (all) {
never@1445 238 generate_all();
never@1445 239 } else {
never@1445 240 generate_initial();
never@1445 241 }
never@1445 242 }
never@1445 243 };
never@1445 244
never@1445 245 void StubGenerator_generate(CodeBuffer* code, bool all) {
never@1445 246 StubGenerator g(code, all);
never@1445 247 }
never@1445 248
twisti@1814 249 EntryFrame *EntryFrame::build(const intptr_t* parameters,
never@1445 250 int parameter_words,
twisti@1814 251 JavaCallWrapper* call_wrapper,
twisti@1814 252 TRAPS) {
twisti@1814 253
twisti@1814 254 ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
twisti@1814 255 stack->overflow_check(header_words + parameter_words, CHECK_NULL);
never@1445 256
never@1445 257 stack->push(0); // next_frame, filled in later
never@1445 258 intptr_t *fp = stack->sp();
never@1445 259 assert(fp - stack->sp() == next_frame_off, "should be");
never@1445 260
never@1445 261 stack->push(ENTRY_FRAME);
never@1445 262 assert(fp - stack->sp() == frame_type_off, "should be");
never@1445 263
never@1445 264 stack->push((intptr_t) call_wrapper);
never@1445 265 assert(fp - stack->sp() == call_wrapper_off, "should be");
never@1445 266
never@1445 267 for (int i = 0; i < parameter_words; i++)
never@1445 268 stack->push(parameters[i]);
never@1445 269
never@1445 270 return (EntryFrame *) fp;
never@1445 271 }

mercurial