提交 1e0a5288 编写于 作者: V vlivanov

8000313: C2 should use jlong for 64bit values

Summary: Replace all occurrences of long with jlong in C2 code.
Reviewed-by: kvn, twisti
上级 d955fbe2
......@@ -1115,7 +1115,7 @@ Node* GraphKit::ConvI2L(Node* offset) {
// short-circuit a common case
jint offset_con = find_int_con(offset, Type::OffsetBot);
if (offset_con != Type::OffsetBot) {
return longcon((long) offset_con);
return longcon((jlong) offset_con);
}
return _gvn.transform( new (C) ConvI2LNode(offset));
}
......
......@@ -92,10 +92,10 @@ void IdealLoopTree::compute_exact_trip_count( PhaseIdealLoop *phase ) {
limit_n != NULL && limit_n->is_Con()) {
// Use longs to avoid integer overflow.
int stride_con = cl->stride_con();
long init_con = cl->init_trip()->get_int();
long limit_con = cl->limit()->get_int();
jlong init_con = cl->init_trip()->get_int();
jlong limit_con = cl->limit()->get_int();
int stride_m = stride_con - (stride_con > 0 ? 1 : -1);
long trip_count = (limit_con - init_con + stride_m)/stride_con;
jlong trip_count = (limit_con - init_con + stride_m)/stride_con;
if (trip_count > 0 && (julong)trip_count < (julong)max_juint) {
// Set exact trip count.
cl->set_exact_trip_count((uint)trip_count);
......@@ -1212,16 +1212,16 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad
} else if (loop_head->has_exact_trip_count() && init->is_Con()) {
// Loop's limit is constant. Loop's init could be constant when pre-loop
// become peeled iteration.
long init_con = init->get_int();
jlong init_con = init->get_int();
// We can keep old loop limit if iterations count stays the same:
// old_trip_count == new_trip_count * 2
// Note: since old_trip_count >= 2 then new_trip_count >= 1
// so we also don't need to adjust zero trip test.
long limit_con = limit->get_int();
jlong limit_con = limit->get_int();
// (stride_con*2) not overflow since stride_con <= 8.
int new_stride_con = stride_con * 2;
int stride_m = new_stride_con - (stride_con > 0 ? 1 : -1);
long trip_count = (limit_con - init_con + stride_m)/new_stride_con;
jlong trip_count = (limit_con - init_con + stride_m)/new_stride_con;
// New trip count should satisfy next conditions.
assert(trip_count > 0 && (julong)trip_count < (julong)max_juint/2, "sanity");
uint new_trip_count = (uint)trip_count;
......
......@@ -328,12 +328,12 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
const TypeInt* limit_t = gvn->type(limit)->is_int();
if (stride_con > 0) {
long init_p = (long)init_t->_lo + stride_con;
if (init_p > (long)max_jint || init_p > (long)limit_t->_hi)
jlong init_p = (jlong)init_t->_lo + stride_con;
if (init_p > (jlong)max_jint || init_p > (jlong)limit_t->_hi)
return false; // cyclic loop or this loop trips only once
} else {
long init_p = (long)init_t->_hi + stride_con;
if (init_p < (long)min_jint || init_p < (long)limit_t->_lo)
jlong init_p = (jlong)init_t->_hi + stride_con;
if (init_p < (jlong)min_jint || init_p < (jlong)limit_t->_lo)
return false; // cyclic loop or this loop trips only once
}
......@@ -716,16 +716,16 @@ Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) {
#endif
if (cl->has_exact_trip_count()) {
// Simple case: loop has constant boundaries.
// Use longs to avoid integer overflow.
// Use jlongs to avoid integer overflow.
int stride_con = cl->stride_con();
long init_con = cl->init_trip()->get_int();
long limit_con = cl->limit()->get_int();
jlong init_con = cl->init_trip()->get_int();
jlong limit_con = cl->limit()->get_int();
julong trip_cnt = cl->trip_count();
long final_con = init_con + trip_cnt*stride_con;
jlong final_con = init_con + trip_cnt*stride_con;
int final_int = (int)final_con;
// The final value should be in integer range since the loop
// is counted and the limit was checked for overflow.
assert(final_con == (long)final_int, "final value should be integer");
assert(final_con == (jlong)final_int, "final value should be integer");
limit = _igvn.intcon(final_int);
} else {
// Create new LoopLimit node to get exact limit (final iv value).
......@@ -790,16 +790,16 @@ const Type *LoopLimitNode::Value( PhaseTransform *phase ) const {
return NULL; // Identity
if (init_t->is_int()->is_con() && limit_t->is_int()->is_con()) {
// Use longs to avoid integer overflow.
long init_con = init_t->is_int()->get_con();
long limit_con = limit_t->is_int()->get_con();
// Use jlongs to avoid integer overflow.
jlong init_con = init_t->is_int()->get_con();
jlong limit_con = limit_t->is_int()->get_con();
int stride_m = stride_con - (stride_con > 0 ? 1 : -1);
long trip_count = (limit_con - init_con + stride_m)/stride_con;
long final_con = init_con + stride_con*trip_count;
jlong trip_count = (limit_con - init_con + stride_m)/stride_con;
jlong final_con = init_con + stride_con*trip_count;
int final_int = (int)final_con;
// The final value should be in integer range since the loop
// is counted and the limit was checked for overflow.
assert(final_con == (long)final_int, "final value should be integer");
assert(final_con == (jlong)final_int, "final value should be integer");
return TypeInt::make(final_int);
}
......@@ -829,7 +829,7 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) {
const TypeInt* init_t = phase->type(in(Init) )->is_int();
const TypeInt* limit_t = phase->type(in(Limit))->is_int();
int stride_p;
long lim, ini;
jlong lim, ini;
julong max;
if (stride_con > 0) {
stride_p = stride_con;
......
......@@ -497,8 +497,8 @@ public:
#ifndef PRODUCT
protected:
// Sub-quadratic implementation of VerifyIterativeGVN.
unsigned long _verify_counter;
unsigned long _verify_full_passes;
julong _verify_counter;
julong _verify_full_passes;
enum { _verify_window_size = 30 };
Node* _verify_window[_verify_window_size];
void verify_step(Node* n);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册