Merge branch 'master' into experimental

db4
Alex Chapman 2009-02-25 11:16:11 +11:00
commit 969fff0f5b
665 changed files with 4505 additions and 4220 deletions

View File

@ -1,4 +1,4 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: byte-arrays arrays assocs kernel kernel.private libc math USING: byte-arrays arrays assocs kernel kernel.private libc math
namespaces make parser sequences strings words assocs splitting namespaces make parser sequences strings words assocs splitting
@ -275,7 +275,7 @@ M: long-long-type box-return ( type -- )
: if-void ( type true false -- ) : if-void ( type true false -- )
pick "void" = [ drop nip call ] [ nip call ] if ; inline pick "void" = [ drop nip call ] [ nip call ] if ; inline
: primitive-types CONSTANT: primitive-types
{ {
"char" "uchar" "char" "uchar"
"short" "ushort" "short" "ushort"
@ -284,7 +284,7 @@ M: long-long-type box-return ( type -- )
"longlong" "ulonglong" "longlong" "ulonglong"
"float" "double" "float" "double"
"void*" "bool" "void*" "bool"
} ; }
[ [
<c-type> <c-type>

View File

@ -0,0 +1 @@
Code generation for C99 complex number support

View File

@ -170,8 +170,8 @@ M: character-type (fortran-type>c-type)
: (parse-fortran-type) ( fortran-type-string -- type ) : (parse-fortran-type) ( fortran-type-string -- type )
parse-out swap parse-dims swap parse-size swap parse-out swap parse-dims swap parse-size swap
dup >lower fortran>c-types at* >lower fortran>c-types ?at
[ nip new-fortran-type ] [ drop misc-type boa ] if ; [ new-fortran-type ] [ misc-type boa ] if ;
: parse-fortran-type ( fortran-type-string/f -- type/f ) : parse-fortran-type ( fortran-type-string/f -- type/f )
dup [ (parse-fortran-type) ] when ; dup [ (parse-fortran-type) ] when ;

View File

@ -0,0 +1 @@
Utilities used in implementation of alien parsing words

View File

@ -0,0 +1 @@
Prettyprinting aliens and DLLs

View File

@ -0,0 +1 @@
Passing Factor strings as C strings and vice versa

View File

@ -0,0 +1 @@
Default string encoding on Unix

View File

@ -0,0 +1 @@
Default string encoding on Windows

View File

@ -0,0 +1 @@
Struct field implementation and reflection support

View File

@ -0,0 +1 @@
Priority queue with fast insertion, removal of first element, and lookup of arbitrary elements by key

View File

@ -0,0 +1 @@
Reading sequences of bits from a byte stream

View File

@ -5,12 +5,13 @@ IN: bootstrap.help
: load-help ( -- ) : load-help ( -- )
"help.lint" require "help.lint" require
"tools.vocabs.browser" require
"alien.syntax" require "alien.syntax" require
"compiler" require "compiler" require
t load-help? set-global t load-help? set-global
[ drop ] load-vocab-hook [ [ vocab ] load-vocab-hook [
dictionary get values dictionary get values
[ docs-loaded?>> not ] filter [ docs-loaded?>> not ] filter
[ load-docs ] each [ load-docs ] each

View File

@ -4,7 +4,7 @@ USING: http.client checksums checksums.md5 splitting assocs
kernel io.files bootstrap.image sequences io urls ; kernel io.files bootstrap.image sequences io urls ;
IN: bootstrap.image.download IN: bootstrap.image.download
: url URL" http://factorcode.org/images/latest/" ; CONSTANT: url URL" http://factorcode.org/images/latest/"
: download-checksums ( -- alist ) : download-checksums ( -- alist )
url "checksums.txt" >url derive-url http-get nip url "checksums.txt" >url derive-url http-get nip

View File

@ -77,20 +77,20 @@ SYMBOL: objects
! Constants ! Constants
: image-magic HEX: 0f0e0d0c ; inline CONSTANT: image-magic HEX: 0f0e0d0c
: image-version 4 ; inline CONSTANT: image-version 4
: data-base 1024 ; inline CONSTANT: data-base 1024
: userenv-size 70 ; inline CONSTANT: userenv-size 70
: header-size 10 ; inline CONSTANT: header-size 10
: data-heap-size-offset 3 ; inline CONSTANT: data-heap-size-offset 3
: t-offset 6 ; inline CONSTANT: t-offset 6
: 0-offset 7 ; inline CONSTANT: 0-offset 7
: 1-offset 8 ; inline CONSTANT: 1-offset 8
: -1-offset 9 ; inline CONSTANT: -1-offset 9
SYMBOL: sub-primitives SYMBOL: sub-primitives

View File

@ -93,9 +93,9 @@ SYMBOL: bootstrap-time
"tools.deploy.shaker" run "tools.deploy.shaker" run
] [ ] [
"staging" get [ "staging" get [
"resource:basis/bootstrap/finish-staging.factor" run-file "vocab:bootstrap/finish-staging.factor" run-file
] [ ] [
"resource:basis/bootstrap/finish-bootstrap.factor" run-file "vocab:bootstrap/finish-bootstrap.factor" run-file
] if ] if
"output-image" get save-image-and-exit "output-image" get save-image-and-exit
@ -104,6 +104,6 @@ SYMBOL: bootstrap-time
drop drop
[ [
load-help? off load-help? off
"resource:basis/bootstrap/bootstrap-error.factor" run-file "vocab:bootstrap/bootstrap-error.factor" run-file
] with-scope ] with-scope
] recover ] recover

View File

@ -1,9 +1,8 @@
USING: arrays byte-arrays help.markup help.syntax kernel USING: arrays byte-arrays help.markup help.syntax kernel combinators ;
byte-vectors.private combinators ;
IN: byte-vectors IN: byte-vectors
ARTICLE: "byte-vectors" "Byte vectors" ARTICLE: "byte-vectors" "Byte vectors"
"A byte vector is a resizable mutable sequence of unsigned bytes. Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary." "The " { $vocab-link "byte-vectors" } " vocabulary implements resizable mutable sequence of unsigned bytes. Byte vectors implement the " { $link "sequence-protocol" } " and thus all " { $link "sequences" } " can be used with them."
$nl $nl
"Byte vectors form a class:" "Byte vectors form a class:"
{ $subsection byte-vector } { $subsection byte-vector }

View File

@ -72,9 +72,9 @@ C-ENUM:
CAIRO_STATUS_INVALID_STRIDE ; CAIRO_STATUS_INVALID_STRIDE ;
TYPEDEF: int cairo_content_t TYPEDEF: int cairo_content_t
: CAIRO_CONTENT_COLOR HEX: 1000 ; CONSTANT: CAIRO_CONTENT_COLOR HEX: 1000
: CAIRO_CONTENT_ALPHA HEX: 2000 ; CONSTANT: CAIRO_CONTENT_ALPHA HEX: 2000
: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000 ; CONSTANT: CAIRO_CONTENT_COLOR_ALPHA HEX: 3000
TYPEDEF: void* cairo_write_func_t TYPEDEF: void* cairo_write_func_t
: cairo-write-func ( quot -- callback ) : cairo-write-func ( quot -- callback )

View File

@ -0,0 +1 @@
Low-level alien interface to Cairo library

View File

@ -0,0 +1 @@
UI gadget for rendering graphics with Cairo

View File

@ -61,7 +61,7 @@ PRIVATE>
: month-abbreviation ( n -- string ) : month-abbreviation ( n -- string )
check-month 1- month-abbreviations nth ; check-month 1- month-abbreviations nth ;
: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 } ; inline CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
: day-names ( -- array ) : day-names ( -- array )
{ {

View File

@ -51,6 +51,11 @@ IN: calendar.format.tests
timestamp>string timestamp>string
] unit-test ] unit-test
[ "20080504070000" ] [
"Sun May 04 07:00:00 2008 GMT" cookie-string>timestamp
timestamp>mdtm
] unit-test
[ [
T{ timestamp f T{ timestamp f
2008 2008
@ -74,3 +79,5 @@ IN: calendar.format.tests
{ gmt-offset T{ duration f 0 0 0 0 0 0 } } { gmt-offset T{ duration f 0 0 0 0 0 0 } }
} }
] [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test ] [ "Thursday, 02-Oct-2008 23:59:59 GMT" cookie-string>timestamp ] unit-test

View File

@ -78,6 +78,9 @@ M: integer year. ( n -- )
M: timestamp year. ( timestamp -- ) M: timestamp year. ( timestamp -- )
year>> year. ; year>> year. ;
: timestamp>mdtm ( timestamp -- str )
[ { YYYY MM DD hh mm ss } formatted ] with-string-writer ;
: (timestamp>string) ( timestamp -- ) : (timestamp>string) ( timestamp -- )
{ DAY ", " D " " MONTH " " YYYY " " hh ":" mm ":" ss } formatted ; { DAY ", " D " " MONTH " " YYYY " " hh ":" mm ":" ss } formatted ;

View File

@ -0,0 +1 @@
Implementation details for calendar.format

View File

@ -0,0 +1 @@
Unix-specific timezone support and C library time data types

View File

@ -0,0 +1 @@
Windows-specific timezone support

1
basis/call/summary.txt Normal file
View File

@ -0,0 +1 @@
Calling arbitrary quotations and executing arbitrary words with a static stack effect

View File

@ -6,7 +6,7 @@ IN: checksums.adler-32
SINGLETON: adler-32 SINGLETON: adler-32
: adler-32-modulus 65521 ; inline CONSTANT: adler-32-modulus 65521
M: adler-32 checksum-bytes ( bytes checksum -- value ) M: adler-32 checksum-bytes ( bytes checksum -- value )
drop drop

View File

@ -0,0 +1 @@
Adler-32 checksum algorithm

View File

@ -0,0 +1 @@
MD5 checksum algorithm

View File

@ -0,0 +1 @@
Dummy checksum algorithm

View File

@ -9,9 +9,9 @@ ERROR: unknown-digest name ;
TUPLE: openssl-checksum name ; TUPLE: openssl-checksum name ;
: openssl-md5 T{ openssl-checksum f "md5" } ; CONSTANT: openssl-md5 T{ openssl-checksum f "md5" }
: openssl-sha1 T{ openssl-checksum f "sha1" } ; CONSTANT: openssl-sha1 T{ openssl-checksum f "sha1" }
INSTANCE: openssl-checksum stream-checksum INSTANCE: openssl-checksum stream-checksum

View File

@ -0,0 +1 @@
OpenSSL's MD5 and SHA1 checksums

View File

@ -0,0 +1 @@
SHA1 checksum algorithm

View File

@ -9,14 +9,14 @@ IN: checksums.sha2
SYMBOLS: vars M K H S0 S1 process-M word-size block-size ; SYMBOLS: vars M K H S0 S1 process-M word-size block-size ;
: a 0 ; inline CONSTANT: a 0
: b 1 ; inline CONSTANT: b 1
: c 2 ; inline CONSTANT: c 2
: d 3 ; inline CONSTANT: d 3
: e 4 ; inline CONSTANT: e 4
: f 5 ; inline CONSTANT: f 5
: g 6 ; inline CONSTANT: g 6
: h 7 ; inline CONSTANT: h 7
: initial-H-256 ( -- seq ) : initial-H-256 ( -- seq )
{ {

View File

@ -0,0 +1 @@
SHA2 checksum algorithm

View File

@ -0,0 +1 @@
Computing checksums of streaming data

View File

@ -19,9 +19,9 @@ IN: cocoa.application
] curry assoc-each ] curry assoc-each
] keep ; ] keep ;
: NSApplicationDelegateReplySuccess 0 ; CONSTANT: NSApplicationDelegateReplySuccess 0
: NSApplicationDelegateReplyCancel 1 ; CONSTANT: NSApplicationDelegateReplyCancel 1
: NSApplicationDelegateReplyFailure 2 ; CONSTANT: NSApplicationDelegateReplyFailure 2
: with-autorelease-pool ( quot -- ) : with-autorelease-pool ( quot -- )
NSAutoreleasePool -> new slip -> release ; inline NSAutoreleasePool -> new slip -> release ; inline

