Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
Carl Shapiro | ad107ab | 2011-08-14 15:54:24 -0700 | [diff] [blame] | 2 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 3 | #ifndef ART_SRC_JNI_COMPILER_H_ |
| 4 | #define ART_SRC_JNI_COMPILER_H_ |
| 5 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 6 | #include "constants.h" |
Brian Carlstrom | f3eb61f | 2011-07-23 20:22:26 -0700 | [diff] [blame] | 7 | #include "macros.h" |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 8 | #include "object.h" |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 9 | |
| 10 | namespace art { |
| 11 | |
| 12 | class Assembler; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 13 | class JniCallingConvention; |
| 14 | class ManagedRegister; |
| 15 | class ManagedRuntimeCallingConvention; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 16 | class Method; |
| 17 | |
| 18 | // A JNI compiler generates code that acts as the bridge between managed code |
| 19 | // and native code. |
| 20 | // TODO: move the responsibility of managing memory to somewhere else |
| 21 | class JniCompiler { |
| 22 | public: |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 23 | explicit JniCompiler(InstructionSet insns); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 24 | ~JniCompiler(); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 25 | |
| 26 | void Compile(Method* method); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 27 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 28 | // Stub to perform native method symbol lookup via dlsym |
| 29 | // TODO: remove from JniCompiler |
| 30 | static ByteArray* CreateJniStub(InstructionSet instruction_set); |
| 31 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 32 | private: |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 33 | // Copy a single parameter from the managed to the JNI calling convention |
| 34 | void CopyParameter(Assembler* jni_asm, |
| 35 | ManagedRuntimeCallingConvention* mr_conv, |
| 36 | JniCallingConvention* jni_conv, |
| 37 | size_t frame_size, size_t out_arg_size); |
| 38 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 39 | void SetNativeParameter(Assembler* jni_asm, |
| 40 | JniCallingConvention* jni_conv, |
Shih-wei Liao | 668512a | 2011-09-01 14:18:34 -0700 | [diff] [blame] | 41 | ManagedRegister in_reg); |
| 42 | |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame^] | 43 | // Architecture to generate code for |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 44 | InstructionSet instruction_set_; |
| 45 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 46 | DISALLOW_COPY_AND_ASSIGN(JniCompiler); |
| 47 | }; |
| 48 | |
| 49 | } // namespace art |
| 50 | |
| 51 | #endif // ART_SRC_JNI_COMPILER_H_ |