提交 dd8b4d98 编写于 作者: T twisti

7035870: JSR 292: Zero support

Summary: This adds support for JSR 292 to Zero.
Reviewed-by: twisti
Contributed-by: NGary Benson <gbenson@redhat.com>
上级 b21b7c6d
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008 Red Hat, Inc.
* Copyright 2007, 2008, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -150,4 +150,22 @@
#define SET_LOCALS_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = \
((VMJavaVal64*)(addr))->l)
// VMSlots implementation
#define VMSLOTS_SLOT(offset) ((intptr_t*)&vmslots[(offset)])
#define VMSLOTS_ADDR(offset) ((address)vmslots[(offset)])
#define VMSLOTS_INT(offset) (*((jint*)&vmslots[(offset)]))
#define VMSLOTS_FLOAT(offset) (*((jfloat*)&vmslots[(offset)]))
#define VMSLOTS_OBJECT(offset) ((oop)vmslots[(offset)])
#define VMSLOTS_DOUBLE(offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->d)
#define VMSLOTS_LONG(offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->l)
#define SET_VMSLOTS_SLOT(value, offset) (*(intptr_t*)&vmslots[(offset)] = *(intptr_t *)(value))
#define SET_VMSLOTS_ADDR(value, offset) (*((address *)&vmslots[(offset)]) = (value))
#define SET_VMSLOTS_INT(value, offset) (*((jint *)&vmslots[(offset)]) = (value))
#define SET_VMSLOTS_FLOAT(value, offset) (*((jfloat *)&vmslots[(offset)]) = (value))
#define SET_VMSLOTS_OBJECT(value, offset) (*((oop *)&vmslots[(offset)]) = (value))
#define SET_VMSLOTS_DOUBLE(value, offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->d = (value))
#define SET_VMSLOTS_LONG(value, offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->l = (value))
#endif // CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_HPP
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2010 Red Hat, Inc.
* Copyright 2007, 2008, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -36,11 +36,21 @@
static int native_entry(methodOop method, intptr_t UNUSED, TRAPS);
static int accessor_entry(methodOop method, intptr_t UNUSED, TRAPS);
static int empty_entry(methodOop method, intptr_t UNUSED, TRAPS);
static int method_handle_entry(methodOop method, intptr_t UNUSED, TRAPS);
public:
// Main loop of normal_entry
static void main_loop(int recurse, TRAPS);
private:
// 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 remove_vmslots(int first_slot, int num_slots, TRAPS);
static BasicType result_type_of_handle(oop method_handle);
static intptr_t* calculate_unwind_sp(ZeroStack* stack, oop method_handle);
static void throw_exception(JavaThread* thread, Symbol* name,char *msg=NULL);
private:
// Fast result type determination
static BasicType result_type_of(methodOop method);
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -49,6 +49,9 @@
#ifdef COMPILER1
#include "c1/c1_Runtime1.hpp"
#endif
#ifdef CC_INTERP
#include "interpreter/cppInterpreter.hpp"
#endif
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
_masm->advance(1);
......@@ -64,11 +67,15 @@ address InterpreterGenerator::generate_math_entry(
}
address InterpreterGenerator::generate_abstract_entry() {
return ShouldNotCallThisEntry();
return generate_entry((address) ShouldNotCallThisEntry());
}
address InterpreterGenerator::generate_method_handle_entry() {
return ShouldNotCallThisEntry();
#ifdef CC_INTERP
return generate_entry((address) CppInterpreter::method_handle_entry);
#else
return generate_entry((address) ShouldNotCallThisEntry());
#endif // CC_INTERP
}
bool AbstractInterpreter::can_be_compiled(methodHandle m) {
......
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2009, 2010 Red Hat, Inc.
* Copyright 2009, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -29,10 +29,21 @@
#include "prims/methodHandles.hpp"
int MethodHandles::adapter_conversion_ops_supported_mask() {
ShouldNotCallThis();
return ((1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS)
|(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS)
//|(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
);
// FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
}
void MethodHandles::generate_method_handle_stub(MacroAssembler* masm,
MethodHandles::EntryKind ek) {
ShouldNotCallThis();
init_entry(ek, (MethodHandleEntry *) ek);
}
......@@ -554,7 +554,7 @@ BytecodeInterpreter::run(interpreterState istate) {
/* 0xB0 */ &&opc_areturn, &&opc_return, &&opc_getstatic, &&opc_putstatic,
/* 0xB4 */ &&opc_getfield, &&opc_putfield, &&opc_invokevirtual,&&opc_invokespecial,
/* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,&&opc_default, &&opc_new,
/* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,&&opc_invokedynamic,&&opc_new,
/* 0xBC */ &&opc_newarray, &&opc_anewarray, &&opc_arraylength, &&opc_athrow,
/* 0xC0 */ &&opc_checkcast, &&opc_instanceof, &&opc_monitorenter, &&opc_monitorexit,
......@@ -568,7 +568,7 @@ BytecodeInterpreter::run(interpreterState istate) {
/* 0xDC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
/* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
/* 0xE4 */ &&opc_default, &&opc_default, &&opc_default, &&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,
/* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
......@@ -1718,8 +1718,7 @@ run:
}
// Need to throw illegal monitor state exception
CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception);
// Should never reach here...
assert(false, "Should have thrown illegal monitor exception");
ShouldNotReachHere();
}
/* All of the non-quick opcodes. */
......@@ -2147,6 +2146,74 @@ run:
UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2);
}
CASE(_fast_aldc_w):
CASE(_fast_aldc): {
if (!EnableInvokeDynamic) {
// We should not encounter this bytecode if !EnableInvokeDynamic.
// The verifier will stop it. However, if we get past the verifier,
// this will stop the thread in a reasonable way, without crashing the JVM.
CALL_VM(InterpreterRuntime::throw_IncompatibleClassChangeError(THREAD),
handle_exception);
ShouldNotReachHere();
}
u2 index;
int incr;
if (opcode == Bytecodes::_fast_aldc) {
index = pc[1];
incr = 2;
} else {
index = Bytes::get_native_u2(pc+1);
incr = 3;
}
// We are resolved if the f1 field contains a non-null object (CallSite, etc.)
// 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.
ConstantPoolCacheEntry* cache = cp->entry_at(index);
if (cache->is_f1_null()) {
CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode),
handle_exception);
}
VERIFY_OOP(cache->f1());
SET_STACK_OBJECT(cache->f1(), 0);
UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1);
}
CASE(_invokedynamic): {
if (!EnableInvokeDynamic) {
// We should not encounter this bytecode if !EnableInvokeDynamic.
// The verifier will stop it. However, if we get past the verifier,
// this will stop the thread in a reasonable way, without crashing the JVM.
CALL_VM(InterpreterRuntime::throw_IncompatibleClassChangeError(THREAD),
handle_exception);
ShouldNotReachHere();
}
int index = Bytes::get_native_u4(pc+1);
// We are resolved if the f1 field contains a non-null object (CallSite, etc.)
// 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.
assert(constantPoolCacheOopDesc::is_secondary_index(index), "incorrect format");
ConstantPoolCacheEntry* cache = cp->secondary_entry_at(index);
if (cache->is_f1_null()) {
CALL_VM(InterpreterRuntime::resolve_invokedynamic(THREAD),
handle_exception);
}
VERIFY_OOP(cache->f1());
oop method_handle = java_lang_invoke_CallSite::target(cache->f1());
CHECK_NULL(method_handle);
istate->set_msg(call_method_handle);
istate->set_callee((methodOop) method_handle);
istate->set_bcp_advance(5);
UPDATE_PC_AND_RETURN(0); // I'll be back...
}
CASE(_invokeinterface): {
u2 index = Bytes::get_native_u2(pc+1);
......
......@@ -107,6 +107,7 @@ public:
rethrow_exception, // unwinding and throwing exception
// requests to frame manager from C++ interpreter
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
more_monitors, // need a new monitor
throwing_exception, // unwind stack and rethrow
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册