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