Commit Graph

329 Commits (b9ae00461d54cd6029566a1aad484236b1b46c01)

Author SHA1 Message Date
Joe Groff 8b75193a57 vm: support self-executing image file 2011-11-27 12:37:54 -08:00
Joe Groff 00f00663ad vm: replace assert with FACTOR_ASSERT
Factor is finally a real C++ project and has a custom assert macro. Assertion failures were still getting caught as exceptions and causing failure loops. Write our own macro that calls factor::abort on failure.
2011-11-23 11:11:26 -08:00
Joe Groff ba88cbbe51 vm: charge samples collected in prolog to parent
Fixes #379
2011-11-23 11:11:26 -08:00
Joe Groff ab9088e7ba vm: disable SIGINT handler while in factorbug
Fixes #410
2011-11-15 18:50:42 -08:00
Joe Groff 05da199174 vm: close_console before exiting anywhere
Add a factor_vm::exit function that does close_console() before ::exit-ing
2011-11-12 23:05:44 -08:00
Philipp Brüschweiler 4dd1f3297e vm: close the console when exiting
This prevents an endless loop caused by the nvidia drivers on linux.
See http://www.nvnews.net/vbulletin/showthread.php?t=164619
2011-11-12 23:05:43 -08:00
Joe Groff 4984bde393 cpu.*.bootstrap: clear faulting flag directly
No reason to go through a safepoint in unwind-native-frames really.
2011-11-12 13:02:57 -08:00
Joe Groff beb0f48da9 vm: more defense against multi-faulting
* Clear faulting_p from a safepoint rather than inside general_error, because jumping into unwind-native-frames could blow up.
* Handle multiple faults from fatal_error by breakpointing. Is there anything else we can safely do at that point?
* Verify memory protection faults in the top half of the signal handlers because signal dispatch could fault. Treat memory faults during gc or fep as fatal errors.
* Add a function factor_vm::abort() that restores the default SIGABRT handler and ::abort()s. Use it from fatal_error() so we get useful context from gdb and so the user gets feedback from the system crash reporter that Factor blew up and didn't just disappear.
* In factorbug(), don't proceed with .s .r .c if it would be unsafe to do so.
* Don't pile on signals if we've already called fatal_error().
2011-11-12 13:02:57 -08:00
Joe Groff c5d7ce0282 vm: "edges" command for factorbug 2011-11-11 10:12:36 -08:00
Joe Groff 5b43301eb6 vm: strip out call-counting profiler
This makes the separate "code" and "entry_point" fields in word and quotation redundant, so also remove them to reclaim an additional cell per word and quotation object, which should help with #318.
2011-11-10 16:01:07 -08:00
Joe Groff 75f9904c40 vm: interrupt stdin_loop when entering fep
The stdin_loop thread will keep trying to consume input unless we stop it by sending it a signal. Use SIGUSR2 to stop the read syscall and a mutex to hold up the loop while the fep is active.
2011-11-08 08:42:48 -08:00
Joe Groff ceeb9f36d8 vm: write async signals to pipe for multiplexer
also factor out safepoint logic into its own file
2011-11-08 08:42:46 -08:00
Joe Groff 04a3c88227 vm: readable feps for more types 2011-11-06 20:26:52 -08:00
Joe Groff ac2fcd1ee0 vm: sample pc on windows 2011-11-02 21:18:31 -07:00
Joe Groff 6b2a34fdc6 vm: count samples during unoptimized compiler 2011-11-02 13:23:21 -07:00
Joe Groff 4f87ab1df7 vm: separate 'current_gc_p' from 'current_gc'
The 'current_gc' handle doesn't need to be volatile, just the state of GC-ness
2011-11-02 13:23:19 -07:00
Joe Groff 9fb10f60b5 vm: add atomic::load and atomic::store functions
Abstract out the fence-and-load and store-and-fence patterns
2011-11-02 13:23:19 -07:00
Joe Groff 2a64c3ed69 vm: sample code block owners instead of blocks 2011-11-02 13:23:17 -07:00
Joe Groff bb2df7da6b vm: die if we fault in a fault 2011-11-02 13:23:16 -07:00
Joe Groff fdeb6ddbaa vm: quell MSVC warnings 2011-11-02 13:23:16 -07:00
Joe Groff d7bc7ae4bf vm: parameterize sampling rate 2011-11-02 13:23:15 -07:00
Joe Groff 66356c1d24 vm: better organize atomics and sample counter 2011-11-02 13:23:15 -07:00
Joe Groff 52bcbe55cf vm: factor out sample counting code 2011-11-02 13:23:13 -07:00
Joe Groff b89335df71 vm: only show factorbug help the first time 2011-11-02 13:23:13 -07:00
Joe Groff c0e4458733 vm: fix build on windows 2011-11-02 13:23:12 -07:00
Joe Groff bec71e9ae2 vm: sampling profiler timer for windows
Spawn a thread and have it spin on the performance counter, triggering safepoints on the main thread every sample time
2011-11-02 13:23:11 -07:00
Joe Groff 1c68bbf8a6 vm: count samples from foreign threads
On OS X it appears the mach exception thread and libdispatch queue threads occasionally get the SIGALRM from the itimer. Count those as foreign_thread_samples instead of letting the signal kill the process.
2011-11-02 13:23:10 -07:00
Joe Groff 1ab4871fcc vm: add primitives to lift sample data to factor 2011-11-02 13:23:09 -07:00
Joe Groff cb2e87ecde vm: release memory used by sampler vectors 2011-11-02 13:23:08 -07:00
Joe Groff 1604c503ab vm: don't allocate callstack samples on data heap
Invoking a GC during a safepoint has some complications, so stuff the callstack samples in a vector instead.
2011-11-02 13:23:07 -07:00
Joe Groff 2ddfdda7b5 vm: groundwork for sampling profiler
Set up the state necessary to collect samples. We still need to add GC support for walking the sample set, and the compiler needs to register GC roots before safepoints as well. We also need primitives to expose the data to Factor for reporting.
2011-11-02 13:23:06 -07:00
Joe Groff 12a4c7a538 vm: change "profiler" names to "counting_profiler" 2011-11-02 13:23:05 -07:00
Joe Groff 83569d3793 vm: give factorbug a help command
Also change the prompt to "> _" instead of "READY\n_" since it's not 1970 anymore
2011-10-27 21:18:23 -07:00
Joe Groff 09088ec3ce cleanups from code review 2011-10-27 21:18:23 -07:00
Joe Groff b1094e0e5f vm: remove half-assed signal queueing scaffolding
Should implement it right later. See #297.
2011-10-27 21:18:22 -07:00
Joe Groff 7e3944509a vm: get CtrlHandler working on windows 2011-10-27 21:18:21 -07:00
Joe Groff ad9b90f23b vm: update windows for resumable signals 2011-10-27 21:18:21 -07:00
Joe Groff e431cef96b vm: move dispatch_signal_handler to cpu-x86.cpp
The new signal handler dispatch is logic is CISC-centric; defer fixing it until we find someone who cares
2011-10-27 21:18:20 -07:00
Joe Groff 1660bd5a19 vm: remove signal_from_leaf flag
Now that the resuming from the signal handler works within leaf procedures, the flag is no longer necessary.
2011-10-27 21:18:20 -07:00
Joe Groff a5da58bb97 vm: fix foreign segfaults and callstack overflows 2011-10-27 21:18:18 -07:00
Joe Groff 1eddaf34f1 vm: resumably handle signals from leaf procedures 2011-10-27 21:18:18 -07:00
Joe Groff f788bc954c vm: sketchy signal dispatch from leaf procs 2011-10-27 21:14:49 -07:00
Joe Groff f759575ddd vm: factor out dispatch_signal_handler logic 2011-10-27 21:14:49 -07:00
Joe Groff 91d8bcd4f8 vm: fep on SIGINT or SIGQUIT instead of exception
It's not robust currently to raise an exception because a lot of our code that isn't already written with exceptions in mind breaks. Also, a signal is likely to be received by an FFI callback installed on the IO multiplexer, which will cause Factor to die since the callback cannot handle the exception. We need a more robust solution to dealing with SIGINT.

Also lay some groundwork for counting profile samples and reporting non-interrupting asynchronous signals.
2011-10-27 21:14:49 -07:00
Joe Groff 675cd246ad vm: fatal_error if VM-less thread gets a signal 2011-10-27 21:14:48 -07:00
Joe Groff d103e6b57d vm: remove unguard-safepoint primitive 2011-10-27 21:14:47 -07:00
Joe Groff 5b4a95a6a0 vm: SetConsoleCtrlHandler on windows 2011-10-27 21:14:47 -07:00
Joe Groff e9309a425a vm: handle async signals at safepoints on unix
Factor now supports the new 4.0BSD feature of "signals".
2011-10-27 21:14:46 -07:00
John Benediktsson 58765c31d5 vm: remove math::bignum_producer. 2011-10-11 21:24:38 -07:00
John Benediktsson da21f5ca61 io.binary: make le> and be> faster (20% and 75%, respectively).
Removed primitive byte-array>bignum and digit_stream_to_bignum from vm/.
2011-10-11 21:13:30 -07:00