blob: 05c02f22fa0ef7bbd94203cd35913ac407f01033 [file] [log] [blame]
Ian Rogers848871b2013-08-05 10:56:33 -07001/*
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"
Brian Carlstromea46f952013-07-30 01:26:50 -070020#include "mirror/art_method-inl.h"
Ian Rogers848871b2013-08-05 10:56:33 -070021#include "mirror/object-inl.h"
22#include "object_utils.h"
23#include "runtime.h"
24#include "stack.h"
25
26namespace art {
27
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070028extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers848871b2013-08-05 10:56:33 -070029 const DexFile::CodeItem* code_item,
Ian Rogers0f40ac32013-08-13 22:10:30 -070030 ShadowFrame* shadow_frame, JValue* result) {
Brian Carlstromea46f952013-07-30 01:26:50 -070031 mirror::ArtMethod* method = shadow_frame->GetMethod();
Ian Rogers848871b2013-08-05 10:56:33 -070032 // Ensure static methods are initialized.
33 if (method->IsStatic()) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +020034 mirror::Class* declaringClass = method->GetDeclaringClass();
35 if (UNLIKELY(!declaringClass->IsInitializing())) {
36 if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(declaringClass,
37 true, true))) {
38 DCHECK(Thread::Current()->IsExceptionPending());
39 return;
40 }
41 CHECK(declaringClass->IsInitializing());
42 }
Ian Rogers848871b2013-08-05 10:56:33 -070043 }
44 uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070045#if defined(ART_USE_PORTABLE_COMPILER)
Ian Rogers848871b2013-08-05 10:56:33 -070046 ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength());
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070047 arg_array.BuildArgArrayFromFrame(shadow_frame, arg_offset);
Ian Rogers848871b2013-08-05 10:56:33 -070048 method->Invoke(self, arg_array.GetArray(), arg_array.GetNumBytes(), result, mh.GetShorty()[0]);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070049#else
50 method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset),
Sebastien Hertzc61124b2013-09-10 11:44:19 +020051 (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t),
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070052 result, mh.GetShorty()[0]);
53#endif
Ian Rogers848871b2013-08-05 10:56:33 -070054}
55
56} // namespace art