src/share/vm/classfile/dictionary.cpp

changeset 1145
e5b0439ef4ae
parent 631
d1605aabd0a1
child 1844
cff162798819
child 1862
cd5dbf694d45
equal deleted inserted replaced
1144:1d037ecd7960 1145:e5b0439ef4ae
1 /* 1 /*
2 * Copyright 2003-2008 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.
547 p->set_next(bucket(index)); 547 p->set_next(bucket(index));
548 set_entry(index, p); 548 set_entry(index, p);
549 } 549 }
550 } 550 }
551 551
552 SymbolPropertyTable::SymbolPropertyTable(int table_size)
553 : Hashtable(table_size, sizeof(SymbolPropertyEntry))
554 {
555 }
556 SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket* t,
557 int number_of_entries)
558 : Hashtable(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
559 {
560 }
561
562
563 SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
564 symbolHandle sym) {
565 assert(index == index_for(sym), "incorrect index?");
566 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
567 if (p->hash() == hash && p->symbol() == sym()) {
568 return p;
569 }
570 }
571 return NULL;
572 }
573
574
575 SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
576 symbolHandle sym) {
577 assert_locked_or_safepoint(SystemDictionary_lock);
578 assert(index == index_for(sym), "incorrect index?");
579 assert(find_entry(index, hash, sym) == NULL, "no double entry");
580
581 SymbolPropertyEntry* p = new_entry(hash, sym());
582 Hashtable::add_entry(index, p);
583 return p;
584 }
585
586
587 void SymbolPropertyTable::oops_do(OopClosure* f) {
588 for (int index = 0; index < table_size(); index++) {
589 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
590 f->do_oop((oop*) p->symbol_addr());
591 if (p->property_oop() != NULL) {
592 f->do_oop(p->property_oop_addr());
593 }
594 }
595 }
596 }
597
598 void SymbolPropertyTable::methods_do(void f(methodOop)) {
599 for (int index = 0; index < table_size(); index++) {
600 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
601 oop prop = p->property_oop();
602 if (prop != NULL && prop->is_method()) {
603 f((methodOop)prop);
604 }
605 }
606 }
607 }
608
552 609
553 // ---------------------------------------------------------------------------- 610 // ----------------------------------------------------------------------------
554 #ifndef PRODUCT 611 #ifndef PRODUCT
555 612
556 void Dictionary::print() { 613 void Dictionary::print() {

mercurial