Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 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" |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 20 | #include "mirror/art_method-inl.h" |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 21 | #include "mirror/object-inl.h" |
| 22 | #include "object_utils.h" |
| 23 | #include "runtime.h" |
| 24 | #include "stack.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
Dragos Sbirlea | 08bf196 | 2013-08-12 08:53:04 -0700 | [diff] [blame] | 28 | extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh, |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 29 | const DexFile::CodeItem* code_item, |
Ian Rogers | 0f40ac3 | 2013-08-13 22:10:30 -0700 | [diff] [blame] | 30 | ShadowFrame* shadow_frame, JValue* result) { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 31 | mirror::ArtMethod* method = shadow_frame->GetMethod(); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 32 | // Ensure static methods are initialized. |
| 33 | if (method->IsStatic()) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 34 | mirror::Class* declaringClass = method->GetDeclaringClass(); |
| 35 | if (UNLIKELY(!declaringClass->IsInitializing())) { |
Mathieu Chartier | f043de4 | 2013-12-10 14:37:16 -0800 | [diff] [blame] | 36 | self->PushShadowFrame(shadow_frame); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 37 | SirtRef<mirror::Class> sirt_c(self, declaringClass); |
| 38 | if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(sirt_c, true, true))) { |
Mathieu Chartier | f043de4 | 2013-12-10 14:37:16 -0800 | [diff] [blame] | 39 | self->PopShadowFrame(); |
| 40 | DCHECK(self->IsExceptionPending()); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 41 | return; |
| 42 | } |
Mathieu Chartier | f043de4 | 2013-12-10 14:37:16 -0800 | [diff] [blame] | 43 | self->PopShadowFrame(); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 44 | CHECK(sirt_c->IsInitializing()); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 45 | } |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 46 | } |
| 47 | uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 48 | if (kUsePortableCompiler) { |
| 49 | ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); |
| 50 | arg_array.BuildArgArrayFromFrame(shadow_frame, arg_offset); |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame^] | 51 | method->Invoke(self, arg_array.GetArray(), arg_array.GetNumBytes(), result, mh.GetShorty()); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 52 | } else { |
| 53 | method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset), |
| 54 | (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t), |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame^] | 55 | result, mh.GetShorty()); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 56 | } |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } // namespace art |