• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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_MIRROR_EMULATED_STACK_FRAME_H_
18 #define ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_
19 
20 #include "base/utils.h"
21 #include "base/macros.h"
22 #include "dex/dex_instruction.h"
23 #include "handle.h"
24 #include "object.h"
25 #include "stack.h"
26 
27 namespace art HIDDEN {
28 
29 struct EmulatedStackFrameOffsets;
30 
31 namespace mirror {
32 
33 class MethodType;
34 
35 // C++ mirror of dalvik.system.EmulatedStackFrame
36 class MANAGED EmulatedStackFrame : public Object {
37  public:
38   MIRROR_CLASS("Ldalvik/system/EmulatedStackFrame;");
39 
40   // Creates an emulated stack frame whose type is |frame_type| from
41   // a shadow frame.
42   static ObjPtr<mirror::EmulatedStackFrame> CreateFromShadowFrameAndArgs(
43       Thread* self,
44       Handle<mirror::MethodType> args_type,
45       Handle<mirror::MethodType> frame_type,
46       const ShadowFrame& caller_frame,
47       const InstructionOperands* const operands) REQUIRES_SHARED(Locks::mutator_lock_);
48 
49   // Writes the contents of this emulated stack frame to the |callee_frame|
50   // whose type is |callee_type|, starting at |first_dest_reg|.
51   void WriteToShadowFrame(
52       Thread* self,
53       Handle<mirror::MethodType> callee_type,
54       const uint32_t first_dest_reg,
55       ShadowFrame* callee_frame) REQUIRES_SHARED(Locks::mutator_lock_);
56 
57   // Sets |value| to the return value written to this emulated stack frame (if any).
58   void GetReturnValue(Thread* self, JValue* value) REQUIRES_SHARED(Locks::mutator_lock_);
59 
60   // Sets the return value slot of this emulated stack frame to |value|.
61   void SetReturnValue(Thread* self, const JValue& value) REQUIRES_SHARED(Locks::mutator_lock_);
62 
63   ObjPtr<mirror::MethodType> GetType() REQUIRES_SHARED(Locks::mutator_lock_);
64 
65   ObjPtr<mirror::Object> GetReceiver() REQUIRES_SHARED(Locks::mutator_lock_);
66 
67  private:
68   ObjPtr<mirror::ObjectArray<mirror::Object>> GetReferences() REQUIRES_SHARED(Locks::mutator_lock_);
69 
70   ObjPtr<mirror::ByteArray> GetStackFrame() REQUIRES_SHARED(Locks::mutator_lock_);
71 
TypeOffset()72   static MemberOffset TypeOffset() {
73     return MemberOffset(OFFSETOF_MEMBER(EmulatedStackFrame, type_));
74   }
75 
ReferencesOffset()76   static MemberOffset ReferencesOffset() {
77     return MemberOffset(OFFSETOF_MEMBER(EmulatedStackFrame, references_));
78   }
79 
StackFrameOffset()80   static MemberOffset StackFrameOffset() {
81     return MemberOffset(OFFSETOF_MEMBER(EmulatedStackFrame, stack_frame_));
82   }
83 
84   HeapReference<mirror::ObjectArray<mirror::Object>> references_;
85   HeapReference<mirror::ByteArray> stack_frame_;
86   HeapReference<mirror::MethodType> type_;
87 
88   friend struct art::EmulatedStackFrameOffsets;  // for verifying offset information
89   DISALLOW_IMPLICIT_CONSTRUCTORS(EmulatedStackFrame);
90 };
91 
92 }  // namespace mirror
93 }  // namespace art
94 
95 #endif  // ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_
96