hotspot/src/share/vm/oops/instanceMirrorKlass.cpp
changeset 39695 946f1321c075
parent 33611 9abd65805e19
child 46329 53ccc37bda19
equal deleted inserted replaced
39694:e8e42da000c5 39695:946f1321c075
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 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.
    48 
    48 
    49 instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
    49 instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
    50   // Query before forming handle.
    50   // Query before forming handle.
    51   int size = instance_size(k);
    51   int size = instance_size(k);
    52   KlassHandle h_k(THREAD, this);
    52   KlassHandle h_k(THREAD, this);
    53   instanceOop i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
    53 
       
    54   assert(size > 0, "total object size must be positive: %d", size);
    54 
    55 
    55   // Since mirrors can be variable sized because of the static fields, store
    56   // Since mirrors can be variable sized because of the static fields, store
    56   // the size in the mirror itself.
    57   // the size in the mirror itself.
    57   java_lang_Class::set_oop_size(i, size);
    58   return (instanceOop)CollectedHeap::class_allocate(h_k, size, CHECK_NULL);
    58 
       
    59   return i;
       
    60 }
    59 }
    61 
    60 
    62 int InstanceMirrorKlass::oop_size(oop obj) const {
    61 int InstanceMirrorKlass::oop_size(oop obj) const {
    63   return java_lang_Class::oop_size(obj);
    62   return java_lang_Class::oop_size(obj);
    64 }
    63 }