// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = Method::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); // Deallocate the old Method* from metadata ClassLoaderData* loader_data = method()->method_holder()->class_loader_data(); loader_data->add_to_deallocate_list(method()()); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = methodOopDesc::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
InterpretedRFrame::InterpretedRFrame(frame fr, JavaThread* thread, RFrame*const callee) : RFrame(fr, thread, callee) { RegisterMap map(thread, false); _vf = javaVFrame::cast(vframe::new_vframe(&_fr, &map, thread)); _method = methodHandle(thread, _vf->method()); assert( _vf->is_interpreted_frame(), "must be interpreted"); init(); }
jlong DTraceJSDT::activate( jint version, jstring module_name, jint providers_count, JVM_DTraceProvider* providers, TRAPS) { size_t count = 0; RegisteredProbes* probes = NULL; if (!is_supported()) { return 0; } assert(module_name != NULL, "valid module name"); assert(providers != NULL, "valid provider array"); for (int i = 0; i < providers_count; ++i) { count += providers[i].probe_count; } probes = new RegisteredProbes(count); count = 0; for (int i = 0; i < providers_count; ++i) { assert(providers[i].name != NULL, "valid provider name"); assert(providers[i].probe_count == 0 || providers[i].probes != NULL, "valid probe count"); for (int j = 0; j < providers[i].probe_count; ++j) { JVM_DTraceProbe* probe = &(providers[i].probes[j]); assert(probe != NULL, "valid probe"); assert(probe->method != NULL, "valid method"); assert(probe->name != NULL, "valid probe name"); assert(probe->function != NULL, "valid probe function spec"); methodHandle h_method = methodHandle(THREAD, JNIHandles::resolve_jmethod_id(probe->method)); nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method); if (nm == NULL) { delete probes; THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to register DTrace probes (CodeCache: no room for DTrace nmethods)."); } h_method()->set_not_compilable(CompLevel_highest_tier); h_method()->set_code(h_method, nm); probes->nmethod_at_put(count++, nm); } } int handle = pd_activate((void*)probes, module_name, providers_count, providers); if (handle <= 0) { delete probes; THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to register DTrace probes (internal error)."); } probes->set_helper_handle(handle); return RegisteredProbes::toOpaqueProbes(probes); }
methodHandle Bytecode_invoke::static_target(TRAPS) { methodHandle m; KlassHandle resolved_klass; constantPoolHandle constants(THREAD, _method->constants()); if (adjusted_invoke_code() != Bytecodes::_invokeinterface) { LinkResolver::resolve_method(m, resolved_klass, constants, index(), CHECK_(methodHandle())); } else { LinkResolver::resolve_interface_method(m, resolved_klass, constants, index(), CHECK_(methodHandle())); } return m; }
void CompiledRFrame::init() { RegisterMap map(thread(), false); vframe* vf = vframe::new_vframe(&_fr, &map, thread()); assert(vf->is_compiled_frame(), "must be compiled"); _nm = compiledVFrame::cast(vf)->code(); vf = vf->top(); _vf = javaVFrame::cast(vf); _method = methodHandle(thread(), CodeCache::find_nmethod(_fr.pc())->method()); assert(_method(), "should have found a method"); #ifndef PRODUCT _invocations = _method->compiled_invocation_count(); #endif }
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset) { _code = code; _decode_offset = decode_offset; // decode header DebugInfoReadStream* stream = stream_at(_decode_offset); _sender_decode_offset = stream->read_int(); _method = methodHandle((methodOop) stream->read_handle()()); _bci = stream->read_int(); // decode offsets for body and sender _locals_decode_offset = stream->read_int(); _expressions_decode_offset = stream->read_int(); _monitors_decode_offset = stream->read_int(); }
void ScopeDesc::decode_body() { if (decode_offset() == DebugInformationRecorder::serialized_null) { // This is a sentinel record, which is only relevant to // approximate queries. Decode a reasonable frame. _sender_decode_offset = DebugInformationRecorder::serialized_null; _method = methodHandle(_code->method()); _bci = InvocationEntryBci; _locals_decode_offset = DebugInformationRecorder::serialized_null; _expressions_decode_offset = DebugInformationRecorder::serialized_null; _monitors_decode_offset = DebugInformationRecorder::serialized_null; } else { // decode header DebugInfoReadStream* stream = stream_at(decode_offset()); _sender_decode_offset = stream->read_int(); _method = methodHandle((methodOop) stream->read_oop()); _bci = stream->read_bci(); // decode offsets for body and sender _locals_decode_offset = stream->read_int(); _expressions_decode_offset = stream->read_int(); _monitors_decode_offset = stream->read_int(); } }
void ZeroStack::handle_overflow(TRAPS) { JavaThread *thread = (JavaThread *) THREAD; // Set up the frame anchor if it isn't already bool has_last_Java_frame = thread->has_last_Java_frame(); if (!has_last_Java_frame) { intptr_t *sp = thread->zero_stack()->sp(); ZeroFrame *frame = thread->top_zero_frame(); while (frame) { if (frame->is_shark_frame()) break; if (frame->is_interpreter_frame()) { interpreterState istate = frame->as_interpreter_frame()->interpreter_state(); if (istate->self_link() == istate) break; } sp = ((intptr_t *) frame) + 1; frame = frame->next(); } if (frame == NULL) fatal("unrecoverable stack overflow"); thread->set_last_Java_frame(frame, sp); } // Throw the exception switch (thread->thread_state()) { case _thread_in_Java: InterpreterRuntime::throw_StackOverflowError(thread); break; case _thread_in_vm: Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__, methodHandle()); break; default: ShouldNotReachHere(); } // Reset the frame anchor if necessary if (!has_last_Java_frame) thread->reset_last_Java_frame(); }
// After constant pool is created, revisit methods containing jsrs. methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { ResolveOopMapConflicts romc(method); methodHandle original_method = method; method = romc.do_potential_rewrite(CHECK_(methodHandle())); if (method() != original_method()) { // Insert invalid bytecode into original methodOop and set // interpreter entrypoint, so that a executing this method // will manifest itself in an easy recognizable form. address bcp = original_method->bcp_from(0); *bcp = (u1)Bytecodes::_shouldnotreachhere; int kind = Interpreter::method_kind(original_method); original_method->set_interpreter_kind(kind); } // Update monitor matching info. if (romc.monitor_safe()) { method->set_guaranteed_monitor_matching(); } return method; }