Mercurial > hg > truffle
comparison src/share/vm/classfile/dictionary.hpp @ 710:e5b0439ef4ae
6655638: dynamic languages need method handles
Summary: initial implementation, with known omissions (x86/64, sparc, compiler optim., c-oops, C++ interp.)
Reviewed-by: kvn, twisti, never
author | jrose |
---|---|
date | Wed, 08 Apr 2009 10:56:49 -0700 |
parents | a61af66fc99e |
children | cd5dbf694d45 |
comparison
equal
deleted
inserted
replaced
709:1d037ecd7960 | 710:e5b0439ef4ae |
---|---|
1 /* | 1 /* |
2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
215 count++; | 215 count++; |
216 } | 216 } |
217 tty->print_cr("pd set = #%d", count); | 217 tty->print_cr("pd set = #%d", count); |
218 } | 218 } |
219 }; | 219 }; |
220 | |
221 // Entry in a SymbolPropertyTable, mapping a single symbolOop | |
222 // to a managed and an unmanaged pointer. | |
223 class SymbolPropertyEntry : public HashtableEntry { | |
224 friend class VMStructs; | |
225 private: | |
226 oop _property_oop; | |
227 address _property_data; | |
228 | |
229 public: | |
230 symbolOop symbol() const { return (symbolOop) literal(); } | |
231 | |
232 oop property_oop() const { return _property_oop; } | |
233 void set_property_oop(oop p) { _property_oop = p; } | |
234 | |
235 address property_data() const { return _property_data; } | |
236 void set_property_data(address p) { _property_data = p; } | |
237 | |
238 SymbolPropertyEntry* next() const { | |
239 return (SymbolPropertyEntry*)HashtableEntry::next(); | |
240 } | |
241 | |
242 SymbolPropertyEntry** next_addr() { | |
243 return (SymbolPropertyEntry**)HashtableEntry::next_addr(); | |
244 } | |
245 | |
246 oop* symbol_addr() { return literal_addr(); } | |
247 oop* property_oop_addr() { return &_property_oop; } | |
248 | |
249 void print_on(outputStream* st) const { | |
250 symbol()->print_value_on(st); | |
251 st->print(" -> "); | |
252 bool printed = false; | |
253 if (property_oop() != NULL) { | |
254 property_oop()->print_value_on(st); | |
255 printed = true; | |
256 } | |
257 if (property_data() != NULL) { | |
258 if (printed) st->print(" and "); | |
259 st->print(INTPTR_FORMAT, property_data()); | |
260 printed = true; | |
261 } | |
262 st->print_cr(printed ? "" : "(empty)"); | |
263 } | |
264 }; | |
265 | |
266 // A system-internal mapping of symbols to pointers, both managed | |
267 // and unmanaged. Used to record the auto-generation of each method | |
268 // MethodHandle.invoke(S)T, for all signatures (S)T. | |
269 class SymbolPropertyTable : public Hashtable { | |
270 friend class VMStructs; | |
271 private: | |
272 SymbolPropertyEntry* bucket(int i) { | |
273 return (SymbolPropertyEntry*) Hashtable::bucket(i); | |
274 } | |
275 | |
276 // The following method is not MT-safe and must be done under lock. | |
277 SymbolPropertyEntry** bucket_addr(int i) { | |
278 return (SymbolPropertyEntry**) Hashtable::bucket_addr(i); | |
279 } | |
280 | |
281 void add_entry(int index, SymbolPropertyEntry* new_entry) { | |
282 ShouldNotReachHere(); | |
283 } | |
284 void set_entry(int index, SymbolPropertyEntry* new_entry) { | |
285 ShouldNotReachHere(); | |
286 } | |
287 | |
288 SymbolPropertyEntry* new_entry(unsigned int hash, symbolOop symbol) { | |
289 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable::new_entry(hash, symbol); | |
290 entry->set_property_oop(NULL); | |
291 entry->set_property_data(NULL); | |
292 return entry; | |
293 } | |
294 | |
295 public: | |
296 SymbolPropertyTable(int table_size); | |
297 SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries); | |
298 | |
299 void free_entry(SymbolPropertyEntry* entry) { | |
300 Hashtable::free_entry(entry); | |
301 } | |
302 | |
303 unsigned int compute_hash(symbolHandle sym) { | |
304 // Use the regular identity_hash. | |
305 return Hashtable::compute_hash(sym); | |
306 } | |
307 | |
308 // need not be locked; no state change | |
309 SymbolPropertyEntry* find_entry(int index, unsigned int hash, symbolHandle name); | |
310 | |
311 // must be done under SystemDictionary_lock | |
312 SymbolPropertyEntry* add_entry(int index, unsigned int hash, symbolHandle name); | |
313 | |
314 // GC support | |
315 void oops_do(OopClosure* f); | |
316 void methods_do(void f(methodOop)); | |
317 | |
318 // Sharing support | |
319 void dump(SerializeOopClosure* soc); | |
320 void restore(SerializeOopClosure* soc); | |
321 void reorder_dictionary(); | |
322 | |
323 #ifndef PRODUCT | |
324 void print(); | |
325 #endif | |
326 void verify(); | |
327 }; | |
328 |