hotspot/src/cpu/sparc/vm/debug_sparc.cpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6800154: Add comments to long_by_long_mulhi() for better understandability Summary: This patch adds a comment pointing to the Hacker's Delight version of the algorithm plus a verbatim copy of it. Furthermore it adds inline comments. Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_debug_sparc.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
extern "C" void findpc(int x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
void pd_ps(frame f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  intptr_t* sp = f.sp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  intptr_t* prev_sp = sp - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  intptr_t *pc = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  intptr_t *next_pc = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  tty->print("register window backtrace from %#x:\n", sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  while (sp != NULL && ((intptr_t)sp & 7) == 0 && sp > prev_sp && sp < prev_sp+1000) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    pc      = next_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    next_pc = (intptr_t*) sp[I7->sp_offset_in_saved_window()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    tty->print("[%d] sp=%#x pc=", count, sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    findpc((intptr_t)pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    if (WizardMode && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
      // print register window contents also
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
      tty->print_cr("    L0..L7: {%#x %#x %#x %#x %#x %#x %#x %#x}",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
                    sp[0+0],sp[0+1],sp[0+2],sp[0+3],
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                    sp[0+4],sp[0+5],sp[0+6],sp[0+7]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
      tty->print_cr("    I0..I7: {%#x %#x %#x %#x %#x %#x %#x %#x}",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
                    sp[8+0],sp[8+1],sp[8+2],sp[8+3],
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
                    sp[8+4],sp[8+5],sp[8+6],sp[8+7]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
      // (and print stack frame contents too??)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
      CodeBlob *b = CodeCache::find_blob((address) pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      if (b != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        if (b->is_nmethod()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
          methodOop m = ((nmethod*)b)->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
          int nlocals = m->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
          int nparams  = m->size_of_parameters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
          tty->print_cr("compiled java method (locals = %d, params = %d)", nlocals, nparams);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    prev_sp = sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    sp = (intptr_t *)sp[FP->sp_offset_in_saved_window()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    sp = (intptr_t *)((intptr_t)sp + STACK_BIAS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    count += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  if (sp != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    tty->print("[%d] sp=%#x [bogus sp!]", count, sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
#endif // PRODUCT