comparison src/share/vm/graal/graalCompilerToVM.cpp @ 5747:120820e30baa

added basic high-level interpreter support to HotSpot
author Christian Haeubl <haeubl@ssw.jku.at>
date Tue, 03 Jul 2012 16:56:40 +0200
parents 7d25723b7699
children 87e8baf5447c
comparison
equal deleted inserted replaced
5746:17d2c3b72762 5747:120820e30baa
800 set_int(env, config, "threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset())); 800 set_int(env, config, "threadTlabEndOffset", in_bytes(JavaThread::tlab_end_offset()));
801 set_int(env, config, "threadObjectOffset", in_bytes(JavaThread::threadObj_offset())); 801 set_int(env, config, "threadObjectOffset", in_bytes(JavaThread::threadObj_offset()));
802 set_int(env, config, "instanceHeaderPrototypeOffset", in_bytes(Klass::prototype_header_offset())); 802 set_int(env, config, "instanceHeaderPrototypeOffset", in_bytes(Klass::prototype_header_offset()));
803 set_int(env, config, "threadExceptionOopOffset", in_bytes(JavaThread::exception_oop_offset())); 803 set_int(env, config, "threadExceptionOopOffset", in_bytes(JavaThread::exception_oop_offset()));
804 set_int(env, config, "threadExceptionPcOffset", in_bytes(JavaThread::exception_pc_offset())); 804 set_int(env, config, "threadExceptionPcOffset", in_bytes(JavaThread::exception_pc_offset()));
805 set_int(env, config, "threadMultiNewArrayStorage", in_bytes(JavaThread::graal_multinewarray_storage_offset())); 805 set_int(env, config, "threadMultiNewArrayStorageOffset", in_bytes(JavaThread::graal_multinewarray_storage_offset()));
806 set_int(env, config, "classMirrorOffset", in_bytes(Klass::java_mirror_offset())); 806 set_int(env, config, "classMirrorOffset", in_bytes(Klass::java_mirror_offset()));
807 807
808 set_int(env, config, "methodDataOopDataOffset", in_bytes(methodDataOopDesc::data_offset())); 808 set_int(env, config, "methodDataOopDataOffset", in_bytes(methodDataOopDesc::data_offset()));
809 set_int(env, config, "methodDataOopTrapHistoryOffset", in_bytes(methodDataOopDesc::trap_history_offset())); 809 set_int(env, config, "methodDataOopTrapHistoryOffset", in_bytes(methodDataOopDesc::trap_history_offset()));
810 set_int(env, config, "dataLayoutHeaderSize", DataLayout::header_size_in_bytes()); 810 set_int(env, config, "dataLayoutHeaderSize", DataLayout::header_size_in_bytes());
964 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); 964 methodHandle method = getMethodFromHotSpotMethod(hotspot_method);
965 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); 965 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL);
966 return JNIHandles::make_local(element); 966 return JNIHandles::make_local(element);
967 } 967 }
968 968
969 class JavaArgumentPusher : public SignatureIterator {
970 protected:
971 JavaCallArguments* _jca;
972 arrayOop _args;
973 int _index;
974
975 oop next_arg(BasicType expectedType) {
976 assert(_index < _args->length(), "out of bounds");
977 oop arg = ((oop*) _args->base(T_OBJECT))[_index++];
978 assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
979 return arg;
980 }
981
982 public:
983 JavaArgumentPusher(Symbol* signature, JavaCallArguments* jca, arrayOop args, bool is_static) : SignatureIterator(signature) {
984 this->_return_type = T_ILLEGAL;
985 _jca = jca;
986 _index = 0;
987 _args = args;
988 if (!is_static) {
989 _jca->push_oop(next_arg(T_OBJECT));
990 }
991 iterate();
992 assert(_index == args->length(), "arg count mismatch with signature");
993 }
994
995 inline void do_bool() { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); }
996 inline void do_char() { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); }
997 inline void do_short() { if (!is_return_type()) _jca->push_int(next_arg(T_SHORT)->short_field(java_lang_boxing_object::value_offset_in_bytes(T_SHORT))); }
998 inline void do_byte() { if (!is_return_type()) _jca->push_int(next_arg(T_BYTE)->byte_field(java_lang_boxing_object::value_offset_in_bytes(T_BYTE))); }
999 inline void do_int() { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); }
1000
1001 inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); }
1002 inline void do_float() { if (!is_return_type()) _jca->push_float(next_arg(T_FLOAT)->float_field(java_lang_boxing_object::value_offset_in_bytes(T_FLOAT))); }
1003 inline void do_double() { if (!is_return_type()) _jca->push_double(next_arg(T_DOUBLE)->double_field(java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE))); }
1004
1005 inline void do_object() { _jca->push_oop(next_arg(T_OBJECT)); }
1006 inline void do_object(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); }
1007 inline void do_array(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); }
1008 inline void do_void() { }
1009 };
1010
1011 // public Object executeCompiledMethodVarargs(HotSpotCompiledMethod method, Object... args); 969 // public Object executeCompiledMethodVarargs(HotSpotCompiledMethod method, Object... args);
1012 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_executeCompiledMethodVarargs(JNIEnv *env, jobject, jobject method, jobject args) { 970 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_executeCompiledMethodVarargs(JNIEnv *env, jobject, jobject method, jobject args) {
1013 TRACE_graal_3("CompilerToVM::executeCompiledMethod"); 971 TRACE_graal_3("CompilerToVM::executeCompiledMethod");
1014 972
1015 VM_ENTRY_MARK; 973 VM_ENTRY_MARK;
1019 assert(method != NULL, "just checking"); 977 assert(method != NULL, "just checking");
1020 methodHandle mh = getMethodFromHotSpotMethod(HotSpotCompiledMethod::method(method)); 978 methodHandle mh = getMethodFromHotSpotMethod(HotSpotCompiledMethod::method(method));
1021 Symbol* signature = mh->signature(); 979 Symbol* signature = mh->signature();
1022 JavaCallArguments jca; 980 JavaCallArguments jca;
1023 981
1024 JavaArgumentPusher jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); 982 JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static());
1025 JavaValue result(jap.get_ret_type()); 983 JavaValue result(jap.get_ret_type());
1026 984
1027 nmethod* nm = (nmethod*) HotSpotCompiledMethod::nmethod(method); 985 nmethod* nm = (nmethod*) HotSpotCompiledMethod::nmethod(method);
1028 if (nm == NULL || !nm->is_alive()) { 986 if (nm == NULL || !nm->is_alive()) {
1029 THROW_0(vmSymbols::MethodInvalidatedException()); 987 THROW_0(vmSymbols::MethodInvalidatedException());