< prev index next >

src/hotspot/share/ci/ciReplay.cpp

Print this page
rev 53818 : 8219642: ciReplay loads wrong data when MethodData size changes
Reviewed-by:


 256   }
 257 
 258   // Look for the tag 'tag' followed by an
 259   bool parse_tag_and_count(const char* tag, int& length) {
 260     const char* t = parse_string();
 261     if (t == NULL) {
 262       return false;
 263     }
 264 
 265     if (strcmp(tag, t) != 0) {
 266       report_error(tag);
 267       return false;
 268     }
 269     length = parse_int("parse_tag_and_count");
 270     return !had_error();
 271   }
 272 
 273   // Parse a sequence of raw data encoded as bytes and return the
 274   // resulting data.
 275   char* parse_data(const char* tag, int& length) {
 276     if (!parse_tag_and_count(tag, length)) {

 277       return NULL;
 278     }
 279 
 280     char * result = NEW_RESOURCE_ARRAY(char, length);
 281     for (int i = 0; i < length; i++) {

























 282       int val = parse_int("data");
 283       result[i] = val;
 284     }

 285     return result;
 286   }
 287 
 288   // Parse a standard chunk of data emitted as:
 289   //   'tag' <length> # # ...
 290   // Where each # is an intptr_t item
 291   intptr_t* parse_intptr_data(const char* tag, int& length) {
 292     if (!parse_tag_and_count(tag, length)) {
 293       return NULL;
 294     }
 295 
 296     intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
 297     for (int i = 0; i < length; i++) {
 298       skip_ws();
 299       intptr_t val = parse_intptr_t("data");
 300       result[i] = val;
 301     }
 302     return result;
 303   }
 304 




 256   }
 257 
 258   // Look for the tag 'tag' followed by an
 259   bool parse_tag_and_count(const char* tag, int& length) {
 260     const char* t = parse_string();
 261     if (t == NULL) {
 262       return false;
 263     }
 264 
 265     if (strcmp(tag, t) != 0) {
 266       report_error(tag);
 267       return false;
 268     }
 269     length = parse_int("parse_tag_and_count");
 270     return !had_error();
 271   }
 272 
 273   // Parse a sequence of raw data encoded as bytes and return the
 274   // resulting data.
 275   char* parse_data(const char* tag, int& length) {
 276     int read_size = 0;
 277     if (!parse_tag_and_count(tag, read_size)) {
 278       return NULL;
 279     }
 280 
 281     int actual_size = sizeof(MethodData);
 282     char *result = NEW_RESOURCE_ARRAY(char, actual_size);
 283     int i = 0;
 284     if (read_size != actual_size) {
 285       tty->print_cr("Warning: ciMethodData parsing sees MethodData size %i in file, current is %i", read_size,
 286                     actual_size);
 287       // Replay serializes the entire MethodData, but the data is at the end.
 288       // If the MethodData instance size has changed, we can pad or truncate in the beginning
 289       int padding = actual_size - read_size;
 290       if (padding > 0) {
 291         // pad missing data with zeros
 292         tty->print_cr("- Padding MethodData");
 293         for (; i < padding; i++) {
 294           result[i] = 0;
 295         }
 296       } else if (padding < 0) {
 297         // drop some data
 298         tty->print_cr("- Truncating MethodData");
 299         for (int j = 0; j < -padding; j++) {
 300           int val = parse_int("data");
 301           // discard val
 302         }
 303       }
 304     }
 305 
 306     assert(i < actual_size, "At least some data must remain to be copied");
 307     for (; i < actual_size; i++) {
 308       int val = parse_int("data");
 309       result[i] = val;
 310     }
 311     length = actual_size;
 312     return result;
 313   }
 314 
 315   // Parse a standard chunk of data emitted as:
 316   //   'tag' <length> # # ...
 317   // Where each # is an intptr_t item
 318   intptr_t* parse_intptr_data(const char* tag, int& length) {
 319     if (!parse_tag_and_count(tag, length)) {
 320       return NULL;
 321     }
 322 
 323     intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
 324     for (int i = 0; i < length; i++) {
 325       skip_ws();
 326       intptr_t val = parse_intptr_t("data");
 327       result[i] = val;
 328     }
 329     return result;
 330   }
 331 


< prev index next >