00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class LookupResult: ValueObj {
00033 protected:
00034 oop _result;
00035
00036 public:
00037
00038 LookupResult() { clear(); }
00039 LookupResult(methodOop method) { set(method); }
00040 LookupResult(nmethod* nm) { set(nm); }
00041
00042
00043 void clear() { _result = NULL; }
00044
00045
00046 bool is_empty() const { return _result == NULL; }
00047 bool is_method() const { return _result->is_mem(); }
00048 bool is_entry() const { return !is_method(); }
00049
00050
00051
00052 bool matches(methodOop m) const;
00053 bool matches(nmethod* nm) const;
00054
00055
00056 oop value() const { return _result; }
00057 methodOop method() const;
00058 methodOop method_or_null() const;
00059 jumpTableEntry* entry() const;
00060 nmethod* get_nmethod() const;
00061
00062
00063 void set(methodOop method) {
00064 assert(method->is_method(), "must be method");
00065 _result = oop(method);
00066 }
00067
00068 void set(nmethod* nm) {
00069 assert(oop(nm)->is_smi(), "nmethod must be aligned");
00070 _result = oop(nm->jump_table_entry()->entry_point());
00071 }
00072
00073 void print_on(outputStream* st) const;
00074 void print_short_on(outputStream* st) const;
00075 };
00076
00077
00078 const unsigned int primary_cache_size = 16 * K;
00079 const unsigned int secondary_cache_size = 2 * K;
00080
00081 class lookupCache : AllStatic {
00082 private:
00083 static int primary_cache_address();
00084 static int secondary_cache_address();
00085
00086 static unsigned int hash_value(LookupKey* key);
00087 static int number_of_primary_hits;
00088 static int number_of_secondary_hits;
00089 static int number_of_misses;
00090
00091 static inline LookupResult ic_lookup(klassOop receiver_klass, oop selector_or_method);
00092
00093 static LookupResult lookup(LookupKey* key, bool compile);
00094 static LookupResult cache_miss_lookup(LookupKey* key, bool compile);
00095 static nmethod* compile_method(LookupKey* key, methodOop method);
00096
00097 public:
00098
00099 static LookupResult lookup_probe(LookupKey* key);
00100
00101
00102 static LookupResult ic_normal_lookup(klassOop receiver_klass, symbolOop selector);
00103 static LookupResult ic_super_lookup(klassOop receiver_klass, klassOop sending_method_holder, symbolOop selector);
00104
00105
00106 friend LookupResult interpreter_normal_lookup(klassOop receiver_klass, symbolOop selector);
00107 friend LookupResult interpreter_super_lookup(symbolOop selector);
00108
00109
00110 static methodOop method_lookup(klassOop receiver_klass, symbolOop selector);
00111 static methodOop compile_time_normal_lookup(klassOop receiver_klass, symbolOop selector);
00112 static methodOop compile_time_super_lookup (klassOop receiver_klass, symbolOop selector);
00113
00114
00115 static LookupResult lookup(LookupKey* key);
00116
00117
00118 static oop normal_lookup(klassOop receiver_klass, symbolOop selector);
00119
00120
00121 static void flush(LookupKey* key);
00122 static void flush();
00123
00124
00125 static void verify();
00126
00127 static void clear_statistics();
00128 static void print_statistics();
00129
00130 friend class InterpreterGenerator;
00131 friend class StubRoutines;
00132 friend class debugPrimitives;
00133 };