Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | // Author: irogers@google.com (Ian Rogers) |
| 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" |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 9 | |
| 10 | namespace art { |
| 11 | |
| 12 | class Assembler; |
| 13 | class Method; |
| 14 | |
| 15 | // A JNI compiler generates code that acts as the bridge between managed code |
| 16 | // and native code. |
| 17 | // TODO: move the responsibility of managing memory to somewhere else |
| 18 | class JniCompiler { |
| 19 | public: |
| 20 | JniCompiler(); |
| 21 | ~JniCompiler(); |
| 22 | void Compile(Assembler* jni_asm, Method* method); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 23 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 24 | private: |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 25 | // Copy a single parameter from the managed to the JNI calling convention |
| 26 | void CopyParameter(Assembler* jni_asm, |
| 27 | ManagedRuntimeCallingConvention* mr_conv, |
| 28 | JniCallingConvention* jni_conv, |
| 29 | size_t frame_size, size_t out_arg_size); |
| 30 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 31 | // A poor man's code cache |
| 32 | void* AllocateCode(size_t size); |
| 33 | |
| 34 | // Base of memory region for allocated code |
| 35 | byte* jni_code_; |
| 36 | |
| 37 | // Allocated code size |
| 38 | size_t jni_code_size_; |
| 39 | |
| 40 | // Pointer to the free space |
| 41 | byte* jni_code_top_; |
| 42 | |
| 43 | DISALLOW_COPY_AND_ASSIGN(JniCompiler); |
| 44 | }; |
| 45 | |
| 46 | } // namespace art |
| 47 | |
| 48 | #endif // ART_SRC_JNI_COMPILER_H_ |