提交 dc27b8d0 编写于 作者: T twisti

8000780: make Zero build and run with JDK8

Reviewed-by: coleenp, dholmes, twisti
Contributed-by: NRoman Kennke <rkennke@redhat.com>
上级 d8c25817
...@@ -453,14 +453,30 @@ ifneq ($(OSNAME),windows) ...@@ -453,14 +453,30 @@ ifneq ($(OSNAME),windows)
ifeq ($(JVM_VARIANT_ZEROSHARK), true) ifeq ($(JVM_VARIANT_ZEROSHARK), true)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX) $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file) $(install-file)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_DIR)/%.debuginfo
$(install-file)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(SHARK_DIR)/%.diz
$(install-file)
$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX) $(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file) $(install-file)
$(EXPORT_SERVER_DIR)/%.debuginfo: $(SHARK_DIR)/%.debuginfo
$(install-file)
$(EXPORT_SERVER_DIR)/%.diz: $(SHARK_DIR)/%.diz
$(install-file)
endif endif
ifeq ($(JVM_VARIANT_ZERO), true) ifeq ($(JVM_VARIANT_ZERO), true)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX) $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file) $(install-file)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo
$(install-file)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(ZERO_DIR)/%.diz
$(install-file)
$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX) $(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
$(install-file) $(install-file)
$(EXPORT_SERVER_DIR)/%.debuginfo: $(ZERO_DIR)/%.debuginfo
$(install-file)
$(EXPORT_SERVER_DIR)/%.diz: $(ZERO_DIR)/%.diz
$(install-file)
endif endif
ifeq ($(JVM_VARIANT_MINIMAL1), true) ifeq ($(JVM_VARIANT_MINIMAL1), true)
$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX) $(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
......
...@@ -31,12 +31,17 @@ ...@@ -31,12 +31,17 @@
return _masm; return _masm;
} }
protected: public:
address generate_entry(address entry_point) { static address generate_entry_impl(MacroAssembler* masm, address entry_point) {
ZeroEntry *entry = (ZeroEntry *) assembler()->pc(); ZeroEntry *entry = (ZeroEntry *) masm->pc();
assembler()->advance(sizeof(ZeroEntry)); masm->advance(sizeof(ZeroEntry));
entry->set_entry_point(entry_point); entry->set_entry_point(entry_point);
return (address) entry; return (address) entry;
} }
protected:
address generate_entry(address entry_point) {
return generate_entry_impl(assembler(), entry_point);
}
#endif // CPU_ZERO_VM_CPPINTERPRETERGENERATOR_ZERO_HPP #endif // CPU_ZERO_VM_CPPINTERPRETERGENERATOR_ZERO_HPP
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
static int native_entry(Method* method, intptr_t UNUSED, TRAPS); static int native_entry(Method* method, intptr_t UNUSED, TRAPS);
static int accessor_entry(Method* method, intptr_t UNUSED, TRAPS); static int accessor_entry(Method* method, intptr_t UNUSED, TRAPS);
static int empty_entry(Method* method, intptr_t UNUSED, TRAPS); static int empty_entry(Method* method, intptr_t UNUSED, TRAPS);
static int method_handle_entry(Method* method, intptr_t UNUSED, TRAPS);
public: public:
// Main loop of normal_entry // Main loop of normal_entry
...@@ -44,7 +43,6 @@ ...@@ -44,7 +43,6 @@
private: private:
// Helpers for method_handle_entry // Helpers for method_handle_entry
static void process_method_handle(oop method_handle, TRAPS);
static void insert_vmslots(int insert_before, int num_slots, TRAPS); static void insert_vmslots(int insert_before, int num_slots, TRAPS);
static void remove_vmslots(int first_slot, int num_slots, TRAPS); static void remove_vmslots(int first_slot, int num_slots, TRAPS);
static BasicType result_type_of_handle(oop method_handle); static BasicType result_type_of_handle(oop method_handle);
......
...@@ -351,7 +351,7 @@ void SharkFrame::identify_word(int frame_index, ...@@ -351,7 +351,7 @@ void SharkFrame::identify_word(int frame_index,
switch (offset) { switch (offset) {
case pc_off: case pc_off:
strncpy(fieldbuf, "pc", buflen); strncpy(fieldbuf, "pc", buflen);
if (method()->is_oop()) { if (method()->is_method()) {
nmethod *code = method()->code(); nmethod *code = method()->code();
if (code && code->pc_desc_at(pc())) { if (code && code->pc_desc_at(pc())) {
SimpleScopeDesc ssd(code, pc()); SimpleScopeDesc ssd(code, pc());
...@@ -367,7 +367,7 @@ void SharkFrame::identify_word(int frame_index, ...@@ -367,7 +367,7 @@ void SharkFrame::identify_word(int frame_index,
case method_off: case method_off:
strncpy(fieldbuf, "method", buflen); strncpy(fieldbuf, "method", buflen);
if (method()->is_oop()) { if (method()->is_method()) {
method()->name_and_sig_as_C_string(valuebuf, buflen); method()->name_and_sig_as_C_string(valuebuf, buflen);
} }
return; return;
...@@ -378,7 +378,7 @@ void SharkFrame::identify_word(int frame_index, ...@@ -378,7 +378,7 @@ void SharkFrame::identify_word(int frame_index,
} }
// Variable part // Variable part
if (method()->is_oop()) { if (method()->is_method()) {
identify_vp_word(frame_index, addr_of_word(offset), identify_vp_word(frame_index, addr_of_word(offset),
addr_of_word(header_words + 1), addr_of_word(header_words + 1),
unextended_sp() + method()->max_stack(), unextended_sp() + method()->max_stack(),
...@@ -430,4 +430,3 @@ intptr_t *frame::initial_deoptimization_info() { ...@@ -430,4 +430,3 @@ intptr_t *frame::initial_deoptimization_info() {
// unused... but returns fp() to minimize changes introduced by 7087445 // unused... but returns fp() to minimize changes introduced by 7087445
return fp(); return fp();
} }
...@@ -36,6 +36,8 @@ inline frame::frame() { ...@@ -36,6 +36,8 @@ inline frame::frame() {
_deopt_state = unknown; _deopt_state = unknown;
} }
inline address frame::sender_pc() const { ShouldNotCallThis(); }
inline frame::frame(ZeroFrame* zf, intptr_t* sp) { inline frame::frame(ZeroFrame* zf, intptr_t* sp) {
_zeroframe = zf; _zeroframe = zf;
_sp = sp; _sp = sp;
......
...@@ -40,7 +40,7 @@ int InlineCacheBuffer::ic_stub_code_size() { ...@@ -40,7 +40,7 @@ int InlineCacheBuffer::ic_stub_code_size() {
} }
void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin,
Metadata* cached_oop, void* cached_oop,
address entry_point) { address entry_point) {
// NB ic_stub_code_size() must return the size of the code we generate // NB ic_stub_code_size() must return the size of the code we generate
ShouldNotCallThis(); ShouldNotCallThis();
...@@ -51,7 +51,6 @@ address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) { ...@@ -51,7 +51,6 @@ address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) {
ShouldNotCallThis(); ShouldNotCallThis();
} }
Metadata* InlineCacheBuffer::ic_buffer_cached_oop(address code_begin) { void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) {
// NB ic_stub_code_size() must return the size of the code we generate
ShouldNotCallThis(); ShouldNotCallThis();
} }
...@@ -24,26 +24,159 @@ ...@@ -24,26 +24,159 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "interpreter/interpreterGenerator.hpp"
#include "interpreter/interpreter.hpp" #include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
int MethodHandles::adapter_conversion_ops_supported_mask() { void MethodHandles::invoke_target(Method* method, TRAPS) {
return ((1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW) JavaThread *thread = (JavaThread *) THREAD;
|(1<<java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST) ZeroStack *stack = thread->zero_stack();
|(1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM) InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
|(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM) interpreterState istate = frame->interpreter_state();
|(1<<java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS) // Trim back the stack to put the parameters at the top
|(1<<java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS) stack->set_sp(istate->stack() + 1);
|(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS)
//|(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG! Interpreter::invoke_method(method, method->from_interpreted_entry(), THREAD);
);
// FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS. // Convert the result
} istate->set_stack(stack->sp() - 1);
void MethodHandles::generate_method_handle_stub(MacroAssembler* masm, }
MethodHandles::EntryKind ek) {
init_entry(ek, (MethodHandleEntry *) ek); oop MethodHandles::popFromStack(TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
interpreterState istate = frame->interpreter_state();
intptr_t* topOfStack = istate->stack();
oop top = STACK_OBJECT(-1);
MORE_STACK(-1);
istate->set_stack(topOfStack);
return top;
}
int MethodHandles::method_handle_entry_invokeBasic(Method* method, intptr_t UNUSED, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
interpreterState istate = frame->interpreter_state();
intptr_t* topOfStack = istate->stack();
// 'this' is a MethodHandle. We resolve the target method by accessing this.form.vmentry.vmtarget.
int numArgs = method->size_of_parameters();
oop lform1 = java_lang_invoke_MethodHandle::form(STACK_OBJECT(-numArgs)); // this.form
oop vmEntry1 = java_lang_invoke_LambdaForm::vmentry(lform1);
Method* vmtarget = (Method*) java_lang_invoke_MemberName::vmtarget(vmEntry1);
invoke_target(vmtarget, THREAD);
// No deoptimized frames on the stack
return 0;
}
int MethodHandles::method_handle_entry_linkToStaticOrSpecial(Method* method, intptr_t UNUSED, TRAPS) {
// Pop appendix argument from stack. This is a MemberName which we resolve to the
// target method.
oop vmentry = popFromStack(THREAD);
Method* vmtarget = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry);
invoke_target(vmtarget, THREAD);
return 0;
}
int MethodHandles::method_handle_entry_linkToInterface(Method* method, intptr_t UNUSED, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
interpreterState istate = frame->interpreter_state();
// Pop appendix argument from stack. This is a MemberName which we resolve to the
// target method.
oop vmentry = popFromStack(THREAD);
intptr_t* topOfStack = istate->stack();
// Resolve target method by looking up in the receiver object's itable.
Klass* clazz = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(vmentry));
intptr_t vmindex = java_lang_invoke_MemberName::vmindex(vmentry);
Method* target = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry);
int numArgs = target->size_of_parameters();
oop recv = STACK_OBJECT(-numArgs);
InstanceKlass* klass_part = InstanceKlass::cast(recv->klass());
itableOffsetEntry* ki = (itableOffsetEntry*) klass_part->start_of_itable();
int i;
for ( i = 0 ; i < klass_part->itable_length() ; i++, ki++ ) {
if (ki->interface_klass() == clazz) break;
}
itableMethodEntry* im = ki->first_method_entry(recv->klass());
Method* vmtarget = im[vmindex].method();
invoke_target(vmtarget, THREAD);
return 0;
}
int MethodHandles::method_handle_entry_linkToVirtual(Method* method, intptr_t UNUSED, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
interpreterState istate = frame->interpreter_state();
// Pop appendix argument from stack. This is a MemberName which we resolve to the
// target method.
oop vmentry = popFromStack(THREAD);
intptr_t* topOfStack = istate->stack();
// Resolve target method by looking up in the receiver object's vtable.
intptr_t vmindex = java_lang_invoke_MemberName::vmindex(vmentry);
Method* target = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry);
int numArgs = target->size_of_parameters();
oop recv = STACK_OBJECT(-numArgs);
Klass* clazz = recv->klass();
Klass* klass_part = InstanceKlass::cast(clazz);
klassVtable* vtable = klass_part->vtable();
Method* vmtarget = vtable->method_at(vmindex);
invoke_target(vmtarget, THREAD);
return 0;
}
int MethodHandles::method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS) {
ShouldNotReachHere();
return 0;
}
address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* masm,
vmIntrinsics::ID iid) {
switch (iid) {
case vmIntrinsics::_invokeGeneric:
case vmIntrinsics::_compiledLambdaForm:
// Perhaps surprisingly, the symbolic references visible to Java are not directly used.
// They are linked to Java-generated adapters via MethodHandleNatives.linkMethod.
// They all allow an appendix argument.
return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invalid);
case vmIntrinsics::_invokeBasic:
return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_invokeBasic);
case vmIntrinsics::_linkToStatic:
case vmIntrinsics::_linkToSpecial:
return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToStaticOrSpecial);
case vmIntrinsics::_linkToInterface:
return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToInterface);
case vmIntrinsics::_linkToVirtual:
return InterpreterGenerator::generate_entry_impl(masm, (address) MethodHandles::method_handle_entry_linkToVirtual);
default:
ShouldNotReachHere();
return NULL;
}
} }
...@@ -26,6 +26,14 @@ ...@@ -26,6 +26,14 @@
// Adapters // Adapters
enum /* platform_dependent_constants */ { enum /* platform_dependent_constants */ {
adapter_code_size = 0 adapter_code_size = sizeof(ZeroEntry) * (Interpreter::method_handle_invoke_LAST - Interpreter::method_handle_invoke_FIRST + 1)
}; };
private:
static oop popFromStack(TRAPS);
static void invoke_target(Method* method, TRAPS);
static int method_handle_entry_invokeBasic(Method* method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_linkToStaticOrSpecial(Method* method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_linkToVirtual(Method* method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_linkToInterface(Method* method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_invalid(Method* method, intptr_t UNUSED, TRAPS);
...@@ -114,5 +114,8 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl { ...@@ -114,5 +114,8 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl {
}; };
CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1));
#ifndef DONT_USE_REGISTER_DEFINES
#define noreg ((Register)(noreg_RegisterEnumValue))
#endif
#endif // CPU_ZERO_VM_REGISTER_ZERO_HPP #endif // CPU_ZERO_VM_REGISTER_ZERO_HPP
...@@ -77,3 +77,7 @@ void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, ...@@ -77,3 +77,7 @@ void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src,
CodeBuffer* dst) { CodeBuffer* dst) {
ShouldNotCallThis(); ShouldNotCallThis();
} }
void metadata_Relocation::pd_fix_value(address x) {
ShouldNotCallThis();
}
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "runtime/sharedRuntime.hpp" #include "runtime/sharedRuntime.hpp"
#include "runtime/vframeArray.hpp" #include "runtime/vframeArray.hpp"
#include "vmreg_zero.inline.hpp" #include "vmreg_zero.inline.hpp"
#ifdef COMPILER1 #ifdef COMPILER1
#include "c1/c1_Runtime1.hpp" #include "c1/c1_Runtime1.hpp"
#endif #endif
...@@ -47,6 +48,12 @@ ...@@ -47,6 +48,12 @@
#endif #endif
static address zero_null_code_stub() {
address start = ShouldNotCallThisStub();
return start;
}
int SharedRuntime::java_calling_convention(const BasicType *sig_bt, int SharedRuntime::java_calling_convention(const BasicType *sig_bt,
VMRegPair *regs, VMRegPair *regs,
int total_args_passed, int total_args_passed,
...@@ -63,16 +70,14 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters( ...@@ -63,16 +70,14 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(
AdapterFingerPrint *fingerprint) { AdapterFingerPrint *fingerprint) {
return AdapterHandlerLibrary::new_entry( return AdapterHandlerLibrary::new_entry(
fingerprint, fingerprint,
ShouldNotCallThisStub(), CAST_FROM_FN_PTR(address,zero_null_code_stub),
ShouldNotCallThisStub(), CAST_FROM_FN_PTR(address,zero_null_code_stub),
ShouldNotCallThisStub()); CAST_FROM_FN_PTR(address,zero_null_code_stub));
} }
nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
methodHandle method, methodHandle method,
int compile_id, int compile_id,
int total_args_passed,
int max_arg,
BasicType *sig_bt, BasicType *sig_bt,
VMRegPair *regs, VMRegPair *regs,
BasicType ret_type) { BasicType ret_type) {
...@@ -96,19 +101,20 @@ uint SharedRuntime::out_preserve_stack_slots() { ...@@ -96,19 +101,20 @@ uint SharedRuntime::out_preserve_stack_slots() {
ShouldNotCallThis(); ShouldNotCallThis();
} }
JRT_LEAF(void, zero_stub())
ShouldNotCallThis();
JRT_END
static RuntimeStub* generate_empty_runtime_stub(const char* name) { static RuntimeStub* generate_empty_runtime_stub(const char* name) {
CodeBuffer buffer(name, 0, 0); return CAST_FROM_FN_PTR(RuntimeStub*,zero_stub);
return RuntimeStub::new_runtime_stub(name, &buffer, 0, 0, NULL, false);
} }
static SafepointBlob* generate_empty_safepoint_blob() { static SafepointBlob* generate_empty_safepoint_blob() {
CodeBuffer buffer("handler_blob", 0, 0); return CAST_FROM_FN_PTR(SafepointBlob*,zero_stub);
return SafepointBlob::create(&buffer, NULL, 0);
} }
static DeoptimizationBlob* generate_empty_deopt_blob() { static DeoptimizationBlob* generate_empty_deopt_blob() {
CodeBuffer buffer("handler_blob", 0, 0); return CAST_FROM_FN_PTR(DeoptimizationBlob*,zero_stub);
return DeoptimizationBlob::create(&buffer, NULL, 0, 0, 0, 0);
} }
...@@ -116,7 +122,7 @@ void SharedRuntime::generate_deopt_blob() { ...@@ -116,7 +122,7 @@ void SharedRuntime::generate_deopt_blob() {
_deopt_blob = generate_empty_deopt_blob(); _deopt_blob = generate_empty_deopt_blob();
} }
SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, bool cause_return) { SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) {
return generate_empty_safepoint_blob(); return generate_empty_safepoint_blob();
} }
...@@ -124,6 +130,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha ...@@ -124,6 +130,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha
return generate_empty_runtime_stub("resolve_blob"); return generate_empty_runtime_stub("resolve_blob");
} }
int SharedRuntime::c_calling_convention(const BasicType *sig_bt, int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
VMRegPair *regs, VMRegPair *regs,
int total_args_passed) { int total_args_passed) {
......
...@@ -758,7 +758,7 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const { ...@@ -758,7 +758,7 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
} }
} }
if (dest->blob() == NULL) { if (dest->blob() == NULL && dest_filled != NULL) {
// Destination is a final resting place, not just another buffer. // Destination is a final resting place, not just another buffer.
// Normalize uninitialized bytes in the final padding. // Normalize uninitialized bytes in the final padding.
Copy::fill_to_bytes(dest_filled, dest_end - dest_filled, Copy::fill_to_bytes(dest_filled, dest_end - dest_filled,
......
...@@ -320,6 +320,7 @@ class AbstractInterpreterGenerator: public StackObj { ...@@ -320,6 +320,7 @@ class AbstractInterpreterGenerator: public StackObj {
void bang_stack_shadow_pages(bool native_call); void bang_stack_shadow_pages(bool native_call);
void generate_all(); void generate_all();
void initialize_method_handle_entries();
public: public:
AbstractInterpreterGenerator(StubQueue* _code); AbstractInterpreterGenerator(StubQueue* _code);
......
...@@ -235,10 +235,6 @@ ...@@ -235,10 +235,6 @@
#endif #endif
#endif #endif
// JavaStack Implementation
#define MORE_STACK(count) \
(topOfStack -= ((count) * Interpreter::stackElementWords))
#define UPDATE_PC(opsize) {pc += opsize; } #define UPDATE_PC(opsize) {pc += opsize; }
/* /*
...@@ -575,7 +571,7 @@ BytecodeInterpreter::run(interpreterState istate) { ...@@ -575,7 +571,7 @@ BytecodeInterpreter::run(interpreterState istate) {
/* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
/* 0xE4 */ &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, &&opc_return_register_finalizer, /* 0xE4 */ &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, &&opc_return_register_finalizer,
/* 0xE8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xE8 */ &&opc_invokehandle,&&opc_default, &&opc_default, &&opc_default,
/* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
/* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
...@@ -1773,7 +1769,7 @@ run: ...@@ -1773,7 +1769,7 @@ run:
oop obj; oop obj;
if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
Klass* k = (Klass*) cache->f1(); Klass* k = cache->f1_as_klass();
obj = k->java_mirror(); obj = k->java_mirror();
MORE_STACK(1); // Assume single slot push MORE_STACK(1); // Assume single slot push
} else { } else {
...@@ -1885,7 +1881,7 @@ run: ...@@ -1885,7 +1881,7 @@ run:
--count; --count;
} }
if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
Klass* k = (Klass*) cache->f1(); Klass* k = cache->f1_as_klass();
obj = k->java_mirror(); obj = k->java_mirror();
} else { } else {
--count; --count;
...@@ -2190,6 +2186,7 @@ run: ...@@ -2190,6 +2186,7 @@ run:
} }
CASE(_invokedynamic): { CASE(_invokedynamic): {
if (!EnableInvokeDynamic) { if (!EnableInvokeDynamic) {
// We should not encounter this bytecode if !EnableInvokeDynamic. // We should not encounter this bytecode if !EnableInvokeDynamic.
// The verifier will stop it. However, if we get past the verifier, // The verifier will stop it. However, if we get past the verifier,
...@@ -2199,30 +2196,68 @@ run: ...@@ -2199,30 +2196,68 @@ run:
ShouldNotReachHere(); ShouldNotReachHere();
} }
int index = Bytes::get_native_u4(pc+1); u4 index = Bytes::get_native_u4(pc+1);
ConstantPoolCacheEntry* cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index);
// We are resolved if the resolved_references field contains a non-null object (CallSite, etc.) // We are resolved if the resolved_references field contains a non-null object (CallSite, etc.)
// This kind of CP cache entry does not need to match the flags byte, because // This kind of CP cache entry does not need to match the flags byte, because
// there is a 1-1 relation between bytecode type and CP entry type. // there is a 1-1 relation between bytecode type and CP entry type.
ConstantPool* constants = METHOD->constants(); if (! cache->is_resolved((Bytecodes::Code) opcode)) {
oop result = constants->resolved_references()->obj_at(index);
if (result == NULL) {
CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD), CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD),
handle_exception); handle_exception);
result = THREAD->vm_result(); cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index);
} }
VERIFY_OOP(result); Method* method = cache->f1_as_method();
oop method_handle = java_lang_invoke_CallSite::target(result); VERIFY_OOP(method);
CHECK_NULL(method_handle);
if (cache->has_appendix()) {
ConstantPool* constants = METHOD->constants();
SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0);
MORE_STACK(1);
}
istate->set_msg(call_method_handle); istate->set_msg(call_method);
istate->set_callee((Method*) method_handle); istate->set_callee(method);
istate->set_callee_entry_point(method->from_interpreted_entry());
istate->set_bcp_advance(5); istate->set_bcp_advance(5);
UPDATE_PC_AND_RETURN(0); // I'll be back... UPDATE_PC_AND_RETURN(0); // I'll be back...
} }
CASE(_invokehandle): {
if (!EnableInvokeDynamic) {
ShouldNotReachHere();
}
u2 index = Bytes::get_native_u2(pc+1);
ConstantPoolCacheEntry* cache = cp->entry_at(index);
if (! cache->is_resolved((Bytecodes::Code) opcode)) {
CALL_VM(InterpreterRuntime::resolve_invokehandle(THREAD),
handle_exception);
cache = cp->entry_at(index);
}
Method* method = cache->f1_as_method();
VERIFY_OOP(method);
if (cache->has_appendix()) {
ConstantPool* constants = METHOD->constants();
SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0);
MORE_STACK(1);
}
istate->set_msg(call_method);
istate->set_callee(method);
istate->set_callee_entry_point(method->from_interpreted_entry());
istate->set_bcp_advance(3);
UPDATE_PC_AND_RETURN(0); // I'll be back...
}
CASE(_invokeinterface): { CASE(_invokeinterface): {
u2 index = Bytes::get_native_u2(pc+1); u2 index = Bytes::get_native_u2(pc+1);
......
...@@ -50,6 +50,10 @@ ...@@ -50,6 +50,10 @@
#ifdef CC_INTERP #ifdef CC_INTERP
// JavaStack Implementation
#define MORE_STACK(count) \
(topOfStack -= ((count) * Interpreter::stackElementWords))
// CVM definitions find hotspot equivalents... // CVM definitions find hotspot equivalents...
union VMJavaVal64 { union VMJavaVal64 {
...@@ -107,7 +111,6 @@ public: ...@@ -107,7 +111,6 @@ public:
rethrow_exception, // unwinding and throwing exception rethrow_exception, // unwinding and throwing exception
// requests to frame manager from C++ interpreter // requests to frame manager from C++ interpreter
call_method, // request for new frame from interpreter, manager responds with method_entry call_method, // request for new frame from interpreter, manager responds with method_entry
call_method_handle, // like the above, except the callee is a method handle
return_from_method, // request from interpreter to unwind, manager responds with method_continue return_from_method, // request from interpreter to unwind, manager responds with method_continue
more_monitors, // need a new monitor more_monitors, // need a new monitor
throwing_exception, // unwind stack and rethrow throwing_exception, // unwind stack and rethrow
......
...@@ -117,7 +117,6 @@ void CppInterpreterGenerator::generate_all() { ...@@ -117,7 +117,6 @@ void CppInterpreterGenerator::generate_all() {
method_entry(empty); method_entry(empty);
method_entry(accessor); method_entry(accessor);
method_entry(abstract); method_entry(abstract);
method_entry(method_handle);
method_entry(java_lang_math_sin ); method_entry(java_lang_math_sin );
method_entry(java_lang_math_cos ); method_entry(java_lang_math_cos );
method_entry(java_lang_math_tan ); method_entry(java_lang_math_tan );
...@@ -125,7 +124,12 @@ void CppInterpreterGenerator::generate_all() { ...@@ -125,7 +124,12 @@ void CppInterpreterGenerator::generate_all() {
method_entry(java_lang_math_sqrt ); method_entry(java_lang_math_sqrt );
method_entry(java_lang_math_log ); method_entry(java_lang_math_log );
method_entry(java_lang_math_log10 ); method_entry(java_lang_math_log10 );
method_entry(java_lang_math_pow );
method_entry(java_lang_math_exp );
method_entry(java_lang_ref_reference_get); method_entry(java_lang_ref_reference_get);
initialize_method_handle_entries();
Interpreter::_native_entry_begin = Interpreter::code()->code_end(); Interpreter::_native_entry_begin = Interpreter::code()->code_end();
method_entry(native); method_entry(native);
method_entry(native_synchronized); method_entry(native_synchronized);
......
...@@ -464,3 +464,11 @@ void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) { ...@@ -464,3 +464,11 @@ void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
} }
} }
} }
void AbstractInterpreterGenerator::initialize_method_handle_entries() {
// method handle entry kinds are generated later in MethodHandlesAdapterGenerator::generate:
for (int i = Interpreter::method_handle_invoke_FIRST; i <= Interpreter::method_handle_invoke_LAST; i++) {
Interpreter::MethodKind kind = (Interpreter::MethodKind) i;
Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract];
}
}
...@@ -373,11 +373,7 @@ void TemplateInterpreterGenerator::generate_all() { ...@@ -373,11 +373,7 @@ void TemplateInterpreterGenerator::generate_all() {
method_entry(java_lang_math_pow ) method_entry(java_lang_math_pow )
method_entry(java_lang_ref_reference_get) method_entry(java_lang_ref_reference_get)
// method handle entry kinds are generated later in MethodHandlesAdapterGenerator::generate: initialize_method_handle_entries();
for (int i = Interpreter::method_handle_invoke_FIRST; i <= Interpreter::method_handle_invoke_LAST; i++) {
Interpreter::MethodKind kind = (Interpreter::MethodKind) i;
Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract];
}
// all native method kinds (must be one contiguous block) // all native method kinds (must be one contiguous block)
Interpreter::_native_entry_begin = Interpreter::code()->code_end(); Interpreter::_native_entry_begin = Interpreter::code()->code_end();
......
...@@ -2474,7 +2474,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary; ...@@ -2474,7 +2474,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary;
/* frame */ \ /* frame */ \
/**********************/ \ /**********************/ \
\ \
X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset)) \ NOT_ZERO(X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset))) \
declare_constant(frame::pc_return_offset) \ declare_constant(frame::pc_return_offset) \
\ \
/*************/ \ /*************/ \
......
...@@ -282,6 +282,22 @@ ...@@ -282,6 +282,22 @@
#define NOT_WIN64(code) code #define NOT_WIN64(code) code
#endif #endif
#if defined(ZERO)
#define ZERO_ONLY(code) code
#define NOT_ZERO(code)
#else
#define ZERO_ONLY(code)
#define NOT_ZERO(code) code
#endif
#if defined(SHARK)
#define SHARK_ONLY(code) code
#define NOT_SHARK(code)
#else
#define SHARK_ONLY(code)
#define NOT_SHARK(code) code
#endif
#if defined(IA32) || defined(AMD64) #if defined(IA32) || defined(AMD64)
#define X86 #define X86
#define X86_ONLY(code) code #define X86_ONLY(code) code
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册