blob: d78404bb90e2838f636821f5ca40ee4d53b496ac [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
Brian Carlstrom16192862011-09-12 17:50:06 -070028 // Stub to perform native method symbol lookup via dlsym
29 // TODO: remove from JniCompiler
30 static ByteArray* CreateJniStub(InstructionSet instruction_set);
31
Ian Rogersb033c752011-07-20 12:22:35 -070032 private:
Ian Rogersdf20fe02011-07-20 20:34:16 -070033 // Copy a single parameter from the managed to the JNI calling convention
34 void CopyParameter(Assembler* jni_asm,
35 ManagedRuntimeCallingConvention* mr_conv,
36 JniCallingConvention* jni_conv,
37 size_t frame_size, size_t out_arg_size);
38
Ian Rogers2c8f6532011-09-02 17:16:34 -070039 void SetNativeParameter(Assembler* jni_asm,
40 JniCallingConvention* jni_conv,
Shih-wei Liao668512a2011-09-01 14:18:34 -070041 ManagedRegister in_reg);
42
Ian Rogersbdb03912011-09-14 00:55:44 -070043 // Architecture to generate code for
Ian Rogers2c8f6532011-09-02 17:16:34 -070044 InstructionSet instruction_set_;
45
Ian Rogersb033c752011-07-20 12:22:35 -070046 DISALLOW_COPY_AND_ASSIGN(JniCompiler);
47};
48
49} // namespace art
50
51#endif // ART_SRC_JNI_COMPILER_H_