提交 0f11ba0c 编写于 作者: J jrose

Merge

......@@ -2317,7 +2317,7 @@ void Assembler::prefetchnta(Address src) {
}
void Assembler::prefetchr(Address src) {
NOT_LP64(assert(VM_Version::supports_3dnow(), "must support"));
NOT_LP64(assert(VM_Version::supports_3dnow_prefetch(), "must support"));
InstructionMark im(this);
prefetch_prefix(src);
emit_byte(0x0D);
......@@ -2349,7 +2349,7 @@ void Assembler::prefetcht2(Address src) {
}
void Assembler::prefetchw(Address src) {
NOT_LP64(assert(VM_Version::supports_3dnow(), "must support"));
NOT_LP64(assert(VM_Version::supports_3dnow_prefetch(), "must support"));
InstructionMark im(this);
prefetch_prefix(src);
emit_byte(0x0D);
......
......@@ -1401,7 +1401,7 @@ void LIR_Assembler::prefetchr(LIR_Opr src) {
default:
ShouldNotReachHere(); break;
}
} else if (VM_Version::supports_3dnow()) {
} else if (VM_Version::supports_3dnow_prefetch()) {
__ prefetchr(from_addr);
}
}
......@@ -1424,7 +1424,7 @@ void LIR_Assembler::prefetchw(LIR_Opr src) {
default:
ShouldNotReachHere(); break;
}
} else if (VM_Version::supports_3dnow()) {
} else if (VM_Version::supports_3dnow_prefetch()) {
__ prefetchw(from_addr);
}
}
......
......@@ -348,7 +348,7 @@ void VM_Version::get_processor_features() {
}
char buf[256];
jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
cores_per_cpu(), threads_per_core(),
cpu_family(), _model, _stepping,
(supports_cmov() ? ", cmov" : ""),
......@@ -363,8 +363,7 @@ void VM_Version::get_processor_features() {
(supports_sse4_2() ? ", sse4.2" : ""),
(supports_popcnt() ? ", popcnt" : ""),
(supports_mmx_ext() ? ", mmxext" : ""),
(supports_3dnow() ? ", 3dnow" : ""),
(supports_3dnow2() ? ", 3dnowext" : ""),
(supports_3dnow_prefetch() ? ", 3dnowpref" : ""),
(supports_lzcnt() ? ", lzcnt": ""),
(supports_sse4a() ? ", sse4a": ""),
(supports_ht() ? ", ht": ""));
......@@ -522,13 +521,13 @@ void VM_Version::get_processor_features() {
// set valid Prefetch instruction
if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
if( !supports_sse() && supports_3dnow() ) ReadPrefetchInstr = 3;
if( ReadPrefetchInstr == 3 && !supports_3dnow_prefetch() ) ReadPrefetchInstr = 0;
if( !supports_sse() && supports_3dnow_prefetch() ) ReadPrefetchInstr = 3;
if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
if( !supports_sse() && supports_3dnow() ) AllocatePrefetchInstr = 3;
if( AllocatePrefetchInstr == 3 && !supports_3dnow_prefetch() ) AllocatePrefetchInstr=0;
if( !supports_sse() && supports_3dnow_prefetch() ) AllocatePrefetchInstr = 3;
// Allocation prefetch settings
intx cache_line_size = L1_data_cache_line_size();
......@@ -576,10 +575,10 @@ void VM_Version::get_processor_features() {
logical_processors_per_package());
tty->print_cr("UseSSE=%d",UseSSE);
tty->print("Allocation: ");
if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow()) {
if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow_prefetch()) {
tty->print_cr("no prefetching");
} else {
if (UseSSE == 0 && supports_3dnow()) {
if (UseSSE == 0 && supports_3dnow_prefetch()) {
tty->print("PREFETCHW");
} else if (UseSSE >= 1) {
if (AllocatePrefetchInstr == 0) {
......
......@@ -188,7 +188,8 @@ protected:
CPU_FXSR = (1 << 2),
CPU_HT = (1 << 3),
CPU_MMX = (1 << 4),
CPU_3DNOW = (1 << 5), // 3DNow comes from cpuid 0x80000001 (EDX)
CPU_3DNOW_PREFETCH = (1 << 5), // Processor supports 3dnow prefetch and prefetchw instructions
// may not necessarily support other 3dnow instructions
CPU_SSE = (1 << 6),
CPU_SSE2 = (1 << 7),
CPU_SSE3 = (1 << 8), // SSE3 comes from cpuid 1 (ECX)
......@@ -328,8 +329,9 @@ protected:
// AMD features.
if (is_amd()) {
if (_cpuid_info.ext_cpuid1_edx.bits.tdnow != 0)
result |= CPU_3DNOW;
if ((_cpuid_info.ext_cpuid1_edx.bits.tdnow != 0) ||
(_cpuid_info.ext_cpuid1_ecx.bits.prefetchw != 0))
result |= CPU_3DNOW_PREFETCH;
if (_cpuid_info.ext_cpuid1_ecx.bits.lzcnt != 0)
result |= CPU_LZCNT;
if (_cpuid_info.ext_cpuid1_ecx.bits.sse4a != 0)
......@@ -446,9 +448,8 @@ public:
//
// AMD features
//
static bool supports_3dnow() { return (_cpuFeatures & CPU_3DNOW) != 0; }
static bool supports_3dnow_prefetch() { return (_cpuFeatures & CPU_3DNOW_PREFETCH) != 0; }
static bool supports_mmx_ext() { return is_amd() && _cpuid_info.ext_cpuid1_edx.bits.mmx_amd != 0; }
static bool supports_3dnow2() { return is_amd() && _cpuid_info.ext_cpuid1_edx.bits.tdnow2 != 0; }
static bool supports_lzcnt() { return (_cpuFeatures & CPU_LZCNT) != 0; }
static bool supports_sse4a() { return (_cpuFeatures & CPU_SSE4A) != 0; }
......
......@@ -3423,7 +3423,7 @@ encode %{
masm.movptr(boxReg, tmpReg); // consider: LEA box, [tmp-2]
// Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes
if ((EmitSync & 2048) && VM_Version::supports_3dnow() && os::is_MP()) {
if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
// prefetchw [eax + Offset(_owner)-2]
masm.prefetchw(Address(rax, ObjectMonitor::owner_offset_in_bytes()-2));
}
......@@ -3467,7 +3467,7 @@ encode %{
masm.movptr(boxReg, tmpReg) ;
// Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes
if ((EmitSync & 2048) && VM_Version::supports_3dnow() && os::is_MP()) {
if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
// prefetchw [eax + Offset(_owner)-2]
masm.prefetchw(Address(rax, ObjectMonitor::owner_offset_in_bytes()-2));
}
......@@ -3614,7 +3614,7 @@ encode %{
// See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html.
masm.get_thread (boxReg) ;
if ((EmitSync & 4096) && VM_Version::supports_3dnow() && os::is_MP()) {
if ((EmitSync & 4096) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
// prefetchw [ebx + Offset(_owner)-2]
masm.prefetchw(Address(rbx, ObjectMonitor::owner_offset_in_bytes()-2));
}
......@@ -7333,7 +7333,7 @@ instruct loadSSD(regD dst, stackSlotD src) %{
// Must be safe to execute with invalid address (cannot fault).
instruct prefetchr0( memory mem ) %{
predicate(UseSSE==0 && !VM_Version::supports_3dnow());
predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
match(PrefetchRead mem);
ins_cost(0);
size(0);
......@@ -7343,7 +7343,7 @@ instruct prefetchr0( memory mem ) %{
%}
instruct prefetchr( memory mem ) %{
predicate(UseSSE==0 && VM_Version::supports_3dnow() || ReadPrefetchInstr==3);
predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch() || ReadPrefetchInstr==3);
match(PrefetchRead mem);
ins_cost(100);
......@@ -7387,7 +7387,7 @@ instruct prefetchrT2( memory mem ) %{
%}
instruct prefetchw0( memory mem ) %{
predicate(UseSSE==0 && !VM_Version::supports_3dnow());
predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
match(PrefetchWrite mem);
ins_cost(0);
size(0);
......@@ -7397,7 +7397,7 @@ instruct prefetchw0( memory mem ) %{
%}
instruct prefetchw( memory mem ) %{
predicate(UseSSE==0 && VM_Version::supports_3dnow() || AllocatePrefetchInstr==3);
predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch() || AllocatePrefetchInstr==3);
match( PrefetchWrite mem );
ins_cost(100);
......
/*
* 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);
}
......@@ -971,8 +971,6 @@ size_t CodeCache::largest_free_block() {
if (CodeCache_lock->owned_by_self()) {
return _heap->largest_free_block();
} else {
// Avoid lock ordering problems with ttyLock.
ttyUnlocker ttyul;
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
return _heap->largest_free_block();
}
......
......@@ -1736,8 +1736,14 @@ void CompileBroker::handle_full_code_cache() {
UseInterpreter = true;
if (UseCompiler || AlwaysCompileLoopMethods ) {
if (xtty != NULL) {
stringStream s;
// Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts.
CodeCache::log_state(&s);
// Lock to prevent tearing
ttyLocker ttyl;
xtty->begin_elem("code_cache_full");
CodeCache::log_state(xtty);
xtty->print(s.as_string());
xtty->stamp();
xtty->end_elem();
}
......
......@@ -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
......
......@@ -921,6 +921,10 @@ methodHandle methodOopDesc::make_invoke_method(KlassHandle holder,
tty->cr();
}
// invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup)
name->increment_refcount();
signature->increment_refcount();
constantPoolHandle cp;
{
constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty));
......
......@@ -795,8 +795,9 @@ float Parse::dynamic_branch_prediction(float &cnt) {
taken = method()->scale_count(taken);
not_taken = method()->scale_count(not_taken);
// Give up if too few counts to be meaningful
if (taken + not_taken < 40) {
// Give up if too few (or too many, in which case the sum will overflow) counts to be meaningful.
// We also check that individual counters are positive first, overwise the sum can become positive.
if (taken < 0 || not_taken < 0 || taken + not_taken < 40) {
if (C->log() != NULL) {
C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken);
}
......@@ -804,13 +805,13 @@ float Parse::dynamic_branch_prediction(float &cnt) {
}
// Compute frequency that we arrive here
int sum = taken + not_taken;
float sum = taken + not_taken;
// Adjust, if this block is a cloned private block but the
// Jump counts are shared. Taken the private counts for
// just this path instead of the shared counts.
if( block()->count() > 0 )
sum = block()->count();
cnt = (float)sum / (float)FreqCountInvocations;
cnt = sum / FreqCountInvocations;
// Pin probability to sane limits
float prob;
......
......@@ -343,6 +343,7 @@ private:
int cpool_symbol_put(int tag, Symbol* con) {
if (con == NULL) return 0;
ConstantValue* cv = new ConstantValue(tag, con);
con->increment_refcount();
return _constants.append(cv);
}
......
......@@ -928,6 +928,7 @@ static const char* always_null_names[] = {
};
static bool is_always_null_type(klassOop klass) {
if (klass == NULL) return false; // safety
if (!Klass::cast(klass)->oop_is_instance()) return false;
instanceKlass* ik = instanceKlass::cast(klass);
// Must be on the boot class path:
......@@ -944,6 +945,8 @@ static bool is_always_null_type(klassOop klass) {
}
bool MethodHandles::class_cast_needed(klassOop src, klassOop dst) {
if (dst == NULL) return true;
if (src == NULL) return (dst != SystemDictionary::Object_klass());
if (src == dst || dst == SystemDictionary::Object_klass())
return false; // quickest checks
Klass* srck = Klass::cast(src);
......@@ -1026,10 +1029,15 @@ void MethodHandles::verify_method_signature(methodHandle m,
int first_ptype_pos,
KlassHandle insert_ptype,
TRAPS) {
Handle mhi_type;
if (m->is_method_handle_invoke()) {
// use this more exact typing instead of the symbolic signature:
mhi_type = Handle(THREAD, m->method_handle_type());
}
objArrayHandle ptypes(THREAD, java_lang_invoke_MethodType::ptypes(mtype()));
int pnum = first_ptype_pos;
int pmax = ptypes->length();
int mnum = 0; // method argument
int anum = 0; // method argument
const char* err = NULL;
ResourceMark rm(THREAD);
for (SignatureStream ss(m->signature()); !ss.is_done(); ss.next()) {
......@@ -1048,47 +1056,70 @@ void MethodHandles::verify_method_signature(methodHandle m,
else
ptype_oop = insert_ptype->java_mirror();
pnum += 1;
mnum += 1;
anum += 1;
}
klassOop pklass = NULL;
BasicType ptype = T_OBJECT;
if (ptype_oop != NULL)
ptype = java_lang_Class::as_BasicType(ptype_oop, &pklass);
else
// null does not match any non-reference; use Object to report the error
pklass = SystemDictionary::Object_klass();
klassOop mklass = NULL;
BasicType mtype = ss.type();
if (mtype == T_ARRAY) mtype = T_OBJECT; // fold all refs to T_OBJECT
if (mtype == T_OBJECT) {
if (ptype_oop == NULL) {
KlassHandle pklass;
BasicType ptype = T_OBJECT;
bool have_ptype = false;
// missing ptype_oop does not match any non-reference; use Object to report the error
pklass = SystemDictionaryHandles::Object_klass();
if (ptype_oop != NULL) {
have_ptype = true;
klassOop pklass_oop = NULL;
ptype = java_lang_Class::as_BasicType(ptype_oop, &pklass_oop);
pklass = KlassHandle(THREAD, pklass_oop);
}
ptype_oop = NULL; //done with this
KlassHandle aklass;
BasicType atype = ss.type();
if (atype == T_ARRAY) atype = T_OBJECT; // fold all refs to T_OBJECT
if (atype == T_OBJECT) {
if (!have_ptype) {
// null matches any reference
continue;
}
KlassHandle pklass_handle(THREAD, pklass); pklass = NULL;
// If we fail to resolve types at this point, we will throw an error.
Symbol* name = ss.as_symbol(CHECK);
instanceKlass* mk = instanceKlass::cast(m->method_holder());
Handle loader(THREAD, mk->class_loader());
Handle domain(THREAD, mk->protection_domain());
mklass = SystemDictionary::resolve_or_null(name, loader, domain, CHECK);
pklass = pklass_handle();
if (mklass == NULL && pklass != NULL &&
Klass::cast(pklass)->name() == name &&
m->is_method_handle_invoke()) {
// Assume a match. We can't really decode the signature of MH.invoke*.
continue;
if (mhi_type.is_null()) {
// If we fail to resolve types at this point, we will usually throw an error.
TempNewSymbol name = ss.as_symbol_or_null();
if (name != NULL) {
instanceKlass* mk = instanceKlass::cast(m->method_holder());
Handle loader(THREAD, mk->class_loader());
Handle domain(THREAD, mk->protection_domain());
klassOop aklass_oop = SystemDictionary::resolve_or_null(name, loader, domain, CHECK);
if (aklass_oop != NULL)
aklass = KlassHandle(THREAD, aklass_oop);
}
} else {
// for method handle invokers we don't look at the name in the signature
oop atype_oop;
if (ss.at_return_type())
atype_oop = java_lang_invoke_MethodType::rtype(mhi_type());
else
atype_oop = java_lang_invoke_MethodType::ptype(mhi_type(), anum-1);
klassOop aklass_oop = NULL;
atype = java_lang_Class::as_BasicType(atype_oop, &aklass_oop);
aklass = KlassHandle(THREAD, aklass_oop);
}
}
if (!ss.at_return_type()) {
err = check_argument_type_change(ptype, pklass, mtype, mklass, mnum);
err = check_argument_type_change(ptype, pklass(), atype, aklass(), anum);
} else {
err = check_return_type_change(mtype, mklass, ptype, pklass); // note reversal!
err = check_return_type_change(atype, aklass(), ptype, pklass()); // note reversal!
}
if (err != NULL) break;
}
if (err != NULL) {
#ifndef PRODUCT
if (PrintMiscellaneous && (Verbose || WizardMode)) {
tty->print("*** verify_method_signature failed: ");
java_lang_invoke_MethodType::print_signature(mtype(), tty);
tty->cr();
tty->print_cr(" first_ptype_pos = %d, insert_ptype = "UINTX_FORMAT, first_ptype_pos, insert_ptype());
tty->print(" Failing method: ");
m->print();
}
#endif //PRODUCT
THROW_MSG(vmSymbols::java_lang_InternalError(), err);
}
}
......@@ -1288,10 +1319,12 @@ const char* MethodHandles::check_argument_type_change(BasicType src_type,
// format, format, format
const char* src_name = type2name(src_type);
const char* dst_name = type2name(dst_type);
if (src_type == T_OBJECT) src_name = Klass::cast(src_klass)->external_name();
if (dst_type == T_OBJECT) dst_name = Klass::cast(dst_klass)->external_name();
if (src_name == NULL) src_name = "unknown type";
if (dst_name == NULL) dst_name = "unknown type";
if (src_type == T_OBJECT)
src_name = (src_klass != NULL) ? Klass::cast(src_klass)->external_name() : "an unresolved class";
if (dst_type == T_OBJECT)
dst_name = (dst_klass != NULL) ? Klass::cast(dst_klass)->external_name() : "an unresolved class";
size_t msglen = strlen(err) + strlen(src_name) + strlen(dst_name) + (argnum < 10 ? 1 : 11);
char* msg = NEW_RESOURCE_ARRAY(char, msglen + 1);
......
......@@ -418,6 +418,11 @@ void NMethodSweeper::speculative_disconnect_nmethods(bool is_full) {
// state of the code cache if it's requested.
void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
if (PrintMethodFlushing) {
stringStream s;
// Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts.
CodeCache::log_state(&s);
ttyLocker ttyl;
tty->print("### sweeper: %s ", msg);
if (format != NULL) {
......@@ -426,10 +431,15 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
tty->vprint(format, ap);
va_end(ap);
}
CodeCache::log_state(tty); tty->cr();
tty->print_cr(s.as_string());
}
if (LogCompilation && (xtty != NULL)) {
stringStream s;
// Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts.
CodeCache::log_state(&s);
ttyLocker ttyl;
xtty->begin_elem("sweeper state='%s' traversals='" INTX_FORMAT "' ", msg, (intx)traversal_count());
if (format != NULL) {
......@@ -438,7 +448,7 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
xtty->vprint(format, ap);
va_end(ap);
}
CodeCache::log_state(xtty);
xtty->print(s.as_string());
xtty->stamp();
xtty->end_elem();
}
......
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -46,7 +46,11 @@
#include <llvm/ModuleProvider.h>
#endif
#include <llvm/Support/IRBuilder.h>
#if SHARK_LLVM_VERSION >= 29
#include <llvm/Support/Threading.h>
#else
#include <llvm/System/Threading.h>
#endif
#include <llvm/Target/TargetSelect.h>
#include <llvm/Type.h>
#include <llvm/ExecutionEngine/JITMemoryManager.h>
......@@ -55,8 +59,12 @@
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/ADT/StringMap.h>
#include <llvm/Support/Debug.h>
#if SHARK_LLVM_VERSION >= 29
#include <llvm/Support/Host.h>
#else
#include <llvm/System/Host.h>
#endif
#endif
#include <map>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册