Commit Graph

458 Commits (cbdd559a759b5aef9b1c97d8b69a29e159d14ae1)

Author SHA1 Message Date
Björn Lindqvist 0274e889b9 VM: refactor tagged.hpp so it's not dependent on the factor_vm class
this way untag<byte_array>(relocation) can be used in code_blocks.hpp
2015-11-24 16:00:50 +01:00
Björn Lindqvist cb55fcf20f VM: prettier and more detailed output when dumping generations 2015-10-08 16:25:35 +02:00
John Benediktsson bd04290187 vm: fix signature for safe_fopen. 2015-09-30 19:03:39 -07:00
Björn Lindqvist 2536b6cd93 VM: fix move_file called from save_image
save_image() shouldn't throw exceptions because if the 'then_die'
argument is t it would leave factor in an inconsistent state. So
therefore move_file() should be fixed and raw_fclose() called instead of
safe_fclose().
2015-09-29 23:13:10 +02:00
Björn Lindqvist cb0bf3b1ce VM: merge memory_protection_error() with memory_signal_handler_impl() 2015-08-24 07:23:40 -07:00
Björn Lindqvist 51daaf6be4 VM: the windows_image_path method is unused 2015-08-24 07:23:40 -07:00
Björn Lindqvist 4efef7bfd9 VM: merge the compute_dlsym_toc_address() with the
compute_dlsym_address() method

it makes the code slightly more cluttered but you get rid of a lot of
special casing for the ppc platform
2015-08-23 18:36:31 -07:00
Björn Lindqvist a53d5be683 VM: make allot_alien() and ffi_dlsym() use cell instead of void*
this way we get rid of a bunch of superfluous casts
2015-08-23 18:36:31 -07:00
Björn Lindqvist 7f545271f4 VM: new iteration method each_object_each_slot()
used by find_data_references() and dump_edges() instead of the functor structs
2015-08-23 18:36:31 -07:00
Björn Lindqvist 59b7a50567 VM: removing the get_datastack/retainstack/callstack primitives
they can all be implemented using the
datastack/retainstack/callstack-for primitives and the less primitives
the better!
2015-08-23 18:36:30 -07:00
Björn Lindqvist df669298ce VM: split dispatch_signal_handler into two methods, one for resumable
and one for non-resumable signals
2015-08-14 20:19:55 -07:00
Björn Lindqvist 2b1c6ca11a VM: move the frame_predecessor() method to the code_heap class 2015-08-14 20:19:54 -07:00
Björn Lindqvist 504be0c7cb VM: signal_error and fp_trap_error not needed, call general_error directly 2015-08-04 16:02:10 +02:00
Björn Lindqvist 73956db33a VM: a bunch of methods on factor_vm that can be converted into free
functions

I think that makes it easier to see whats going on than having
everything added to factor_vm
2015-08-04 16:02:09 +02:00
Björn Lindqvist ae725b737a VM: lets merge entry_points.hpp with vm.hpp, so you have one less header
file to worry about
2015-08-04 16:02:09 +02:00
Björn Lindqvist f5f8ce1501 VM: word_stack_frame_p() is not used and find_all_quotations() is
trivial so those methods can be removed
2015-08-04 16:02:09 +02:00
Björn Lindqvist 49a406d880 VM: using compute_external_address everywhere instead of store_external_address 2015-08-04 16:02:09 +02:00
Björn Lindqvist 50318a6f77 VM: new method compute_external_address 2015-08-04 16:02:08 +02:00
Björn Lindqvist 718ea51d8a VM: remove the collect_compact_code_impl(), collect_compact_impl() can
be used instead

