Mercurial > hg > icedtea7-forest > hotspot
changeset 6516:4eea81cf6f63 icedtea-2.7.0pre10
Merge jdk7u131-b00
line wrap: on
line diff
--- a/.hgtags Mon Feb 06 19:40:32 2017 +0000 +++ b/.hgtags Thu Mar 30 18:03:59 2017 +0100 @@ -893,3 +893,5 @@ b6971126dc0fbb792acb92c6fb159001117a1e2a icedtea-2.7.0pre07 c2a745174c849bd6222ee7c764cadaef4dbc1b8b icedtea-2.7.0pre08 9a1457cc02ae1d5feedb4a965652d8e280e66e31 icedtea-2.7.0pre09 +17b40d99ea3665de2bfffe163b68f2dfcf675cba jdk7u121-b00 +95e4ea3d479ebdab9d78725776b6b11d4add6b0e jdk7u131-b00
--- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -2135,6 +2135,27 @@ __ delayed()->nop(); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(dst, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) { + __ load_klass(src, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + } + if (flags & LIR_OpArrayCopy::src_pos_positive_check) { // test src_pos register __ cmp_zero_and_br(Assembler::less, src_pos, *stub->entry());
--- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -3222,6 +3222,23 @@ __ jcc(Assembler::zero, *stub->entry()); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(tmp, dst); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + + if (!(flags & LIR_OpArrayCopy::src_objarray)) { + __ load_klass(tmp, src); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + } + // check if negative if (flags & LIR_OpArrayCopy::src_pos_positive_check) { __ testl(src_pos, src_pos);
--- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -94,7 +94,7 @@ private: #ifdef PRODUCT -#define inc_counter_np(counter) (0) +#define inc_counter_np(counter) ((void)0) #else void inc_counter_np_(int& counter) { __ incrementl(ExternalAddress((address)&counter));
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -92,7 +92,7 @@ private: #ifdef PRODUCT -#define inc_counter_np(counter) (0) +#define inc_counter_np(counter) ((void)0) #else void inc_counter_np_(int& counter) { // This can destroy rscratch1 if counter is far from the code cache
--- a/src/share/vm/adlc/formssel.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/adlc/formssel.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -565,6 +565,12 @@ attr = (Attribute *)attr->_next; } + // Ugly: until a better fix is implemented, disable rematerialization for + // negD nodes because they are proved to be problematic. + if (is_ideal_negD()) { + return false; + } + // Constants if( _components.count() == 1 && _components[0]->is(Component::USE_DEF) ) rematerialize = true;
--- a/src/share/vm/c1/c1_IR.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/c1/c1_IR.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -499,7 +499,7 @@ _loop_map(0, 0), // initialized later with correct size _compilation(c) { - TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order"); + TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order")); init_visited(); count_edges(start_block, NULL); @@ -665,7 +665,7 @@ } void ComputeLinearScanOrder::assign_loop_depth(BlockBegin* start_block) { - TRACE_LINEAR_SCAN(3, "----- computing loop-depth and weight"); + TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing loop-depth and weight")); init_visited(); assert(_work_list.is_empty(), "work list must be empty before processing"); @@ -839,7 +839,7 @@ } void ComputeLinearScanOrder::compute_order(BlockBegin* start_block) { - TRACE_LINEAR_SCAN(3, "----- computing final block order"); + TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing final block order")); // the start block is always the first block in the linear scan order _linear_scan_order = new BlockList(_num_blocks);
--- a/src/share/vm/ci/ciUtilities.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/ci/ciUtilities.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -93,7 +93,7 @@ CLEAR_PENDING_EXCEPTION; \ return (result); \ } \ - (0 + (void)(0 #define KILL_COMPILE_ON_ANY \ THREAD); \ @@ -101,7 +101,7 @@ fatal("unhandled ci exception"); \ CLEAR_PENDING_EXCEPTION; \ } \ -(0 +(void)(0 inline const char* bool_to_str(bool b) {
--- a/src/share/vm/classfile/classFileParser.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -966,7 +966,8 @@ runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->get_u1_buffer(); assert(runtime_visible_annotations != NULL, "null visible annotations"); - cfs->skip_u1(runtime_visible_annotations_length, CHECK); + cfs->guarantee_more(runtime_visible_annotations_length, CHECK); + cfs->skip_u1_fast(runtime_visible_annotations_length); } else if (PreserveAllAnnotations && attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { runtime_invisible_annotations_length = attribute_length; runtime_invisible_annotations = cfs->get_u1_buffer(); @@ -1658,6 +1659,11 @@ return index; } +// Safely increment index by val if does not pass limit +#define SAFE_ADD(index, limit, val) \ +if (index >= limit - val) return limit; \ +index += val; + // Skip an annotation value. Return >=limit if there is any problem. int ClassFileParser::skip_annotation_value(u1* buffer, int limit, int index) { // value := switch (tag:u1) { @@ -1668,19 +1674,19 @@ // case @: annotation; // case s: s_con:u2; // } - if ((index += 1) >= limit) return limit; // read tag + SAFE_ADD(index, limit, 1); // read tag u1 tag = buffer[index-1]; switch (tag) { case 'B': case 'C': case 'I': case 'S': case 'Z': case 'D': case 'F': case 'J': case 'c': case 's': - index += 2; // skip con or s_con + SAFE_ADD(index, limit, 2); // skip con or s_con break; case 'e': - index += 4; // skip e_class, e_name + SAFE_ADD(index, limit, 4); // skip e_class, e_name break; case '[': { - if ((index += 2) >= limit) return limit; // read nval + SAFE_ADD(index, limit, 2); // read nval int nval = Bytes::get_Java_u2(buffer+index-2); while (--nval >= 0 && index < limit) { index = skip_annotation_value(buffer, limit, index); @@ -1704,8 +1710,8 @@ ClassFileParser::AnnotationCollector* coll, TRAPS) { // annotations := do(nann:u2) {annotation} - int index = 0; - if ((index += 2) >= limit) return; // read nann + int index = 2; + if (index >= limit) return; // read nann int nann = Bytes::get_Java_u2(buffer+index-2); enum { // initial annotation layout atype_off = 0, // utf8 such as 'Ljava/lang/annotation/Retention;' @@ -1721,7 +1727,8 @@ c_size = 9, // end of 'c' annotation min_size = 6 // smallest possible size (zero members) }; - while ((--nann) >= 0 && (index-2 + min_size <= limit)) { + // Cannot add min_size to index in case of overflow MAX_INT + while ((--nann) >= 0 && (index-2 <= limit - min_size)) { int index0 = index; index = skip_annotation(buffer, limit, index); u1* abase = buffer + index0; @@ -2138,8 +2145,9 @@ runtime_visible_annotations_length = method_attribute_length; runtime_visible_annotations = cfs->get_u1_buffer(); assert(runtime_visible_annotations != NULL, "null visible annotations"); + cfs->guarantee_more(runtime_visible_annotations_length, CHECK_(nullHandle)); parse_annotations(class_loader, runtime_visible_annotations, runtime_visible_annotations_length, cp, &parsed_annotations, CHECK_(nullHandle)); - cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle)); + cfs->skip_u1_fast(runtime_visible_annotations_length); } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { runtime_invisible_annotations_length = method_attribute_length; runtime_invisible_annotations = cfs->get_u1_buffer(); @@ -2835,13 +2843,14 @@ runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->get_u1_buffer(); assert(runtime_visible_annotations != NULL, "null visible annotations"); + cfs->guarantee_more(runtime_visible_annotations_length, CHECK); parse_annotations(class_loader, runtime_visible_annotations, runtime_visible_annotations_length, cp, parsed_annotations, CHECK); - cfs->skip_u1(runtime_visible_annotations_length, CHECK); + cfs->skip_u1_fast(runtime_visible_annotations_length); } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_annotations()) { runtime_invisible_annotations_length = attribute_length; runtime_invisible_annotations = cfs->get_u1_buffer(); @@ -3219,6 +3228,11 @@ // Make sure this is the end of class file stream guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle)); + if (_class_name == vmSymbols::java_lang_Object()) { + check_property(local_interfaces == Universe::the_empty_system_obj_array(), + "java.lang.Object cannot implement an interface in class file %s", + CHECK_(nullHandle)); + } // We check super class after class file is parsed and format is checked if (super_class_index > 0 && super_klass.is_null()) { Symbol* sk = cp->klass_name_at(super_class_index);
--- a/src/share/vm/classfile/stackMapFrame.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/stackMapFrame.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. 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 @@ -174,47 +174,8 @@ return i; } -bool StackMapFrame::has_flag_match_exception( - const StackMapFrame* target) const { - // We allow flags of {UninitThis} to assign to {} if-and-only-if the - // target frame does not depend upon the current type. - // This is slightly too strict, as we need only enforce that the - // slots that were initialized by the <init> (the things that were - // UninitializedThis before initialize_object() converted them) are unused. - // However we didn't save that information so we'll enforce this upon - // anything that might have been initialized. This is a rare situation - // and javac never generates code that would end up here, but some profilers - // (such as NetBeans) might, when adding exception handlers in <init> - // methods to cover the invokespecial instruction. See 7020118. - - assert(max_locals() == target->max_locals() && - stack_size() == target->stack_size(), "StackMap sizes must match"); - - VerificationType top = VerificationType::top_type(); - VerificationType this_type = verifier()->current_type(); - - if (!flag_this_uninit() || target->flags() != 0) { - return false; - } - - for (int i = 0; i < target->locals_size(); ++i) { - if (locals()[i] == this_type && target->locals()[i] != top) { - return false; - } - } - - for (int i = 0; i < target->stack_size(); ++i) { - if (stack()[i] == this_type && target->stack()[i] != top) { - return false; - } - } - - return true; -} - bool StackMapFrame::is_assignable_to( - const StackMapFrame* target, bool is_exception_handler, - ErrorContext* ctx, TRAPS) const { + const StackMapFrame* target, ErrorContext* ctx, TRAPS) const { if (_max_locals != target->max_locals()) { *ctx = ErrorContext::locals_size_mismatch( _offset, (StackMapFrame*)this, (StackMapFrame*)target); @@ -245,8 +206,7 @@ return false; } - bool match_flags = (_flags | target->flags()) == target->flags(); - if (match_flags || is_exception_handler && has_flag_match_exception(target)) { + if ((_flags | target->flags()) == target->flags()) { return true; } else { *ctx = ErrorContext::bad_flags(target->offset(),
--- a/src/share/vm/classfile/stackMapFrame.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/stackMapFrame.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. 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 @@ -172,8 +172,7 @@ // Return true if this stack map frame is assignable to target. bool is_assignable_to( - const StackMapFrame* target, bool is_exception_handler, - ErrorContext* ctx, TRAPS) const; + const StackMapFrame* target, ErrorContext* ctx, TRAPS) const; inline void set_mark() { #ifdef DEBUG @@ -295,8 +294,6 @@ int is_assignable_to( VerificationType* src, VerificationType* target, int32_t len, TRAPS) const; - bool has_flag_match_exception(const StackMapFrame* target) const; - TypeOrigin stack_top_ctx(); void print_on(outputStream* str) const;
--- a/src/share/vm/classfile/stackMapTable.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/stackMapTable.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. 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 @@ -70,26 +70,25 @@ bool StackMapTable::match_stackmap( StackMapFrame* frame, int32_t target, - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const { + bool match, bool update, ErrorContext* ctx, TRAPS) const { int index = get_index_from_offset(target); - return match_stackmap(frame, target, index, match, update, handler, ctx, THREAD); + return match_stackmap(frame, target, index, match, update, ctx, THREAD); } // Match and/or update current_frame to the frame in stackmap table with // specified offset and frame index. Return true if the two frames match. -// handler is true if the frame in stackmap_table is for an exception handler. // -// The values of match and update are: _match__update__handler +// The values of match and update are: _match__update // -// checking a branch target: true false false -// checking an exception handler: true false true +// checking a branch target: true false +// checking an exception handler: true false // linear bytecode verification following an -// unconditional branch: false true false +// unconditional branch: false true // linear bytecode verification not following an -// unconditional branch: true true false +// unconditional branch: true true bool StackMapTable::match_stackmap( StackMapFrame* frame, int32_t target, int32_t frame_index, - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const { + bool match, bool update, ErrorContext* ctx, TRAPS) const { if (frame_index < 0 || frame_index >= _frame_count) { *ctx = ErrorContext::missing_stackmap(frame->offset()); frame->verifier()->verify_error( @@ -102,7 +101,7 @@ if (match) { // Has direct control flow from last instruction, need to match the two // frames. - result = frame->is_assignable_to(stackmap_frame, handler, + result = frame->is_assignable_to(stackmap_frame, ctx, CHECK_VERIFY_(frame->verifier(), result)); } if (update) { @@ -126,7 +125,7 @@ StackMapFrame* frame, int32_t target, TRAPS) const { ErrorContext ctx; bool match = match_stackmap( - frame, target, true, false, false, &ctx, CHECK_VERIFY(frame->verifier())); + frame, target, true, false, &ctx, CHECK_VERIFY(frame->verifier())); if (!match || (target < 0 || target >= _code_length)) { frame->verifier()->verify_error(ctx, "Inconsistent stackmap frames at branch target %d", target);
--- a/src/share/vm/classfile/stackMapTable.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/stackMapTable.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. 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 @@ -77,12 +77,12 @@ // specified offset. Return true if the two frames match. bool match_stackmap( StackMapFrame* current_frame, int32_t offset, - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const; + bool match, bool update, ErrorContext* ctx, TRAPS) const; // Match and/or update current_frame to the frame in stackmap table with // specified offset and frame index. Return true if the two frames match. bool match_stackmap( StackMapFrame* current_frame, int32_t offset, int32_t frame_index, - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const; + bool match, bool update, ErrorContext* ctx, TRAPS) const; // Check jump instructions. Make sure there are no uninitialized // instances on backward branch.
--- a/src/share/vm/classfile/stackMapTableFormat.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/stackMapTableFormat.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. 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 @@ -203,6 +203,7 @@ inline bool verify(address start, address end) const; inline void print_on(outputStream* st, int current_offset) const; + inline void print_truncated(outputStream* st, int current_offset) const; // Create as_xxx and is_xxx methods for the subtypes #define FRAME_TYPE_DECL(stackmap_frame_type, arg1, arg2) \ @@ -263,6 +264,10 @@ void print_on(outputStream* st, int current_offset = -1) const { st->print("same_frame(@%d)", offset_delta() + current_offset); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + print_on(st, current_offset); + } }; class same_frame_extended : public stack_map_frame { @@ -309,6 +314,10 @@ void print_on(outputStream* st, int current_offset = -1) const { st->print("same_frame_extended(@%d)", offset_delta() + current_offset); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + print_on(st, current_offset); + } }; class same_locals_1_stack_item_frame : public stack_map_frame { @@ -381,6 +390,11 @@ types()->print_on(st); st->print(")"); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + st->print("same_locals_1_stack_item_frame(@%d), output truncated, Stackmap exceeds table size.", + offset_delta() + current_offset); + } }; class same_locals_1_stack_item_extended : public stack_map_frame { @@ -446,6 +460,11 @@ types()->print_on(st); st->print(")"); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + st->print("same_locals_1_stack_item_extended(@%d), output truncated, Stackmap exceeds table size.", + offset_delta() + current_offset); + } }; class chop_frame : public stack_map_frame { @@ -511,6 +530,10 @@ void print_on(outputStream* st, int current_offset = -1) const { st->print("chop_frame(@%d,%d)", offset_delta() + current_offset, chops()); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + print_on(st, current_offset); + } }; class append_frame : public stack_map_frame { @@ -619,6 +642,11 @@ } st->print(")"); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + st->print("append_frame(@%d), output truncated, Stackmap exceeds table size.", + offset_delta() + current_offset); + } }; class full_frame : public stack_map_frame { @@ -784,6 +812,11 @@ } st->print("})"); } + + void print_truncated(outputStream* st, int current_offset = -1) const { + st->print("full_frame(@%d), output truncated, Stackmap exceeds table size.", + offset_delta() + current_offset); + } }; #define VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \ @@ -841,6 +874,10 @@ FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_on, (st, offs)); } +void stack_map_frame::print_truncated(outputStream* st, int offs = -1) const { + FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_truncated, (st, offs)); +} + #undef VIRTUAL_DISPATCH #undef VOID_VIRTUAL_DISPATCH
--- a/src/share/vm/classfile/verifier.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/verifier.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -506,8 +506,13 @@ stack_map_frame* sm_frame = sm_table->entries(); streamIndentor si2(ss); int current_offset = -1; + address end_of_sm_table = (address)sm_table + method->stackmap_data()->length(); for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { ss->indent(); + if (!sm_frame->verify((address)sm_frame, end_of_sm_table)) { + sm_frame->print_truncated(ss, current_offset); + return; + } sm_frame->print_on(ss, current_offset); ss->print_cr(""); current_offset += sm_frame->offset_delta(); @@ -1806,7 +1811,7 @@ // If matched, current_frame will be updated by this method. bool matches = stackmap_table->match_stackmap( current_frame, this_offset, stackmap_index, - !no_control_flow, true, false, &ctx, CHECK_VERIFY_(this, 0)); + !no_control_flow, true, &ctx, CHECK_VERIFY_(this, 0)); if (!matches) { // report type error verify_error(ctx, "Instruction type does not match stack map"); @@ -1853,7 +1858,7 @@ } ErrorContext ctx; bool matches = stackmap_table->match_stackmap( - new_frame, handler_pc, true, false, true, &ctx, CHECK_VERIFY(this)); + new_frame, handler_pc, true, false, &ctx, CHECK_VERIFY(this)); if (!matches) { verify_error(ctx, "Stack map does not match the one at " "exception handler %d", handler_pc);
--- a/src/share/vm/classfile/verifier.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/classfile/verifier.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -85,9 +85,9 @@ // These macros are used similarly to CHECK macros but also check // the status of the verifier and return if that has an error. #define CHECK_VERIFY(verifier) \ - CHECK); if ((verifier)->has_error()) return; (0 + CHECK); if ((verifier)->has_error()) return; ((void)0 #define CHECK_VERIFY_(verifier, result) \ - CHECK_(result)); if ((verifier)->has_error()) return (result); (0 + CHECK_(result)); if ((verifier)->has_error()) return (result); ((void)0 class TypeOrigin VALUE_OBJ_CLASS_SPEC { private:
--- a/src/share/vm/code/dependencies.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/code/dependencies.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -936,7 +936,7 @@ assert(changes.involves_context(context_type), "irrelevant dependency"); klassOop new_type = changes.new_type(); - count_find_witness_calls(); + (void)count_find_witness_calls(); NOT_PRODUCT(deps_find_witness_singles++); // Current thread must be in VM (not native mode, as in CI):
--- a/src/share/vm/code/nmethod.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/code/nmethod.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -2533,7 +2533,8 @@ relocation_begin()-1+ip[1]); for (; ip < index_end; ip++) tty->print_cr(" (%d ?)", ip[0]); - tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", ip, *ip++); + tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", ip, *ip); + ip++; tty->print_cr("reloc_end @" INTPTR_FORMAT ":", ip); } }
--- a/src/share/vm/interpreter/bytecodeInterpreter.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -2136,7 +2136,7 @@ // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases // out so c++ compiler has a chance for constant prop to fold everything possible away. - oop obj,too; + oop obj; int count; TosState tos_type = cache->flag_state(); @@ -2160,9 +2160,8 @@ if (tos_type == itos) { obj->release_int_field_put(field_offset, STACK_INT(-1)); } else if (tos_type == atos) { - too = (oop) STACK_OBJECT(-1); - VERIFY_OOP(too); - obj->release_obj_field_put(field_offset, too); + VERIFY_OOP(STACK_OBJECT(-1)); + obj->release_obj_field_put(field_offset, STACK_OBJECT(-1)); } else if (tos_type == btos) { obj->release_byte_field_put(field_offset, STACK_INT(-1)); } else if (tos_type == ztos) { @@ -2184,8 +2183,7 @@ if (tos_type == itos) { obj->int_field_put(field_offset, STACK_INT(-1)); } else if (tos_type == atos) { - too = (oop) STACK_OBJECT(-1); - VERIFY_OOP(too); + VERIFY_OOP(STACK_OBJECT(-1)); // On IA64 we perform all stores of references with release semantics. // This guarantees that everybody using this reference sees a fully // initialized object. On PPC64 we emit a storestore barrier after @@ -2314,8 +2312,7 @@ } CASE(_checkcast): if (STACK_OBJECT(-1) != NULL) { - oop too = (oop) STACK_OBJECT(-1); - VERIFY_OOP(too); + VERIFY_OOP(STACK_OBJECT(-1)); u2 index = Bytes::get_Java_u2(pc+1); // Constant pool may have actual klass or unresolved klass. If it is // unresolved we must resolve it. @@ -2352,8 +2349,7 @@ // Profile instanceof with null_seen and receiver. BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/true, NULL); } else { - oop too = (oop) STACK_OBJECT(-1); - VERIFY_OOP(too); + VERIFY_OOP(STACK_OBJECT(-1)); u2 index = Bytes::get_Java_u2(pc+1); // Constant pool may have actual klass or unresolved klass. If it is // unresolved we must resolve it. @@ -2582,8 +2578,7 @@ // another compliant java compiler. if (cache->is_forced_virtual()) { methodOop callee; - oop too = (oop) STACK_OBJECT(-(cache->parameter_size())); - CHECK_NULL(too); + CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); if (cache->is_vfinal()) { callee = cache->f2_as_vfinal_method(); // Profile 'special case of invokeinterface' final call. @@ -2670,8 +2665,7 @@ { methodOop callee; if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { - oop too = (oop) STACK_OBJECT(-(cache->parameter_size())); - CHECK_NULL(too); + CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); if (cache->is_vfinal()) { callee = cache->f2_as_vfinal_method(); // Profile final call. @@ -2710,8 +2704,7 @@ } } else { if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { - oop too = (oop) STACK_OBJECT(-(cache->parameter_size())); - CHECK_NULL(too); + CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); } callee = cache->f1_as_method();
--- a/src/share/vm/memory/cardTableModRefBS.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/memory/cardTableModRefBS.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -389,7 +389,7 @@ } // Touch the last card of the covered region to show that it // is committed (or SEGV). - debug_only(*byte_for(_covered[ind].last());) + debug_only((void) (*byte_for(_covered[ind].last()));) debug_only(verify_guard();) }
--- a/src/share/vm/memory/universe.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/memory/universe.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -660,7 +660,9 @@ if (vt) vt->initialize_vtable(false, CHECK); if (ko->oop_is_instance()) { instanceKlass* ik = (instanceKlass*)ko; - for (KlassHandle s_h(THREAD, ik->subklass()); s_h() != NULL; s_h = (THREAD, s_h()->klass_part()->next_sibling())) { + for (KlassHandle s_h(THREAD, ik->subklass()); + s_h() != NULL; + s_h = (THREAD, s_h()->klass_part()->next_sibling())) { reinitialize_vtable_of(s_h, CHECK); } }
--- a/src/share/vm/oops/constantPoolOop.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/oops/constantPoolOop.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1030,9 +1030,10 @@ int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); int i1 = invoke_dynamic_bootstrap_specifier_index(index1); int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); - bool match = compare_entry_to(k1, cp2, k2, CHECK_false) && - compare_operand_to(i1, cp2, i2, CHECK_false); - return match; + // separate statements and variables because CHECK_false is used + bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); + bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); + return (match_entry && match_operand); } break; case JVM_CONSTANT_UnresolvedString:
--- a/src/share/vm/opto/memnode.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/opto/memnode.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -4360,7 +4360,7 @@ } } #else // !ASSERT -#define verify_memory_slice(m,i,n) (0) // PRODUCT version is no-op +#define verify_memory_slice(m,i,n) (void)(0) // PRODUCT version is no-op #endif
--- a/src/share/vm/prims/forte.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/prims/forte.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -640,7 +640,7 @@ void* null_argument_3); #pragma weak collector_func_load #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \ - ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 ) + ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 ) #endif // __APPLE__ #endif // !_WINDOWS
--- a/src/share/vm/prims/jvm.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/prims/jvm.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. 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 @@ -2455,7 +2455,6 @@ switch (cp->tag_at(cp_index).value()) { case JVM_CONSTANT_InterfaceMethodref: case JVM_CONSTANT_Methodref: - case JVM_CONSTANT_NameAndType: // for invokedynamic return cp->uncached_name_ref_at(cp_index)->as_utf8(); default: fatal("JVM_GetCPMethodNameUTF: illegal constant"); @@ -2473,7 +2472,6 @@ switch (cp->tag_at(cp_index).value()) { case JVM_CONSTANT_InterfaceMethodref: case JVM_CONSTANT_Methodref: - case JVM_CONSTANT_NameAndType: // for invokedynamic return cp->uncached_signature_ref_at(cp_index)->as_utf8(); default: fatal("JVM_GetCPMethodSignatureUTF: illegal constant"); @@ -2698,7 +2696,18 @@ int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { // see bug 4399518, 4417214 if ((intptr_t)count <= 0) return -1; - return vsnprintf(str, count, fmt, args); + + int result = vsnprintf(str, count, fmt, args); + // Note: on truncation vsnprintf(3) on Unix returns number of + // characters which would have been written had the buffer been large + // enough; on Windows, it returns -1. We handle both cases here and + // always return -1, and perform null termination. + if ((result > 0 && (size_t)result >= count) || result == -1) { + str[count - 1] = '\0'; + result = -1; + } + + return result; }
--- a/src/share/vm/runtime/arguments.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/runtime/arguments.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -550,8 +550,9 @@ (os::file_name_strcmp(ext, ".jar") == 0 || os::file_name_strcmp(ext, ".zip") == 0); if (isJarOrZip) { - char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal); - sprintf(jarpath, "%s%s%s", directory, dir_sep, name); + size_t length = directory_len + 2 + strlen(name); + char* jarpath = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(jarpath, length, "%s%s%s", directory, dir_sep, name); path = add_to_path(path, jarpath, false); FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); } @@ -694,9 +695,10 @@ } else if (new_len == 0) { value = old_value; } else { - char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal); + size_t length = old_len + 1 + new_len + 1; + char* buf = NEW_C_HEAP_ARRAY(char, length, mtInternal); // each new setting adds another LINE to the switch: - sprintf(buf, "%s\n%s", old_value, new_value); + jio_snprintf(buf, length, "%s\n%s", old_value, new_value); value = buf; free_this_too = buf; } @@ -803,15 +805,17 @@ if (args == NULL || count == 0) { return NULL; } - size_t length = strlen(args[0]) + 1; // add 1 for the null terminator - for (int i = 1; i < count; i++) { - length += strlen(args[i]) + 1; // add 1 for a space + size_t length = 0; + for (int i = 0; i < count; i++) { + length += strlen(args[i]) + 1; // add 1 for a space or NULL terminating character } char* s = NEW_RESOURCE_ARRAY(char, length); - strcpy(s, args[0]); - for (int j = 1; j < count; j++) { - strcat(s, " "); - strcat(s, args[j]); + char* dst = s; + for (int j = 0; j < count; j++) { + size_t offset = strlen(args[j]) + 1; // add 1 for a space or NULL terminating character + jio_snprintf(dst, length, "%s ", args[j]); // jio_snprintf will replace the last space character with NULL character + dst += offset; + length -= offset; } return (const char*) s; } @@ -1730,7 +1734,7 @@ // Feed the cache size setting into the JDK char buffer[1024]; - sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); + jio_snprintf(buffer, 1024, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax); add_property(buffer); } if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) { @@ -2392,7 +2396,9 @@ char *options = NULL; if(pos != NULL) { - options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); + size_t length = strlen(pos + 1) + 1; + options = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(options, length, "%s", pos + 1); } add_init_agent(name, options, is_absolute_path); @@ -2400,7 +2406,9 @@ // -javaagent } else if (match_option(option, "-javaagent:", &tail)) { if(tail != NULL) { - char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail); + size_t length = strlen(tail) + 1; + char *options = NEW_C_HEAP_ARRAY(char, length, mtInternal); + jio_snprintf(options, length, "%s", tail); add_init_agent("instrument", options, false); } // -Xnoclassgc @@ -3166,8 +3174,7 @@ } } else { char buffer[256]; - strcpy(buffer, "java.awt.headless="); - strcat(buffer, envbuffer); + jio_snprintf(buffer, 256, "java.awt.headless=%s", envbuffer); if (!add_property(buffer)) { return JNI_ENOMEM; }
--- a/src/share/vm/runtime/deoptimization.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/runtime/deoptimization.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1802,8 +1802,6 @@ trap_reason_name(reason), recomp_flag ? " recompiled" : ""); } - if (len >= buflen) - buf[buflen-1] = '\0'; return buf; } @@ -1871,8 +1869,6 @@ len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'", reason, action, unloaded_class_index); } - if (len >= buflen) - buf[buflen-1] = '\0'; return buf; }
--- a/src/share/vm/runtime/java.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/runtime/java.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. 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 @@ -775,25 +775,36 @@ } void JDK_Version::to_string(char* buffer, size_t buflen) const { + assert(buffer && buflen > 0, "call with useful buffer"); size_t index = 0; if (!is_valid()) { jio_snprintf(buffer, buflen, "%s", "(uninitialized)"); } else if (is_partially_initialized()) { jio_snprintf(buffer, buflen, "%s", "(uninitialized) pre-1.6.0"); } else { - index += jio_snprintf( + int rc = jio_snprintf( &buffer[index], buflen - index, "%d.%d", _major, _minor); + if (rc == -1) return; + index += rc; if (_micro > 0) { - index += jio_snprintf(&buffer[index], buflen - index, ".%d", _micro); + rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _micro); + if (rc == -1) return; + index += rc; } if (_update > 0) { - index += jio_snprintf(&buffer[index], buflen - index, "_%02d", _update); + rc = jio_snprintf(&buffer[index], buflen - index, "_%02d", _update); + if (rc == -1) return; + index += rc; } if (_special > 0) { - index += jio_snprintf(&buffer[index], buflen - index, "%c", _special); + rc = jio_snprintf(&buffer[index], buflen - index, "%c", _special); + if (rc == -1) return; + index += rc; } if (_build > 0) { - index += jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build); + rc = jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build); + if (rc == -1) return; + index += rc; } } }
--- a/src/share/vm/runtime/sharedRuntime.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/runtime/sharedRuntime.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -2821,9 +2821,7 @@ // ResourceObject, so do not put any ResourceMarks in here. char *s = sig->as_C_string(); int len = (int)strlen(s); - *s++; len--; // Skip opening paren - char *t = s+len; - while( *(--t) != ')' ) ; // Find close paren + s++; len--; // Skip opening paren BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 ); VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 ); @@ -2832,7 +2830,7 @@ sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature } - while( s < t ) { + while( *s != ')' ) { // Find closing right paren switch( *s++ ) { // Switch on signature character case 'B': sig_bt[cnt++] = T_BYTE; break; case 'C': sig_bt[cnt++] = T_CHAR; break;
--- a/src/share/vm/runtime/signature.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/runtime/signature.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -224,7 +224,49 @@ _index = 0; expect('('); Symbol* sig = _signature; - while (sig->byte_at(_index) != ')') _index++; + // Need to skip over each type in the signature's argument list until a + // closing ')' is found., then get the return type. We cannot just scan + // for the first ')' because ')' is a legal character in a type name. + while (sig->byte_at(_index) != ')') { + switch(sig->byte_at(_index)) { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + case 'V': + { + _index++; + } + break; + case 'L': + { + while (sig->byte_at(_index++) != ';') ; + } + break; + case '[': + { + int begin = ++_index; + skip_optional_size(); + while (sig->byte_at(_index) == '[') { + _index++; + skip_optional_size(); + } + if (sig->byte_at(_index) == 'L') { + while (sig->byte_at(_index++) != ';') ; + } else { + _index++; + } + } + break; + default: + ShouldNotReachHere(); + break; + } + } expect(')'); // Parse return type _parameter_index = -1;
--- a/src/share/vm/services/diagnosticArgument.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/services/diagnosticArgument.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -247,7 +247,7 @@ } else { _value._time = 0; _value._nanotime = 0; - strcmp(_value._unit, "ns"); + strcpy(_value._unit, "ns"); } }
--- a/src/share/vm/utilities/exceptions.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/utilities/exceptions.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -194,15 +194,15 @@ #define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception()) #define CLEAR_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_exception()) -#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (0 -#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (0 +#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (void)(0 +#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0 #define CHECK_0 CHECK_(0) #define CHECK_NH CHECK_(Handle()) #define CHECK_NULL CHECK_(NULL) #define CHECK_false CHECK_(false) -#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (0 -#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0 +#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (void)(0 +#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0 #define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0) #define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle()) #define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL) @@ -281,7 +281,7 @@ CLEAR_PENDING_EXCEPTION; \ ex->print(); \ ShouldNotReachHere(); \ - } (0 + } (void)(0 // ExceptionMark is a stack-allocated helper class for local exception handling. // It is used with the EXCEPTION_MARK macro.
--- a/src/share/vm/utilities/macros.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/utilities/macros.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -219,14 +219,6 @@ #define NOT_AMD64(code) code #endif -#ifdef AARCH64 -#define AARCH64_ONLY(code) code -#define NOT_AARCH64(code) -#else -#define AARCH64_ONLY(code) -#define NOT_AARCH64(code) code -#endif - #ifdef SPARC #define SPARC_ONLY(code) code #define NOT_SPARC(code) @@ -242,11 +234,7 @@ #define PPC_ONLY(code) code #define NOT_PPC(code) #else - -#ifdef PPC -#error "PPC is either 32- or 64-bit." -#endif - +#undef PPC #define PPC_ONLY(code) #define NOT_PPC(code) code #endif
--- a/src/share/vm/utilities/taskqueue.hpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/utilities/taskqueue.hpp Thu Mar 30 18:03:59 2017 +0100 @@ -376,8 +376,12 @@ if (dirty_n_elems == N - 1) { // Actually means 0, so do the push. uint localBot = this->get_bottom(); - // g++ complains if the volatile result of the assignment is unused. - const_cast<E&>(_elems[localBot] = t); + // g++ complains if the volatile result of the assignment is + // unused, so we cast the volatile away. We cannot cast directly + // to void, because gcc treats that as not using the result of the + // assignment. However, casting to E& means that we trigger an + // unused-value warning. So, we cast the E& to void. + (void)const_cast<E&>(_elems[localBot] = t); this->set_bottom(increment_index(localBot)); TASKQUEUE_STATS_ONLY(stats.record_push()); return true; @@ -441,7 +445,12 @@ return false; } - const_cast<E&>(t = _elems[oldAge.top()]); + // g++ complains if the volatile result of the assignment is + // unused, so we cast the volatile away. We cannot cast directly + // to void, because gcc treats that as not using the result of the + // assignment. However, casting to E& means that we trigger an + // unused-value warning. So, we cast the E& to void. + (void) const_cast<E&>(t = _elems[oldAge.top()]); Age newAge(oldAge); newAge.increment(); Age resAge = this->cmpxchg_age(newAge, oldAge); @@ -726,8 +735,12 @@ uint dirty_n_elems = dirty_size(localBot, top); assert(dirty_n_elems < N, "n_elems out of range."); if (dirty_n_elems < max_elems()) { - // g++ complains if the volatile result of the assignment is unused. - const_cast<E&>(_elems[localBot] = t); + // g++ complains if the volatile result of the assignment is + // unused, so we cast the volatile away. We cannot cast directly + // to void, because gcc treats that as not using the result of the + // assignment. However, casting to E& means that we trigger an + // unused-value warning. So, we cast the E& to void. + (void) const_cast<E&>(_elems[localBot] = t); this->set_bottom(increment_index(localBot)); TASKQUEUE_STATS_ONLY(stats.record_push()); return true; @@ -751,7 +764,12 @@ // This is necessary to prevent any read below from being reordered // before the store just above. OrderAccess::fence(); - const_cast<E&>(t = _elems[localBot]); + // g++ complains if the volatile result of the assignment is + // unused, so we cast the volatile away. We cannot cast directly + // to void, because gcc treats that as not using the result of the + // assignment. However, casting to E& means that we trigger an + // unused-value warning. So, we cast the E& to void. + (void) const_cast<E&>(t = _elems[localBot]); // This is a second read of "age"; the "size()" above is the first. // If there's still at least one element in the queue, based on the // "_bottom" and "age" we've read, then there can be no interference with
--- a/src/share/vm/utilities/vmError.cpp Mon Feb 06 19:40:32 2017 +0000 +++ b/src/share/vm/utilities/vmError.cpp Thu Mar 30 18:03:59 2017 +0100 @@ -22,7 +22,6 @@ * */ -#include <fcntl.h> #include "precompiled.hpp" #include "compiler/compileBroker.hpp" #include "gc_interface/collectedHeap.hpp"
--- a/test/runtime/handlerInTry/LoadHandlerInTry.java Mon Feb 06 19:40:32 2017 +0000 +++ b/test/runtime/handlerInTry/LoadHandlerInTry.java Thu Mar 30 18:03:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. 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 @@ -24,7 +24,7 @@ /* * @test * @bug 8075118 - * @summary Allow a ctor to call super() from a switch bytecode. + * @summary JVM stuck in infinite loop during verification * @compile HandlerInTry.jasm * @compile IsolatedHandlerInTry.jasm * @run main/othervm -Xverify:all LoadHandlerInTry @@ -70,9 +70,10 @@ System.out.println("Regression test for bug 8075118"); try { Class newClass = Class.forName("HandlerInTry"); - } catch (Exception e) { - System.out.println("Failed: Exception was thrown: " + e.toString()); - throw e; + throw new RuntimeException( + "Failed to throw VerifyError for HandlerInTry"); + } catch (java.lang.VerifyError e) { + System.out.println("Passed: VerifyError exception was thrown"); } try {