Mercurial > hg > truffle
comparison src/share/vm/ci/ciInstanceKlass.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | 46f211fe010c e6b1331a51d2 |
children | 716a2c5c0656 |
comparison
equal
deleted
inserted
replaced
3737:9dc19b7d89a3 | 4137:04b9a2566eec |
---|---|
29 #include "ci/ciUtilities.hpp" | 29 #include "ci/ciUtilities.hpp" |
30 #include "classfile/systemDictionary.hpp" | 30 #include "classfile/systemDictionary.hpp" |
31 #include "memory/allocation.hpp" | 31 #include "memory/allocation.hpp" |
32 #include "memory/allocation.inline.hpp" | 32 #include "memory/allocation.inline.hpp" |
33 #include "oops/oop.inline.hpp" | 33 #include "oops/oop.inline.hpp" |
34 #include "oops/fieldStreams.hpp" | |
34 #include "runtime/fieldDescriptor.hpp" | 35 #include "runtime/fieldDescriptor.hpp" |
35 | 36 |
36 // ciInstanceKlass | 37 // ciInstanceKlass |
37 // | 38 // |
38 // This class represents a klassOop in the HotSpot virtual machine | 39 // This class represents a klassOop in the HotSpot virtual machine |
409 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() { | 410 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() { |
410 if (_non_static_fields == NULL) { | 411 if (_non_static_fields == NULL) { |
411 VM_ENTRY_MARK; | 412 VM_ENTRY_MARK; |
412 ciEnv* curEnv = ciEnv::current(); | 413 ciEnv* curEnv = ciEnv::current(); |
413 instanceKlass* ik = get_instanceKlass(); | 414 instanceKlass* ik = get_instanceKlass(); |
414 int max_n_fields = ik->fields()->length()/instanceKlass::next_offset; | 415 int max_n_fields = ik->java_fields_count(); |
415 | 416 |
416 Arena* arena = curEnv->arena(); | 417 Arena* arena = curEnv->arena(); |
417 _non_static_fields = | 418 _non_static_fields = |
418 new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL); | 419 new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL); |
419 NonStaticFieldFiller filler(curEnv, _non_static_fields); | 420 NonStaticFieldFiller filler(curEnv, _non_static_fields); |
473 int flen = fields->length(); | 474 int flen = fields->length(); |
474 | 475 |
475 // Now sort them by offset, ascending. | 476 // Now sort them by offset, ascending. |
476 // (In principle, they could mix with superclass fields.) | 477 // (In principle, they could mix with superclass fields.) |
477 fields->sort(sort_field_by_offset); | 478 fields->sort(sort_field_by_offset); |
478 #ifdef ASSERT | |
479 int last_offset = instanceOopDesc::base_offset_in_bytes(); | |
480 for (int i = 0; i < fields->length(); i++) { | |
481 ciField* field = fields->at(i); | |
482 int offset = field->offset_in_bytes(); | |
483 int size = (field->_type == NULL) ? heapOopSize : field->size_in_bytes(); | |
484 assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset)); | |
485 if (last_offset > (int)sizeof(oopDesc)) | |
486 assert((offset - last_offset) < BytesPerLong, "no big holes"); | |
487 // Note: Two consecutive T_BYTE fields will be separated by wordSize-1 | |
488 // padding bytes if one of them is declared by a superclass. | |
489 // This is a minor inefficiency classFileParser.cpp. | |
490 last_offset = offset + size; | |
491 } | |
492 assert(last_offset <= (int)instanceOopDesc::base_offset_in_bytes() + fsize, "no overflow"); | |
493 #endif | |
494 | |
495 _nonstatic_fields = fields; | 479 _nonstatic_fields = fields; |
496 return flen; | 480 return flen; |
497 } | 481 } |
498 | 482 |
499 GrowableArray<ciField*>* | 483 GrowableArray<ciField*>* |
502 ASSERT_IN_VM; | 486 ASSERT_IN_VM; |
503 Arena* arena = CURRENT_ENV->arena(); | 487 Arena* arena = CURRENT_ENV->arena(); |
504 int flen = 0; | 488 int flen = 0; |
505 GrowableArray<ciField*>* fields = NULL; | 489 GrowableArray<ciField*>* fields = NULL; |
506 instanceKlass* k = get_instanceKlass(); | 490 instanceKlass* k = get_instanceKlass(); |
507 typeArrayOop fields_array = k->fields(); | 491 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
508 for (int pass = 0; pass <= 1; pass++) { | 492 if (fs.access_flags().is_static()) continue; |
509 for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) { | 493 flen += 1; |
510 fieldDescriptor fd; | 494 } |
511 fd.initialize(k->as_klassOop(), i); | 495 |
512 if (fd.is_static()) continue; | 496 // allocate the array: |
513 if (pass == 0) { | 497 if (flen == 0) { |
514 flen += 1; | 498 return NULL; // return nothing if none are locally declared |
515 } else { | 499 } |
516 ciField* field = new (arena) ciField(&fd); | 500 if (super_fields != NULL) { |
517 fields->append(field); | 501 flen += super_fields->length(); |
518 } | 502 } |
519 } | 503 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); |
520 | 504 if (super_fields != NULL) { |
521 // Between passes, allocate the array: | 505 fields->appendAll(super_fields); |
522 if (pass == 0) { | 506 } |
523 if (flen == 0) { | 507 |
524 return NULL; // return nothing if none are locally declared | 508 for (JavaFieldStream fs(k); !fs.done(); fs.next()) { |
525 } | 509 if (fs.access_flags().is_static()) continue; |
526 if (super_fields != NULL) { | 510 fieldDescriptor fd; |
527 flen += super_fields->length(); | 511 fd.initialize(k->as_klassOop(), fs.index()); |
528 } | 512 ciField* field = new (arena) ciField(&fd); |
529 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); | 513 fields->append(field); |
530 if (super_fields != NULL) { | |
531 fields->appendAll(super_fields); | |
532 } | |
533 } | |
534 } | 514 } |
535 assert(fields->length() == flen, "sanity"); | 515 assert(fields->length() == flen, "sanity"); |
536 return fields; | 516 return fields; |
537 } | 517 } |
538 | 518 |