this might slow down collect_growing_heap(), but heap growth happens so
rarely that it shouldn't matter
2015-08-04 16:02:08 +02:00
Björn Lindqvist b44db91f65 VM: init_code_heap is trivial and only used once, so let's remove it 2015-08-04 16:02:08 +02:00
John Benediktsson 4c2c8f133f vm: rename some primitives, and some cleanup.
* quot-compiled? => quotation-compiled?
* optimized? => word-optimized?
2015-07-15 11:13:52 -07:00
Björn Lindqvist b9b75c272b VM: let's merge (save-image) and (save-image-and-exit) into one 3
arg (save-image). it's good not to have to many similar primitives
2015-07-12 22:36:59 +02:00
Björn Lindqvist d608f3377b VM: get_entry_point is unused 2015-07-12 22:36:59 +02:00
Björn Lindqvist e14d7a3508 VM: make the bignum_to_* family free functions, they don't need to be
members of factor_vm
2015-06-27 16:14:58 +02:00
Björn Lindqvist 40b7805e0a VM: fixes so that raw_fread and safe_fread returns a size_t again 2015-06-05 02:14:49 +02:00
Björn Lindqvist 0713f28bdb VM: safe_fread needs to return an int so you can return -1 on error 2015-06-05 02:14:49 +02:00
Doug Coleman 27590b514c vm: Only call fclose() once. Rename io_error() to io_error_if_not_EINTR() to be more explicit.
Fixes #1335.
2015-06-03 14:35:48 -07:00
Björn Lindqvist 016614747d VM: the delete_context() and reset_context() api functions can be
simplified a bit