View File

@ -18,8 +18,8 @@ IN: cocoa.dialogs
dup 0 -> setCanChooseDirectories: dup 0 -> setCanChooseDirectories:
dup 0 -> setAllowsMultipleSelection: ; dup 0 -> setAllowsMultipleSelection: ;
: NSOKButton 1 ; CONSTANT: NSOKButton 1
: NSCancelButton 0 ; CONSTANT: NSCancelButton 0
: open-panel ( -- paths ) : open-panel ( -- paths )
<NSOpenPanel> <NSOpenPanel>

View File

@ -5,7 +5,7 @@ sequences vectors fry libc destructors
specialized-arrays.direct.alien ; specialized-arrays.direct.alien ;
IN: cocoa.enumeration IN: cocoa.enumeration
: NS-EACH-BUFFER-SIZE 16 ; inline CONSTANT: NS-EACH-BUFFER-SIZE 16
: with-enumeration-buffers ( quot -- ) : with-enumeration-buffers ( quot -- )
[ [

View File

@ -0,0 +1 @@
Support for iterating over NSFastEnumerations

View File

@ -1,11 +1,11 @@
! Copyright (C) 2006, 2008 Slava Pestov. ! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types alien.strings arrays assocs USING: accessors alien alien.c-types alien.strings arrays assocs
continuations combinators compiler compiler.alien kernel math continuations combinators compiler compiler.alien stack-checker kernel
namespaces make parser quotations sequences strings words math namespaces make parser quotations sequences strings words
cocoa.runtime io macros memoize io.encodings.utf8 cocoa.runtime io macros memoize io.encodings.utf8 effects libc
effects libc libc.private parser lexer init core-foundation fry libc.private parser lexer init core-foundation fry generalizations
generalizations specialized-arrays.direct.alien call ; specialized-arrays.direct.alien call ;
IN: cocoa.messages IN: cocoa.messages
: make-sender ( method function -- quot ) : make-sender ( method function -- quot )
@ -14,7 +14,7 @@ IN: cocoa.messages
: sender-stub ( method function -- word ) : sender-stub ( method function -- word )
[ "( sender-stub )" f <word> dup ] 2dip [ "( sender-stub )" f <word> dup ] 2dip
over first large-struct? [ "_stret" append ] when over first large-struct? [ "_stret" append ] when
make-sender define ; make-sender dup infer define-declared ;
SYMBOL: message-senders SYMBOL: message-senders
SYMBOL: super-message-senders SYMBOL: super-message-senders

View File

@ -5,7 +5,7 @@ cocoa.classes cocoa.application sequences cocoa core-foundation
core-foundation.strings core-foundation.arrays ; core-foundation.strings core-foundation.arrays ;
IN: cocoa.pasteboard IN: cocoa.pasteboard
: NSStringPboardType "NSStringPboardType" ; CONSTANT: NSStringPboardType "NSStringPboardType"
: pasteboard-string? ( pasteboard -- ? ) : pasteboard-string? ( pasteboard -- ? )
NSStringPboardType swap -> types CF>string-array member? ; NSStringPboardType swap -> types CF>string-array member? ;

View File

@ -0,0 +1 @@
Reading and writing Cocoa property lists

View File

@ -21,15 +21,15 @@ C-STRUCT: objc-super
{ "id" "receiver" } { "id" "receiver" }
{ "Class" "class" } ; { "Class" "class" } ;
: CLS_CLASS HEX: 1 ; CONSTANT: CLS_CLASS HEX: 1
: CLS_META HEX: 2 ; CONSTANT: CLS_META HEX: 2
: CLS_INITIALIZED HEX: 4 ; CONSTANT: CLS_INITIALIZED HEX: 4
: CLS_POSING HEX: 8 ; CONSTANT: CLS_POSING HEX: 8
: CLS_MAPPED HEX: 10 ; CONSTANT: CLS_MAPPED HEX: 10
: CLS_FLUSH_CACHE HEX: 20 ; CONSTANT: CLS_FLUSH_CACHE HEX: 20
: CLS_GROW_CACHE HEX: 40 ; CONSTANT: CLS_GROW_CACHE HEX: 40
: CLS_NEED_BIND HEX: 80 ; CONSTANT: CLS_NEED_BIND HEX: 80
: CLS_METHOD_ARRAY HEX: 100 ; CONSTANT: CLS_METHOD_ARRAY HEX: 100
FUNCTION: int objc_getClassList ( void* buffer, int bufferLen ) ; FUNCTION: int objc_getClassList ( void* buffer, int bufferLen ) ;

View File

@ -38,9 +38,9 @@ IN: cocoa.subclassing
] map concat ; ] map concat ;
: prepare-method ( ret types quot -- type imp ) : prepare-method ( ret types quot -- type imp )
[ [ encode-types ] 2keep ] dip [ [ [ encode-types ] 2keep ] dip
"cdecl" swap 4array % \ alien-callback , '[ _ _ "cdecl" _ alien-callback ]
] [ ] make define-temp ; (( -- callback )) define-temp ;
: prepare-methods ( methods -- methods ) : prepare-methods ( methods -- methods )
[ [

View File

@ -5,43 +5,43 @@ cocoa cocoa.messages cocoa.classes cocoa.types sequences
continuations accessors ; continuations accessors ;
IN: cocoa.views IN: cocoa.views
: NSOpenGLPFAAllRenderers 1 ; CONSTANT: NSOpenGLPFAAllRenderers 1
: NSOpenGLPFADoubleBuffer 5 ; CONSTANT: NSOpenGLPFADoubleBuffer 5
: NSOpenGLPFAStereo 6 ; CONSTANT: NSOpenGLPFAStereo 6
: NSOpenGLPFAAuxBuffers 7 ; CONSTANT: NSOpenGLPFAAuxBuffers 7
: NSOpenGLPFAColorSize 8 ; CONSTANT: NSOpenGLPFAColorSize 8
: NSOpenGLPFAAlphaSize 11 ; CONSTANT: NSOpenGLPFAAlphaSize 11
: NSOpenGLPFADepthSize 12 ; CONSTANT: NSOpenGLPFADepthSize 12
: NSOpenGLPFAStencilSize 13 ; CONSTANT: NSOpenGLPFAStencilSize 13
: NSOpenGLPFAAccumSize 14 ; CONSTANT: NSOpenGLPFAAccumSize 14
: NSOpenGLPFAMinimumPolicy 51 ; CONSTANT: NSOpenGLPFAMinimumPolicy 51
: NSOpenGLPFAMaximumPolicy 52 ; CONSTANT: NSOpenGLPFAMaximumPolicy 52
: NSOpenGLPFAOffScreen 53 ; CONSTANT: NSOpenGLPFAOffScreen 53
: NSOpenGLPFAFullScreen 54 ; CONSTANT: NSOpenGLPFAFullScreen 54
: NSOpenGLPFASampleBuffers 55 ; CONSTANT: NSOpenGLPFASampleBuffers 55
: NSOpenGLPFASamples 56 ; CONSTANT: NSOpenGLPFASamples 56
: NSOpenGLPFAAuxDepthStencil 57 ; CONSTANT: NSOpenGLPFAAuxDepthStencil 57
: NSOpenGLPFAColorFloat 58 ; CONSTANT: NSOpenGLPFAColorFloat 58
: NSOpenGLPFAMultisample 59 ; CONSTANT: NSOpenGLPFAMultisample 59
: NSOpenGLPFASupersample 60 ; CONSTANT: NSOpenGLPFASupersample 60
: NSOpenGLPFASampleAlpha 61 ; CONSTANT: NSOpenGLPFASampleAlpha 61
: NSOpenGLPFARendererID 70 ; CONSTANT: NSOpenGLPFARendererID 70
: NSOpenGLPFASingleRenderer 71 ; CONSTANT: NSOpenGLPFASingleRenderer 71
: NSOpenGLPFANoRecovery 72 ; CONSTANT: NSOpenGLPFANoRecovery 72
: NSOpenGLPFAAccelerated 73 ; CONSTANT: NSOpenGLPFAAccelerated 73
: NSOpenGLPFAClosestPolicy 74 ; CONSTANT: NSOpenGLPFAClosestPolicy 74
: NSOpenGLPFARobust 75 ; CONSTANT: NSOpenGLPFARobust 75
: NSOpenGLPFABackingStore 76 ; CONSTANT: NSOpenGLPFABackingStore 76
: NSOpenGLPFAMPSafe 78 ; CONSTANT: NSOpenGLPFAMPSafe 78
: NSOpenGLPFAWindow 80 ; CONSTANT: NSOpenGLPFAWindow 80
: NSOpenGLPFAMultiScreen 81 ; CONSTANT: NSOpenGLPFAMultiScreen 81
: NSOpenGLPFACompliant 83 ; CONSTANT: NSOpenGLPFACompliant 83
: NSOpenGLPFAScreenMask 84 ; CONSTANT: NSOpenGLPFAScreenMask 84
: NSOpenGLPFAPixelBuffer 90 ; CONSTANT: NSOpenGLPFAPixelBuffer 90
: NSOpenGLPFAAllowOfflineRenderers 96 ; CONSTANT: NSOpenGLPFAAllowOfflineRenderers 96
: NSOpenGLPFAVirtualScreenCount 128 ; CONSTANT: NSOpenGLPFAVirtualScreenCount 128
: kCGLRendererGenericFloatID HEX: 00020400 ; CONSTANT: kCGLRendererGenericFloatID HEX: 00020400
<PRIVATE <PRIVATE
@ -94,7 +94,7 @@ PRIVATE>
USE: opengl.gl USE: opengl.gl
USE: alien.syntax USE: alien.syntax
: NSOpenGLCPSwapInterval 222 ; CONSTANT: NSOpenGLCPSwapInterval 222
LIBRARY: OpenGL LIBRARY: OpenGL

View File

@ -4,15 +4,15 @@ USING: arrays kernel math cocoa cocoa.messages cocoa.classes
sequences math.bitwise ; sequences math.bitwise ;
IN: cocoa.windows IN: cocoa.windows
: NSBorderlessWindowMask 0 ; inline CONSTANT: NSBorderlessWindowMask 0
: NSTitledWindowMask 1 ; inline CONSTANT: NSTitledWindowMask 1
: NSClosableWindowMask 2 ; inline CONSTANT: NSClosableWindowMask 2
: NSMiniaturizableWindowMask 4 ; inline CONSTANT: NSMiniaturizableWindowMask 4
: NSResizableWindowMask 8 ; inline CONSTANT: NSResizableWindowMask 8
: NSBackingStoreRetained 0 ; inline CONSTANT: NSBackingStoreRetained 0
: NSBackingStoreNonretained 1 ; inline CONSTANT: NSBackingStoreNonretained 1
: NSBackingStoreBuffered 2 ; inline CONSTANT: NSBackingStoreBuffered 2
: standard-window-type ( -- n ) : standard-window-type ( -- n )
{ {

View File

@ -18,16 +18,16 @@ M: color red>> ( color -- red ) >rgba red>> ;
M: color green>> ( color -- green ) >rgba green>> ; M: color green>> ( color -- green ) >rgba green>> ;
M: color blue>> ( color -- blue ) >rgba blue>> ; M: color blue>> ( color -- blue ) >rgba blue>> ;
: black T{ rgba f 0.0 0.0 0.0 1.0 } ; inline CONSTANT: black T{ rgba f 0.0 0.0 0.0 1.0 }
: blue T{ rgba f 0.0 0.0 1.0 1.0 } ; inline CONSTANT: blue T{ rgba f 0.0 0.0 1.0 1.0 }
: cyan T{ rgba f 0 0.941 0.941 1 } ; inline CONSTANT: cyan T{ rgba f 0 0.941 0.941 1 }
: gray T{ rgba f 0.6 0.6 0.6 1.0 } ; inline CONSTANT: gray T{ rgba f 0.6 0.6 0.6 1.0 }
: green T{ rgba f 0.0 1.0 0.0 1.0 } ; inline CONSTANT: green T{ rgba f 0.0 1.0 0.0 1.0 }
: light-gray T{ rgba f 0.95 0.95 0.95 0.95 } ; inline CONSTANT: light-gray T{ rgba f 0.95 0.95 0.95 0.95 }
: light-purple T{ rgba f 0.8 0.8 1.0 1.0 } ; inline CONSTANT: light-purple T{ rgba f 0.8 0.8 1.0 1.0 }
: magenta T{ rgba f 0.941 0 0.941 1 } ; inline CONSTANT: magenta T{ rgba f 0.941 0 0.941 1 }
: orange T{ rgba f 0.941 0.627 0 1 } ; inline CONSTANT: orange T{ rgba f 0.941 0.627 0 1 }
: purple T{ rgba f 0.627 0 0.941 1 } ; inline CONSTANT: purple T{ rgba f 0.627 0 0.941 1 }
: red T{ rgba f 1.0 0.0 0.0 1.0 } ; inline CONSTANT: red T{ rgba f 1.0 0.0 0.0 1.0 }
: white T{ rgba f 1.0 1.0 1.0 1.0 } ; inline CONSTANT: white T{ rgba f 1.0 1.0 1.0 1.0 }
: yellow T{ rgba f 1.0 1.0 0.0 1.0 } ; inline CONSTANT: yellow T{ rgba f 1.0 1.0 0.0 1.0 }

View File

@ -0,0 +1 @@
Grayscale colors

View File

@ -0,0 +1 @@
Hue-saturation-value colors

View File

@ -0,0 +1 @@
Short-circuiting logical operations which infer the arity

View File

@ -0,0 +1 @@
Short-circuiting logical operations

View File

@ -0,0 +1 @@
Combinators which infer arities

View File

@ -0,0 +1 @@
Common code used for analysis and code generation of alien bindings

View File

@ -0,0 +1 @@
Alias analysis for stack operations, array elements and tuple slots

View File

@ -0,0 +1 @@
Common code used by several passes to perform copy propagation

View File

@ -0,0 +1 @@
Dead-code elimination

View File

@ -16,7 +16,7 @@ M: callable test-cfg
build-tree optimize-tree gensym build-cfg ; build-tree optimize-tree gensym build-cfg ;
M: word test-cfg M: word test-cfg
[ build-tree-from-word nip optimize-tree ] keep build-cfg ; [ build-tree-from-word optimize-tree ] keep build-cfg ;
SYMBOL: allocate-registers? SYMBOL: allocate-registers?

View File

@ -0,0 +1 @@
Tools for debugging low-level optimizer

View File

@ -0,0 +1 @@
Common code used by several passes for def-use analysis

View File

@ -0,0 +1 @@
Utility for constructing basic blocks

View File

@ -0,0 +1 @@
Stack height normalization coalesces height changes at start of basic block

View File

@ -0,0 +1 @@
Basic block instructions

View File

@ -0,0 +1 @@
Parsing word for defining instructions

View File

@ -0,0 +1 @@
Generating instructions for alien calls

View File

@ -0,0 +1 @@
Generating instructions for inline memory allocation

View File

@ -0,0 +1 @@
Generating instructions for fixnum arithmetic

View File

@ -0,0 +1 @@
Generating instructions for floating point arithmetic

View File

@ -0,0 +1 @@
Generating instructions for miscellaneous primitives

View File

@ -0,0 +1 @@
Generating instructions for slot access

View File

@ -0,0 +1 @@
Generating instructions from certain primitives

View File

@ -0,0 +1 @@
Utility for iterating for high-level IR

View File

@ -0,0 +1 @@
Allocating registers for live intervals

View File

@ -0,0 +1 @@
Assigning registers to live intervals

View File

@ -0,0 +1 @@
Tools for debugging register allocator

View File

@ -0,0 +1 @@
Live intervals

View File

@ -0,0 +1 @@
Linear-scan register allocation

View File

@ -0,0 +1 @@
Flattening CFG into MR (machine representation)

View File

@ -0,0 +1 @@
Top-level harness for CFG optimization

View File

@ -0,0 +1 @@
Computing predecessors of basic blocks in CFG

View File

@ -0,0 +1 @@
Virtual single-assignment registers

View File

@ -0,0 +1 @@
Reverse post-order linearization of CFG

View File

@ -0,0 +1 @@
Computing stack frame size and layout

View File

@ -0,0 +1 @@
Generating instructions for accessing the data and retain stacks

View File

@ -0,0 +1 @@
Low-level control flow graph IR

View File

@ -0,0 +1 @@
Converting three-operand instructions into two-operand form

View File

@ -0,0 +1 @@
Eliminating unreachable basic blocks and unconditional jumps

View File

@ -0,0 +1 @@
Utility words used by CFG optimization

View File

@ -0,0 +1 @@
Value numbering expressions

View File

@ -0,0 +1 @@
Value numbering expression graph

View File

@ -0,0 +1 @@
Propagation pass to update code after value numbering

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
Algebraic simplification of expressions

View File

@ -0,0 +1 @@
Local value numbering for common subexpression elimination

View File

@ -0,0 +1 @@
Write barrier elimination

View File

@ -0,0 +1 @@
Code generation from MR (machine representation)

View File

@ -1,5 +1,5 @@
USING: help.markup help.syntax words io parser USING: help.markup help.syntax words io parser
assocs words.private sequences compiler.units ; assocs words.private sequences compiler.units quotations ;
IN: compiler IN: compiler
HELP: enable-compiler HELP: enable-compiler
@ -16,18 +16,24 @@ ARTICLE: "compiler-usage" "Calling the optimizing compiler"
{ $subsection optimized-recompile-hook } { $subsection optimized-recompile-hook }
"Removing a word's optimized definition:" "Removing a word's optimized definition:"
{ $subsection decompile } { $subsection decompile }
"Compiling a single quotation:"
{ $subsection compile-call }
"Higher-level words can be found in " { $link "compilation-units" } "." ; "Higher-level words can be found in " { $link "compilation-units" } "." ;
ARTICLE: "compiler" "Optimizing compiler" ARTICLE: "compiler" "Optimizing compiler"
"Factor is a fully compiled language implementation with two distinct compilers:" "Factor includes two compilers which work behind the scenes. Words are always compiled, and the compilers do not have to be invoked explicitly. For the most part, compilation is fully transparent. However, there are a few things worth knowing about the compilation process."
$nl
"The two compilers differ in the level of analysis they perform:"
{ $list { $list
{ "The " { $emphasis "non-optimizing quotation compiler" } " compiles quotations to naive machine code very quickly. The non-optimizing quotation compiler is part of the VM." } { "The " { $emphasis "non-optimizing quotation compiler" } " compiles quotations to naive machine code very quickly. The non-optimizing quotation compiler is part of the VM." }
{ "The " { $emphasis "optimizing word compiler" } " compiles whole words at a time while performing extensive data and control flow analysis. This provides greater performance for generated code, but incurs a much longer compile time. The optimizing compiler is written in Factor." } { "The " { $emphasis "optimizing word compiler" } " compiles whole words at a time while performing extensive data and control flow analysis. This provides greater performance for generated code, but incurs a much longer compile time. The optimizing compiler is written in Factor." }
} }
"The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect; for otherwise, most of the system would be compiled with the non-optimizing compiler. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "." "The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "."
{ $subsection "compiler-usage" } $nl
"The optimizing compiler also trades off compile time for performance of generated code, so loading certain vocabularies might take a while. Saving the image after loading vocabularies can save you a lot of time that you would spend waiting for the same code to load in every coding session; see " { $link "images" } " for information."
{ $subsection "compiler-errors" } { $subsection "compiler-errors" }
{ $subsection "hints" } ; { $subsection "hints" }
{ $subsection "compiler-usage" } ;
ABOUT: "compiler" ABOUT: "compiler"
@ -44,3 +50,8 @@ HELP: optimized-recompile-hook
{ $values { "words" "a sequence of words" } { "alist" "an association list" } } { $values { "words" "a sequence of words" } { "alist" "an association list" } }
{ $description "Compile a set of words." } { $description "Compile a set of words." }
{ $notes "This is an internal word, and user code should call " { $link compile } " instead." } ; { $notes "This is an internal word, and user code should call " { $link compile } " instead." } ;
HELP: compile-call
{ $values { "quot" quotation } }
{ $description "Compiles and runs a quotation." }
{ $notes "This word is used by compiler unit tests to test compilation of small pieces of code." } ;

View File

@ -1,46 +1,47 @@
! Copyright (C) 2004, 2009 Slava Pestov. ! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel namespaces arrays sequences io USING: accessors kernel namespaces arrays sequences io words fry
words fry continuations vocabs assocs dlists definitions math continuations vocabs assocs dlists definitions math graphs
graphs generic combinators deques search-deques io generic combinators deques search-deques io stack-checker
stack-checker stack-checker.state stack-checker.inlining stack-checker.state stack-checker.inlining
compiler.errors compiler.units compiler.tree.builder combinators.short-circuit compiler.errors compiler.units
compiler.tree.optimizer compiler.cfg.builder compiler.tree.builder compiler.tree.optimizer
compiler.cfg.optimizer compiler.cfg.linearization compiler.cfg.builder compiler.cfg.optimizer
compiler.cfg.two-operand compiler.cfg.linear-scan compiler.cfg.linearization compiler.cfg.two-operand
compiler.cfg.stack-frame compiler.codegen compiler.utilities ; compiler.cfg.linear-scan compiler.cfg.stack-frame
compiler.codegen compiler.utilities ;
IN: compiler IN: compiler
SYMBOL: compile-queue SYMBOL: compile-queue
SYMBOL: compiled SYMBOL: compiled
: queue-compile ( word -- ) : queue-compile? ( word -- ? )
{ {
{ [ dup "forgotten" word-prop ] [ ] } [ "forgotten" word-prop ]
{ [ dup compiled get key? ] [ ] } [ compiled get key? ]
{ [ dup inlined-block? ] [ ] } [ inlined-block? ]
{ [ dup primitive? ] [ ] } [ primitive? ]
[ dup compile-queue get push-front ] } 1|| not ;
} cond drop ;
: queue-compile ( word -- )
dup queue-compile? [ compile-queue get push-front ] [ drop ] if ;
: maybe-compile ( word -- ) : maybe-compile ( word -- )
dup optimized>> [ drop ] [ queue-compile ] if ; dup optimized>> [ drop ] [ queue-compile ] if ;
SYMBOL: +failed+ SYMBOLS: +optimized+ +unoptimized+ ;
: ripple-up ( words -- ) : ripple-up ( words -- )
dup "compiled-effect" word-prop +failed+ eq? dup "compiled-status" word-prop +unoptimized+ eq?
[ usage [ word? ] filter ] [ compiled-usage keys ] if [ usage [ word? ] filter ] [ compiled-usage keys ] if
[ queue-compile ] each ; [ queue-compile ] each ;
: ripple-up? ( word effect -- ? ) : ripple-up? ( word status -- ? )
#! If the word has previously been compiled and had a swap "compiled-status" word-prop [ = not ] keep and ;
#! different stack effect, we have to recompile any callers.
swap "compiled-effect" word-prop [ = not ] keep and ;
: save-effect ( word effect -- ) : save-compiled-status ( word status -- )
[ dupd ripple-up? [ ripple-up ] [ drop ] if ] [ dupd ripple-up? [ ripple-up ] [ drop ] if ]
[ "compiled-effect" set-word-prop ] [ "compiled-status" set-word-prop ]
2bi ; 2bi ;
: start ( word -- ) : start ( word -- )
@ -49,18 +50,18 @@ SYMBOL: +failed+
H{ } clone generic-dependencies set H{ } clone generic-dependencies set
f swap compiler-error ; f swap compiler-error ;
: fail ( word error -- ) : fail ( word error -- * )
[ swap compiler-error ] [ swap compiler-error ]
[ [
drop drop
[ compiled-unxref ] [ compiled-unxref ]
[ f swap compiled get set-at ] [ f swap compiled get set-at ]
[ +failed+ save-effect ] [ +unoptimized+ save-compiled-status ]
tri tri
] 2bi ] 2bi
return ; return ;
: frontend ( word -- effect nodes ) : frontend ( word -- nodes )
[ build-tree-from-word ] [ fail ] recover optimize-tree ; [ build-tree-from-word ] [ fail ] recover optimize-tree ;
! Only switch this off for debugging. ! Only switch this off for debugging.
@ -84,8 +85,8 @@ t compile-dependencies? set-global
save-asm save-asm
] each ; ] each ;
: finish ( effect word -- ) : finish ( word -- )
[ swap save-effect ] [ +optimized+ save-compiled-status ]
[ compiled-unxref ] [ compiled-unxref ]
[ [
dup crossref? dup crossref?
@ -112,6 +113,9 @@ t compile-dependencies? set-global
: decompile ( word -- ) : decompile ( word -- )
f 2array 1array modify-code-heap ; f 2array 1array modify-code-heap ;
: compile-call ( quot -- )
[ dup infer define-temp ] with-compilation-unit execute ;
: optimized-recompile-hook ( words -- alist ) : optimized-recompile-hook ( words -- alist )
[ [
<hashed-dlist> compile-queue set <hashed-dlist> compile-queue set

View File

@ -4,8 +4,8 @@ USING: math kernel layouts system strings ;
IN: compiler.constants IN: compiler.constants
! These constants must match vm/memory.h ! These constants must match vm/memory.h
: card-bits 8 ; inline CONSTANT: card-bits 8
: deck-bits 18 ; inline CONSTANT: deck-bits 18
: card-mark ( -- n ) HEX: 40 HEX: 80 bitor ; inline : card-mark ( -- n ) HEX: 40 HEX: 80 bitor ; inline
! These constants must match vm/layouts.h ! These constants must match vm/layouts.h
@ -26,25 +26,25 @@ IN: compiler.constants
: compiled-header-size ( -- n ) 4 bootstrap-cells ; inline : compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
! Relocation classes ! Relocation classes
: rc-absolute-cell 0 ; inline CONSTANT: rc-absolute-cell 0
: rc-absolute 1 ; inline CONSTANT: rc-absolute 1
: rc-relative 2 ; inline CONSTANT: rc-relative 2
: rc-absolute-ppc-2/2 3 ; inline CONSTANT: rc-absolute-ppc-2/2 3
: rc-relative-ppc-2 4 ; inline CONSTANT: rc-relative-ppc-2 4
: rc-relative-ppc-3 5 ; inline CONSTANT: rc-relative-ppc-3 5
: rc-relative-arm-3 6 ; inline CONSTANT: rc-relative-arm-3 6
: rc-indirect-arm 7 ; inline CONSTANT: rc-indirect-arm 7
: rc-indirect-arm-pc 8 ; inline CONSTANT: rc-indirect-arm-pc 8
! Relocation types ! Relocation types
: rt-primitive 0 ; inline CONSTANT: rt-primitive 0
: rt-dlsym 1 ; inline CONSTANT: rt-dlsym 1
: rt-dispatch 2 ; inline CONSTANT: rt-dispatch 2
: rt-xt 3 ; inline CONSTANT: rt-xt 3
: rt-here 4 ; inline CONSTANT: rt-here 4
: rt-label 5 ; inline CONSTANT: rt-label 5
: rt-immediate 6 ; inline CONSTANT: rt-immediate 6
: rt-stack-chain 7 ; inline CONSTANT: rt-stack-chain 7
: rc-absolute? ( n -- ? ) : rc-absolute? ( n -- ? )
[ rc-absolute-ppc-2/2 = ] [ rc-absolute-ppc-2/2 = ]

View File

@ -51,7 +51,7 @@ unit-test
\ foo [ global >n get ndrop ] compile-call \ foo [ global >n get ndrop ] compile-call
] unit-test ] unit-test
: blech drop ; : blech ( x -- ) drop ;
[ 3 ] [ 3 ]
[ [
@ -102,7 +102,7 @@ unit-test
[ ] [ [ ] [
[ [
[ 200 dup [ 200 3array ] curry map drop ] times [ 200 dup [ 200 3array ] curry map drop ] times
] [ define-temp ] with-compilation-unit drop ] [ (( n -- )) define-temp ] with-compilation-unit drop
] unit-test ] unit-test
! Test how dispatch handles the end of a basic block ! Test how dispatch handles the end of a basic block

Some files were not shown because too many files have changed in this diff Show More