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 #ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_H_
18 #define ART_RUNTIME_INTERPRETER_INTERPRETER_H_
19 
20 #include "base/locks.h"
21 #include "base/macros.h"
22 #include "dex/dex_file.h"
23 #include "obj_ptr.h"
24 
25 namespace art HIDDEN {
26 namespace mirror {
27 class Object;
28 }  // namespace mirror
29 
30 class ArtMethod;
31 class CodeItemDataAccessor;
32 union JValue;
33 class ShadowFrame;
34 class Thread;
35 enum class DeoptimizationMethodType;
36 
37 namespace interpreter {
38 
39 // Called by ArtMethod::Invoke, shadow frames arguments are taken from the args array.
40 // The optional stay_in_interpreter parameter (false by default) can be used by clients to
41 // explicitly force interpretation in the remaining path that implements method invocation.
42 extern void EnterInterpreterFromInvoke(Thread* self, ArtMethod* method,
43                                        ObjPtr<mirror::Object> receiver,
44                                        uint32_t* args,
45                                        JValue* result,
46                                        bool stay_in_interpreter = false)
47     REQUIRES_SHARED(Locks::mutator_lock_);
48 
49 // 'from_code' denotes whether the deoptimization was explicitly triggered by compiled code.
50 extern void EnterInterpreterFromDeoptimize(Thread* self,
51                                            ShadowFrame* shadow_frame,
52                                            JValue* ret_val,
53                                            bool from_code,
54                                            DeoptimizationMethodType method_type)
55     REQUIRES_SHARED(Locks::mutator_lock_);
56 
57 extern JValue EnterInterpreterFromEntryPoint(Thread* self,
58                                              const CodeItemDataAccessor& accessor,
59                                              ShadowFrame* shadow_frame)
60     REQUIRES_SHARED(Locks::mutator_lock_);
61 
62 void ArtInterpreterToInterpreterBridge(Thread* self,
63                                        const CodeItemDataAccessor& accessor,
64                                        ShadowFrame* shadow_frame,
65                                        JValue* result)
66     REQUIRES_SHARED(Locks::mutator_lock_);
67 
68 // One-time check of assembler constants.
69 void CheckInterpreterAsmConstants();
70 
71 // Returns true if the previous frame has the ForceRetryInstruction bit set. This is required for
72 // ForPopFrame to work correctly since that will cause the java function return with null/0 which
73 // might not be expected by the code being run.
74 bool PrevFrameWillRetry(Thread* self, const ShadowFrame& frame)
75     REQUIRES_SHARED(Locks::mutator_lock_);
76 
77 }  // namespace interpreter
78 
79 }  // namespace art
80 
81 #endif  // ART_RUNTIME_INTERPRETER_INTERPRETER_H_
82