blob: 25514b9f4a657c893bbc0f7cf52d19be58bd9a1a [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
Ian Rogers2c8f6532011-09-02 17:16:34 -07006#include "constants.h"
Brian Carlstromf3eb61f2011-07-23 20:22:26 -07007#include "macros.h"
Shih-wei Liao31384c52011-09-06 15:27:45 -07008#include "object.h"
Ian Rogersb033c752011-07-20 12:22:35 -07009
10namespace art {
11
12class Assembler;
Ian Rogers2c8f6532011-09-02 17:16:34 -070013class JniCallingConvention;
14class ManagedRegister;
15class ManagedRuntimeCallingConvention;
Ian Rogersb033c752011-07-20 12:22:35 -070016class Method;
17
18// A JNI compiler generates code that acts as the bridge between managed code
19// and native code.
20// TODO: move the responsibility of managing memory to somewhere else
21class JniCompiler {
22 public:
Ian Rogers2c8f6532011-09-02 17:16:34 -070023 explicit JniCompiler(InstructionSet insns);
Ian Rogersb033c752011-07-20 12:22:35 -070024 ~JniCompiler();
Ian Rogers2c8f6532011-09-02 17:16:34 -070025
26 void Compile(Method* method);
Ian Rogersdf20fe02011-07-20 20:34:16 -070027
Ian Rogersb033c752011-07-20 12:22:35 -070028 private:
Ian Rogersdf20fe02011-07-20 20:34:16 -070029 // Copy a single parameter from the managed to the JNI calling convention
30 void CopyParameter(Assembler* jni_asm,
31 ManagedRuntimeCallingConvention* mr_conv,
32 JniCallingConvention* jni_conv,
33 size_t frame_size, size_t out_arg_size);
34
Ian Rogers2c8f6532011-09-02 17:16:34 -070035 void SetNativeParameter(Assembler* jni_asm,
36 JniCallingConvention* jni_conv,
Shih-wei Liao668512a2011-09-01 14:18:34 -070037 ManagedRegister in_reg);
38
Ian Rogers2c8f6532011-09-02 17:16:34 -070039 InstructionSet instruction_set_;
40
Shih-wei Liao31384c52011-09-06 15:27:45 -070041 ByteArray* jni_stub_; // Stub to perform native method symbol lookup
42
Ian Rogersb033c752011-07-20 12:22:35 -070043 DISALLOW_COPY_AND_ASSIGN(JniCompiler);
44};
45
46} // namespace art
47
48#endif // ART_SRC_JNI_COMPILER_H_