Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 487 lines (439 sloc) 15.124 kb
cfd7b4d added licensing information on the new files
Laurent Sansonetti authored
1 /*
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
2 * MacRuby Compiler.
cfd7b4d added licensing information on the new files
Laurent Sansonetti authored
3 *
4 * This file is covered by the Ruby license. See COPYING for more details.
5 *
4aca101 @drernie Added 2010 Copyrights
drernie authored
6 * Copyright (C) 2008-2010, Apple Inc. All rights reserved.
cfd7b4d added licensing information on the new files
Laurent Sansonetti authored
7 */
8
cb65416 the great schism, part I
Laurent Sansonetti authored
9 #ifndef __COMPILER_H_
10 #define __COMPILER_H_
11
12 // For the dispatcher.
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored
13 #define DISPATCH_VCALL 0x1 // no receiver, no argument
14 #define DISPATCH_FCALL 0x2 // no receiver, one or more arguments
15 #define DISPATCH_SUPER 0x4 // super call
16 #define DISPATCH_SPLAT 0x8 // has splat
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
17 #define SPLAT_ARG_FOLLOWS 0xdeadbeef
cb65416 the great schism, part I
Laurent Sansonetti authored
18
370e385 get rid of bad allocas, disable frame pointer elimination, simplified co...
Laurent Sansonetti authored
19 // For const lookup.
20 #define CONST_LOOKUP_LEXICAL 1
21 #define CONST_LOOKUP_DYNAMIC_CLASS 2
22
cb65416 the great schism, part I
Laurent Sansonetti authored
23 // For defined?
24 #define DEFINED_IVAR 1
25 #define DEFINED_GVAR 2
26 #define DEFINED_CVAR 3
27 #define DEFINED_CONST 4
28 #define DEFINED_LCONST 5
29 #define DEFINED_SUPER 6
30 #define DEFINED_METHOD 7
31
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
32 #if defined(__cplusplus)
33
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
34 class RoxorInterpreter;
35
cb65416 the great schism, part I
Laurent Sansonetti authored
36 class RoxorCompiler {
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
37 friend class RoxorInterpreter;
38
cb65416 the great schism, part I
Laurent Sansonetti authored
39 public:
40 static llvm::Module *module;
41 static RoxorCompiler *shared;
42
cf73725 experimental debugger
Laurent Sansonetti authored
43 RoxorCompiler(bool debug_mode);
cb65416 the great schism, part I
Laurent Sansonetti authored
44 virtual ~RoxorCompiler(void) { }
45
0f14388 emit dwarf metadata at compilation time and use it to establish backtrac...
Laurent Sansonetti authored
46 void set_fname(const char *_fname);
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
47
cb65416 the great schism, part I
Laurent Sansonetti authored
48 Value *compile_node(NODE *node);
49
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
50 virtual Function *compile_main_function(NODE *node,
51 bool *can_be_interpreted);
cb65416 the great schism, part I
Laurent Sansonetti authored
52 Function *compile_read_attr(ID name);
53 Function *compile_write_attr(ID name);
9fab1ac fixed variadic functions/methods calls
Laurent Sansonetti authored
54 Function *compile_stub(const char *types, bool variadic, int min_argc,
55 bool is_objc);
485e435 Allow methods/blocks with 12+ arguments
Thibault Martin-Lagardette authored
56 Function *compile_long_arity_stub(int argc, bool is_block);
cb65416 the great schism, part I
Laurent Sansonetti authored
57 Function *compile_bs_struct_new(rb_vm_bs_boxed_t *bs_boxed);
58 Function *compile_bs_struct_writer(rb_vm_bs_boxed_t *bs_boxed,
59 int field);
60 Function *compile_ffi_function(void *stub, void *imp, int argc);
61 Function *compile_to_rval_convertor(const char *type);
62 Function *compile_to_ocval_convertor(const char *type);
c1c347f AOT compiler: now supporting objc stubs and super dispatch
Laurent Sansonetti authored
63 Function *compile_objc_stub(Function *ruby_func, IMP ruby_imp,
64 const rb_vm_arity_t &arity, const char *types);
208a965 a quick implementation for #define_method (not yet 100% complete)
Laurent Sansonetti authored
65 Function *compile_block_caller(rb_vm_block_t *block);
4b7c757 cleaning a bit public headers, added support for methods defined for the...
Laurent Sansonetti authored
66 Function *compile_mri_stub(void *imp, const int arity);
cb65416 the great schism, part I
Laurent Sansonetti authored
67
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
68 void inline_function_calls(Function *f);
69
cb65416 the great schism, part I
Laurent Sansonetti authored
70 const Type *convert_type(const char *type);
71
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
72 bool is_inside_eval(void) { return inside_eval; }
73 void set_inside_eval(bool flag) { inside_eval = flag; }
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
74 bool is_dynamic_class(void) { return dynamic_class; }
75 void set_dynamic_class(bool flag) { dynamic_class = flag; }
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
76
cb65416 the great schism, part I
Laurent Sansonetti authored
77 protected:
0f14388 emit dwarf metadata at compilation time and use it to establish backtrac...
Laurent Sansonetti authored
78 DIFactory *debug_info;
79 DICompileUnit debug_compile_unit;
80 DISubprogram debug_subprogram;
81
cf73725 experimental debugger
Laurent Sansonetti authored
82 bool debug_mode;
cb65416 the great schism, part I
Laurent Sansonetti authored
83 const char *fname;
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
84 bool inside_eval;
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
85 bool should_interpret;
86 bool can_interpret;
cb65416 the great schism, part I
Laurent Sansonetti authored
87
88 std::map<ID, Value *> lvars;
89 std::vector<ID> dvars;
8c55086 better ivar slot system for RubyObject + misc fixes/cleanup
Laurent Sansonetti authored
90 std::map<ID, void *> ivars_slots_cache;
cb65416 the great schism, part I
Laurent Sansonetti authored
91 std::map<std::string, GlobalVariable *> static_strings;
e379686 some work on unicode support (still in progress)
Laurent Sansonetti authored
92 std::map<CFHashCode, GlobalVariable *> static_ustrings;
cb65416 the great schism, part I
Laurent Sansonetti authored
93
94 #if ROXOR_COMPILER_DEBUG
95 int level;
96 # define DEBUG_LEVEL_INC() (level++)
97 # define DEBUG_LEVEL_DEC() (level--)
98 #else
99 # define DEBUG_LEVEL_INC()
100 # define DEBUG_LEVEL_DEC()
101 #endif
102
2541db3 added preliminary support for backtracing/symbolication
Laurent Sansonetti authored
103 unsigned int current_line;
cb65416 the great schism, part I
Laurent Sansonetti authored
104 BasicBlock *bb;
105 BasicBlock *entry_bb;
106 ID current_mid;
164ca93 fixed super within a method that has a splat argument
Laurent Sansonetti authored
107 rb_vm_arity_t current_arity;
cb65416 the great schism, part I
Laurent Sansonetti authored
108 bool current_instance_method;
109 ID self_id;
110 Value *current_self;
111 bool current_block;
1961daa better fix than last one
Laurent Sansonetti authored
112 bool current_block_chain;
cb65416 the great schism, part I
Laurent Sansonetti authored
113 Value *current_var_uses;
114 Value *running_block;
cc6f8a9 fixed a bug in super without argument, it should pass the method's &bloc...
Laurent Sansonetti authored
115 Value *current_block_arg;
cb65416 the great schism, part I
Laurent Sansonetti authored
116 BasicBlock *begin_bb;
63c77f8 @vincentisambart now rescues in rescues should work properly in most cases
vincentisambart authored
117 // block used in an invoke when an exception occurs
118 BasicBlock *rescue_invoke_bb;
119 // block to return to in a rescue if an exception is not handled
120 BasicBlock *rescue_rethrow_bb;
cb65416 the great schism, part I
Laurent Sansonetti authored
121 BasicBlock *ensure_bb;
122 bool current_rescue;
123 NODE *current_block_node;
124 Function *current_block_func;
1e86229 fixed ZSUPER compilation inside blocks
Laurent Sansonetti authored
125 Function *current_non_block_func;
cb65416 the great schism, part I
Laurent Sansonetti authored
126 GlobalVariable *current_opened_class;
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
127 bool dynamic_class;
cb65416 the great schism, part I
Laurent Sansonetti authored
128 bool current_module;
129 BasicBlock *current_loop_begin_bb;
130 BasicBlock *current_loop_body_bb;
131 BasicBlock *current_loop_end_bb;
513ee74 @vincentisambart Fixed the return value of while/until loops
vincentisambart authored
132 PHINode *current_loop_exit_val;
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
133 int return_from_block;
134 int return_from_block_ids;
5d7a33f @vincentisambart when there are multiple returns in an ensure,
vincentisambart authored
135 PHINode *ensure_pn;
13f5368 fixed a bunch of super-dispatch bugs
Laurent Sansonetti authored
136 bool block_declaration;
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored
137 AllocaInst *dispatch_argv;
cb65416 the great schism, part I
Laurent Sansonetti authored
138
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored
139 Function *dispatchFunc;
38456a4 most fast ops in place
Laurent Sansonetti authored
140 Function *fastPlusFunc;
141 Function *fastMinusFunc;
142 Function *fastMultFunc;
143 Function *fastDivFunc;
144 Function *fastLtFunc;
145 Function *fastLeFunc;
146 Function *fastGtFunc;
147 Function *fastGeFunc;
944d624 optimize #== and #!= for non fixnum/float types
Laurent Sansonetti authored
148 Function *fastEqFunc;
149 Function *fastNeqFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
150 Function *fastEqqFunc;
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
151 Function *fastArefFunc;
152 Function *fastAsetFunc;
153 Function *fastShiftFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
154 Function *whenSplatFunc;
155 Function *prepareBlockFunc;
156 Function *pushBindingFunc;
157 Function *getBlockFunc;
158 Function *currentBlockObjectFunc;
159 Function *getConstFunc;
160 Function *setConstFunc;
161 Function *prepareMethodFunc;
162 Function *singletonClassFunc;
163 Function *defineClassFunc;
164 Function *prepareIvarSlotFunc;
165 Function *getIvarFunc;
166 Function *setIvarFunc;
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
167 Function *willChangeValueFunc;
168 Function *didChangeValueFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
169 Function *definedFunc;
170 Function *undefFunc;
171 Function *aliasFunc;
172 Function *valiasFunc;
173 Function *newHashFunc;
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
174 Function *storeHashFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
175 Function *toAFunc;
176 Function *toAryFunc;
177 Function *catArrayFunc;
178 Function *dupArrayFunc;
179 Function *newArrayFunc;
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
180 Function *asetArrayFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
181 Function *newStructFunc;
182 Function *newOpaqueFunc;
ff75d60 added support for overwriting an ObjC method that accepts a pointer
Laurent Sansonetti authored
183 Function *newPointerFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
184 Function *getStructFieldsFunc;
185 Function *getOpaqueDataFunc;
186 Function *getPointerPtrFunc;
d1bb30d added simple compiler support for bit fields and C-style arrays, improve...
Laurent Sansonetti authored
187 Function *xmallocFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
188 Function *checkArityFunc;
189 Function *setStructFunc;
190 Function *newRangeFunc;
191 Function *newRegexpFunc;
192 Function *strInternFunc;
193 Function *keepVarsFunc;
194 Function *masgnGetElemBeforeSplatFunc;
195 Function *masgnGetElemAfterSplatFunc;
196 Function *masgnGetSplatFunc;
197 Function *newStringFunc;
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
198 Function *newString2Func;
199 Function *newString3Func;
cb65416 the great schism, part I
Laurent Sansonetti authored
200 Function *yieldFunc;
7da28cb make sure break makes yield return from its scope
Laurent Sansonetti authored
201 Function *getBrokenFunc;
208a965 a quick implementation for #define_method (not yet 100% complete)
Laurent Sansonetti authored
202 Function *blockEvalFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
203 Function *gvarSetFunc;
204 Function *gvarGetFunc;
205 Function *cvarSetFunc;
206 Function *cvarGetFunc;
207 Function *currentExceptionFunc;
208 Function *popExceptionFunc;
209 Function *getSpecialFunc;
210 Function *breakFunc;
6c5b476 a new implementation for return-from-block which uses an exception inste...
Laurent Sansonetti authored
211 Function *returnFromBlockFunc;
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
212 Function *returnedFromBlockFunc;
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
213 Function *checkReturnFromBlockFunc;
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
214 Function *setHasEnsureFunc;
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
215 Function *setScopeFunc;
216 Function *setCurrentClassFunc;
cf73725 experimental debugger
Laurent Sansonetti authored
217 Function *debugTrapFunc;
c437b62 - Adds the flip-flop operator (fixes #548)
Thibault Martin-Lagardette authored
218 Function *getFFStateFunc;
219 Function *setFFStateFunc;
945dba1 moving more primitives to the kernel
Laurent Sansonetti authored
220 Function *releaseOwnershipFunc;
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
221 Function *ocvalToRvalFunc;
222 Function *charToRvalFunc;
223 Function *ucharToRvalFunc;
224 Function *shortToRvalFunc;
225 Function *ushortToRvalFunc;
226 Function *intToRvalFunc;
227 Function *uintToRvalFunc;
228 Function *longToRvalFunc;
229 Function *ulongToRvalFunc;
230 Function *longLongToRvalFunc;
231 Function *ulongLongToRvalFunc;
232 Function *floatToRvalFunc;
233 Function *doubleToRvalFunc;
234 Function *selToRvalFunc;
235 Function *charPtrToRvalFunc;
236 Function *rvalToOcvalFunc;
237 Function *rvalToBoolFunc;
238 Function *rvalToCharFunc;
239 Function *rvalToUcharFunc;
240 Function *rvalToShortFunc;
241 Function *rvalToUshortFunc;
242 Function *rvalToIntFunc;
243 Function *rvalToUintFunc;
244 Function *rvalToLongFunc;
245 Function *rvalToUlongFunc;
246 Function *rvalToLongLongFunc;
247 Function *rvalToUlongLongFunc;
248 Function *rvalToFloatFunc;
249 Function *rvalToDoubleFunc;
250 Function *rvalToSelFunc;
251 Function *rvalToCharPtrFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
252
253 Constant *zeroVal;
254 Constant *oneVal;
255 Constant *twoVal;
01528a7 floating point arithmetic optimization: Float objects are now immediate ...
Laurent Sansonetti authored
256 Constant *threeVal;
cb65416 the great schism, part I
Laurent Sansonetti authored
257 Constant *nilVal;
258 Constant *trueVal;
259 Constant *falseVal;
260 Constant *undefVal;
261 Constant *splatArgFollowsVal;
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
262 Constant *defaultScope;
263 Constant *publicScope;
bb0b28c moving to LLVM r82747
Laurent Sansonetti authored
264
265 const Type *VoidTy;
266 const Type *Int1Ty;
267 const Type *Int8Ty;
268 const Type *Int16Ty;
269 const Type *Int32Ty;
270 const Type *Int64Ty;
271 const Type *FloatTy;
272 const Type *DoubleTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
273 const Type *RubyObjTy;
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
274 const PointerType *RubyObjPtrTy;
275 const PointerType *RubyObjPtrPtrTy;
276 const PointerType *PtrTy;
277 const PointerType *PtrPtrTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
278 const Type *IntTy;
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
279 const PointerType *Int32PtrTy;
d1bb30d added simple compiler support for bit fields and C-style arrays, improve...
Laurent Sansonetti authored
280 const Type *BitTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
281
fa57162 follow LLVM ToT
Laurent Sansonetti authored
282 unsigned dbg_mdkind;
283
cb65416 the great schism, part I
Laurent Sansonetti authored
284 void compile_node_error(const char *msg, NODE *node);
285
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
286 Function *
287 get_function(const char *name) {
288 Function *f = module->getFunction(name);
289 if (f == NULL) {
290 printf("function %s cannot be found!\n", name);
291 abort();
292 }
293 return f;
294 }
295
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
296 virtual Constant *
297 compile_const_pointer(void *ptr, const PointerType *type=NULL) {
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
298 if (type == NULL) {
299 type = PtrTy;
300 }
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
301 if (ptr == NULL) {
302 return ConstantPointerNull::get(type);
303 }
304 else {
305 Constant *ptrint = ConstantInt::get(IntTy, (long)ptr);
306 return ConstantExpr::getIntToPtr(ptrint, type);
307 }
cb65416 the great schism, part I
Laurent Sansonetti authored
308 }
309
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
310 Constant *
311 compile_const_pointer_to_pointer(void *ptr) {
312 return compile_const_pointer(ptr, PtrPtrTy);
cb65416 the great schism, part I
Laurent Sansonetti authored
313 }
314
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
315 bool should_inline_function(Function *f);
316
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
317 Value *compile_node0(NODE *node);
1e86229 fixed ZSUPER compilation inside blocks
Laurent Sansonetti authored
318 Function *compile_scope(NODE *node);
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored
319 Value *compile_call(NODE *node);
320 Value *compile_yield(NODE *node);
fb086cf reduce usage of std::vector
Laurent Sansonetti authored
321 Instruction *compile_protected_call(Value *imp, Value **args_begin,
322 Value **args_end);
8e4c2c7 moving the dispatcher bits into the kernel + misc fixes/cleanup
Laurent Sansonetti authored
323 Instruction *compile_protected_call(Value *imp, std::vector<Value *>
324 &params);
325 Value *recompile_dispatch_argv(std::vector<Value *> &params, int idx);
cb65416 the great schism, part I
Laurent Sansonetti authored
326 void compile_dispatch_arguments(NODE *args,
327 std::vector<Value *> &arguments, int *pargc);
328 Function::ArgumentListType::iterator compile_optional_arguments(
329 Function::ArgumentListType::iterator iter, NODE *node);
330 void compile_boolean_test(Value *condVal, BasicBlock *ifTrueBB,
331 BasicBlock *ifFalseBB);
332 void compile_when_arguments(NODE *args, Value *comparedToVal,
333 BasicBlock *thenBB);
334 void compile_single_when_argument(NODE *arg, Value *comparedToVal,
335 BasicBlock *thenBB);
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
336 void compile_method_definition(NODE *node);
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
337 virtual void compile_prepare_method(Value *classVal, Value *sel,
338 bool singleton, Function *new_function, rb_vm_arity_t &arity,
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
339 NODE *body);
cb65416 the great schism, part I
Laurent Sansonetti authored
340 Value *compile_dispatch_call(std::vector<Value *> &params);
341 Value *compile_when_splat(Value *comparedToVal, Value *splatVal);
342 Value *compile_attribute_assign(NODE *node, Value *extra_val);
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
343 virtual Value *compile_prepare_block_args(Function *func, int *flags);
945dba1 moving more primitives to the kernel
Laurent Sansonetti authored
344 Value *compile_prepare_block(void);
345 Value *compile_block(NODE *node);
cc6f8a9 fixed a bug in super without argument, it should pass the method's &bloc...
Laurent Sansonetti authored
346 Value *compile_block_get(Value *block_object);
cb65416 the great schism, part I
Laurent Sansonetti authored
347 Value *compile_binding(void);
348 Value *compile_optimized_dispatch_call(SEL sel, int argc,
349 std::vector<Value *> &params);
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
350 Value *compile_lvar_assignment(ID vid, Value *val);
351 Value *compile_dvar_assignment(ID vid, Value *val);
352 Value *compile_lvar_get(ID vid);
cb65416 the great schism, part I
Laurent Sansonetti authored
353 Value *compile_ivar_assignment(ID vid, Value *val);
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
354 Value *compile_ivar_get(ID vid);
cb65416 the great schism, part I
Laurent Sansonetti authored
355 Value *compile_cvar_assignment(ID vid, Value *val);
eeb7a10 added support for @@foo||=42, a lot of changes for a very stupid functio...
Laurent Sansonetti authored
356 Value *compile_cvar_get(ID vid, bool check);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
357 Value *compile_gvar_assignment(NODE *node, Value *val);
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
358 Value *compile_gvar_get(NODE *node);
cb65416 the great schism, part I
Laurent Sansonetti authored
359 Value *compile_constant_declaration(NODE *node, Value *val);
360 Value *compile_multiple_assignment(NODE *node, Value *val);
361 void compile_multiple_assignment_element(NODE *node, Value *val);
362 Value *compile_current_class(void);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
363 virtual Value *compile_nsobject(void);
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
364 virtual Value *compile_standarderror(void);
e037cf2 fix a const lookup bug inside Foo::Bar modules
Laurent Sansonetti authored
365 Value *compile_class_path(NODE *node, int *flags);
cb65416 the great schism, part I
Laurent Sansonetti authored
366 Value *compile_const(ID id, Value *outer);
367 Value *compile_singleton_class(Value *obj);
368 Value *compile_defined_expression(NODE *node);
369 Value *compile_dstr(NODE *node);
370 Value *compile_dvar_slot(ID name);
371 void compile_break_val(Value *val);
e8d79c7 @vincentisambart a return in an ensure should now work properly
vincentisambart authored
372 void compile_simple_return(Value *val);
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
373 Value *compile_set_has_ensure(Value *val);
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
374 void compile_return_from_block(Value *val, int id);
375 void compile_return_from_block_handler(int id);
cb65416 the great schism, part I
Laurent Sansonetti authored
376 Value *compile_jump(NODE *node);
377 virtual Value *compile_ccache(ID id);
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
378 virtual Value *compile_sel(SEL sel, bool add_to_bb=true) {
379 return compile_const_pointer(sel, PtrTy);
cb65416 the great schism, part I
Laurent Sansonetti authored
380 }
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
381 virtual Value *compile_id(ID id);
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
382 GlobalVariable *compile_const_global_string(const char *str,
383 const size_t str_len);
384 GlobalVariable *compile_const_global_string(const char *str) {
385 return compile_const_global_string(str, strlen(str));
386 }
e379686 some work on unicode support (still in progress)
Laurent Sansonetti authored
387 GlobalVariable *compile_const_global_ustring(const UniChar *str,
f045214 regexps are now AOT compilable
Laurent Sansonetti authored
388 const size_t str_len);
e379686 some work on unicode support (still in progress)
Laurent Sansonetti authored
389
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
390 Value *compile_arity(rb_vm_arity_t &arity);
95f3b23 added support for AOT compilation of literal ranges
Laurent Sansonetti authored
391 Instruction *compile_range(Value *beg, Value *end, bool exclude_end,
14423f1 fixed AOT compilation of literal ranges (objects should be retained)
Laurent Sansonetti authored
392 bool retain=false, bool add_to_bb=true);
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
393 Value *compile_literal(VALUE val);
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
394 virtual Value *compile_immutable_literal(VALUE val);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
395 virtual Value *compile_global_entry(NODE *node);
cb65416 the great schism, part I
Laurent Sansonetti authored
396
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
397 void compile_set_current_scope(Value *klass, Value *scope);
398 Value *compile_set_current_class(Value *klass);
399
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
400 Value *compile_landing_pad_header(void);
401 Value *compile_landing_pad_header(const std::type_info &eh_type);
6c5b476 a new implementation for return-from-block which uses an exception inste...
Laurent Sansonetti authored
402 void compile_landing_pad_footer(bool pop_exception=true);
c80c60a in the objc->ruby 32-bit stub convert ruby exceptions to objc
Laurent Sansonetti authored
403 Value *compile_current_exception(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
404 void compile_rethrow_exception(void);
23ef57e now properly popping exceptions from the VM stack when we unwind from a ...
Laurent Sansonetti authored
405 void compile_pop_exception(int pos=0);
cb65416 the great schism, part I
Laurent Sansonetti authored
406 Value *compile_lvar_slot(ID name);
407 bool compile_lvars(ID *tbl);
408 Value *compile_new_struct(Value *klass, std::vector<Value *> &fields);
409 Value *compile_new_opaque(Value *klass, Value *val);
ff75d60 added support for overwriting an ObjC method that accepts a pointer
Laurent Sansonetti authored
410 Value *compile_new_pointer(const char *type, Value *val);
cb65416 the great schism, part I
Laurent Sansonetti authored
411 void compile_get_struct_fields(Value *val, Value *buf,
412 rb_vm_bs_boxed_t *bs_boxed);
413 Value *compile_get_opaque_data(Value *val, rb_vm_bs_boxed_t *bs_boxed,
414 Value *slot);
415 Value *compile_get_cptr(Value *val, const char *type, Value *slot);
416 void compile_check_arity(Value *given, Value *requested);
417 void compile_set_struct(Value *rcv, int field, Value *val);
d1bb30d added simple compiler support for bit fields and C-style arrays, improve...
Laurent Sansonetti authored
418 Value *compile_xmalloc(size_t len);
cb65416 the great schism, part I
Laurent Sansonetti authored
419
420 Value *compile_conversion_to_c(const char *type, Value *val,
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
421 Value *slot);
cb65416 the great schism, part I
Laurent Sansonetti authored
422 Value *compile_conversion_to_ruby(const char *type,
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
423 const Type *llvm_type, Value *val);
cf73725 experimental debugger
Laurent Sansonetti authored
424 void compile_debug_trap(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
425
8c55086 better ivar slot system for RubyObject + misc fixes/cleanup
Laurent Sansonetti authored
426 virtual Value *compile_slot_cache(ID id);
2a1240c @vincentisambart some refactoring
vincentisambart authored
427 void compile_keep_vars(BasicBlock *startBB, BasicBlock *mergeBB);
01528a7 floating point arithmetic optimization: Float objects are now immediate ...
Laurent Sansonetti authored
428
cb65416 the great schism, part I
Laurent Sansonetti authored
429 SEL mid_to_sel(ID mid, int arity);
4e1a3ba let's attach more metadata
Laurent Sansonetti authored
430
c437b62 - Adds the flip-flop operator (fixes #548)
Thibault Martin-Lagardette authored
431 Value *compile_get_ffstate(GlobalVariable *ffstate);
002ed5d now compile some of the VM primitives into bitcode that will be added to...
Laurent Sansonetti authored
432 Value *compile_set_ffstate(Value *val, Value *expected,
433 GlobalVariable *ffstate, BasicBlock *mergeBB, Function *f);
c437b62 - Adds the flip-flop operator (fixes #548)
Thibault Martin-Lagardette authored
434 Value *compile_ff2(NODE *current_node);
435 Value *compile_ff3(NODE *current_node);
436
4e1a3ba let's attach more metadata
Laurent Sansonetti authored
437 void attach_current_line_metadata(Instruction *insn);
cb65416 the great schism, part I
Laurent Sansonetti authored
438 };
439
bb0b28c moving to LLVM r82747
Laurent Sansonetti authored
440 #define context (RoxorCompiler::module->getContext())
441
cb65416 the great schism, part I
Laurent Sansonetti authored
442 class RoxorAOTCompiler : public RoxorCompiler {
443 public:
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
444 RoxorAOTCompiler(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
445
e29c2ec now interpreting potential cold paths (work in progress)
Laurent Sansonetti authored
446 Function *compile_main_function(NODE *node, bool *can_be_interpreted);
cb65416 the great schism, part I
Laurent Sansonetti authored
447
448 private:
449 std::map<ID, GlobalVariable *> ccaches;
450 std::map<SEL, GlobalVariable *> sels;
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
451 std::map<ID, GlobalVariable *> ids;
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
452 std::map<ID, GlobalVariable *> global_entries;
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
453 std::vector<GlobalVariable *> ivar_slots;
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
454 std::map<VALUE, GlobalVariable *> literals;
455
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
456 GlobalVariable *cObject_gvar;
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
457 GlobalVariable *cStandardError_gvar;
458 std::vector<GlobalVariable *> class_gvars;
cb65416 the great schism, part I
Laurent Sansonetti authored
459
460 Value *compile_ccache(ID id);
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
461 Value *compile_sel(SEL sel, bool add_to_bb=true);
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
462 void compile_prepare_method(Value *classVal, Value *sel,
463 bool singleton, Function *new_function, rb_vm_arity_t &arity,
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
464 NODE *body);
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
465 Value *compile_prepare_block_args(Function *func, int *flags);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
466 Value *compile_nsobject(void);
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
467 Value *compile_standarderror(void);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
468 Value *compile_id(ID id);
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
469 Value *compile_immutable_literal(VALUE val);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
470 Value *compile_global_entry(NODE *node);
8c55086 better ivar slot system for RubyObject + misc fixes/cleanup
Laurent Sansonetti authored
471 Value *compile_slot_cache(ID id);
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
472
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
473 Constant *
474 compile_const_pointer(void *ptr, const PointerType *type=NULL) {
cb65416 the great schism, part I
Laurent Sansonetti authored
475 if (ptr == NULL) {
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
476 return RoxorCompiler::compile_const_pointer(ptr, type);
cb65416 the great schism, part I
Laurent Sansonetti authored
477 }
478 printf("compile_const_pointer() called with a non-NULL pointer " \
479 "on the AOT compiler - leaving the ship!\n");
480 abort();
481 }
482 };
483
484 #endif /* __cplusplus */
485
486 #endif /* __COMPILER_H_ */
Something went wrong with that request. Please try again.