diff --git a/src/cpu/sparc/vm/sparc.ad b/src/cpu/sparc/vm/sparc.ad index 757bb388356f30bc8b77fa88605f1ac8b88b237d..9751224d7728aa18d8b40512e0f49d587fcf3f3b 100644 --- a/src/cpu/sparc/vm/sparc.ad +++ b/src/cpu/sparc/vm/sparc.ad @@ -5707,7 +5707,7 @@ instruct loadUS2L_immI16(iRegL dst, memory mem, immI16 mask, iRegL tmp) %{ effect(TEMP dst, TEMP tmp); ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST); - size(3*4); + size((3+1)*4); // set may use two instructions. format %{ "LDUH $mem,$dst\t! ushort/char & 16-bit mask -> long\n\t" "SET $mask,$tmp\n\t" "AND $dst,$tmp,$dst" %} @@ -5851,7 +5851,7 @@ instruct loadI2L_immI(iRegL dst, memory mem, immI mask, iRegL tmp) %{ effect(TEMP dst, TEMP tmp); ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST); - size(3*4); + size((3+1)*4); // set may use two instructions. format %{ "LDUW $mem,$dst\t! int & 32-bit mask -> long\n\t" "SET $mask,$tmp\n\t" "AND $dst,$tmp,$dst" %} diff --git a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 997babc7afe24bd4447cf4feeb5fc24f5c08da21..d49793aba5653e5c515cc65695742856044e92df 100644 --- a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -827,8 +827,8 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { case vmIntrinsics::_dsin: __ sin (calc_input, calc_result, tmp1, tmp2); break; case vmIntrinsics::_dcos: __ cos (calc_input, calc_result, tmp1, tmp2); break; case vmIntrinsics::_dtan: __ tan (calc_input, calc_result, tmp1, tmp2); break; - case vmIntrinsics::_dlog: __ log (calc_input, calc_result, LIR_OprFact::illegalOpr); break; - case vmIntrinsics::_dlog10: __ log10(calc_input, calc_result, LIR_OprFact::illegalOpr); break; + case vmIntrinsics::_dlog: __ log (calc_input, calc_result, tmp1); break; + case vmIntrinsics::_dlog10: __ log10(calc_input, calc_result, tmp1); break; default: ShouldNotReachHere(); } diff --git a/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/src/cpu/x86/vm/c1_LinearScan_x86.cpp index d0b5fa397743b3258c221807b4a5a8e04b72b390..eaf745c16befe90d5086f0af89c4e9b4b55a8a06 100644 --- a/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -764,8 +764,6 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) { break; } - case lir_log: - case lir_log10: case lir_abs: case lir_sqrt: { // Right argument appears to be unused @@ -785,6 +783,30 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) { break; } + case lir_log: + case lir_log10: { + // log and log10 needs one temporary fpu stack slot, so there is ontemporary + // registers stored in temp of the operation. + // the stack allocator must guarantee that the stack slots are really free, + // otherwise there might be a stack overflow. + assert(right->is_illegal(), "must be"); + assert(left->is_fpu_register(), "must be"); + assert(res->is_fpu_register(), "must be"); + assert(op2->tmp_opr()->is_fpu_register(), "must be"); + + insert_free_if_dead(op2->tmp_opr()); + insert_free_if_dead(res, left); + insert_exchange(left); + do_rename(left, res); + + new_left = to_fpu_stack_top(res); + new_res = new_left; + + op2->set_fpu_stack_size(sim()->stack_size()); + assert(sim()->stack_size() <= 7, "at least one stack slot must be free"); + break; + } + case lir_tan: case lir_sin: diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp index 0c0f1eda6237f9b87a82d24cbd396f6f9ab06771..b967785fbbb6a23e6511ee9c0dc7c6bdd57c6151 100644 --- a/src/share/vm/c1/c1_LIR.cpp +++ b/src/share/vm/c1/c1_LIR.cpp @@ -567,8 +567,6 @@ void LIR_OpVisitState::visit(LIR_Op* op) { case lir_rem: case lir_sqrt: case lir_abs: - case lir_log: - case lir_log10: case lir_logic_and: case lir_logic_or: case lir_logic_xor: @@ -644,13 +642,16 @@ void LIR_OpVisitState::visit(LIR_Op* op) { case lir_tan: case lir_sin: - case lir_cos: { + case lir_cos: + case lir_log: + case lir_log10: { assert(op->as_Op2() != NULL, "must be"); LIR_Op2* op2 = (LIR_Op2*)op; - // sin and cos need two temporary fpu stack slots, so register - // two temp operands. Register input operand as temp to - // guarantee that they do not overlap + // On x86 tan/sin/cos need two temporary fpu stack slots and + // log/log10 need one so handle opr2 and tmp as temp inputs. + // Register input operand as temp to guarantee that it doesn't + // overlap with the input. assert(op2->_info == NULL, "not used"); assert(op2->_opr1->is_valid(), "used"); do_input(op2->_opr1); do_temp(op2->_opr1); diff --git a/src/share/vm/c1/c1_LIR.hpp b/src/share/vm/c1/c1_LIR.hpp index d263b4e6b8d3cbc2bc22b40be75c9fd336694167..c3da44e2329461bd0233a89b75f2feda36edabba 100644 --- a/src/share/vm/c1/c1_LIR.hpp +++ b/src/share/vm/c1/c1_LIR.hpp @@ -1840,8 +1840,8 @@ class LIR_List: public CompilationResourceObj { void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_abs , from, tmp, to)); } void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_sqrt, from, tmp, to)); } - void log (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log, from, tmp, to)); } - void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log10, from, tmp, to)); } + void log (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log, from, LIR_OprFact::illegalOpr, to, tmp)); } + void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp) { append(new LIR_Op2(lir_log10, from, LIR_OprFact::illegalOpr, to, tmp)); } void sin (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_sin , from, tmp1, to, tmp2)); } void cos (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_cos , from, tmp1, to, tmp2)); } void tan (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_tan , from, tmp1, to, tmp2)); } diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp index 248a10336975e280fa0b5cd3e74d22d52e2132fb..cc0db7a173bda483535b41ad4e3db2928d96ac72 100644 --- a/src/share/vm/classfile/javaClasses.cpp +++ b/src/share/vm/classfile/javaClasses.cpp @@ -252,7 +252,7 @@ symbolHandle java_lang_String::as_symbol(Handle java_string, TRAPS) { typeArrayOop value = java_lang_String::value(obj); int offset = java_lang_String::offset(obj); int length = java_lang_String::length(obj); - jchar* base = value->char_at_addr(offset); + jchar* base = (length == 0) ? NULL : value->char_at_addr(offset); symbolOop sym = SymbolTable::lookup_unicode(base, length, THREAD); return symbolHandle(THREAD, sym); } @@ -261,7 +261,7 @@ symbolOop java_lang_String::as_symbol_or_null(oop java_string) { typeArrayOop value = java_lang_String::value(java_string); int offset = java_lang_String::offset(java_string); int length = java_lang_String::length(java_string); - jchar* base = value->char_at_addr(offset); + jchar* base = (length == 0) ? NULL : value->char_at_addr(offset); return SymbolTable::probe_unicode(base, length); } diff --git a/src/share/vm/opto/escape.cpp b/src/share/vm/opto/escape.cpp index f19a0871ec7e567963a918c31b4460a7e32b72d0..bd04a5ae7ac3d039b8b5f7ab9740bdbd43b451f5 100644 --- a/src/share/vm/opto/escape.cpp +++ b/src/share/vm/opto/escape.cpp @@ -439,6 +439,11 @@ static Node* get_addp_base(Node *addp) { Node *base = addp->in(AddPNode::Base)->uncast(); if (base->is_top()) { // The AddP case #3 and #6. base = addp->in(AddPNode::Address)->uncast(); + while (base->is_AddP()) { + // Case #6 (unsafe access) may have several chained AddP nodes. + assert(base->in(AddPNode::Base)->is_top(), "expected unsafe access address only"); + base = base->in(AddPNode::Address)->uncast(); + } assert(base->Opcode() == Op_ConP || base->Opcode() == Op_ThreadLocal || base->Opcode() == Op_CastX2P || base->is_DecodeN() || (base->is_Mem() && base->bottom_type() == TypeRawPtr::NOTNULL) || diff --git a/src/share/vm/opto/graphKit.cpp b/src/share/vm/opto/graphKit.cpp index 955b736eed12ce18d11288de92fb8162492b8899..a08ff89f9dc29c3325783af6fe063332ebe62768 100644 --- a/src/share/vm/opto/graphKit.cpp +++ b/src/share/vm/opto/graphKit.cpp @@ -622,11 +622,13 @@ BuildCutout::~BuildCutout() { //---------------------------PreserveReexecuteState---------------------------- PreserveReexecuteState::PreserveReexecuteState(GraphKit* kit) { + assert(!kit->stopped(), "must call stopped() before"); _kit = kit; _sp = kit->sp(); _reexecute = kit->jvms()->_reexecute; } PreserveReexecuteState::~PreserveReexecuteState() { + if (_kit->stopped()) return; _kit->jvms()->_reexecute = _reexecute; _kit->set_sp(_sp); } @@ -1086,7 +1088,7 @@ Node* GraphKit::load_array_length(Node* array) { alen = _gvn.transform( new (C, 3) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); } else { alen = alloc->Ideal_length(); - Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_aryptr(), &_gvn); + Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_oopptr(), &_gvn); if (ccast != alen) { alen = _gvn.transform(ccast); } @@ -1123,8 +1125,8 @@ Node* GraphKit::null_check_common(Node* value, BasicType type, case T_OBJECT : { const Type *t = _gvn.type( value ); - const TypeInstPtr* tp = t->isa_instptr(); - if (tp != NULL && !tp->klass()->is_loaded() + const TypeOopPtr* tp = t->isa_oopptr(); + if (tp != NULL && tp->klass() != NULL && !tp->klass()->is_loaded() // Only for do_null_check, not any of its siblings: && !assert_null && null_control == NULL) { // Usually, any field access or invocation on an unloaded oop type diff --git a/src/share/vm/opto/library_call.cpp b/src/share/vm/opto/library_call.cpp index f609eedd931f6fdbdf575069105669c517c6e5d8..62424824172e047a79180390750c5410d2a2be40 100644 --- a/src/share/vm/opto/library_call.cpp +++ b/src/share/vm/opto/library_call.cpp @@ -3903,19 +3903,10 @@ void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, b guarantee(alloc != NULL && alloc->maybe_set_complete(&_gvn), ""); } - // Cast to Object for arraycopy. - // We can't use the original CheckCastPP since it should be moved - // after the arraycopy to prevent stores flowing above it. - Node* new_obj = new(C, 2) CheckCastPPNode(alloc_obj->in(0), raw_obj, - TypeInstPtr::NOTNULL); - new_obj = _gvn.transform(new_obj); - // Substitute in the locally valid dest_oop. - replace_in_map(alloc_obj, new_obj); - // Copy the fastest available way. // TODO: generate fields copies for small objects instead. Node* src = obj; - Node* dest = new_obj; + Node* dest = alloc_obj; Node* size = _gvn.transform(obj_size); // Exclude the header but include array length to copy by 8 bytes words. @@ -3961,7 +3952,7 @@ void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, b int raw_adr_idx = Compile::AliasIdxRaw; post_barrier(control(), memory(raw_adr_type), - new_obj, + alloc_obj, no_particular_field, raw_adr_idx, no_particular_value, @@ -3969,16 +3960,8 @@ void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, b false); } - // Move the original CheckCastPP after arraycopy. - _gvn.hash_delete(alloc_obj); - alloc_obj->set_req(0, control()); - // Replace raw memory edge with new CheckCastPP to have a live oop - // at safepoints instead of raw value. - assert(new_obj->is_CheckCastPP() && new_obj->in(1) == alloc_obj->in(1), "sanity"); - alloc_obj->set_req(1, new_obj); // cast to the original type - _gvn.hash_find_insert(alloc_obj); // put back into GVN table - // Restore in the locally valid dest_oop. - replace_in_map(new_obj, alloc_obj); + // Do not let reads from the cloned object float above the arraycopy. + insert_mem_bar(Op_MemBarCPUOrder); } //------------------------inline_native_clone---------------------------- @@ -4448,15 +4431,6 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, assert(init->is_complete(), "we just did this"); assert(dest->is_CheckCastPP(), "sanity"); assert(dest->in(0)->in(0) == init, "dest pinned"); - - // Cast to Object for arraycopy. - // We can't use the original CheckCastPP since it should be moved - // after the arraycopy to prevent stores flowing above it. - Node* new_obj = new(C, 2) CheckCastPPNode(dest->in(0), dest->in(1), - TypeInstPtr::NOTNULL); - dest = _gvn.transform(new_obj); - // Substitute in the locally valid dest_oop. - replace_in_map(original_dest, dest); adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory // From this point on, every exit path is responsible for // initializing any non-copied parts of the object to zero. @@ -4786,18 +4760,6 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, set_i_o( _gvn.transform(result_i_o) ); set_memory( _gvn.transform(result_memory), adr_type ); - if (dest != original_dest) { - // Pin the "finished" array node after the arraycopy/zeroing operations. - _gvn.hash_delete(original_dest); - original_dest->set_req(0, control()); - // Replace raw memory edge with new CheckCastPP to have a live oop - // at safepoints instead of raw value. - assert(dest->is_CheckCastPP() && dest->in(1) == original_dest->in(1), "sanity"); - original_dest->set_req(1, dest); // cast to the original type - _gvn.hash_find_insert(original_dest); // put back into GVN table - // Restore in the locally valid dest_oop. - replace_in_map(dest, original_dest); - } // The memory edges above are precise in order to model effects around // array copies accurately to allow value numbering of field loads around // arraycopy. Such field loads, both before and after, are common in Java @@ -4808,7 +4770,9 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, // The next memory barrier is added to avoid it. If the arraycopy can be // optimized away (which it can, sometimes) then we can manually remove // the membar also. - if (InsertMemBarAfterArraycopy) + // + // Do not let reads from the cloned object float above the arraycopy. + if (InsertMemBarAfterArraycopy || alloc != NULL) insert_mem_bar(Op_MemBarCPUOrder); } diff --git a/src/share/vm/opto/superword.cpp b/src/share/vm/opto/superword.cpp index c8198392c331bab66dc7305da76cd67e77bc1e37..6709d15b9e75946865e8dc3e5ef1765f59339859 100644 --- a/src/share/vm/opto/superword.cpp +++ b/src/share/vm/opto/superword.cpp @@ -990,8 +990,8 @@ void SuperWord::remove_and_insert(MemNode *current, MemNode *prev, MemNode *lip, // (5) We know there is no dependence cycle, so there in no other case; // (6) Finally, all memory ops in another single pack should be moved in the same direction. // -// To schedule a load pack: the memory edge of every loads in the pack must be -// the same as the memory edge of the last executed load in the pack +// To schedule a load pack, we use the memory state of either the first or the last load in +// the pack, based on the dependence constraint. void SuperWord::co_locate_pack(Node_List* pk) { if (pk->at(0)->is_Store()) { MemNode* first = executed_first(pk)->as_Mem(); @@ -1076,15 +1076,32 @@ void SuperWord::co_locate_pack(Node_List* pk) { current = my_mem->as_Mem(); } // end while } else if (pk->at(0)->is_Load()) { //load - // all use the memory state that the last executed load uses - LoadNode* last_load = executed_last(pk)->as_Load(); - Node* last_mem = last_load->in(MemNode::Memory); - _igvn.hash_delete(last_mem); - // Give each load same memory state as last + // all loads in the pack should have the same memory state. By default, + // we use the memory state of the last load. However, if any load could + // not be moved down due to the dependence constraint, we use the memory + // state of the first load. + Node* last_mem = executed_last(pk)->in(MemNode::Memory); + Node* first_mem = executed_first(pk)->in(MemNode::Memory); + bool schedule_last = true; + for (uint i = 0; i < pk->size(); i++) { + Node* ld = pk->at(i); + for (Node* current = last_mem; current != ld->in(MemNode::Memory); + current=current->in(MemNode::Memory)) { + assert(current != first_mem, "corrupted memory graph"); + if(current->is_Mem() && !independent(current, ld)){ + schedule_last = false; // a later store depends on this load + break; + } + } + } + + Node* mem_input = schedule_last ? last_mem : first_mem; + _igvn.hash_delete(mem_input); + // Give each load the same memory state for (uint i = 0; i < pk->size(); i++) { LoadNode* ld = pk->at(i)->as_Load(); _igvn.hash_delete(ld); - ld->set_req(MemNode::Memory, last_mem); + ld->set_req(MemNode::Memory, mem_input); _igvn._worklist.push(ld); } } diff --git a/src/share/vm/opto/type.cpp b/src/share/vm/opto/type.cpp index 1db520a4254cda0aa3a968cdbf9527078f5bf1c9..f06726a3c44e730cc8d2788c50e72d167f2efc75 100644 --- a/src/share/vm/opto/type.cpp +++ b/src/share/vm/opto/type.cpp @@ -2236,12 +2236,12 @@ TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int //------------------------------make------------------------------------------- const TypeOopPtr *TypeOopPtr::make(PTR ptr, - int offset) { + int offset, int instance_id) { assert(ptr != Constant, "no constant generic pointers"); ciKlass* k = ciKlassKlass::make(); bool xk = false; ciObject* o = NULL; - return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, InstanceBot))->hashcons(); + return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); } @@ -2330,7 +2330,8 @@ const Type *TypeOopPtr::xmeet( const Type *t ) const { case OopPtr: { // Meeting to other OopPtrs const TypeOopPtr *tp = t->is_oopptr(); - return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()) ); + int instance_id = meet_instance_id(tp->instance_id()); + return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id ); } case InstPtr: // For these, flip the call around to cut down @@ -2801,7 +2802,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { case OopPtr: { // Meeting to OopPtrs // Found a OopPtr type vs self-InstPtr type - const TypePtr *tp = t->is_oopptr(); + const TypeOopPtr *tp = t->is_oopptr(); int offset = meet_offset(tp->offset()); PTR ptr = meet_ptr(tp->ptr()); switch (tp->ptr()) { @@ -2812,8 +2813,10 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { (ptr == Constant ? const_oop() : NULL), offset, instance_id); } case NotNull: - case BotPTR: - return TypeOopPtr::make(ptr, offset); + case BotPTR: { + int instance_id = meet_instance_id(tp->instance_id()); + return TypeOopPtr::make(ptr, offset, instance_id); + } default: typerr(t); } } @@ -3259,7 +3262,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { case OopPtr: { // Meeting to OopPtrs // Found a OopPtr type vs self-AryPtr type - const TypePtr *tp = t->is_oopptr(); + const TypeOopPtr *tp = t->is_oopptr(); int offset = meet_offset(tp->offset()); PTR ptr = meet_ptr(tp->ptr()); switch (tp->ptr()) { @@ -3270,8 +3273,10 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { _ary, _klass, _klass_is_exact, offset, instance_id); } case BotPTR: - case NotNull: - return TypeOopPtr::make(ptr, offset); + case NotNull: { + int instance_id = meet_instance_id(tp->instance_id()); + return TypeOopPtr::make(ptr, offset, instance_id); + } default: ShouldNotReachHere(); } } diff --git a/src/share/vm/opto/type.hpp b/src/share/vm/opto/type.hpp index 01a652ee7993355f8d7c9f5ac60e59e461476263..4ad11402bce1d739e5a252187103e8fad58829f6 100644 --- a/src/share/vm/opto/type.hpp +++ b/src/share/vm/opto/type.hpp @@ -714,7 +714,7 @@ public: static const TypeOopPtr* make_from_constant(ciObject* o); // Make a generic (unclassed) pointer to an oop. - static const TypeOopPtr* make(PTR ptr, int offset); + static const TypeOopPtr* make(PTR ptr, int offset, int instance_id = InstanceBot); ciObject* const_oop() const { return _const_oop; } virtual ciKlass* klass() const { return _klass; } diff --git a/test/compiler/6636138/Test1.java b/test/compiler/6636138/Test1.java index 8efc9d4f192c9496628f9e20e96f2359b0eeecb1..306db6d106cec2376e3c266a5faa7544946b0fad 100644 --- a/test/compiler/6636138/Test1.java +++ b/test/compiler/6636138/Test1.java @@ -45,7 +45,7 @@ public class Test1 { for (int i = 0; i < src.length; i++) { if (src[i] != ref[i]) { System.out.println("Error: src and ref don't match at " + i); - System.exit(-1); + System.exit(97); } } } diff --git a/test/compiler/6636138/Test2.java b/test/compiler/6636138/Test2.java index 27bc41060c8c5d33bda519fafc0825786bef45a8..b9d9831e6c3d1e62150b2994ec6055a795594a2f 100644 --- a/test/compiler/6636138/Test2.java +++ b/test/compiler/6636138/Test2.java @@ -51,7 +51,7 @@ public class Test2 { int value = (i-1 + src.length)%src.length; // correct value after shifting if (src[i] != value) { System.out.println("Error: src["+i+"] should be "+ value + " instead of " + src[i]); - System.exit(-1); + System.exit(97); } } } diff --git a/test/compiler/6855215/Test6855215.java b/test/compiler/6855215/Test6855215.java new file mode 100644 index 0000000000000000000000000000000000000000..259e513546653ff4abf8d40574682062c6d607b7 --- /dev/null +++ b/test/compiler/6855215/Test6855215.java @@ -0,0 +1,55 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +/** + * @test + * @bug 6855215 + * @summary Calculation error (NaN) after about 1500 calculations + * + * @run main/othervm -Xbatch -XX:UseSSE=0 Test6855215 + */ + +public class Test6855215 { + private double m; + private double b; + + public static double log10(double x) { + return Math.log(x) / Math.log(10); + } + + void calcMapping(double xmin, double xmax, double ymin, double ymax) { + m = (ymax - ymin) / (log10(xmax) - log10(xmin)); + b = (log10(xmin) * ymax - log10(xmax) * ymin); + } + + public static void main(String[] args) { + Test6855215 c = new Test6855215(); + for (int i = 0; i < 30000; i++) { + c.calcMapping(91, 121, 177, 34); + if (c.m != c.m) { + throw new InternalError(); + } + } + } +} diff --git a/test/compiler/6865031/Test.java b/test/compiler/6865031/Test.java index 3262410840cf1ca46dc30e9088ce816b03e7232e..a502f298f9d8363889634e1f4b94be6d5ddb87fa 100644 --- a/test/compiler/6865031/Test.java +++ b/test/compiler/6865031/Test.java @@ -26,7 +26,7 @@ * @test * @bug 6865031 * @summary Application gives bad result (throws bad exception) with compressed oops - * @run main/othervm -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g -XX:-LoopUnswitching -XX:CompileCommand=inline,AbstractMemoryEfficientList.equals Test hello goodbye + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g -XX:-LoopUnswitching -XX:CompileCommand=inline,AbstractMemoryEfficientList.equals Test hello goodbye */ import java.lang.ref.ReferenceQueue;