blob: 3c0d8b48b0cb8a48a0f7f689d0d583db861c1530 [file] [log] [blame]
Ian Rogersb033c752011-07-20 12:22:35 -07001// Copyright 2011 Google Inc. All Rights Reserved.
Carl Shapiroad107ab2011-08-14 15:54:24 -07002
Ian Rogersb033c752011-07-20 12:22:35 -07003#ifndef ART_SRC_JNI_COMPILER_H_
4#define ART_SRC_JNI_COMPILER_H_
5
Elliott Hughes90a33692011-08-30 13:27:07 -07006#include "UniquePtr.h"
Brian Carlstromf3eb61f2011-07-23 20:22:26 -07007#include "calling_convention.h"
8#include "globals.h"
9#include "macros.h"
Brian Carlstromdb4d5402011-08-09 12:18:28 -070010#include "mem_map.h"
Ian Rogersb033c752011-07-20 12:22:35 -070011
12namespace art {
13
14class Assembler;
15class 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
20class JniCompiler {
21 public:
22 JniCompiler();
23 ~JniCompiler();
24 void Compile(Assembler* jni_asm, Method* method);
Ian Rogersdf20fe02011-07-20 20:34:16 -070025
Ian Rogersb033c752011-07-20 12:22:35 -070026 private:
Ian Rogersdf20fe02011-07-20 20:34:16 -070027 // 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
Shih-wei Liao668512a2011-09-01 14:18:34 -070033 void SetNativeParameter(Assembler *jni_asm,
34 JniCallingConvention *jni_conv,
35 ManagedRegister in_reg);
36
Ian Rogersb033c752011-07-20 12:22:35 -070037 // A poor man's code cache
38 void* AllocateCode(size_t size);
39
Brian Carlstromdb4d5402011-08-09 12:18:28 -070040 // Allocated code
Elliott Hughes90a33692011-08-30 13:27:07 -070041 UniquePtr<MemMap> jni_code_;
Ian Rogersb033c752011-07-20 12:22:35 -070042
43 // Pointer to the free space
44 byte* jni_code_top_;
45
46 DISALLOW_COPY_AND_ASSIGN(JniCompiler);
47};
48
49} // namespace art
50
51#endif // ART_SRC_JNI_COMPILER_H_