blob: 48666aa2da3544da35709fd3306df378d6a315d9 [file] [log] [blame]
Ian Rogersb033c752011-07-20 12:22:35 -07001// 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 Carlstromf3eb61f2011-07-23 20:22:26 -07006#include "calling_convention.h"
7#include "globals.h"
8#include "macros.h"
Ian Rogersb033c752011-07-20 12:22:35 -07009
10namespace art {
11
12class Assembler;
13class 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
18class JniCompiler {
19 public:
20 JniCompiler();
21 ~JniCompiler();
22 void Compile(Assembler* jni_asm, Method* method);
Ian Rogersdf20fe02011-07-20 20:34:16 -070023
Ian Rogersb033c752011-07-20 12:22:35 -070024 private:
Ian Rogersdf20fe02011-07-20 20:34:16 -070025 // 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 Rogersb033c752011-07-20 12:22:35 -070031 // 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_