Mercurial > hg > truffle
changeset 9584:4172233f32fd
make lookupConstantInPool use ConstantPool logic
author | twisti |
---|---|
date | Mon, 06 May 2013 15:15:09 -0700 |
parents | c382fa74b1ee |
children | 404eb9b2c511 d5c2b20e9d73 |
files | src/share/vm/graal/graalCompilerToVM.cpp |
diffstat | 1 files changed, 45 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompilerToVM.cpp Mon May 06 14:17:11 2013 -0700 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon May 06 15:15:09 2013 -0700 @@ -391,35 +391,52 @@ oop result = NULL; constantTag tag = cp->tag_at(index); - if (tag.is_int()) { - result = VMToCompiler::createConstant(Kind::Int(), cp->int_at(index), CHECK_0); - } else if (tag.is_long()) { - result = VMToCompiler::createConstant(Kind::Long(), cp->long_at(index), CHECK_0); - } else if (tag.is_float()) { - result = VMToCompiler::createConstantFloat(cp->float_at(index), CHECK_0); - } else if (tag.is_double()) { - result = VMToCompiler::createConstantDouble(cp->double_at(index), CHECK_0); - } else if (tag.is_string()) { - oop string = NULL; - if (cp->is_pseudo_string_at(index)) { - int obj_index = cp->cp_to_object_index(index); - string = cp->pseudo_string_at(index, obj_index); - } else { - string = cp->string_at(index, THREAD); - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - // TODO: Gracefully exit compilation. - fatal("out of memory during compilation!"); - return NULL; - } + + switch (tag.value()) { + case JVM_CONSTANT_Integer: + result = VMToCompiler::createConstant(Kind::Int(), cp->int_at(index), CHECK_NULL); + break; + + case JVM_CONSTANT_Long: + result = VMToCompiler::createConstant(Kind::Long(), cp->long_at(index), CHECK_NULL); + break; + + case JVM_CONSTANT_Float: + result = VMToCompiler::createConstantFloat(cp->float_at(index), CHECK_NULL); + break; + + case JVM_CONSTANT_Double: + result = VMToCompiler::createConstantDouble(cp->double_at(index), CHECK_NULL); + break; + + case JVM_CONSTANT_Class: + case JVM_CONSTANT_UnresolvedClass: + case JVM_CONSTANT_UnresolvedClassInError: + { + Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); + result = type(); + break; } - result = VMToCompiler::createConstantObject(string, CHECK_0); - } else if (tag.is_klass() || tag.is_unresolved_klass()) { - Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); - result = type(); - } else { - tty->print("unknown constant pool tag (%s) at cpi %d in %s: ", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string()); - ShouldNotReachHere(); + + case JVM_CONSTANT_String: + { + oop result_oop = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); + result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL); + break; + } + + case JVM_CONSTANT_MethodHandle: + case JVM_CONSTANT_MethodHandleInError: + case JVM_CONSTANT_MethodType: + case JVM_CONSTANT_MethodTypeInError: + { + oop result_oop = cp->resolve_constant_at(index, CHECK_NULL); + result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL); + break; + } + + default: + fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string())); } return JNIHandles::make_local(THREAD, result);