Joe Groff
dea0bedb99
vm: fix msvc warning
2011-11-29 12:19:17 -08:00
Joe Groff
26226d460e
vm: factor out embedded image detection code
2011-11-27 14:39:21 -08:00
Joe Groff
cca526df73
vm: support self-executing image file
2011-11-27 12:37:54 -08:00
Joe Groff
88d31b166b
vm: don't die if foreign thread gets async signal
...
Fixes #425
2011-11-23 11:26:42 -08:00
Joe Groff
065a4d4353
vm: remove useless forward declare
2011-11-23 11:11:28 -08:00
Joe Groff
b6246f2c00
vm: quell warnings from vars only used by asserts
2011-11-23 11:11:28 -08:00
Joe Groff
4df56f31f2
vm: clean up baroque jit safepoint logic
2011-11-23 11:11:27 -08:00
Joe Groff
15c4b7aa57
vm: verify code heap's all_blocks set when DEBUG
2011-11-23 11:11:27 -08:00
Joe Groff
c2c2023e34
vm: FACTOR_ASSERT only if FACTOR_DEBUG
2011-11-23 11:11:27 -08:00
Joe Groff
0a1a252cdb
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
6c0ecf631a
vm: charge samples collected in prolog to parent
...
Fixes #379
2011-11-23 11:11:26 -08:00
Joe Groff
81911b9f87
vm: initialize all_blocks map from image
...
um, code blocks from the image need to go in the set too
2011-11-23 11:11:26 -08:00
Joe Groff
2705fc67cb
vm: keep a set of all code_blocks in the code_heap
...
This way looking up code blocks by return address is an O(log n) set lookup rather than an O(n) linear scan.
2011-11-23 11:11:26 -08:00
Joe Groff
44b608bb22
vm: emit safepoints before VM compiler prologs
...
For #379
2011-11-23 11:11:25 -08:00
Joe Groff
5e99a7bbbf
vm: disable SIGINT handler while in factorbug
...
Fixes #410
2011-11-15 18:50:42 -08:00
Joe Groff
c4885ac082
vm: fashion police
2011-11-12 23:05:44 -08:00
Joe Groff
c0a44000cc
vm: set stdin_loop cancellation state
...
Make it asynchronous so it doesn't wait till the next syscall to cancel.
2011-11-12 23:05:44 -08:00
Joe Groff
3fc82282f7
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
db19efe1b3
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
8e7baef1a0
vm: typo in os-windows.hpp
2011-11-12 19:23:44 -08:00
Joe Groff
e0dc236725
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
e24400679f
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
2c5014e74e
vm: "edges" command for factorbug
2011-11-11 10:12:36 -08:00
Joe Groff
c31530caec
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
139c9ca38c
init signals or console after stage2 init
...
A signal during early bootstrap is certainly an error, and the environment isn't there yet for Factor's signal handlers to work, so it makes no sense to install Factor's signal handlers beforehand. They'll just crash.
2011-11-10 16:01:07 -08:00
Joe Groff
9e4a51c55f
vm: don't SIGQUIT on unix or Ctrl-Break on windows
...
This gives us an escape hatch for when things go way south and ^C can't be handled. Also unmask SIGQUIT and SIGTERM from the stdin_loop thread so the thread doesn't keep the process alive after those signals.
2011-11-10 16:01:07 -08:00
Joe Groff
2e9552d98a
vm: hand SIGALRM to signal pipe if not sampling
2011-11-08 23:37:22 -08:00
Joe Groff
c0094186a1
vm: fix build on windows
2011-11-08 23:17:51 -08:00
Joe Groff
5f3cd4079c
vm: make signal pipe nonblocking
...
On the off chance the Factor end of the signal handler mechanism isn't listening, we don't want to tie up the VM because the pipe's buffer got full.
2011-11-08 22:07:22 -08:00
Joe Groff
820fd6417d
vm: don't send foreign samples to outer space
2011-11-08 14:00:33 -08:00
Joe Groff
90609cc5d8
vm: don't pass this to safepoint constructor
...
It's bad juju and MSVC calls us out on it.
2011-11-08 11:06:00 -08:00
Joe Groff
fc7c175c9f
new module unix.signals: app-level signal handlers
...
example:
IN: scratchpad USING: unix.ffi unix.signals ;
Loading resource:basis/unix/signals/signals.factor
IN: scratchpad [ V{ "Me not that kind of orc!" "Me busy, leave me alone!" "Work work" "Zug zug" } pop print flush ] SIGINFO add-signal-handler
IN: scratchpad load: 0.60 cmd: factor 41541 running 0.28u 0.16s
Zug zug
load: 0.71 cmd: factor 41541 running 0.28u 0.16s
Work work
load: 0.71 cmd: factor 41541 running 0.28u 0.16s
Me busy, leave me alone!
load: 0.73 cmd: factor 41541 running 0.28u 0.16s
Me not that kind of orc!
2011-11-08 10:21:49 -08:00
Joe Groff
0c58fd5c26
vm: more commentary on lock_console() stuff
2011-11-08 08:52:52 -08:00
Joe Groff
5f811c0573
vm: don't mask SIGTTIN from stdin_loop
...
Fixes #360
2011-11-08 08:42:48 -08:00
Joe Groff
f9aa0419c4
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
04c6b2c393
vm: write signals to pipe immediately
...
The whole point is to wake up the mx without waiting for the next safepoint derp
2011-11-08 08:42:47 -08:00
Joe Groff
0e3c315099
vm: move bignum.cpp includes to master.hpp
...
That way they get PCHed
2011-11-08 08:42:47 -08:00
Joe Groff
18e01f7770
vm: enqueue signals for FEP signals too
...
Although SIGINT still can't interrupt the current Factor thread in a sane way, this will at least wake up the run loop when waiting for input and fix #348 when implemented at the application level.
2011-11-08 08:42:47 -08:00
Joe Groff
b46fd5e655
GNUmakefile: use PCH so compiler goes faster
...
Also add more accurate dependencies on headers so "make" works right when headers change
2011-11-08 08:42:46 -08:00
Joe Groff
72d335f2b5
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
212d012cb1
vm: switch atomic::add to atomic::fetch_add
...
Win32 only provides fetch-and-add, not add-and-fetch, and we don't really care. Rename the functions so the order of operations is clear.
2011-11-07 17:58:53 -08:00
Joe Groff
ec19171220
vm: readable feps for more types
2011-11-06 20:26:52 -08:00
Joe Groff
f4479ee1e6
vm: print type names instead of numbers in fep
2011-11-06 20:26:51 -08:00
Joe Groff
f0d4fcc587
switch back to gcc from clang since it goes faster
2011-11-04 00:09:30 -07:00
Joe Groff
94eb922998
makefile: add macosx-x86-fat target
2011-11-03 20:19:37 -07:00
Joe Groff
3cad288f90
use gcc-4.2 on OS X 10.5, or clang on Xcode 4
2011-11-03 12:18:07 -07:00
Joe Groff
6bb46a3f1e
vm: always generate safepoints in jit
...
Even if there's no stack frame we still need to safepoint before leaving the function. Fixes #332 .
2011-11-03 11:57:43 -07:00
Joe Groff
92445d77e2
vm: restore sigaltstack setup on unix
...
#ifdef __OpenBSD__ is different from #ifndef __OpenBSD
2011-11-03 11:57:43 -07:00
Joe Groff
d28845a1ef
vm: reserve some more special-objects
...
Need a jit-safepoint object to deal with #332 , and ffi-signal-handler words for immediate signal handling during FFI calls
2011-11-02 22:16:08 -07:00
Joe Groff
2d87b68a56
vm: sample pc on windows
2011-11-02 21:18:31 -07:00