< prev index next >

src/share/vm/opto/compile.cpp

Print this page




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)
3880       found_void = true;  // jump-tables
3881     else
3882       assert(!found_void, "wrong sorting");
3883   }
3884 #endif
3885 
3886   int offset = 0;
3887   for (int i = 0; i < _constants.length(); i++) {
3888     Constant* con = _constants.adr_at(i);
3889 
3890     // Align offset for type.
3891     int typesize = type_to_size_in_bytes(con->type());
3892     offset = align_size_up(offset, typesize);
3893     con->set_offset(offset);   // set constant's offset
3894 
3895     if (con->type() == T_VOID) {
3896       MachConstantNode* n = (MachConstantNode*) con->get_jobject();
3897       offset = offset + typesize * n->outcnt();  // expand jump-table
3898     } else {
3899       offset = offset + typesize;
3900     }
3901   }
3902 
3903   // Align size up to the next section start (which is insts; see
3904   // CodeBuffer::align_at_start).
3905   assert(_size == -1, "already set?");
3906   _size = align_size_up(offset, (int)CodeEntryAlignment);
3907 }
3908 
3909 void Compile::ConstantTable::emit(CodeBuffer& cb) {
3910   MacroAssembler _masm(&cb);
3911   for (int i = 0; i < _constants.length(); i++) {
3912     Constant con = _constants.at(i);
3913     address constant_addr = NULL;
3914     switch (con.type()) {
3915     case T_INT:    constant_addr = _masm.int_constant(   con.get_jint()   ); break;
3916     case T_LONG:   constant_addr = _masm.long_constant(  con.get_jlong()  ); break;
3917     case T_FLOAT:  constant_addr = _masm.float_constant( con.get_jfloat() ); break;
3918     case T_DOUBLE: constant_addr = _masm.double_constant(con.get_jdouble()); break;
3919     case T_OBJECT: {
3920       jobject obj = con.get_jobject();
3921       int oop_index = _masm.oop_recorder()->find_index(obj);
3922       constant_addr = _masm.address_constant((address) obj, oop_Relocation::spec(oop_index));
3923       break;
3924     }
3925     case T_ADDRESS: {
3926       address addr = (address) con.get_jobject();




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)
3880       found_void = true;  // jump-tables
3881     else
3882       assert(!found_void, "wrong sorting");
3883   }
3884 #endif
3885 
3886   int offset = 0;
3887   for (int i = 0; i < _constants.length(); i++) {
3888     Constant* con = _constants.adr_at(i);
3889 
3890     // Align offset for type.
3891     int typesize = type_to_size_in_bytes(con->type());
3892     offset = align_up(offset, typesize);
3893     con->set_offset(offset);   // set constant's offset
3894 
3895     if (con->type() == T_VOID) {
3896       MachConstantNode* n = (MachConstantNode*) con->get_jobject();
3897       offset = offset + typesize * n->outcnt();  // expand jump-table
3898     } else {
3899       offset = offset + typesize;
3900     }
3901   }
3902 
3903   // Align size up to the next section start (which is insts; see
3904   // CodeBuffer::align_at_start).
3905   assert(_size == -1, "already set?");
3906   _size = align_up(offset, (int)CodeEntryAlignment);
3907 }
3908 
3909 void Compile::ConstantTable::emit(CodeBuffer& cb) {
3910   MacroAssembler _masm(&cb);
3911   for (int i = 0; i < _constants.length(); i++) {
3912     Constant con = _constants.at(i);
3913     address constant_addr = NULL;
3914     switch (con.type()) {
3915     case T_INT:    constant_addr = _masm.int_constant(   con.get_jint()   ); break;
3916     case T_LONG:   constant_addr = _masm.long_constant(  con.get_jlong()  ); break;
3917     case T_FLOAT:  constant_addr = _masm.float_constant( con.get_jfloat() ); break;
3918     case T_DOUBLE: constant_addr = _masm.double_constant(con.get_jdouble()); break;
3919     case T_OBJECT: {
3920       jobject obj = con.get_jobject();
3921       int oop_index = _masm.oop_recorder()->find_index(obj);
3922       constant_addr = _masm.address_constant((address) obj, oop_Relocation::spec(oop_index));
3923       break;
3924     }
3925     case T_ADDRESS: {
3926       address addr = (address) con.get_jobject();


< prev index next >