Merge

Wed, 20 Feb 2013 08:51:44 -0800

author
sspitsyn
date
Wed, 20 Feb 2013 08:51:44 -0800
changeset 4611
20fff74158eb
parent 4597
57b81d6c3641
parent 4610
1048edb5434a
child 4616
5741d3fc502d
child 4630
abf488c22e09

Merge

     1.1 --- a/agent/src/os/bsd/MacosxDebuggerLocal.m	Fri Feb 15 13:36:56 2013 -0800
     1.2 +++ b/agent/src/os/bsd/MacosxDebuggerLocal.m	Wed Feb 20 08:51:44 2013 -0800
     1.3 @@ -38,6 +38,8 @@
     1.4  #import <dlfcn.h>
     1.5  #import <limits.h>
     1.6  #import <errno.h>
     1.7 +#import <sys/types.h>
     1.8 +#import <sys/ptrace.h>
     1.9  
    1.10  jboolean debug = JNI_FALSE;
    1.11  
    1.12 @@ -430,6 +432,73 @@
    1.13    return (jint) usable_tid;
    1.14  }
    1.15  
    1.16 +
    1.17 +static bool ptrace_continue(pid_t pid, int signal) {
    1.18 +  // pass the signal to the process so we don't swallow it
    1.19 +  int res;
    1.20 +  if ((res = ptrace(PT_CONTINUE, pid, (caddr_t)1, signal)) < 0) {
    1.21 +    fprintf(stderr, "attach: ptrace(PT_CONTINUE, %d) failed with %d\n", pid, res);
    1.22 +    return false;
    1.23 +  }
    1.24 +  return true;
    1.25 +}
    1.26 +
    1.27 +// waits until the ATTACH has stopped the process
    1.28 +// by signal SIGSTOP
    1.29 +static bool ptrace_waitpid(pid_t pid) {
    1.30 +  int ret;
    1.31 +  int status;
    1.32 +  while (true) {
    1.33 +    // Wait for debuggee to stop.
    1.34 +    ret = waitpid(pid, &status, 0);
    1.35 +    if (ret >= 0) {
    1.36 +      if (WIFSTOPPED(status)) {
    1.37 +        // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
    1.38 +        // will still be pending and delivered when the process is DETACHED and the process
    1.39 +        // will go to sleep.
    1.40 +        if (WSTOPSIG(status) == SIGSTOP) {
    1.41 +          // Debuggee stopped by SIGSTOP.
    1.42 +          return true;
    1.43 +        }
    1.44 +        if (!ptrace_continue(pid, WSTOPSIG(status))) {
    1.45 +          fprintf(stderr, "attach: Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
    1.46 +          return false;
    1.47 +        }
    1.48 +      } else {
    1.49 +        fprintf(stderr, "attach: waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
    1.50 +        return false;
    1.51 +      }
    1.52 +    } else {
    1.53 +      switch (errno) {
    1.54 +        case EINTR:
    1.55 +          continue;
    1.56 +          break;
    1.57 +        case ECHILD:
    1.58 +          fprintf(stderr, "attach: waitpid() failed. Child process pid (%d) does not exist \n", pid);
    1.59 +          break;
    1.60 +        case EINVAL:
    1.61 +          fprintf(stderr, "attach: waitpid() failed. Invalid options argument.\n");
    1.62 +          break;
    1.63 +        default:
    1.64 +          fprintf(stderr, "attach: waitpid() failed. Unexpected error %d\n",errno);
    1.65 +          break;
    1.66 +      }
    1.67 +      return false;
    1.68 +    }
    1.69 +  }
    1.70 +}
    1.71 +
    1.72 +// attach to a process/thread specified by "pid"
    1.73 +static bool ptrace_attach(pid_t pid) {
    1.74 +  int res;
    1.75 +  if ((res = ptrace(PT_ATTACH, pid, 0, 0)) < 0) {
    1.76 +    fprintf(stderr, "ptrace(PT_ATTACH, %d) failed with %d\n", pid, res);
    1.77 +    return false;
    1.78 +  } else {
    1.79 +    return ptrace_waitpid(pid);
    1.80 +  }
    1.81 +}
    1.82 +
    1.83  /*
    1.84   * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
    1.85   * Method:    attach0
    1.86 @@ -445,7 +514,8 @@
    1.87    else
    1.88      debug = JNI_FALSE;
    1.89    if (debug) printf("attach0 called for jpid=%d\n", (int)jpid);
    1.90 -
    1.91 +  
    1.92 +  // get the task from the pid
    1.93    kern_return_t result;
    1.94    task_t gTask = 0;
    1.95    result = task_for_pid(mach_task_self(), jpid, &gTask);
    1.96 @@ -455,6 +525,13 @@
    1.97    }
    1.98    putTask(env, this_obj, gTask);
    1.99  
   1.100 +  // use ptrace to stop the process
   1.101 +  // on os x, ptrace only needs to be called on the process, not the individual threads
   1.102 +  if (ptrace_attach(jpid) != true) {
   1.103 +    mach_port_deallocate(mach_task_self(), gTask);
   1.104 +    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
   1.105 +  }
   1.106 +
   1.107    id symbolicator = nil;
   1.108    id jrsSymbolicator = objc_lookUpClass("JRSSymbolicator");
   1.109    if (jrsSymbolicator != nil) {
   1.110 @@ -486,6 +563,21 @@
   1.111    if (debug) printf("detach0 called\n");
   1.112  
   1.113    task_t gTask = getTask(env, this_obj);
   1.114 +
   1.115 +  // detach from the ptraced process causing it to resume execution
   1.116 +  int pid;
   1.117 +  kern_return_t k_res;
   1.118 +  k_res = pid_for_task(gTask, &pid);
   1.119 +  if (k_res != KERN_SUCCESS) {
   1.120 +    fprintf(stderr, "detach: pid_for_task(%d) failed (%d)\n", pid, k_res);
   1.121 +  }
   1.122 +  else {
   1.123 +    int res = ptrace(PT_DETACH, pid, 0, 0);
   1.124 +    if (res < 0) {
   1.125 +      fprintf(stderr, "detach: ptrace(PT_DETACH, %d) failed (%d)\n", pid, res);
   1.126 +    }
   1.127 +  }
   1.128 +  
   1.129    mach_port_deallocate(mach_task_self(), gTask);
   1.130    id symbolicator = getSymbolicator(env, this_obj);
   1.131    if (symbolicator != nil) {
     2.1 --- a/agent/src/os/bsd/libproc_impl.c	Fri Feb 15 13:36:56 2013 -0800
     2.2 +++ b/agent/src/os/bsd/libproc_impl.c	Wed Feb 20 08:51:44 2013 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -91,6 +91,14 @@
    2.11     }
    2.12  }
    2.13  
    2.14 +void print_error(const char* format,...) {
    2.15 +  va_list alist;
    2.16 +  va_start(alist, format);
    2.17 +  fputs("ERROR: ", stderr);
    2.18 +  vfprintf(stderr, format, alist);
    2.19 +  va_end(alist);
    2.20 +}
    2.21 +
    2.22  bool is_debug() {
    2.23     return _libsaproc_debug;
    2.24  }
     3.1 --- a/agent/src/os/bsd/libproc_impl.h	Fri Feb 15 13:36:56 2013 -0800
     3.2 +++ b/agent/src/os/bsd/libproc_impl.h	Wed Feb 20 08:51:44 2013 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -107,6 +107,7 @@
    3.11  int pathmap_open(const char* name);
    3.12  
    3.13  void print_debug(const char* format,...);
    3.14 +void print_error(const char* format,...);
    3.15  bool is_debug();
    3.16  
    3.17  typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
     4.1 --- a/agent/src/os/bsd/ps_proc.c	Fri Feb 15 13:36:56 2013 -0800
     4.2 +++ b/agent/src/os/bsd/ps_proc.c	Wed Feb 20 08:51:44 2013 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -129,42 +129,66 @@
    4.11    return (errno == 0)? true: false;
    4.12  }
    4.13  
    4.14 +static bool ptrace_continue(pid_t pid, int signal) {
    4.15 +  // pass the signal to the process so we don't swallow it
    4.16 +  if (ptrace(PTRACE_CONT, pid, NULL, signal) < 0) {
    4.17 +    print_debug("ptrace(PTRACE_CONT, ..) failed for %d\n", pid);
    4.18 +    return false;
    4.19 +  }
    4.20 +  return true;
    4.21 +}
    4.22 +
    4.23 +// waits until the ATTACH has stopped the process
    4.24 +// by signal SIGSTOP
    4.25 +static bool ptrace_waitpid(pid_t pid) {
    4.26 +  int ret;
    4.27 +  int status;
    4.28 +  do {
    4.29 +    // Wait for debuggee to stop.
    4.30 +    ret = waitpid(pid, &status, 0);
    4.31 +    if (ret >= 0) {
    4.32 +      if (WIFSTOPPED(status)) {
    4.33 +        // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
    4.34 +        // will still be pending and delivered when the process is DETACHED and the process
    4.35 +        // will go to sleep.
    4.36 +        if (WSTOPSIG(status) == SIGSTOP) {
    4.37 +          // Debuggee stopped by SIGSTOP.
    4.38 +          return true;
    4.39 +        }
    4.40 +        if (!ptrace_continue(pid, WSTOPSIG(status))) {
    4.41 +          print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
    4.42 +          return false;
    4.43 +        }
    4.44 +      } else {
    4.45 +        print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
    4.46 +        return false;
    4.47 +      }
    4.48 +    } else {
    4.49 +      switch (errno) {
    4.50 +        case EINTR:
    4.51 +          continue;
    4.52 +          break;
    4.53 +        case ECHILD:
    4.54 +          print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
    4.55 +          break;
    4.56 +        case EINVAL:
    4.57 +          print_debug("waitpid() failed. Invalid options argument.\n");
    4.58 +          break;
    4.59 +        default:
    4.60 +          print_debug("waitpid() failed. Unexpected error %d\n",errno);
    4.61 +      }
    4.62 +      return false;
    4.63 +    }
    4.64 +  } while(true);
    4.65 +}
    4.66 +
    4.67  // attach to a process/thread specified by "pid"
    4.68  static bool ptrace_attach(pid_t pid) {
    4.69    if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
    4.70      print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
    4.71      return false;
    4.72    } else {
    4.73 -    int ret;
    4.74 -    int status;
    4.75 -    do {
    4.76 -      // Wait for debuggee to stop.
    4.77 -      ret = waitpid(pid, &status, 0);
    4.78 -      if (ret >= 0) {
    4.79 -        if (WIFSTOPPED(status)) {
    4.80 -          // Debuggee stopped.
    4.81 -          return true;
    4.82 -        } else {
    4.83 -          print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
    4.84 -          return false;
    4.85 -        }
    4.86 -      } else {
    4.87 -        switch (errno) {
    4.88 -          case EINTR:
    4.89 -            continue;
    4.90 -            break;
    4.91 -          case ECHILD:
    4.92 -            print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
    4.93 -            break;
    4.94 -          case EINVAL:
    4.95 -            print_debug("waitpid() failed. Invalid options argument.\n");
    4.96 -            break;
    4.97 -          default:
    4.98 -            print_debug("waitpid() failed. Unexpected error %d\n",errno);
    4.99 -        }
   4.100 -        return false;
   4.101 -      }
   4.102 -    } while(true);
   4.103 +    return ptrace_waitpid(pid);
   4.104    }
   4.105  }
   4.106  
     5.1 --- a/agent/src/os/linux/libproc_impl.c	Fri Feb 15 13:36:56 2013 -0800
     5.2 +++ b/agent/src/os/linux/libproc_impl.c	Wed Feb 20 08:51:44 2013 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -92,6 +92,14 @@
    5.11     }
    5.12  }
    5.13  
    5.14 +void print_error(const char* format,...) {
    5.15 +  va_list alist;
    5.16 +  va_start(alist, format);
    5.17 +  fputs("ERROR: ", stderr);
    5.18 +  vfprintf(stderr, format, alist);
    5.19 +  va_end(alist);
    5.20 +}
    5.21 +
    5.22  bool is_debug() {
    5.23     return _libsaproc_debug;
    5.24  }
     6.1 --- a/agent/src/os/linux/libproc_impl.h	Fri Feb 15 13:36:56 2013 -0800
     6.2 +++ b/agent/src/os/linux/libproc_impl.h	Wed Feb 20 08:51:44 2013 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -105,6 +105,7 @@
    6.11  int pathmap_open(const char* name);
    6.12  
    6.13  void print_debug(const char* format,...);
    6.14 +void print_error(const char* format,...);
    6.15  bool is_debug();
    6.16  
    6.17  typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
     7.1 --- a/agent/src/os/linux/ps_proc.c	Fri Feb 15 13:36:56 2013 -0800
     7.2 +++ b/agent/src/os/linux/ps_proc.c	Wed Feb 20 08:51:44 2013 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -25,6 +25,7 @@
    7.11  #include <stdio.h>
    7.12  #include <stdlib.h>
    7.13  #include <string.h>
    7.14 +#include <signal.h>
    7.15  #include <errno.h>
    7.16  #include <sys/ptrace.h>
    7.17  #include "libproc_impl.h"
    7.18 @@ -142,46 +143,71 @@
    7.19  
    7.20  }
    7.21  
    7.22 +static bool ptrace_continue(pid_t pid, int signal) {
    7.23 +  // pass the signal to the process so we don't swallow it
    7.24 +  if (ptrace(PTRACE_CONT, pid, NULL, signal) < 0) {
    7.25 +    print_debug("ptrace(PTRACE_CONT, ..) failed for %d\n", pid);
    7.26 +    return false;
    7.27 +  }
    7.28 +  return true;
    7.29 +}
    7.30 +
    7.31 +// waits until the ATTACH has stopped the process
    7.32 +// by signal SIGSTOP
    7.33 +static bool ptrace_waitpid(pid_t pid) {
    7.34 +  int ret;
    7.35 +  int status;
    7.36 +  while (true) {
    7.37 +    // Wait for debuggee to stop.
    7.38 +    ret = waitpid(pid, &status, 0);
    7.39 +    if (ret == -1 && errno == ECHILD) {
    7.40 +      // try cloned process.
    7.41 +      ret = waitpid(pid, &status, __WALL);
    7.42 +    }
    7.43 +    if (ret >= 0) {
    7.44 +      if (WIFSTOPPED(status)) {
    7.45 +        // Any signal will stop the thread, make sure it is SIGSTOP. Otherwise SIGSTOP
    7.46 +        // will still be pending and delivered when the process is DETACHED and the process
    7.47 +        // will go to sleep.
    7.48 +        if (WSTOPSIG(status) == SIGSTOP) {
    7.49 +          // Debuggee stopped by SIGSTOP.
    7.50 +          return true;
    7.51 +        }
    7.52 +        if (!ptrace_continue(pid, WSTOPSIG(status))) {
    7.53 +          print_error("Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
    7.54 +          return false;
    7.55 +        }
    7.56 +      } else {
    7.57 +        print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
    7.58 +        return false;
    7.59 +      }
    7.60 +    } else {
    7.61 +      switch (errno) {
    7.62 +        case EINTR:
    7.63 +          continue;
    7.64 +          break;
    7.65 +        case ECHILD:
    7.66 +          print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
    7.67 +          break;
    7.68 +        case EINVAL:
    7.69 +          print_debug("waitpid() failed. Invalid options argument.\n");
    7.70 +          break;
    7.71 +        default:
    7.72 +          print_debug("waitpid() failed. Unexpected error %d\n",errno);
    7.73 +          break;
    7.74 +      }
    7.75 +      return false;
    7.76 +    }
    7.77 +  }
    7.78 +}
    7.79 +
    7.80  // attach to a process/thread specified by "pid"
    7.81  static bool ptrace_attach(pid_t pid) {
    7.82    if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
    7.83      print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
    7.84      return false;
    7.85    } else {
    7.86 -    int ret;
    7.87 -    int status;
    7.88 -    do {
    7.89 -      // Wait for debuggee to stop.
    7.90 -      ret = waitpid(pid, &status, 0);
    7.91 -      if (ret == -1 && errno == ECHILD) {
    7.92 -        // try cloned process.
    7.93 -        ret = waitpid(pid, &status, __WALL);
    7.94 -      }
    7.95 -      if (ret >= 0) {
    7.96 -        if (WIFSTOPPED(status)) {
    7.97 -          // Debuggee stopped.
    7.98 -          return true;
    7.99 -        } else {
   7.100 -          print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
   7.101 -          return false;
   7.102 -        }
   7.103 -      } else {
   7.104 -        switch (errno) {
   7.105 -          case EINTR:
   7.106 -            continue;
   7.107 -            break;
   7.108 -          case ECHILD:
   7.109 -            print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
   7.110 -            break;
   7.111 -          case EINVAL:
   7.112 -            print_debug("waitpid() failed. Invalid options argument.\n");
   7.113 -            break;
   7.114 -          default:
   7.115 -            print_debug("waitpid() failed. Unexpected error %d\n",errno);
   7.116 -        }
   7.117 -        return false;
   7.118 -      }
   7.119 -    } while(true);
   7.120 +    return ptrace_waitpid(pid);
   7.121    }
   7.122  }
   7.123  
     8.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java	Fri Feb 15 13:36:56 2013 -0800
     8.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java	Wed Feb 20 08:51:44 2013 -0800
     8.3 @@ -61,15 +61,13 @@
     8.4      CMSBitMap markBitMap = markBitMap();
     8.5      long addressSize = VM.getVM().getAddressSize();
     8.6      if ( markBitMap.isMarked(addr) &&  markBitMap.isMarked(addr.addOffsetTo(1*addressSize)) ) {
     8.7 -       System.err.println("Printezis bits are set...");
     8.8        Address nextOneAddr = markBitMap.getNextMarkedWordAddress(addr.addOffsetTo(2*addressSize));
     8.9        //return size in bytes
    8.10        long size =  (nextOneAddr.addOffsetTo(1*addressSize)).minus(addr);
    8.11        return size;
    8.12      } else {
    8.13 -     //missing Printezis marks
    8.14 -     System.err.println("Missing Printszis marks...");
    8.15 -     return -1;
    8.16 +      //missing Printezis marks
    8.17 +      return -1;
    8.18      }
    8.19  
    8.20    }
     9.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java	Fri Feb 15 13:36:56 2013 -0800
     9.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java	Wed Feb 20 08:51:44 2013 -0800
     9.3 @@ -191,7 +191,6 @@
     9.4              //Find the object size using Printezis bits and skip over
     9.5              long size = collector().blockSizeUsingPrintezisBits(cur);
     9.6              if (size == -1) {
     9.7 -              System.err.println("Printezis bits not set...");
     9.8                break;
     9.9              }
    9.10              cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
    10.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java	Fri Feb 15 13:36:56 2013 -0800
    10.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java	Wed Feb 20 08:51:44 2013 -0800
    10.3 @@ -184,7 +184,6 @@
    10.4        if (trapReasonName[index] == null) {
    10.5          throw new InternalError("missing reason for " + index);
    10.6        }
    10.7 -      System.out.println(trapReasonName[index]);
    10.8      }
    10.9    }
   10.10  
    11.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Fri Feb 15 13:36:56 2013 -0800
    11.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Wed Feb 20 08:51:44 2013 -0800
    11.3 @@ -335,7 +335,6 @@
    11.4            }
    11.5            if (obj == null) {
    11.6               //Find the object size using Printezis bits and skip over
    11.7 -             System.err.println("Finding object size using Printezis bits and skipping over...");
    11.8               long size = 0;
    11.9  
   11.10               if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){
    12.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Fri Feb 15 13:36:56 2013 -0800
    12.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Wed Feb 20 08:51:44 2013 -0800
    12.3 @@ -90,10 +90,6 @@
    12.4    /** Flags indicating whether we are attached to a core, C1, or C2 build */
    12.5    private boolean      usingClientCompiler;
    12.6    private boolean      usingServerCompiler;
    12.7 -  /** Flag indicating whether UseTLAB is turned on */
    12.8 -  private boolean      useTLAB;
    12.9 -  /** Flag indicating whether invokedynamic support is on */
   12.10 -  private boolean      enableInvokeDynamic;
   12.11    /** alignment constants */
   12.12    private boolean      isLP64;
   12.13    private int          bytesPerLong;
   12.14 @@ -326,9 +322,6 @@
   12.15        }
   12.16      }
   12.17  
   12.18 -    useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0);
   12.19 -    enableInvokeDynamic = (db.lookupIntConstant("EnableInvokeDynamic").intValue() != 0);
   12.20 -
   12.21      if (debugger != null) {
   12.22        isLP64 = debugger.getMachineDescription().isLP64();
   12.23      }
   12.24 @@ -579,15 +572,6 @@
   12.25      }
   12.26    }
   12.27  
   12.28 -  /** Indicates whether Thread-Local Allocation Buffers are used */
   12.29 -  public boolean getUseTLAB() {
   12.30 -    return useTLAB;
   12.31 -  }
   12.32 -
   12.33 -  public boolean getEnableInvokeDynamic() {
   12.34 -    return enableInvokeDynamic;
   12.35 -  }
   12.36 -
   12.37    public TypeDataBase getTypeDataBase() {
   12.38      return db;
   12.39    }
   12.40 @@ -822,6 +806,12 @@
   12.41      return objectAlignmentInBytes;
   12.42    }
   12.43  
   12.44 +  /** Indicates whether Thread-Local Allocation Buffers are used */
   12.45 +  public boolean getUseTLAB() {
   12.46 +      Flag flag = getCommandLineFlag("UseTLAB");
   12.47 +      return (flag == null) ? false: flag.getBool();
   12.48 +  }
   12.49 +
   12.50    // returns null, if not available.
   12.51    public Flag[] getCommandLineFlags() {
   12.52      if (commandLineFlags == null) {
    13.1 --- a/make/bsd/makefiles/vm.make	Fri Feb 15 13:36:56 2013 -0800
    13.2 +++ b/make/bsd/makefiles/vm.make	Wed Feb 20 08:51:44 2013 -0800
    13.3 @@ -94,7 +94,12 @@
    13.4  # This is VERY important! The version define must only be supplied to vm_version.o
    13.5  # If not, ccache will not re-use the cache at all, since the version string might contain
    13.6  # a time and date. 
    13.7 -vm_version.o: CXXFLAGS += ${JRE_VERSION} 
    13.8 +CXXFLAGS/vm_version.o += ${JRE_VERSION}
    13.9 +
   13.10 +CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
   13.11 +
   13.12 +# File specific flags
   13.13 +CXXFLAGS += $(CXXFLAGS/BYFILE)
   13.14  
   13.15  ifdef DEFAULT_LIBPATH
   13.16  CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
    14.1 --- a/make/linux/makefiles/vm.make	Fri Feb 15 13:36:56 2013 -0800
    14.2 +++ b/make/linux/makefiles/vm.make	Wed Feb 20 08:51:44 2013 -0800
    14.3 @@ -100,7 +100,13 @@
    14.4  # This is VERY important! The version define must only be supplied to vm_version.o
    14.5  # If not, ccache will not re-use the cache at all, since the version string might contain
    14.6  # a time and date. 
    14.7 -vm_version.o: CXXFLAGS += ${JRE_VERSION}
    14.8 +CXXFLAGS/vm_version.o += ${JRE_VERSION}
    14.9 +
   14.10 +CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
   14.11 +
   14.12 +# File specific flags
   14.13 +CXXFLAGS += $(CXXFLAGS/BYFILE)
   14.14 +
   14.15  
   14.16  ifndef JAVASE_EMBEDDED 
   14.17  ifneq (${ARCH},arm)
    15.1 --- a/make/solaris/makefiles/vm.make	Fri Feb 15 13:36:56 2013 -0800
    15.2 +++ b/make/solaris/makefiles/vm.make	Wed Feb 20 08:51:44 2013 -0800
    15.3 @@ -88,7 +88,13 @@
    15.4  # This is VERY important! The version define must only be supplied to vm_version.o
    15.5  # If not, ccache will not re-use the cache at all, since the version string might contain
    15.6  # a time and date. 
    15.7 -vm_version.o: CXXFLAGS += ${JRE_VERSION} 
    15.8 +CXXFLAGS/vm_version.o += ${JRE_VERSION}
    15.9 +
   15.10 +CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
   15.11 +
   15.12 +# File specific flags
   15.13 +CXXFLAGS += $(CXXFLAGS/BYFILE)
   15.14 +
   15.15  
   15.16  # CFLAGS_WARN holds compiler options to suppress/enable warnings.
   15.17  CFLAGS += $(CFLAGS_WARN)
    16.1 --- a/src/os/bsd/vm/os_bsd.cpp	Fri Feb 15 13:36:56 2013 -0800
    16.2 +++ b/src/os/bsd/vm/os_bsd.cpp	Wed Feb 20 08:51:44 2013 -0800
    16.3 @@ -2887,7 +2887,9 @@
    16.4  
    16.5  void signalHandler(int sig, siginfo_t* info, void* uc) {
    16.6    assert(info != NULL && uc != NULL, "it must be old kernel");
    16.7 +  int orig_errno = errno;  // Preserve errno value over signal handler.
    16.8    JVM_handle_bsd_signal(sig, info, uc, true);
    16.9 +  errno = orig_errno;
   16.10  }
   16.11  
   16.12  
    17.1 --- a/src/os/linux/vm/os_linux.cpp	Fri Feb 15 13:36:56 2013 -0800
    17.2 +++ b/src/os/linux/vm/os_linux.cpp	Wed Feb 20 08:51:44 2013 -0800
    17.3 @@ -3653,7 +3653,9 @@
    17.4  
    17.5  void signalHandler(int sig, siginfo_t* info, void* uc) {
    17.6    assert(info != NULL && uc != NULL, "it must be old kernel");
    17.7 +  int orig_errno = errno;  // Preserve errno value over signal handler.
    17.8    JVM_handle_linux_signal(sig, info, uc, true);
    17.9 +  errno = orig_errno;
   17.10  }
   17.11  
   17.12  
    18.1 --- a/src/os/solaris/vm/os_solaris.cpp	Fri Feb 15 13:36:56 2013 -0800
    18.2 +++ b/src/os/solaris/vm/os_solaris.cpp	Wed Feb 20 08:51:44 2013 -0800
    18.3 @@ -1865,7 +1865,7 @@
    18.4  
    18.5  // Die immediately, no exit hook, no abort hook, no cleanup.
    18.6  void os::die() {
    18.7 -  _exit(-1);
    18.8 +  ::abort(); // dump core (for debugging)
    18.9  }
   18.10  
   18.11  // unused
   18.12 @@ -4317,7 +4317,9 @@
   18.13  
   18.14  
   18.15  void signalHandler(int sig, siginfo_t* info, void* ucVoid) {
   18.16 +  int orig_errno = errno;  // Preserve errno value over signal handler.
   18.17    JVM_handle_solaris_signal(sig, info, ucVoid, true);
   18.18 +  errno = orig_errno;
   18.19  }
   18.20  
   18.21  /* Do not delete - if guarantee is ever removed,  a signal handler (even empty)
    19.1 --- a/src/os/windows/vm/os_windows.cpp	Fri Feb 15 13:36:56 2013 -0800
    19.2 +++ b/src/os/windows/vm/os_windows.cpp	Wed Feb 20 08:51:44 2013 -0800
    19.3 @@ -1940,7 +1940,7 @@
    19.4  
    19.5  // a counter for each possible signal value, including signal_thread exit signal
    19.6  static volatile jint pending_signals[NSIG+1] = { 0 };
    19.7 -static HANDLE sig_sem;
    19.8 +static HANDLE sig_sem = NULL;
    19.9  
   19.10  void os::signal_init_pd() {
   19.11    // Initialize signal structures
   19.12 @@ -1970,10 +1970,11 @@
   19.13  
   19.14  void os::signal_notify(int signal_number) {
   19.15    BOOL ret;
   19.16 -
   19.17 -  Atomic::inc(&pending_signals[signal_number]);
   19.18 -  ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
   19.19 -  assert(ret != 0, "ReleaseSemaphore() failed");
   19.20 +  if (sig_sem != NULL) {
   19.21 +    Atomic::inc(&pending_signals[signal_number]);
   19.22 +    ret = ::ReleaseSemaphore(sig_sem, 1, NULL);
   19.23 +    assert(ret != 0, "ReleaseSemaphore() failed");
   19.24 +  }
   19.25  }
   19.26  
   19.27  static int check_pending_signals(bool wait_for_signal) {
    20.1 --- a/src/share/vm/classfile/verifier.cpp	Fri Feb 15 13:36:56 2013 -0800
    20.2 +++ b/src/share/vm/classfile/verifier.cpp	Wed Feb 20 08:51:44 2013 -0800
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    20.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -61,7 +61,8 @@
   20.11  # include "bytes_ppc.hpp"
   20.12  #endif
   20.13  
   20.14 -#define NOFAILOVER_MAJOR_VERSION 51
   20.15 +#define NOFAILOVER_MAJOR_VERSION                  51
   20.16 +#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION  52
   20.17  
   20.18  // Access to external entry for VerifyClassCodes - old byte code verifier
   20.19  
   20.20 @@ -2317,6 +2318,11 @@
   20.21        types = (1 << JVM_CONSTANT_InterfaceMethodref) |
   20.22                (1 << JVM_CONSTANT_Methodref);
   20.23        break;
   20.24 +    case Bytecodes::_invokestatic:
   20.25 +      types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ?
   20.26 +        (1 << JVM_CONSTANT_Methodref) :
   20.27 +        ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref));
   20.28 +      break;
   20.29      default:
   20.30        types = 1 << JVM_CONSTANT_Methodref;
   20.31    }
    21.1 --- a/src/share/vm/oops/method.hpp	Fri Feb 15 13:36:56 2013 -0800
    21.2 +++ b/src/share/vm/oops/method.hpp	Wed Feb 20 08:51:44 2013 -0800
    21.3 @@ -456,6 +456,8 @@
    21.4    void print_codes_on(int from, int to, outputStream* st) const    PRODUCT_RETURN;
    21.5  
    21.6    // method parameters
    21.7 +  bool has_method_parameters() const
    21.8 +                         { return constMethod()->has_method_parameters(); }
    21.9    int method_parameters_length() const
   21.10                           { return constMethod()->method_parameters_length(); }
   21.11    MethodParametersElement* method_parameters_start() const
    22.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Feb 15 13:36:56 2013 -0800
    22.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Wed Feb 20 08:51:44 2013 -0800
    22.3 @@ -1558,6 +1558,18 @@
    22.4        } break;
    22.5      }
    22.6    } // end for each bytecode
    22.7 +
    22.8 +  // We also need to rewrite the parameter name indexes, if there is
    22.9 +  // method parameter data present
   22.10 +  if(method->has_method_parameters()) {
   22.11 +    const int len = method->method_parameters_length();
   22.12 +    MethodParametersElement* elem = method->method_parameters_start();
   22.13 +
   22.14 +    for (int i = 0; i < len; i++) {
   22.15 +      const u2 cp_index = elem[i].name_cp_index;
   22.16 +      elem[i].name_cp_index = find_new_index(cp_index);
   22.17 +    }
   22.18 +  }
   22.19  } // end rewrite_cp_refs_in_method()
   22.20  
   22.21  
    23.1 --- a/src/share/vm/runtime/vmStructs.cpp	Fri Feb 15 13:36:56 2013 -0800
    23.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Wed Feb 20 08:51:44 2013 -0800
    23.3 @@ -2109,8 +2109,6 @@
    23.4    /* Useful globals */                                                    \
    23.5    /******************/                                                    \
    23.6                                                                            \
    23.7 -  declare_constant(UseTLAB)                                               \
    23.8 -  declare_constant(EnableInvokeDynamic)                                   \
    23.9                                                                            \
   23.10    /**************/                                                        \
   23.11    /* Stack bias */                                                        \
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/runtime/8007736/TestStaticIF.java	Wed Feb 20 08:51:44 2013 -0800
    24.3 @@ -0,0 +1,44 @@
    24.4 +/*
    24.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + *
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + *
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + *
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + *
   24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   24.23 + * or visit www.oracle.com if you need additional information or have any
   24.24 + * questions.
   24.25 + *
   24.26 + */
   24.27 +
   24.28 +/*
   24.29 + * @test
   24.30 + * @bug 8007736
   24.31 + * @summary Test static interface method.
   24.32 + * @run main/othervm -Xverify:all TestStaticIF
   24.33 + */
   24.34 +
   24.35 +public class TestStaticIF implements StaticMethodInInterface {
   24.36 +
   24.37 +    public static void main(String[] args) {
   24.38 +        System.out.printf("main: %s%n", StaticMethodInInterface.get());
   24.39 +    }
   24.40 +}
   24.41 +
   24.42 +interface StaticMethodInInterface {
   24.43 +
   24.44 +    public static String get() {
   24.45 +        return "Hello from StaticMethodInInterface.get()";
   24.46 +    }
   24.47 +}

mercurial