< prev index next >

src/hotspot/share/opto/stringopts.cpp

Print this page




1195     C->record_for_igvn(phi);
1196     C->record_for_igvn(size);
1197 
1198     // for (int i=0; ; i++)
1199     //   if (x <= sizeTable[i])
1200     //     return i+1;
1201 
1202     // Add loop predicate first.
1203     kit.add_predicate();
1204 
1205     RegionNode *loop = new RegionNode(3);
1206     loop->init_req(1, kit.control());
1207     kit.gvn().set_type(loop, Type::CONTROL);
1208 
1209     Node *index = new PhiNode(loop, TypeInt::INT);
1210     index->init_req(1, __ intcon(0));
1211     kit.gvn().set_type(index, TypeInt::INT);
1212     kit.set_control(loop);
1213     Node* sizeTable = fetch_static_field(kit, size_table_field);
1214 


1215     Node* value = kit.load_array_element(NULL, sizeTable, index, TypeAryPtr::INTS);
1216     C->record_for_igvn(value);
1217     Node* limit = __ CmpI(phi, value);
1218     Node* limitb = __ Bool(limit, BoolTest::le);
1219     IfNode* iff2 = kit.create_and_map_if(kit.control(), limitb, PROB_MIN, COUNT_UNKNOWN);
1220     Node* lessEqual = __ IfTrue(iff2);
1221     Node* greater = __ IfFalse(iff2);
1222 
1223     loop->init_req(2, greater);
1224     index->init_req(2, __ AddI(index, __ intcon(1)));
1225 
1226     kit.set_control(lessEqual);
1227     C->record_for_igvn(loop);
1228     C->record_for_igvn(index);
1229 
1230     final_merge->init_req(2, kit.control());
1231     final_size->init_req(2, __ AddI(__ AddI(index, size), __ intcon(1)));
1232   }
1233 
1234   kit.set_control(final_merge);


1530         val = src_array->byte_at(i) & 0xff;
1531       } else {
1532         val = readChar(src_array, i++);
1533       }
1534       __ store(__ ctrl(), adr, __ ConI(val), T_CHAR, byte_adr_idx, MemNode::unordered, true /* mismatched */);
1535       index = __ AddI(index, __ ConI(2));
1536     }
1537     if (src_is_byte) {
1538       // Multiply count by two since we now need two bytes per char
1539       __ set(count, __ ConI(2 * length));
1540     }
1541   }
1542   if (!dcon) {
1543     __ end_if();
1544   }
1545 }
1546 
1547 // Compress copy contents of the byte/char String str into dst_array starting at index start.
1548 Node* PhaseStringOpts::copy_string(GraphKit& kit, Node* str, Node* dst_array, Node* dst_coder, Node* start) {
1549   Node* src_array = kit.load_String_value(kit.control(), str);


1550 
1551   IdealKit ideal(&kit, true, true);
1552   IdealVariable count(ideal); __ declarations_done();
1553 
1554   if (str->is_Con()) {
1555     // Constant source string
1556     ciTypeArray* src_array_type = get_constant_value(kit, str);
1557 
1558     // Check encoding of constant string
1559     bool src_is_byte = (get_constant_coder(kit, str) == java_lang_String::CODER_LATIN1);
1560 
1561     // For small constant strings just emit individual stores.
1562     // A length of 6 seems like a good space/speed tradeof.
1563     __ set(count, __ ConI(src_array_type->length()));
1564     int src_len = src_array_type->length() / (src_is_byte ? 1 : 2);
1565     if (src_len < unroll_string_copy_length) {
1566       // Small constant string
1567       copy_constant_string(kit, ideal, src_array_type, count, src_is_byte, dst_array, dst_coder, start);
1568     } else if (src_is_byte) {
1569       // Source is Latin1




1195     C->record_for_igvn(phi);
1196     C->record_for_igvn(size);
1197 
1198     // for (int i=0; ; i++)
1199     //   if (x <= sizeTable[i])
1200     //     return i+1;
1201 
1202     // Add loop predicate first.
1203     kit.add_predicate();
1204 
1205     RegionNode *loop = new RegionNode(3);
1206     loop->init_req(1, kit.control());
1207     kit.gvn().set_type(loop, Type::CONTROL);
1208 
1209     Node *index = new PhiNode(loop, TypeInt::INT);
1210     index->init_req(1, __ intcon(0));
1211     kit.gvn().set_type(index, TypeInt::INT);
1212     kit.set_control(loop);
1213     Node* sizeTable = fetch_static_field(kit, size_table_field);
1214 
1215     sizeTable = kit.access_resolve_for_read(sizeTable);
1216 
1217     Node* value = kit.load_array_element(NULL, sizeTable, index, TypeAryPtr::INTS);
1218     C->record_for_igvn(value);
1219     Node* limit = __ CmpI(phi, value);
1220     Node* limitb = __ Bool(limit, BoolTest::le);
1221     IfNode* iff2 = kit.create_and_map_if(kit.control(), limitb, PROB_MIN, COUNT_UNKNOWN);
1222     Node* lessEqual = __ IfTrue(iff2);
1223     Node* greater = __ IfFalse(iff2);
1224 
1225     loop->init_req(2, greater);
1226     index->init_req(2, __ AddI(index, __ intcon(1)));
1227 
1228     kit.set_control(lessEqual);
1229     C->record_for_igvn(loop);
1230     C->record_for_igvn(index);
1231 
1232     final_merge->init_req(2, kit.control());
1233     final_size->init_req(2, __ AddI(__ AddI(index, size), __ intcon(1)));
1234   }
1235 
1236   kit.set_control(final_merge);


1532         val = src_array->byte_at(i) & 0xff;
1533       } else {
1534         val = readChar(src_array, i++);
1535       }
1536       __ store(__ ctrl(), adr, __ ConI(val), T_CHAR, byte_adr_idx, MemNode::unordered, true /* mismatched */);
1537       index = __ AddI(index, __ ConI(2));
1538     }
1539     if (src_is_byte) {
1540       // Multiply count by two since we now need two bytes per char
1541       __ set(count, __ ConI(2 * length));
1542     }
1543   }
1544   if (!dcon) {
1545     __ end_if();
1546   }
1547 }
1548 
1549 // Compress copy contents of the byte/char String str into dst_array starting at index start.
1550 Node* PhaseStringOpts::copy_string(GraphKit& kit, Node* str, Node* dst_array, Node* dst_coder, Node* start) {
1551   Node* src_array = kit.load_String_value(kit.control(), str);
1552 
1553   src_array = kit.access_resolve_for_read(src_array);
1554 
1555   IdealKit ideal(&kit, true, true);
1556   IdealVariable count(ideal); __ declarations_done();
1557 
1558   if (str->is_Con()) {
1559     // Constant source string
1560     ciTypeArray* src_array_type = get_constant_value(kit, str);
1561 
1562     // Check encoding of constant string
1563     bool src_is_byte = (get_constant_coder(kit, str) == java_lang_String::CODER_LATIN1);
1564 
1565     // For small constant strings just emit individual stores.
1566     // A length of 6 seems like a good space/speed tradeof.
1567     __ set(count, __ ConI(src_array_type->length()));
1568     int src_len = src_array_type->length() / (src_is_byte ? 1 : 2);
1569     if (src_len < unroll_string_copy_length) {
1570       // Small constant string
1571       copy_constant_string(kit, ideal, src_array_type, count, src_is_byte, dst_array, dst_coder, start);
1572     } else if (src_is_byte) {
1573       // Source is Latin1


< prev index next >