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