提交 7eb3c564 编写于 作者: A asaha

Merge

......@@ -895,6 +895,10 @@ b5ecd8067e899c4bfb8d327ee7583a32129772d4 jdk8u102-b09
f6daf04c0f48dab5420ad63d21da82a7fa4e3ad7 jdk8u102-b13
ac29c9c1193aef5d480b200ed94c5d579243c17b jdk8u102-b14
96e1c72fc617d3c6c125bcfc9182f77fc6aa38e6 jdk8u102-b31
c8988d2e4212583ec0f04591c8e241ad3cf95674 jdk8u102-b32
9050d85e29600400ce4ba2b4db9616388082ae08 jdk8u102-b33
b678b66d1538af31bac7cf5e74c029395607decd jdk8u102-b34
8a2db0a6c499250050b59f9a47acd9ea80de92c2 jdk8u102-b35
ceecf88e5c2c09bfabf5926581e6d0b0f65f5148 jdk8u111-b00
e73d79ce00e4a0451e464c7a73d9c911d01e169a jdk8u111-b01
d584a614818562e1187e1a15c202aec01491caeb jdk8u111-b02
......@@ -926,6 +930,21 @@ c2ca4df6580822835f3b21436b79e123910c4eb5 jdk8u112-b11
c2c4db2a42a215c98a4f027edb8bbb00dd62d9b9 jdk8u112-b14
b28d012a24cab8f4ceeee0c9d3252969757423ed jdk8u112-b15
e134dc1879b72124e478be01680b0646a2fbf585 jdk8u112-b16
87440ed4e1de7753a436f957d35555d8b4e26f1d jdk8u112-b31
3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
251a2493b1857f2ff4f11eab2dfd8b2fe8ed441b jdk8u121-b01
70c4a50f576a01ec975d0a02b3642ee33db39ed8 jdk8u121-b02
fa3bb4153a28b45a7a80cbf1058979b8f1c8b104 jdk8u121-b03
35cff8508ca15dc18c598501cab160aee7220d44 jdk8u121-b04
f71447f104ce7b018a08bf1cf385438525744d13 jdk8u121-b05
49a2fc91c46f3d73aac7dbd420a4a007fe453ef8 jdk8u121-b06
f31c7533cfcb55acfb8dc5b31779d3a64708f5ce jdk8u121-b07
02a3d0dcbeddd8507d9a4b1f5a9f83aca75e5acb jdk8u121-b08
8cae1bdbd73cb1a84afad07a8e18467f56560bc4 jdk8u121-b09
f26f6895c9dfb32dfb4c228d69b371d8ab118536 jdk8u121-b10
11f91811e4d7e5ddfaf938dcf386ec8fe5bf7b7c jdk8u121-b11
b132b08b28bf23a26329928cf6b4ffda5857f4d3 jdk8u121-b12
90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13
5aa8c4ca51f0e666d368a4f119ed734d3ac59d7c jdk8u122-b00
2198ef7e1c1702b3506b95b5d8c886ad5a12bbe5 jdk8u122-b01
58d961f47dd4ee1d516512b7744e0f1fc83d8f52 jdk8u122-b02
......
......@@ -944,11 +944,12 @@ void ClassFileParser::parse_field_attributes(u2 attributes_count,
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(runtime_visible_annotations,
runtime_visible_annotations_length,
parsed_annotations,
CHECK);
cfs->skip_u1(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();
......@@ -1655,6 +1656,11 @@ int ClassFileParser::skip_annotation(u1* buffer, int limit, int index) {
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) {
......@@ -1665,19 +1671,19 @@ int ClassFileParser::skip_annotation_value(u1* buffer, int limit, int index) {
// 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);
......@@ -1699,8 +1705,8 @@ void ClassFileParser::parse_annotations(u1* buffer, int limit,
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;'
......@@ -1719,7 +1725,8 @@ void ClassFileParser::parse_annotations(u1* buffer, int limit,
s_size = 9,
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;
......@@ -2324,10 +2331,11 @@ methodHandle ClassFileParser::parse_method(bool is_interface,
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(runtime_visible_annotations,
runtime_visible_annotations_length, &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();
......@@ -2953,11 +2961,12 @@ void ClassFileParser::parse_classfile_attributes(ClassFileParser::ClassAnnotatio
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(runtime_visible_annotations,
runtime_visible_annotations_length,
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();
......
/*
* 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
......@@ -155,47 +155,8 @@ int StackMapFrame::is_assignable_to(
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);
......@@ -226,8 +187,7 @@ bool StackMapFrame::is_assignable_to(
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(),
......
/*
* 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
......@@ -167,8 +167,7 @@ class StackMapFrame : public ResourceObj {
// 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 ASSERT
......@@ -290,8 +289,6 @@ class StackMapFrame : public ResourceObj {
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;
......
/*
* 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 @@ int StackMapTable::get_index_from_offset(int32_t offset) const {
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 @@ bool StackMapTable::match_stackmap(
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 @@ void StackMapTable::check_jump_target(
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);
......
/*
* Copyright (c) 2003, 2012, 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
......@@ -74,12 +74,12 @@ class StackMapTable : public StackObj {
// 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.
......
......@@ -504,19 +504,13 @@ void ErrorContext::stackmap_details(outputStream* ss, const Method* method) cons
stack_map_frame* sm_frame = sm_table->entries();
streamIndentor si2(ss);
int current_offset = -1;
// Subtract two from StackMapAttribute length because the length includes
// two bytes for number of table entries.
size_t sm_table_space = method->stackmap_data()->length() - 2;
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();
size_t sm_frame_size = sm_frame->size();
// If the size of the next stackmap exceeds the length of the entire
// stackmap table then print a truncated message and return.
if (sm_frame_size > sm_table_space) {
if (!sm_frame->verify((address)sm_frame, end_of_sm_table)) {
sm_frame->print_truncated(ss, current_offset);
return;
}
sm_table_space -= sm_frame_size;
sm_frame->print_on(ss, current_offset);
ss->cr();
current_offset += sm_frame->offset_delta();
......@@ -1820,7 +1814,7 @@ u2 ClassVerifier::verify_stackmap_table(u2 stackmap_index, u2 bci,
// 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");
......@@ -1867,7 +1861,7 @@ void ClassVerifier::verify_exception_handler_targets(u2 bci, bool this_uninit, S
}
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);
......
/*
* 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 @@ public class LoadHandlerInTry {
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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册