| 
									
										
										
										
											2010-02-03 07:36:52 -05:00
										 |  |  | ! Copyright (C) 2007, 2010 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2008-01-01 14:54:14 -05:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-05-14 17:54:16 -04:00
										 |  |  | USING: accessors cpu.architecture vocabs.loader system | 
					
						
							| 
									
										
										
										
											2008-06-28 03:36:20 -04:00
										 |  |  | sequences namespaces parser kernel kernel.private classes | 
					
						
							|  |  |  | classes.private arrays hashtables vectors classes.tuple sbufs | 
					
						
							| 
									
										
										
										
											2008-08-12 04:31:48 -04:00
										 |  |  | hashtables.private sequences.private math classes.tuple.private | 
					
						
							| 
									
										
										
										
											2009-10-30 19:00:47 -04:00
										 |  |  | growable namespaces.private assocs words command-line vocabs io | 
					
						
							| 
									
										
										
										
											2009-05-14 17:54:16 -04:00
										 |  |  | io.encodings.string libc splitting math.parser memory compiler.units | 
					
						
							| 
									
										
										
										
											2009-07-30 03:45:29 -04:00
										 |  |  | math.order quotations quotations.private assocs.private ;
 | 
					
						
							|  |  |  | FROM: compiler => enable-optimizer ;
 | 
					
						
							| 
									
										
										
										
											2007-12-24 21:54:45 -05:00
										 |  |  | IN: bootstrap.compiler | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-30 22:27:52 -04:00
										 |  |  | "profile-compiler" get [ | 
					
						
							|  |  |  |     "bootstrap.compiler.timing" require | 
					
						
							|  |  |  | ] when
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-07 16:14:09 -05:00
										 |  |  | ! Don't bring this in when deploying, since it will store a | 
					
						
							|  |  |  | ! reference to 'eval' in a global variable | 
					
						
							| 
									
										
										
										
											2008-12-08 15:58:00 -05:00
										 |  |  | "deploy-vocab" get "staging" get or [ | 
					
						
							| 
									
										
										
										
											2008-01-07 16:14:09 -05:00
										 |  |  |     "alien.remote-control" require | 
					
						
							|  |  |  | ] unless
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-18 15:29:24 -04:00
										 |  |  | { "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when | 
					
						
							|  |  |  | { "boostrap.compiler" "debugger" } "alien.debugger" require-when | 
					
						
							| 
									
										
										
										
											2008-12-08 15:58:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-28 03:36:20 -04:00
										 |  |  | "cpu." cpu name>> append require | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 06:52:05 -04:00
										 |  |  | enable-optimizer | 
					
						
							| 
									
										
										
										
											2008-02-24 03:19:38 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-25 21:33:52 -04:00
										 |  |  | ! Push all tuple layouts to tenured space to improve method caching | 
					
						
							|  |  |  | gc | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 01:37:02 -05:00
										 |  |  | : compile-unoptimized ( words -- )
 | 
					
						
							| 
									
										
										
										
											2010-02-03 07:36:52 -05:00
										 |  |  |     [ [ subwords ] map ] keep suffix concat
 | 
					
						
							| 
									
										
										
										
											2009-04-28 18:26:11 -04:00
										 |  |  |     [ optimized? not ] filter compile ;
 | 
					
						
							| 
									
										
										
										
											2008-04-28 22:26:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  | "debug-compiler" get [ | 
					
						
							| 
									
										
										
										
											2010-04-19 02:13:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     nl
 | 
					
						
							|  |  |  |     "Compiling..." write flush
 | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     ! Compile a set of words ahead of the full compile. | 
					
						
							|  |  |  |     ! This set of words was determined semi-empirically | 
					
						
							|  |  |  |     ! using the profiler. It improves bootstrap time | 
					
						
							|  |  |  |     ! significantly, because frequenly called words | 
					
						
							|  |  |  |     ! which are also quick to compile are replaced by | 
					
						
							|  |  |  |     ! compiled definitions as soon as possible. | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         not ?
 | 
					
						
							| 
									
										
										
										
											2009-07-30 03:45:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-30 19:00:47 -04:00
										 |  |  |         2over
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         array? hashtable? vector?
 | 
					
						
							|  |  |  |         tuple? sbuf? tombstone? | 
					
						
							|  |  |  |         curry? compose? callable? | 
					
						
							|  |  |  |         quotation? | 
					
						
							| 
									
										
										
										
											2009-07-30 03:45:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         curry compose uncurry | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-18 22:42:19 -04:00
										 |  |  |         array-nth set-array-nth | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         wrap probe | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         namestack* | 
					
						
							| 
									
										
										
										
											2009-07-30 03:45:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         layout-of | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2008-06-29 03:12:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         bitand bitor bitxor bitnot
 | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-01-19 08:48:31 -05:00
										 |  |  |         + * 2/ < <= > >= shift
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         new-sequence nth push pop last flip
 | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         hashcode* = equal? assoc-stack (assoc-stack) get set
 | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2008-01-01 14:54:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-10-28 16:02:00 -04:00
										 |  |  |         member-eq? split harvest sift cut cut-slice start index clone
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         set-at reverse push-all class number>string string>number | 
					
						
							|  |  |  |         like clone-like
 | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2007-10-05 17:54:25 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2007-12-28 21:45:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-02-03 08:55:00 -05:00
										 |  |  |         lines prefix suffix unclip new-assoc assoc-union!
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |         word-prop set-word-prop 1array 2array 3array ?nth
 | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							| 
									
										
										
										
											2008-08-22 04:12:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2008-08-22 04:12:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-13 14:58:30 -04:00
										 |  |  |     os windows? [ | 
					
						
							|  |  |  |         "GetLastError" "windows.kernel32" lookup | 
					
						
							|  |  |  |         "FormatMessageW" "windows.kernel32" lookup | 
					
						
							|  |  |  |         2array compile-unoptimized | 
					
						
							|  |  |  |     ] when
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-13 16:17:42 -04:00
										 |  |  |     os unix? [ | 
					
						
							|  |  |  |         "(dlerror)" "alien.libraries.unix" lookup | 
					
						
							|  |  |  |         1array compile-unoptimized | 
					
						
							|  |  |  |     ] when
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         malloc calloc free memcpy | 
					
						
							|  |  |  |     } compile-unoptimized | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     "." write flush
 | 
					
						
							| 
									
										
										
										
											2008-11-06 02:11:28 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     vocabs [ words compile-unoptimized "." write flush ] each
 | 
					
						
							| 
									
										
										
										
											2008-04-05 08:35:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-20 04:48:03 -04:00
										 |  |  |     " done" print flush
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-09 21:36:52 -04:00
										 |  |  |     "alien.syntax" require | 
					
						
							| 
									
										
										
										
											2010-04-19 02:13:21 -04:00
										 |  |  |     "io.streams.byte-array.fast" require | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 16:02:00 -04:00
										 |  |  | ] unless
 |