1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. 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. |
671 void Klass::oop_verify_on(oop obj, outputStream* st) { |
671 void Klass::oop_verify_on(oop obj, outputStream* st) { |
672 guarantee(obj->is_oop(), "should be oop"); |
672 guarantee(obj->is_oop(), "should be oop"); |
673 guarantee(obj->klass()->is_klass(), "klass field is not a klass"); |
673 guarantee(obj->klass()->is_klass(), "klass field is not a klass"); |
674 } |
674 } |
675 |
675 |
|
676 klassVtable* Klass::vtable() const { |
|
677 return new klassVtable(this, start_of_vtable(), vtable_length() / vtableEntry::size()); |
|
678 } |
|
679 |
|
680 vtableEntry* Klass::start_of_vtable() const { |
|
681 return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset())); |
|
682 } |
|
683 |
|
684 Method* Klass::method_at_vtable(int index) { |
|
685 #ifndef PRODUCT |
|
686 assert(index >= 0, "valid vtable index"); |
|
687 if (DebugVtables) { |
|
688 verify_vtable_index(index); |
|
689 } |
|
690 #endif |
|
691 return start_of_vtable()[index].method(); |
|
692 } |
|
693 |
|
694 ByteSize Klass::vtable_start_offset() { |
|
695 return in_ByteSize(InstanceKlass::header_size() * wordSize); |
|
696 } |
|
697 |
676 #ifndef PRODUCT |
698 #ifndef PRODUCT |
677 |
699 |
678 bool Klass::verify_vtable_index(int i) { |
700 bool Klass::verify_vtable_index(int i) { |
679 int limit = vtable_length()/vtableEntry::size(); |
701 int limit = vtable_length()/vtableEntry::size(); |
680 assert(i >= 0 && i < limit, "index %d out of bounds %d", i, limit); |
702 assert(i >= 0 && i < limit, "index %d out of bounds %d", i, limit); |