PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 0ms

/JIT/opcodes/call.h

http://unladen-swallow.googlecode.com/
C++ Header | 57 lines | 35 code | 13 blank | 9 comment | 0 complexity | c7cfbe7862923ebdef326f0c38cdfa76 MD5 | raw file
 1// -*- C++ -*-
 2#ifndef OPCODE_CALL_H_
 3#define OPCODE_CALL_H_
 4
 5#ifndef __cplusplus
 6#error This header expects to be included only in C++ source
 7#endif
 8
 9#include "llvm/Support/IRBuilder.h"
10#include "llvm/Support/TargetFolder.h"
11
12namespace py {
13
14class LlvmFunctionBuilder;
15class LlvmFunctionState;
16
17// This class contains the implementation of all CALL_FUNCTION* opcodes.
18class OpcodeCall
19{
20public:
21    OpcodeCall(LlvmFunctionBuilder *fbuilder);
22
23    void CALL_FUNCTION(int num_args);
24    void CALL_METHOD(int num_args);
25    void CALL_FUNCTION_VAR(int num_args);
26    void CALL_FUNCTION_KW(int num_args);
27    void CALL_FUNCTION_VAR_KW(int num_args);
28
29private:
30    typedef llvm::IRBuilder<true, llvm::TargetFolder> BuilderT;
31
32    // Helper method for CALL_FUNCTION_(VAR|KW|VAR_KW); calls
33    // _PyEval_CallFunctionVarKw() with the given flags and the current
34    // stack pointer.
35    void CallVarKwFunction(int num_args, int call_flag);
36
37    // CALL_FUNCTION comes in two flavors: CALL_FUNCTION_safe is guaranteed to
38    // work, while CALL_FUNCTION_fast takes advantage of data gathered while
39    // running through the eval loop to omit as much flexibility as possible.
40    void CALL_FUNCTION_safe(int num_args);
41    bool CALL_FUNCTION_fast(int num_args);
42
43    // Specialized version of CALL_FUNCTION for len() on certain types.
44    void CALL_FUNCTION_fast_len(llvm::Value *actual_func,
45                                llvm::Value *stack_pointer,
46                                llvm::BasicBlock *invalid_assumptions,
47                                const char *function_name);
48
49    LlvmFunctionBuilder *fbuilder_;
50    LlvmFunctionState *state_;
51    BuilderT &builder_;
52    PyGlobalLlvmData *const llvm_data_;
53};
54
55}
56
57#endif /* OPCODE_CALL_H_ */