Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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