6579789: Internal error "c1_LinearScan.cpp:1429 Error: assert(false,"")" in debuggee with fastdebug VM
Reviewed-by: kvn, iveresov
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp Thu Dec 16 12:47:52 2010 -0800
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp Fri Dec 17 15:55:32 2010 -0800
@@ -90,6 +90,7 @@
, _intervals(0) // initialized later with correct length
, _new_intervals_from_allocation(new IntervalList())
, _sorted_intervals(NULL)
+ , _needs_full_resort(false)
, _lir_ops(0) // initialized later with correct length
, _block_of_op(0) // initialized later with correct length
, _has_info(0)
@@ -1520,6 +1521,14 @@
void LinearScan::sort_intervals_before_allocation() {
TIME_LINEAR_SCAN(timer_sort_intervals_before);
+ if (_needs_full_resort) {
+ // There is no known reason why this should occur but just in case...
+ assert(false, "should never occur");
+ // Re-sort existing interval list because an Interval::from() has changed
+ _sorted_intervals->sort(interval_cmp);
+ _needs_full_resort = false;
+ }
+
IntervalList* unsorted_list = &_intervals;
int unsorted_len = unsorted_list->length();
int sorted_len = 0;
@@ -1559,11 +1568,18 @@
}
}
_sorted_intervals = sorted_list;
+ assert(is_sorted(_sorted_intervals), "intervals unsorted");
}
void LinearScan::sort_intervals_after_allocation() {
TIME_LINEAR_SCAN(timer_sort_intervals_after);
+ if (_needs_full_resort) {
+ // Re-sort existing interval list because an Interval::from() has changed
+ _sorted_intervals->sort(interval_cmp);
+ _needs_full_resort = false;
+ }
+
IntervalArray* old_list = _sorted_intervals;
IntervalList* new_list = _new_intervals_from_allocation;
int old_len = old_list->length();
@@ -1571,6 +1587,7 @@
if (new_len == 0) {
// no intervals have been added during allocation, so sorted list is already up to date
+ assert(is_sorted(_sorted_intervals), "intervals unsorted");
return;
}
@@ -1593,6 +1610,7 @@
}
_sorted_intervals = combined_list;
+ assert(is_sorted(_sorted_intervals), "intervals unsorted");
}
@@ -1825,6 +1843,8 @@
interval = interval->split(from_op_id);
interval->assign_reg(reg, regHi);
append_interval(interval);
+ } else {
+ _needs_full_resort = true;
}
assert(interval->from() == from_op_id, "must be true now");
@@ -4492,7 +4512,8 @@
}
} else {
type_name = type2name(type());
- if (assigned_reg() != -1) {
+ if (assigned_reg() != -1 &&
+ (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) {
opr = LinearScan::calc_operand_for_interval(this);
}
}
--- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp Thu Dec 16 12:47:52 2010 -0800
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp Fri Dec 17 15:55:32 2010 -0800
@@ -148,6 +148,7 @@
IntervalList _intervals; // mapping from register number to interval
IntervalList* _new_intervals_from_allocation; // list with all intervals created during allocation when an existing interval is split
IntervalArray* _sorted_intervals; // intervals sorted by Interval::from()
+ bool _needs_full_resort; // set to true if an Interval::from() is changed and _sorted_intervals must be resorted
LIR_OpArray _lir_ops; // mapping from LIR_Op id to LIR_Op node
BlockBeginArray _block_of_op; // mapping from LIR_Op id to the BlockBegin containing this instruction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6579789/Test6579789.java Fri Dec 17 15:55:32 2010 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6579789
+ * @summary Internal error "c1_LinearScan.cpp:1429 Error: assert(false,"")" in debuggee with fastdebug VM
+ * @run main/othervm -Xcomp -XX:UseSSE=0 -XX:CompileOnly=Test6579789.bug Test6579789
+ */
+
+public class Test6579789 {
+ public static void main(String[] args) {
+ bug(4);
+ }
+ public static void bug(int n) {
+ float f = 1;
+ int i = 1;
+ try {
+ int x = 1 / n; // instruction that can trap
+ f = 2;
+ i = 2;
+ int y = 2 / n; // instruction that can trap
+ } catch (Exception ex) {
+ f++;
+ i++;
+ }
+ }
+}