The functions always operates on parent->ctx, so passing a context*
parameter is redundant. This enables shorter assembly code for
the (start-context-and-delete) and (set-context-and-delete) primitives.
2015-05-22 12:22:26 -07:00
Björn Lindqvist 3887b58c02 VM: cleanups, like removing redundant paranthesis and removing method
declarations that doesn't exist
2015-05-09 20:04:22 -07:00
Björn Lindqvist e4bb3058e0 VM: the copying_collector only contained one method, so it can easily be
merged with its base class
2015-05-09 20:04:21 -07:00
Björn Lindqvist 6b29c0ea00 VM: refactoring to remove redundancy in retainstack|datastack_to_array 2015-02-28 14:14:30 -08:00
Björn Lindqvist f5dc4afb2e VM: better error message in case factor_vm::store_external_address fails 2015-01-28 14:58:22 +00:00
Björn Lindqvist 434e4ef4b7 VM: fix the debug printing so that instead of always printing to std::cout, you supply the stream to print to 2015-01-28 14:58:21 +00:00
Björn Lindqvist ee5fd49b9e VM: simplified fixup_gc_workhorse::fixup_data by mering lots of functions only used once 2015-01-15 09:29:14 +00:00
Björn Lindqvist 8ea1eea4e1 VM: instead of passing around the trace_contexts_p arg, just clear the contexts in primitive_save_image_and_exit() it has the same effect but is simpler 2015-01-15 09:29:14 +00:00
Björn Lindqvist dc9e937beb VM: vm::iterate_active_callstacks is only used once, so it's simpler if the code body is "inline" 2015-01-15 09:29:14 +00:00
Björn Lindqvist fb9fa12cdd VM: change the definition of entry_point in word and quotation from void* to cell
this gets rid of lots of redundant casts from void* to cell
2015-01-15 09:29:13 +00:00
Björn Lindqvist e47181e87a VM: change type of callstack_top and callstack_bottom from void* to cell
cell and void* is always the same size, but now you can remove lots of
redundant type casts from void* to cell.
2015-01-15 09:29:13 +00:00
Björn Lindqvist 423e983514 VM: refactoring to get rid of the megamorphic_call_stub and check_code_pointer() words 2014-12-04 10:23:33 -08:00
Björn Lindqvist 885b5c7043 VM: no need for a nursery_space class, it's just a bump_allocator 2014-12-04 10:23:33 -08:00
Björn Lindqvist 50c74fc496 VM: get rid of the duplicated nursery instance in vm->data->nursery
vm.nursery and vm->data->nursery are different objects. They get out
of sync when Factor code bumps vm.nursery but leaves vm->data->nursery
unchanged. The emptiness of vm->data->nursery meant that each_object()
never iterated it.
2014-11-21 02:16:03 -08:00
Björn Lindqvist 2a5e1e06f3 VM: each_object() can't iterate the nursery so instead we assume it's empty 2014-11-21 02:16:03 -08:00
Björn Lindqvist 161eb0bb49 VM: fixed bignum_divide_unsigned_large_denominator so that it wont data_root-protect NULL-pointers 2014-11-17 17:27:36 -08:00
Björn Lindqvist 8741dbefce VM: bignum_roots traversal code deleted! 2014-11-17 17:27:35 -08:00
Björn Lindqvist 981a02be27 VM: Erasing the last traces of GC_BIGNUM from bignum.cpp 2014-11-17 17:27:35 -08:00
Björn Lindqvist 7d6f282d91 VM: conversion of many more bignum.cpp methods to use data_roots instead
of gc_bignum
2014-11-17 17:27:35 -08:00
Björn Lindqvist 2fcea047d2 VM: bignum_new_sign, bignum_maybe_new_sign and bitnum_magnitude_ash
converted to using data_roots
2014-11-17 17:27:35 -08:00
Björn Lindqvist a4df09a34e VM: a lot of methods in bignum.cpp converted to use data_roots instead of gc_bignums 2014-11-17 17:27:35 -08:00
Björn Lindqvist e00798cd2a VM: new primitive free-callback which is able to free a callback
previously allocated using <callback>
2014-09-29 07:30:21 -07:00
Björn Lindqvist 4a96e6163b VM: new primitive (callback-room) for querying the VM about memory usage
The word works exactly like (code-room) except it looks at the memory
usage in the callback heap instead of the code heap.
2014-09-29 07:30:21 -07:00
Björn Lindqvist a6e0867b22 VM: change type of bignum_roots and remove unnecessary not-null checks
Declaring bignum_roots to contain bignum** instead of cell avoids some
superfluous casts. Casting it to cell is wrong because the items in it
are never tagged. And due to a earlier commit, bignum_roots will never
contain NULL:s so checking for them is not needed.
2014-06-12 13:50:10 -07:00
Björn Lindqvist 8ac3b80173 VM: rename all variables named "bignum" in bignum.cpp to "bn"
The name can cause compiler errors because it's the same as the type
name. It only matters in some functions, but I like consistency so I
renamed it everywhere.
2014-06-12 13:50:10 -07:00
Björn Lindqvist 0c9e61ca99 VM: refactoring that removes data_root_ranges
instead of storing data_root_ranges in data_roots, you can just store
cell pointers directly. the advantage with doing it that way is that
registration and traversal code becomes simpler (and slightly faster).
2014-06-12 13:50:10 -07:00
John Benediktsson e9e1fd4e6a vm: generate a to_fixnum_strict to workaround an odd io.monitors issue. 2014-06-07 12:06:03 -07:00
John Benediktsson eeaa91d6c1 vm: using bignum>fixnum-strict in integer>fixnum-strict. 2014-06-07 09:46:05 -07:00
Björn Lindqvist a9a52d9174 VM: bignum_to_fixnum_strict and an accompanying vm error in case the conversion fails 2014-06-07 12:13:59 +02:00
Björn Lindqvist 877e3a12e1 VM: allot_array_1, allot_array_2 are unused and primitive_array should use allot_array 2014-06-07 12:13:59 +02:00
John Benediktsson 6c703bbd6c vm: adding a fast path for bignum sq. 2014-06-06 10:45:09 -07:00
Erik Charlebois ffe41b3d7f VM: Fixup cast formatting after clang-format
clang-format doesn't recognize casts to non-pointer/non-template types
so it winds up adding a space between the right paren and the expression
and then failing to recognize prefix operators in the process
(e.g. foo = (cell) & bar; should be foo = (cell)&bar;). This commit
manually fixes up the major cases (fixnum, cell, all types ending in _t).
2013-05-13 14:59:24 -04:00
Erik Charlebois 88d7c10d03 VM: Replace u8-64, s8-64, cell, fixnum with stdint.h equivalents 2013-05-13 00:28:25 -04:00
Erik Charlebois b918c3e646 VM: Remove redundant #ifdef FACTOR_DEBUGs
FACTOR_DEBUG checks around asserts aren't needed, since FACTOR_ASSERT is
already conditionally defined by FACTOR_DEBUG.
2013-05-12 23:44:32 -04:00
Erik Charlebois 5614985c3d VM: Refactor vm.cpp/hpp to Factor style 2013-05-12 13:24:48 -04:00
Erik Charlebois ca2ea548be VM: Remove exec bit from VM source files 2013-05-11 17:04:23 -04:00
Doug Coleman 2b33dde782 vm: Add more Allocates memory comments. 2013-03-25 17:52:30 -07:00
John Benediktsson 5be15d7e3f vm: more use of ctx->replace(). 2013-03-22 09:17:02 -07:00
John Benediktsson 22c26ff3f5 vm: adding bignum_gcd primitive. 2012-04-05 09:17:35 -07:00
Joe Groff b6f323450f vm: load mega cache object before popping frame
Fixes #457 harder
2011-12-20 14:38:01 -08:00
Joe Groff a1ee881435 vm: get rid of now-trivial innermost_stack_frame 2011-12-14 09:56:49 -08:00
Joe Groff 604ceb957c vm: replace remaining stack_frame-based logic 2011-12-14 09:56:49 -08:00
Joe Groff d74f194b07 vm: remove _reversed from callstack iterator names
Now that they're the only game in town we can give them the short names
2011-12-14 09:56:49 -08:00
Joe Groff f6a5f48da0 vm: remove iterate_callstack_object 2011-12-14 09:56:48 -08:00
Joe Groff a1958c67bd vm: callstack_reversed for callstack_to_array 2011-12-14 09:56:48 -08:00
Joe Groff 0af5fff27c remove iterate_callstack now that it's unused 2011-12-14 09:56:48 -08:00
Joe Groff e6a80aa9aa vm: callstack_reversed in code_block_visitor 2011-12-14 09:56:48 -08:00
Joe Groff d12b6e375b vm: iterate_callstack_reversed in slot_visitor 2011-12-14 09:56:47 -08:00
Joe Groff e116bc497b vm: reversed callstack iteration 2011-12-14 09:56:47 -08:00
Joe Groff e2fafaed9c WIP verify_callstack function
dumps callstack in reverse order so i can visually inspect that it matches the old forward walking logic
2011-12-14 09:56:47 -08:00
Joe Groff e21f316583 vm: store stack frame size in code blocks
Change modify-code-heap primitive so it takes a sixth element in each array for the frame size.
2011-12-14 09:56:45 -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 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 5e99a7bbbf vm: disable SIGINT handler while in factorbug
Fixes #410
2011-11-15 18:50:42 -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 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 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 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 ec19171220 vm: readable feps for more types 2011-11-06 20:26:52 -08:00
Joe Groff 2d87b68a56 vm: sample pc on windows 2011-11-02 21:18:31 -07:00
Joe Groff 82a62181ce vm: count samples during unoptimized compiler 2011-11-02 13:23:21 -07:00
Joe Groff 73845fdad9 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 4d39e59054 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 7da8a9776f vm: sample code block owners instead of blocks 2011-11-02 13:23:17 -07:00
Joe Groff 4037c981eb vm: die if we fault in a fault 2011-11-02 13:23:16 -07:00
Joe Groff 29fa23c40a vm: quell MSVC warnings 2011-11-02 13:23:16 -07:00
Joe Groff 30ed9b535b vm: parameterize sampling rate 2011-11-02 13:23:15 -07:00