Skip to content
Newer
Older
100644 442 lines (347 sloc) 10.9 KB
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 25, 2008
1 #include "vm.hpp"
2 #include "objectmemory.hpp"
9eb4748 Flesh out Task considerable more
Evan Phoenix authored Apr 20, 2008
3 #include "event.hpp"
4 #include "global_cache.hpp"
baf87dc GC performance tweeks
Evan Phoenix authored Oct 21, 2009
5 #include "gc/gc.hpp"
3a0e9a4 @rue Renamed vm/object.hpp to vm/object_utils.hpp. File/#include shuffling.
rue authored Oct 19, 2008
6
7 #include "vm/object_utils.hpp"
8
6ac48bd Fixed a LOT of dependencies by stripping objects.hpp and prelude.hpp …
Ryan Davis authored Aug 1, 2008
9 #include "builtin/class.hpp"
10 #include "builtin/fixnum.hpp"
11 #include "builtin/list.hpp"
255a070 Re-enabled instrumenting profiler.
Brian Ford authored Apr 4, 2009
12 #include "builtin/lookuptable.hpp"
6ac48bd Fixed a LOT of dependencies by stripping objects.hpp and prelude.hpp …
Ryan Davis authored Aug 2, 2008
13 #include "builtin/symbol.hpp"
14 #include "builtin/thread.hpp"
15 #include "builtin/tuple.hpp"
16 #include "builtin/string.hpp"
58f050c Ensure probe variables are initialized.
Brian Ford authored Sep 9, 2008
17 #include "builtin/taskprobe.hpp"
5d3b39f Populate a StackError with a backtrace
Evan Phoenix authored Apr 22, 2009
18 #include "builtin/system.hpp"
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 26, 2008
19
255a070 Re-enabled instrumenting profiler.
Brian Ford authored Apr 5, 2009
20 #include "instruments/profiler.hpp"
21
b09a24c Wire the JIT in via MachineMethod
Evan Phoenix authored Dec 12, 2008
22 #include "config_parser.hpp"
6c31ab6 Add cli switch to enable jit
Evan Phoenix authored Jan 5, 2009
23 #include "config.h"
1dd0497 Hooked a bit of Threads back up
Evan Phoenix authored Feb 6, 2009
24
25 #include "native_thread.hpp"
3d7bc75 Fix reraising off non-Exception raise values
Evan Phoenix authored Apr 23, 2009
26 #include "call_frame.hpp"
e6bb96a Fix a number of IO/Signal interaction issues
Evan Phoenix authored May 1, 2009
27 #include "signal.hpp"
bf09647 Add ability to turn on GIL debugging at runtime
Evan Phoenix authored May 26, 2009
28 #include "configuration.hpp"
8dc150e Implement ConfigParser, wire in into RUBY_CONFIG.
Evan Phoenix authored Aug 14, 2008
29
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 7, 2008
30 #include <iostream>
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
31 #include <iomanip>
f9ec582 Add preemptive thread scheduling
Evan Phoenix authored Oct 10, 2008
32 #include <signal.h>
3d3c195 @dbussink Small build fixes for FreeBSD
dbussink authored Oct 15, 2009
33 #include <sys/resource.h>
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 8, 2008
34
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
35 // Reset macros since we're inside state
36 #undef G
37 #undef GO
38 #define G(whatever) globals.whatever.get()
39 #define GO(whatever) globals.whatever
40
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 26, 2008
41 namespace rubinius {
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
42
bf09647 Add ability to turn on GIL debugging at runtime
Evan Phoenix authored May 26, 2009
43 bool GlobalLock::debug_locking = false;
38100a0 Add simple recursion protection
Evan Phoenix authored Feb 18, 2009
44 int VM::cStackDepthMax = 655300;
45
41400f4 Remove VMManager, simply SharedState/VM workflow
Evan Phoenix authored Apr 29, 2009
46 VM::VM(SharedState& shared)
945145d Big memory usage cleanup
Evan Phoenix authored Jan 8, 2010
47 : ManagedThread(shared)
48 , saved_call_frame_(0)
17b1959 Add deletion of unused VMs
Evan Phoenix authored Mar 10, 2009
49 , alive_(true)
51cb55a Fixed profiler.
Brian Ford authored Apr 20, 2009
50 , profiler_(0)
e6bb96a Fix a number of IO/Signal interaction issues
Evan Phoenix authored May 1, 2009
51 , run_signals_(false)
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
52 , shared(shared)
0d55903 Initialize waiter_ in VM constructor.
Brian Ford authored Mar 18, 2009
53 , waiter_(NULL)
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
54 , globals(shared.globals)
55 , om(shared.om)
56 , global_cache(shared.global_cache)
57 , interrupts(shared.interrupts)
58 , symbols(shared.symbols)
07fc27b Hook up signal delivery
Evan Phoenix authored Feb 10, 2009
59 , check_local_interrupts(false)
12aeac9 Fix return-in-ensure, a stack problem, and more
Evan Phoenix authored Feb 12, 2009
60 , thread_state_(this)
1dd0497 Hooked a bit of Threads back up
Evan Phoenix authored Feb 7, 2009
61 , thread(this, (Thread*)Qnil)
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
62 , current_mark(NULL)
31ad5c2 Introduces the dynamic interpreter
Evan Phoenix authored Jan 5, 2009
63 , reuse_llvm(true)
a5aa8c4 Initialize probe correctly so threads work
Evan Phoenix authored Nov 5, 2009
64 {
65 probe.set(Qnil, &globals.roots);
66 }
67
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
68
41400f4 Remove VMManager, simply SharedState/VM workflow
Evan Phoenix authored Apr 29, 2009
69 void VM::discard(VM* vm) {
70 vm->alive_ = false;
71 vm->saved_call_frame_ = 0;
72 if(vm->profiler_) {
73 vm->shared.remove_profiler(vm, vm->profiler_);
255a070 Re-enabled instrumenting profiler.
Brian Ford authored Apr 5, 2009
74 }
41400f4 Remove VMManager, simply SharedState/VM workflow
Evan Phoenix authored Apr 29, 2009
75
76 vm->shared.remove_vm(vm);
77 delete vm;
17b1959 Add deletion of unused VMs
Evan Phoenix authored Mar 10, 2009
78 }
79
37dc489 Add real Configuration infrastructure
Evan Phoenix authored Apr 29, 2009
80 void VM::initialize() {
1615ead Refactoring of ObjectMemory's object creation
Evan Phoenix authored Oct 7, 2008
81 VM::register_state(this);
82
37dc489 Add real Configuration infrastructure
Evan Phoenix authored Apr 30, 2009
83 om = new ObjectMemory(this, shared.config);
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
84 shared.om = om;
85
86 global_cache = new GlobalCache;
87 shared.global_cache = global_cache;
6c31ab6 Add cli switch to enable jit
Evan Phoenix authored Jan 6, 2009
88
86fe9a8 @rue Some notes on Thread/VM interaction.
rue authored Feb 19, 2009
89 /** @todo Done by Environment::boot_vm(), and Thread::s_new()
90 * does not boot at all. Should this be removed? --rue */
91 // this->boot();
6cfae75 Add VMManager, fix exit to behave well
Evan Phoenix authored Feb 6, 2009
92
93 shared.set_initialized();
e53284c Wire background compiling thread into JIT mode
Evan Phoenix authored May 26, 2009
94
95 // This seems like we should do this in VM(), ie, for every VM and
96 // therefore every Thread object in the process. But in fact, because
97 // we're using the GIL atm, we only do it once. When the GIL goes
98 // away, this needs to be moved to VM().
99
100 shared.gc_dependent();
6c31ab6 Add cli switch to enable jit
Evan Phoenix authored Jan 6, 2009
101 }
102
103 void VM::boot() {
5e917ee Move TypeInfo::init under ObjectMemory
Evan Phoenix authored Dec 10, 2008
104 TypeInfo::auto_learn_fields(this);
5be79de Implement simple context cache
Evan Phoenix authored Aug 9, 2008
105
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 26, 2008
106 bootstrap_ontology();
da8639a Added libev integration. 60% coverage.
Evan Phoenix authored Apr 14, 2008
107
3f594b6 @rue Changed all TODO:s to @todo so that doxygen picks them up.
rue authored Oct 19, 2008
108 /* @todo Using a single default loop, revisit when many loops.
109 * @todo This needs to be handled through the environment.
6767c76 @dgtized disabled EVBACKEND_EPOLL as it seems to make linux unhappy -- this sh…
dgtized authored Oct 27, 2008
110 * (disabled epoll backend as it frequently caused hangs on epoll_wait)
d75d4be @rue Add forkcheck flag to event loop and init SIGCHLD handler at VM startup.
rue authored Oct 7, 2008
111 */
b4cfdcb Fix subtend, irb runs
Evan Phoenix authored Feb 11, 2009
112 // signal_events = new event::Loop(EVFLAG_FORKCHECK | EVBACKEND_SELECT | EVBACKEND_POLL);
113 // events = signal_events;
432b29d Get send_on_signal working and couple simple fixes.
Evan Phoenix authored Aug 27, 2008
114
b4cfdcb Fix subtend, irb runs
Evan Phoenix authored Feb 11, 2009
115 // signal_events->start(new event::Child::Event(this));
116
117 events = 0;
118 signal_events = 0;
d75d4be @rue Add forkcheck flag to event loop and init SIGCHLD handler at VM startup.
rue authored Oct 7, 2008
119
31ad5c2 Introduces the dynamic interpreter
Evan Phoenix authored Jan 5, 2009
120 VMMethod::init(this);
121
86fe9a8 @rue Some notes on Thread/VM interaction.
rue authored Feb 19, 2009
122 /** @todo Should a thread be starting a VM or is it the other way around? */
49d27d7 Move LLVM's lazy code generation into the execute pipeline
Evan Phoenix authored Jul 14, 2008
123 boot_threads();
f9ec582 Add preemptive thread scheduling
Evan Phoenix authored Oct 10, 2008
124
125 // Force these back to false because creating the default Thread
126 // sets them to true.
127 interrupts.enable_preempt = false;
bf09647 Add ability to turn on GIL debugging at runtime
Evan Phoenix authored May 26, 2009
128
129 GlobalLock::debug_locking = shared.config.gil_debug;
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 26, 2008
130 }
131
2ad580f Cleanup some jit config options
Evan Phoenix authored Dec 10, 2009
132 void VM::initialize_config() {
133 #ifdef USE_DYNAMIC_INTERPRETER
134 if(shared.config.dynamic_interpreter_enabled) {
135 G(rubinius)->set_const(this, "INTERPRETER", symbol("dynamic"));
136 } else {
137 G(rubinius)->set_const(this, "INTERPRETER", symbol("static"));
138 }
139 #else
140 G(rubinius)->set_const(this, "INTERPRETER", symbol("static"));
141 #endif
142
143 #ifdef ENABLE_LLVM
144 if(!shared.config.jit_disabled) {
145 Array* ary = Array::create(this, 3);
146 ary->append(this, symbol("usage"));
147 if(shared.config.jit_inline_generic) {
148 ary->append(this, symbol("inline_generic"));
149 }
150
151 if(shared.config.jit_inline_blocks) {
152 ary->append(this, symbol("inline_blocks"));
153 }
154 G(rubinius)->set_const(this, "JIT", ary);
155 } else {
156 G(rubinius)->set_const(this, "JIT", Qfalse);
157 }
158 #else
159 G(rubinius)->set_const(this, "JIT", Qnil);
160 #endif
161 }
162
bc4b80f Remove STATE argument from debug functions
Evan Phoenix authored Aug 26, 2008
163 // HACK so not thread safe or anything!
164 static VM* __state = NULL;
165
166 VM* VM::current_state() {
167 return __state;
168 }
169
170 void VM::register_state(VM *vm) {
171 __state = vm;
172 }
173
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 8, 2008
174 void VM::boot_threads() {
d0dbabb Rework how pthread_t is passed down
Evan Phoenix authored Apr 29, 2009
175 thread.set(Thread::create(this, this, pthread_self()), &globals.roots);
2cc2e45 @rue Update/fix Thread handling in VM. Possibly over-cautious again.
rue authored Oct 25, 2008
176 thread->sleep(this, Qfalse);
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 8, 2008
177 }
178
78632ae Remove using Type::fields infavor of sizeof(Type)
Evan Phoenix authored Dec 10, 2008
179 Object* VM::new_object_typed(Class* cls, size_t bytes, object_type type) {
180 return om->new_object_typed(cls, bytes, type);
181 }
182
2fd060c Fix spurious wakeup of Condition
Evan Phoenix authored Mar 15, 2009
183 Object* VM::new_object_typed_mature(Class* cls, size_t bytes, object_type type) {
184 return om->new_object_typed_mature(cls, bytes, type);
185 }
186
78632ae Remove using Type::fields infavor of sizeof(Type)
Evan Phoenix authored Dec 10, 2008
187 Object* VM::new_object_from_type(Class* cls, TypeInfo* ti) {
188 return om->new_object_typed(cls, ti->instance_size, ti->type);
15fc505 More builtin objects, and a README file
Evan Phoenix authored Apr 7, 2008
189 }
190
e8107bb Remove all traces of ::fields
Evan Phoenix authored Dec 10, 2008
191 Class* VM::new_basic_class(Class* sup) {
ea2b516 Allocate Class/Module/IncludedModule as enduring objects
Evan Phoenix authored Aug 2, 2009
192 Class *cls = om->new_object_enduring<Class>(G(klass));
3cee96d Add ability to inline ivar accessors
Evan Phoenix authored Jun 24, 2009
193 cls->set_class_id(shared.inc_class_count());
0be116a Add prelim support for packed object layout
Evan Phoenix authored Oct 20, 2009
194 cls->set_packed_size(0);
3cee96d Add ability to inline ivar accessors
Evan Phoenix authored Jun 24, 2009
195
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
196 if(sup->nil_p()) {
387bc2d Converted to attr_accessor for C++ member variable access.
Brian Ford authored Sep 11, 2008
197 cls->instance_type(this, Fixnum::from(ObjectType));
481c5e5 Class / TypeInfo cleanup
Evan Phoenix authored Mar 19, 2009
198 cls->set_type_info(find_type(ObjectType));
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
199 } else {
387bc2d Converted to attr_accessor for C++ member variable access.
Brian Ford authored Sep 11, 2008
200 cls->instance_type(this, sup->instance_type()); // HACK test that this is always true
481c5e5 Class / TypeInfo cleanup
Evan Phoenix authored Mar 19, 2009
201 cls->set_type_info(sup->type_info());
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
202 }
387bc2d Converted to attr_accessor for C++ member variable access.
Brian Ford authored Sep 11, 2008
203 cls->superclass(this, sup);
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
204
205 return cls;
206 }
207
208 Class* VM::new_class(const char* name) {
e8107bb Remove all traces of ::fields
Evan Phoenix authored Dec 10, 2008
209 return new_class(name, G(object), G(object));
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
210 }
211
212 Class* VM::new_class(const char* name, Class* super_class) {
e8107bb Remove all traces of ::fields
Evan Phoenix authored Dec 10, 2008
213 return new_class(name, super_class, G(object));
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
214 }
215
e8107bb Remove all traces of ::fields
Evan Phoenix authored Dec 10, 2008
216 Class* VM::new_class(const char* name, Class* sup, Module* under) {
217 Class* cls = new_basic_class(sup);
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
218 cls->setup(this, name, under);
219
220 // HACK test that we've got the MOP setup properly
221 MetaClass::attach(this, cls, sup->metaclass(this));
222 return cls;
223 }
224
225 Class* VM::new_class_under(const char* name, Module* under) {
e8107bb Remove all traces of ::fields
Evan Phoenix authored Dec 10, 2008
226 return new_class(name, G(object), under);
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
227 }
228
229 Module* VM::new_module(const char* name, Module* under) {
78632ae Remove using Type::fields infavor of sizeof(Type)
Evan Phoenix authored Dec 10, 2008
230 Module *mod = new_object<Module>(G(module));
f5cf833 Reorganize ontology and class initialization
Evan Phoenix authored Aug 23, 2008
231 mod->setup(this, name, under);
232 return mod;
233 }
234
235
1fdd151 @rue Changed all OBJECT, SYMBOL, FIXNUM, INTEGER to normal syntax.
rue authored Oct 19, 2008
236 Symbol* VM::symbol(const char* str) {
5f2adf4 Replaced SymbolTable with native C++ class using STL.
Brian Ford authored Aug 13, 2008
237 return symbols.lookup(this, str);
304caf3 Bunch more work.
Evan Phoenix authored Apr 4, 2008
238 }
239
1fdd151 @rue Changed all OBJECT, SYMBOL, FIXNUM, INTEGER to normal syntax.
rue authored Oct 18, 2008
240 Symbol* VM::symbol(String* str) {
5f2adf4 Replaced SymbolTable with native C++ class using STL.
Brian Ford authored Aug 14, 2008
241 return symbols.lookup(this, str);
195ef1b Isolated access to SymbolTable behind VM methods.
Brian Ford authored Aug 11, 2008
242 }
243
1fdd151 @rue Changed all OBJECT, SYMBOL, FIXNUM, INTEGER to normal syntax.
rue authored Oct 18, 2008
244 void type_assert(STATE, Object* obj, object_type type, const char* reason) {
481c5e5 Class / TypeInfo cleanup
Evan Phoenix authored Mar 19, 2009
245 if((obj->reference_p() && obj->type_id() != type)
a1704be Rework exceptions in the VM.
Brian Ford authored Oct 1, 2008
246 || (type == FixnumType && !obj->fixnum_p())) {
247 Exception::type_error(state, type, obj, reason);
fceff3d NativeFunction, Selector, SendSite
Evan Phoenix authored Apr 9, 2008
248 }
304caf3 Bunch more work.
Evan Phoenix authored Apr 4, 2008
249 }
4c08cc4 Add object cleanup post collect and on shutdown
Evan Phoenix authored Apr 10, 2008
250
5d3b39f Populate a StackError with a backtrace
Evan Phoenix authored Apr 23, 2009
251 void VM::raise_stack_error(CallFrame* call_frame) {
252 G(stack_error)->locations(this, System::vm_backtrace(this, Fixnum::from(0), call_frame));
38100a0 Add simple recursion protection
Evan Phoenix authored Feb 18, 2009
253 thread_state()->raise_exception(G(stack_error));
254 }
255
256 void VM::init_stack_size() {
257 struct rlimit rlim;
258 if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
259 unsigned int space = rlim.rlim_cur/5;
260
261 if (space > 1024*1024) space = 1024*1024;
262 cStackDepthMax = (rlim.rlim_cur - space);
263 }
264 }
265
388b751 Wire up primitives to be resolved and executed.
Evan Phoenix authored May 21, 2008
266 TypeInfo* VM::find_type(int type) {
267 return om->type_info[type];
268 }
269
f1fa512 @drbrain Oh yeah, C++ isn't ruby.
drbrain authored Aug 1, 2008
270 Thread *VM::current_thread() {
6f546f0 @drbrain Implement VM::current_thread().
drbrain authored Aug 1, 2008
271 return globals.current_thread.get();
da8639a Added libev integration. 60% coverage.
Evan Phoenix authored Apr 15, 2008
272 }
f10f155 Pass in valgrind to find some GC bugs
Evan Phoenix authored Apr 22, 2008
273
3dc347c Fix memory thrash and interrupt checks
Evan Phoenix authored Oct 28, 2008
274 void VM::run_gc_soon() {
275 om->collect_young_now = true;
276 om->collect_mature_now = true;
d390938 Cleanup interrupt checking, improve JIT debugging output
Evan Phoenix authored Oct 13, 2009
277 interrupts.set_perform_gc();
3dc347c Fix memory thrash and interrupt checks
Evan Phoenix authored Oct 28, 2008
278 }
279
f0e8625 Remove task from execution logic, add code to run GC
Evan Phoenix authored Feb 4, 2009
280 void VM::collect(CallFrame* call_frame) {
e04d3da Performance fix for seeing all top CallFrames
Evan Phoenix authored Feb 11, 2009
281 this->set_call_frame(call_frame);
bb9618c Fix wait, Channels, and GC for multiple threads
Evan Phoenix authored Feb 9, 2009
282
0c8eb66 Healthy living through better thread management
Evan Phoenix authored May 28, 2009
283 // Stops all other threads, so we're only here by ourselves.
284 StopTheWorld guard(this);
285
1431083 Add OnStack class to protect C++ variables from GC
Evan Phoenix authored Mar 13, 2009
286 GCData gc_data(this);
287
288 om->collect_young(gc_data);
289 om->collect_mature(gc_data);
f10f155 Pass in valgrind to find some GC bugs
Evan Phoenix authored Apr 23, 2008
290 }
52c078b Fleshing out Instruction tests, more type safety
Evan Phoenix authored Apr 30, 2008
291
f0e8625 Remove task from execution logic, add code to run GC
Evan Phoenix authored Feb 5, 2009
292 void VM::collect_maybe(CallFrame* call_frame) {
e04d3da Performance fix for seeing all top CallFrames
Evan Phoenix authored Feb 12, 2009
293 this->set_call_frame(call_frame);
e53284c Wire background compiling thread into JIT mode
Evan Phoenix authored May 26, 2009
294
295 // Stops all other threads, so we're only here by ourselves.
296 StopTheWorld guard(this);
297
1431083 Add OnStack class to protect C++ variables from GC
Evan Phoenix authored Mar 13, 2009
298 GCData gc_data(this);
bb9618c Fix wait, Channels, and GC for multiple threads
Evan Phoenix authored Feb 9, 2009
299
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
300 uint64_t start_time = 0;
301
f781b6a Move GC running into VM, remove Task::check_interrupts
Evan Phoenix authored Oct 13, 2008
302 if(om->collect_young_now) {
720b6a4 Add -Xgc.show to print out when the GC runs
Evan Phoenix authored May 26, 2009
303 if(shared.config.gc_show) {
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
304 start_time = get_current_time();
720b6a4 Add -Xgc.show to print out when the GC runs
Evan Phoenix authored May 26, 2009
305 }
ef185e2 Refactor timing code and add GC timing
Evan Phoenix authored Jan 6, 2009
306
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
307 YoungCollectStats stats;
5599aa0 Added pseudo profiler methods for GC runs.
Brian Ford authored Nov 2, 2009
308
309 #ifdef RBX_PROFILER
310 if(unlikely(shared.profiling())) {
311 profiler::MethodEntry method(this, profiler::kYoungGC);
312 om->collect_young(gc_data, &stats);
313 } else {
314 om->collect_young(gc_data, &stats);
315 }
316 #else
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
317 om->collect_young(gc_data, &stats);
5599aa0 Added pseudo profiler methods for GC runs.
Brian Ford authored Nov 3, 2009
318 #endif
651bdc0 Show GC stops as well with -Xgc.show
Evan Phoenix authored Oct 15, 2009
319
320 if(shared.config.gc_show) {
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
321 uint64_t fin_time = get_current_time();
322 int diff = (fin_time - start_time) / 1000000;
323
324 fprintf(stderr, "[GC %0.1f%% %d/%d %d %2dms]\n",
325 stats.percentage_used,
326 stats.promoted_objects,
327 stats.excess_objects,
328 stats.lifetime,
329 diff);
651bdc0 Show GC stops as well with -Xgc.show
Evan Phoenix authored Oct 15, 2009
330 }
f781b6a Move GC running into VM, remove Task::check_interrupts
Evan Phoenix authored Oct 13, 2008
331 }
332
333 if(om->collect_mature_now) {
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
334 int before_kb = 0;
335
720b6a4 Add -Xgc.show to print out when the GC runs
Evan Phoenix authored May 26, 2009
336 if(shared.config.gc_show) {
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
337 start_time = get_current_time();
338 before_kb = om->mature_bytes_allocated() / 1024;
720b6a4 Add -Xgc.show to print out when the GC runs
Evan Phoenix authored May 26, 2009
339 }
ef185e2 Refactor timing code and add GC timing
Evan Phoenix authored Jan 7, 2009
340
5599aa0 Added pseudo profiler methods for GC runs.
Brian Ford authored Nov 3, 2009
341 #ifdef RBX_PROFILER
342 if(unlikely(shared.profiling())) {
343 profiler::MethodEntry method(this, profiler::kMatureGC);
344 om->collect_mature(gc_data);
345 } else {
346 om->collect_mature(gc_data);
347 }
348 #else
1431083 Add OnStack class to protect C++ variables from GC
Evan Phoenix authored Mar 13, 2009
349 om->collect_mature(gc_data);
5599aa0 Added pseudo profiler methods for GC runs.
Brian Ford authored Nov 3, 2009
350 #endif
ef185e2 Refactor timing code and add GC timing
Evan Phoenix authored Jan 7, 2009
351
651bdc0 Show GC stops as well with -Xgc.show
Evan Phoenix authored Oct 15, 2009
352 if(shared.config.gc_show) {
4e26843 Improve young GC and add more GC stats
Evan Phoenix authored Oct 26, 2009
353 uint64_t fin_time = get_current_time();
354 int diff = (fin_time - start_time) / 1000000;
355 int kb = om->mature_bytes_allocated() / 1024;
356 fprintf(stderr, "[Full GC %dkB => %dkB %2dms]\n",
357 before_kb,
358 kb,
359 diff);
651bdc0 Show GC stops as well with -Xgc.show
Evan Phoenix authored Oct 15, 2009
360 }
361
f781b6a Move GC running into VM, remove Task::check_interrupts
Evan Phoenix authored Oct 13, 2008
362 }
363 }
364
1fdd151 @rue Changed all OBJECT, SYMBOL, FIXNUM, INTEGER to normal syntax.
rue authored Oct 18, 2008
365 void VM::set_const(const char* name, Object* val) {
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 8, 2008
366 globals.object->set_const(this, (char*)name, val);
367 }
879a046 A whole slew. Enhanced type-info, debugged GC.
Evan Phoenix authored May 15, 2008
368
1fdd151 @rue Changed all OBJECT, SYMBOL, FIXNUM, INTEGER to normal syntax.
rue authored Oct 18, 2008
369 void VM::set_const(Module* mod, const char* name, Object* val) {
feb91b4 Tons of stuff (too much probably)
Evan Phoenix authored May 8, 2008
370 mod->set_const(this, (char*)name, val);
371 }
310a461 Cleanup stack usage and fix interpreter
Evan Phoenix authored Aug 7, 2008
372
373 void VM::print_backtrace() {
bb9618c Fix wait, Channels, and GC for multiple threads
Evan Phoenix authored Feb 9, 2009
374 abort();
310a461 Cleanup stack usage and fix interpreter
Evan Phoenix authored Aug 7, 2008
375 }
376
1dd0497 Hooked a bit of Threads back up
Evan Phoenix authored Feb 7, 2009
377 void VM::install_waiter(Waiter& waiter) {
378 waiter_ = &waiter;
379 }
380
381 bool VM::wakeup() {
382 if(waiter_) {
e53284c Wire background compiling thread into JIT mode
Evan Phoenix authored May 26, 2009
383 waiter_->run();
b4cfdcb Fix subtend, irb runs
Evan Phoenix authored Feb 11, 2009
384 waiter_ = NULL;
1dd0497 Hooked a bit of Threads back up
Evan Phoenix authored Feb 7, 2009
385 return true;
386 }
387
388 return false;
389 }
390
b4cfdcb Fix subtend, irb runs
Evan Phoenix authored Feb 11, 2009
391 void VM::clear_waiter() {
392 waiter_ = NULL;
393 }
394
07fc27b Hook up signal delivery
Evan Phoenix authored Feb 10, 2009
395 void VM::send_async_signal(int sig) {
396 mailbox_.add(ASyncMessage(ASyncMessage::cSignal, sig));
397 check_local_interrupts = true;
398
399 // TODO I'm worried there might be a race calling
400 // wakeup without the lock held...
401 wakeup();
402 }
403
404 bool VM::process_async(CallFrame* call_frame) {
405 check_local_interrupts = false;
406
e6bb96a Fix a number of IO/Signal interaction issues
Evan Phoenix authored May 1, 2009
407 if(run_signals_) {
408 shared.signal_handler()->deliver_signals(call_frame);
c17afc3 Fix up Thread
Evan Phoenix authored Mar 11, 2009
409 }
410
e6bb96a Fix a number of IO/Signal interaction issues
Evan Phoenix authored May 1, 2009
411 if(thread_state_.raise_reason() != cNone) return false;
412
07fc27b Hook up signal delivery
Evan Phoenix authored Feb 10, 2009
413 return true;
414 }
c17afc3 Fix up Thread
Evan Phoenix authored Mar 11, 2009
415
416 void VM::register_raise(Exception* exc) {
417 thread_state_.raise_exception(exc);
418 check_local_interrupts = true;
419 }
420
3d7bc75 Fix reraising off non-Exception raise values
Evan Phoenix authored Apr 23, 2009
421 void VM::check_exception(CallFrame* call_frame) {
422 if(thread_state()->raise_reason() == cNone) {
423 std::cout << "Exception propogating, but none registered!\n";
424 call_frame->print_backtrace(this);
425 rubinius::abort();
426 }
427 }
428
d815cbb Fixed responsibilities for creating, registering, removing, deleting …
Brian Ford authored Apr 7, 2009
429 profiler::Profiler* VM::profiler() {
430 if(unlikely(!profiler_)) {
431 profiler_ = new profiler::Profiler(this);
432 shared.add_profiler(this, profiler_);
433 }
434
435 return profiler_;
436 }
437
438 void VM::remove_profiler() {
439 profiler_ = 0;
255a070 Re-enabled instrumenting profiler.
Brian Ford authored Apr 5, 2009
440 }
d769c94 Initial work on new C++ VM
Evan Phoenix authored Mar 26, 2008
441 };
Something went wrong with that request. Please try again.