1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
3387 // Go over safepoints nodes to skip DecodeN/DecodeNKlass nodes for debug edges.
3388 // It could be done for an uncommon traps or any safepoints/calls
3389 // if the DecodeN/DecodeNKlass node is referenced only in a debug info.
3390 while (sfpt.size() > 0) {
3391 n = sfpt.pop();
3392 JVMState *jvms = n->as_SafePoint()->jvms();
3393 assert(jvms != NULL, "sanity");
3394 int start = jvms->debug_start();
3395 int end = n->req();
3396 bool is_uncommon = (n->is_CallStaticJava() &&
3397 n->as_CallStaticJava()->uncommon_trap_request() != 0);
3398 for (int j = start; j < end; j++) {
3399 Node* in = n->in(j);
3400 if (in->is_DecodeNarrowPtr()) {
3401 bool safe_to_skip = true;
3402 if (!is_uncommon ) {
3403 // Is it safe to skip?
3404 for (uint i = 0; i < in->outcnt(); i++) {
3405 Node* u = in->raw_out(i);
3406 if (!u->is_SafePoint() ||
3407 u->is_Call() && u->as_Call()->has_non_debug_use(n)) {
3408 safe_to_skip = false;
3409 }
3410 }
3411 }
3412 if (safe_to_skip) {
3413 n->set_req(j, in->in(1));
3414 }
3415 if (in->outcnt() == 0) {
3416 in->disconnect_inputs(NULL, this);
3417 }
3418 }
3419 }
3420 }
3421 }
3422
3423 //------------------------------final_graph_reshaping--------------------------
3424 // Final Graph Reshaping.
3425 //
3426 // (1) Clone simple inputs to uncommon calls, so they can be scheduled late
3427 // and not commoned up and forced early. Must come after regular
3819 if (_log != NULL) {
3820 _log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes());
3821 }
3822 }
3823
3824 //=============================================================================
3825 // Two Constant's are equal when the type and the value are equal.
3826 bool Compile::Constant::operator==(const Constant& other) {
3827 if (type() != other.type() ) return false;
3828 if (can_be_reused() != other.can_be_reused()) return false;
3829 // For floating point values we compare the bit pattern.
3830 switch (type()) {
3831 case T_INT:
3832 case T_FLOAT: return (_v._value.i == other._v._value.i);
3833 case T_LONG:
3834 case T_DOUBLE: return (_v._value.j == other._v._value.j);
3835 case T_OBJECT:
3836 case T_ADDRESS: return (_v._value.l == other._v._value.l);
3837 case T_VOID: return (_v._value.l == other._v._value.l); // jump-table entries
3838 case T_METADATA: return (_v._metadata == other._v._metadata);
3839 default: ShouldNotReachHere();
3840 }
3841 return false;
3842 }
3843
3844 static int type_to_size_in_bytes(BasicType t) {
3845 switch (t) {
3846 case T_INT: return sizeof(jint );
3847 case T_LONG: return sizeof(jlong );
3848 case T_FLOAT: return sizeof(jfloat );
3849 case T_DOUBLE: return sizeof(jdouble);
3850 case T_METADATA: return sizeof(Metadata*);
3851 // We use T_VOID as marker for jump-table entries (labels) which
3852 // need an internal word relocation.
3853 case T_VOID:
3854 case T_ADDRESS:
3855 case T_OBJECT: return sizeof(jobject);
3856 }
3857
3858 ShouldNotReachHere();
3859 return -1;
3860 }
3861
3862 int Compile::ConstantTable::qsort_comparator(Constant* a, Constant* b) {
3863 // sort descending
3864 if (a->freq() > b->freq()) return -1;
3865 if (a->freq() < b->freq()) return 1;
3866 return 0;
3867 }
3868
3869 void Compile::ConstantTable::calculate_offsets_and_size() {
3870 // First, sort the array by frequencies.
3871 _constants.sort(qsort_comparator);
3872
3873 #ifdef ASSERT
3874 // Make sure all jump-table entries were sorted to the end of the
3875 // array (they have a negative frequency).
3876 bool found_void = false;
3877 for (int i = 0; i < _constants.length(); i++) {
3878 Constant con = _constants.at(i);
3879 if (con.type() == T_VOID)
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
3387 // Go over safepoints nodes to skip DecodeN/DecodeNKlass nodes for debug edges.
3388 // It could be done for an uncommon traps or any safepoints/calls
3389 // if the DecodeN/DecodeNKlass node is referenced only in a debug info.
3390 while (sfpt.size() > 0) {
3391 n = sfpt.pop();
3392 JVMState *jvms = n->as_SafePoint()->jvms();
3393 assert(jvms != NULL, "sanity");
3394 int start = jvms->debug_start();
3395 int end = n->req();
3396 bool is_uncommon = (n->is_CallStaticJava() &&
3397 n->as_CallStaticJava()->uncommon_trap_request() != 0);
3398 for (int j = start; j < end; j++) {
3399 Node* in = n->in(j);
3400 if (in->is_DecodeNarrowPtr()) {
3401 bool safe_to_skip = true;
3402 if (!is_uncommon ) {
3403 // Is it safe to skip?
3404 for (uint i = 0; i < in->outcnt(); i++) {
3405 Node* u = in->raw_out(i);
3406 if (!u->is_SafePoint() ||
3407 (u->is_Call() && u->as_Call()->has_non_debug_use(n))) {
3408 safe_to_skip = false;
3409 }
3410 }
3411 }
3412 if (safe_to_skip) {
3413 n->set_req(j, in->in(1));
3414 }
3415 if (in->outcnt() == 0) {
3416 in->disconnect_inputs(NULL, this);
3417 }
3418 }
3419 }
3420 }
3421 }
3422
3423 //------------------------------final_graph_reshaping--------------------------
3424 // Final Graph Reshaping.
3425 //
3426 // (1) Clone simple inputs to uncommon calls, so they can be scheduled late
3427 // and not commoned up and forced early. Must come after regular
3819 if (_log != NULL) {
3820 _log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes());
3821 }
3822 }
3823
3824 //=============================================================================
3825 // Two Constant's are equal when the type and the value are equal.
3826 bool Compile::Constant::operator==(const Constant& other) {
3827 if (type() != other.type() ) return false;
3828 if (can_be_reused() != other.can_be_reused()) return false;
3829 // For floating point values we compare the bit pattern.
3830 switch (type()) {
3831 case T_INT:
3832 case T_FLOAT: return (_v._value.i == other._v._value.i);
3833 case T_LONG:
3834 case T_DOUBLE: return (_v._value.j == other._v._value.j);
3835 case T_OBJECT:
3836 case T_ADDRESS: return (_v._value.l == other._v._value.l);
3837 case T_VOID: return (_v._value.l == other._v._value.l); // jump-table entries
3838 case T_METADATA: return (_v._metadata == other._v._metadata);
3839 default: ShouldNotReachHere(); return false;
3840 }
3841 }
3842
3843 static int type_to_size_in_bytes(BasicType t) {
3844 switch (t) {
3845 case T_INT: return sizeof(jint );
3846 case T_LONG: return sizeof(jlong );
3847 case T_FLOAT: return sizeof(jfloat );
3848 case T_DOUBLE: return sizeof(jdouble);
3849 case T_METADATA: return sizeof(Metadata*);
3850 // We use T_VOID as marker for jump-table entries (labels) which
3851 // need an internal word relocation.
3852 case T_VOID:
3853 case T_ADDRESS:
3854 case T_OBJECT: return sizeof(jobject);
3855 default:
3856 ShouldNotReachHere();
3857 return -1;
3858 }
3859 }
3860
3861 int Compile::ConstantTable::qsort_comparator(Constant* a, Constant* b) {
3862 // sort descending
3863 if (a->freq() > b->freq()) return -1;
3864 if (a->freq() < b->freq()) return 1;
3865 return 0;
3866 }
3867
3868 void Compile::ConstantTable::calculate_offsets_and_size() {
3869 // First, sort the array by frequencies.
3870 _constants.sort(qsort_comparator);
3871
3872 #ifdef ASSERT
3873 // Make sure all jump-table entries were sorted to the end of the
3874 // array (they have a negative frequency).
3875 bool found_void = false;
3876 for (int i = 0; i < _constants.length(); i++) {
3877 Constant con = _constants.at(i);
3878 if (con.type() == T_VOID)
|