blob: f6e8cd444cab78eb067d945b7fc4a4ff223ad458 [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 Carlstrom3320cf42011-10-04 14:58:28 -07006#include "compiled_method.h"
Ian Rogers2c8f6532011-09-02 17:16:34 -07007#include "constants.h"
Brian Carlstromf3eb61f2011-07-23 20:22:26 -07008#include "macros.h"
Ian Rogers169c9a72011-11-13 20:13:17 -08009#include "thread.h"
Ian Rogersb033c752011-07-20 12:22:35 -070010
11namespace art {
12
13class Assembler;
Ian Rogers169c9a72011-11-13 20:13:17 -080014class ClassLoader;
Brian Carlstrom3320cf42011-10-04 14:58:28 -070015class Compiler;
Ian Rogers169c9a72011-11-13 20:13:17 -080016class DexFile;
Ian Rogers2c8f6532011-09-02 17:16:34 -070017class JniCallingConvention;
18class ManagedRegister;
19class ManagedRuntimeCallingConvention;
Ian Rogersb033c752011-07-20 12:22:35 -070020class Method;
21
22// A JNI compiler generates code that acts as the bridge between managed code
23// and native code.
24// TODO: move the responsibility of managing memory to somewhere else
25class JniCompiler {
26 public:
Brian Carlstrom3320cf42011-10-04 14:58:28 -070027 explicit JniCompiler(InstructionSet instruction_set);
Ian Rogersb033c752011-07-20 12:22:35 -070028 ~JniCompiler();
Ian Rogers2c8f6532011-09-02 17:16:34 -070029
Ian Rogers169c9a72011-11-13 20:13:17 -080030 CompiledMethod* Compile(uint32_t access_flags, uint32_t method_idx,
31 const ClassLoader* class_loader, const DexFile& dex_file);
Brian Carlstrom16192862011-09-12 17:50:06 -070032
Ian Rogersb033c752011-07-20 12:22:35 -070033 private:
Ian Rogersdf20fe02011-07-20 20:34:16 -070034 // Copy a single parameter from the managed to the JNI calling convention
35 void CopyParameter(Assembler* jni_asm,
36 ManagedRuntimeCallingConvention* mr_conv,
37 JniCallingConvention* jni_conv,
38 size_t frame_size, size_t out_arg_size);
39
Ian Rogers2c8f6532011-09-02 17:16:34 -070040 void SetNativeParameter(Assembler* jni_asm,
41 JniCallingConvention* jni_conv,
Shih-wei Liao668512a2011-09-01 14:18:34 -070042 ManagedRegister in_reg);
43
Ian Rogerse5de95b2011-09-18 20:31:38 -070044 void ChangeThreadState(Assembler* jni_asm, Thread::State new_state,
45 ManagedRegister scratch, ManagedRegister return_reg,
46 FrameOffset return_save_location,
47 size_t return_size);
48
Ian Rogersbdb03912011-09-14 00:55:44 -070049 // Architecture to generate code for
Ian Rogers2c8f6532011-09-02 17:16:34 -070050 InstructionSet instruction_set_;
51
Ian Rogersb033c752011-07-20 12:22:35 -070052 DISALLOW_COPY_AND_ASSIGN(JniCompiler);
53};
54
55} // namespace art
56
57#endif // ART_SRC_JNI_COMPILER_H_