src/hotspot/share/ci/ciReplay.cpp
changeset 54036 c70747878f6f
parent 53838 c8c9bd65c198
child 54347 235883996bc7
equal deleted inserted replaced
54035:65a9f034954f 54036:c70747878f6f
   272   }
   272   }
   273 
   273 
   274   // Parse a sequence of raw data encoded as bytes and return the
   274   // Parse a sequence of raw data encoded as bytes and return the
   275   // resulting data.
   275   // resulting data.
   276   char* parse_data(const char* tag, int& length) {
   276   char* parse_data(const char* tag, int& length) {
   277     if (!parse_tag_and_count(tag, length)) {
   277     int read_size = 0;
       
   278     if (!parse_tag_and_count(tag, read_size)) {
   278       return NULL;
   279       return NULL;
   279     }
   280     }
   280 
   281 
   281     char * result = NEW_RESOURCE_ARRAY(char, length);
   282     int actual_size = sizeof(MethodData);
   282     for (int i = 0; i < length; i++) {
   283     char *result = NEW_RESOURCE_ARRAY(char, actual_size);
       
   284     int i = 0;
       
   285     if (read_size != actual_size) {
       
   286       tty->print_cr("Warning: ciMethodData parsing sees MethodData size %i in file, current is %i", read_size,
       
   287                     actual_size);
       
   288       // Replay serializes the entire MethodData, but the data is at the end.
       
   289       // If the MethodData instance size has changed, we can pad or truncate in the beginning
       
   290       int padding = actual_size - read_size;
       
   291       if (padding > 0) {
       
   292         // pad missing data with zeros
       
   293         tty->print_cr("- Padding MethodData");
       
   294         for (; i < padding; i++) {
       
   295           result[i] = 0;
       
   296         }
       
   297       } else if (padding < 0) {
       
   298         // drop some data
       
   299         tty->print_cr("- Truncating MethodData");
       
   300         for (int j = 0; j < -padding; j++) {
       
   301           int val = parse_int("data");
       
   302           // discard val
       
   303         }
       
   304       }
       
   305     }
       
   306 
       
   307     assert(i < actual_size, "At least some data must remain to be copied");
       
   308     for (; i < actual_size; i++) {
   283       int val = parse_int("data");
   309       int val = parse_int("data");
   284       result[i] = val;
   310       result[i] = val;
   285     }
   311     }
       
   312     length = actual_size;
   286     return result;
   313     return result;
   287   }
   314   }
   288 
   315 
   289   // Parse a standard chunk of data emitted as:
   316   // Parse a standard chunk of data emitted as:
   290   //   'tag' <length> # # ...
   317   //   'tag' <length> # # ...