hotspot/src/share/vm/ci/ciObjectFactory.hpp
author kvn
Fri, 08 May 2009 10:44:20 -0700
changeset 2867 69187054225f
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits Summary: Cache Jvmti and DTrace flags used by Compiler. Reviewed-by: never
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
// ciObjectFactory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// This class handles requests for the creation of new instances
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// of ciObject and its subclasses.  It contains a caching mechanism
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// which ensures that for each oop, at most one ciObject is created.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// This invariant allows efficient implementation of ciObject.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class ciObjectFactory : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  static volatile bool _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  static GrowableArray<ciObject*>* _shared_ci_objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  static ciSymbol*                 _shared_ci_symbols[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  static int                       _shared_ident_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  Arena*                    _arena;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  GrowableArray<ciObject*>* _ci_objects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  GrowableArray<ciMethod*>* _unloaded_methods;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  GrowableArray<ciKlass*>* _unloaded_klasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  GrowableArray<ciReturnAddress*>* _return_addresses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  int                       _next_ident;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  struct NonPermObject : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    ciObject*      _object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    NonPermObject* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    ciObject*     object()  { return _object; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    NonPermObject* &next()  { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  enum { NON_PERM_BUCKETS = 61 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  int _non_perm_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  int find(oop key, GrowableArray<ciObject*>* objects);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  bool is_found_at(int index, oop key, GrowableArray<ciObject*>* objects);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  void insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  ciObject* create_new_object(oop o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  static bool is_equal(NonPermObject* p, oop key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    return p->object()->get_oop() == key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  NonPermObject* &find_non_perm(oop key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void init_ident_of(ciObject* obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  Arena* arena() { return _arena; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void print_contents_impl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  static bool is_initialized() { return _initialized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void init_shared_objects();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  ciObjectFactory(Arena* arena, int expected_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Get the ciObject corresponding to some oop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  ciObject* get(oop key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Get the ciSymbol corresponding to one of the vmSymbols.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  static ciSymbol* vm_symbol_at(int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // Get the ciMethod representing an unloaded/unfound method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  ciMethod* get_unloaded_method(ciInstanceKlass* holder,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                                ciSymbol*        name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                ciSymbol*        signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Get a ciKlass representing an unloaded klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                              ciSymbol* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                              bool create_if_not_found);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Get the ciMethodData representing the methodData for a method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // with none.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  ciMethodData* get_empty_methodData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  ciReturnAddress* get_return_address(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void print_contents();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
};