1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "class_linker.h" 18 #include "interpreter/interpreter.h" 19 #include "invoke_arg_array_builder.h" 20 #include "mirror/art_method-inl.h" 21 #include "mirror/object-inl.h" 22 #include "object_utils.h" 23 #include "runtime.h" 24 #include "stack.h" 25 26 namespace art { 27 28 extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh, 29 const DexFile::CodeItem* code_item, 30 ShadowFrame* shadow_frame, JValue* result) { 31 mirror::ArtMethod* method = shadow_frame->GetMethod(); 32 // Ensure static methods are initialized. 33 if (method->IsStatic()) { 34 Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); 35 } 36 uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_; 37 #if defined(ART_USE_PORTABLE_COMPILER) 38 ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); 39 arg_array.BuildArgArrayFromFrame(shadow_frame, arg_offset); 40 method->Invoke(self, arg_array.GetArray(), arg_array.GetNumBytes(), result, mh.GetShorty()[0]); 41 #else 42 method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset), 43 (shadow_frame->NumberOfVRegs() - arg_offset) * 4, 44 result, mh.GetShorty()[0]); 45 #endif 46 } 47 48 } // namespace art 49