blob: f1bd4e21123d41d789677235d08488a7514b05ed [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
Brian Carlstromf3eb61f2011-07-23 20:22:26 -07006#include "calling_convention.h"
7#include "globals.h"
8#include "macros.h"
Brian Carlstromdb4d5402011-08-09 12:18:28 -07009#include "mem_map.h"
10#include "scoped_ptr.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
Ian Rogersb033c752011-07-20 12:22:35 -070033 // A poor man's code cache
34 void* AllocateCode(size_t size);
35
Brian Carlstromdb4d5402011-08-09 12:18:28 -070036 // Allocated code
37 scoped_ptr<MemMap> jni_code_;
Ian Rogersb033c752011-07-20 12:22:35 -070038
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_