hotspot/src/share/vm/ci/ciEnv.cpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)ciEnv.cpp    1.128 07/05/17 15:49:53 JVM"
   3 #endif
   4 /*
   5  * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


 470 // ------------------------------------------------------------------
 471 // ciEnv::get_constant_by_index_impl
 472 //
 473 // Implementation of get_constant_by_index().
 474 ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
 475                                              int index) {
 476   EXCEPTION_CONTEXT;
 477   instanceKlass* ik_accessor = accessor->get_instanceKlass();
 478   assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
 479   constantPoolOop cpool = ik_accessor->constants();
 480   constantTag tag = cpool->tag_at(index);
 481   if (tag.is_int()) {
 482     return ciConstant(T_INT, (jint)cpool->int_at(index));
 483   } else if (tag.is_long()) {
 484     return ciConstant((jlong)cpool->long_at(index));
 485   } else if (tag.is_float()) {
 486     return ciConstant((jfloat)cpool->float_at(index));
 487   } else if (tag.is_double()) {
 488     return ciConstant((jdouble)cpool->double_at(index));
 489   } else if (tag.is_string() || tag.is_unresolved_string()) {
 490     oop string = cpool->string_at(index, THREAD);




 491     if (HAS_PENDING_EXCEPTION) {
 492       CLEAR_PENDING_EXCEPTION;
 493       record_out_of_memory_failure();
 494       return ciConstant();
 495     }

 496     ciObject* constant = get_object(string);
 497     assert (constant->is_instance(), "must be an instance, or not? ");
 498     return ciConstant(T_OBJECT, constant);
 499   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 500     // 4881222: allow ldc to take a class type
 501     bool ignore;
 502     ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
 503     if (HAS_PENDING_EXCEPTION) {
 504       CLEAR_PENDING_EXCEPTION;
 505       record_out_of_memory_failure();
 506       return ciConstant();
 507     }
 508     assert (klass->is_instance_klass() || klass->is_array_klass(), 
 509             "must be an instance or array klass ");
 510     return ciConstant(T_OBJECT, klass);
 511   } else {
 512     ShouldNotReachHere();
 513     return ciConstant();
 514   }
 515 }


   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)ciEnv.cpp    1.128 07/05/17 15:49:53 JVM"
   3 #endif
   4 /*
   5  * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


 470 // ------------------------------------------------------------------
 471 // ciEnv::get_constant_by_index_impl
 472 //
 473 // Implementation of get_constant_by_index().
 474 ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
 475                                              int index) {
 476   EXCEPTION_CONTEXT;
 477   instanceKlass* ik_accessor = accessor->get_instanceKlass();
 478   assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
 479   constantPoolOop cpool = ik_accessor->constants();
 480   constantTag tag = cpool->tag_at(index);
 481   if (tag.is_int()) {
 482     return ciConstant(T_INT, (jint)cpool->int_at(index));
 483   } else if (tag.is_long()) {
 484     return ciConstant((jlong)cpool->long_at(index));
 485   } else if (tag.is_float()) {
 486     return ciConstant((jfloat)cpool->float_at(index));
 487   } else if (tag.is_double()) {
 488     return ciConstant((jdouble)cpool->double_at(index));
 489   } else if (tag.is_string() || tag.is_unresolved_string()) {
 490     oop string = NULL;
 491     if (cpool->is_pseudo_string_at(index)) {
 492       string = cpool->pseudo_string_at(index);
 493     } else {
 494       string = cpool->string_at(index, THREAD);
 495       if (HAS_PENDING_EXCEPTION) {
 496         CLEAR_PENDING_EXCEPTION;
 497         record_out_of_memory_failure();
 498         return ciConstant();
 499       }
 500     }
 501     ciObject* constant = get_object(string);
 502     assert (constant->is_instance(), "must be an instance, or not? ");
 503     return ciConstant(T_OBJECT, constant);
 504   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
 505     // 4881222: allow ldc to take a class type
 506     bool ignore;
 507     ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
 508     if (HAS_PENDING_EXCEPTION) {
 509       CLEAR_PENDING_EXCEPTION;
 510       record_out_of_memory_failure();
 511       return ciConstant();
 512     }
 513     assert (klass->is_instance_klass() || klass->is_array_klass(), 
 514             "must be an instance or array klass ");
 515     return ciConstant(T_OBJECT, klass);
 516   } else {
 517     ShouldNotReachHere();
 518     return ciConstant();
 519   }
 520 }