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 | |
Brian Carlstrom | f3eb61f | 2011-07-23 20:22:26 -0700 | [diff] [blame] | 6 | #include "calling_convention.h" |
| 7 | #include "globals.h" |
| 8 | #include "macros.h" |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 9 | #include "mem_map.h" |
| 10 | #include "scoped_ptr.h" |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 11 | |
| 12 | namespace art { |
| 13 | |
| 14 | class Assembler; |
| 15 | class Method; |
| 16 | |
| 17 | // A JNI compiler generates code that acts as the bridge between managed code |
| 18 | // and native code. |
| 19 | // TODO: move the responsibility of managing memory to somewhere else |
| 20 | class JniCompiler { |
| 21 | public: |
| 22 | JniCompiler(); |
| 23 | ~JniCompiler(); |
| 24 | void Compile(Assembler* jni_asm, Method* method); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 25 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 26 | private: |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 27 | // Copy a single parameter from the managed to the JNI calling convention |
| 28 | void CopyParameter(Assembler* jni_asm, |
| 29 | ManagedRuntimeCallingConvention* mr_conv, |
| 30 | JniCallingConvention* jni_conv, |
| 31 | size_t frame_size, size_t out_arg_size); |
| 32 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 33 | // A poor man's code cache |
| 34 | void* AllocateCode(size_t size); |
| 35 | |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 36 | // Allocated code |
| 37 | scoped_ptr<MemMap> jni_code_; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 38 | |
| 39 | // Pointer to the free space |
| 40 | byte* jni_code_top_; |
| 41 | |
| 42 | DISALLOW_COPY_AND_ASSIGN(JniCompiler); |
| 43 | }; |
| 44 | |
| 45 | } // namespace art |
| 46 | |
| 47 | #endif // ART_SRC_JNI_COMPILER_H_ |