Compare commits

..

1 Commits

Author SHA1 Message Date
Doug Coleman e5ec13217d dragonflybsd: Initial support. 2019-02-09 20:59:57 +00:00
1397 changed files with 6909 additions and 1766131 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,2 @@
*.factor text eol=lf
*.html text eol=lf
misc/vim/*/*/generated.vim linguist-generated

View File

@ -31,19 +31,8 @@ addons:
- cmake
- libaio-dev
- libsnappy-dev
- libgtk2.0-dev
- gtk2-engines-pixbuf
before_install:
- uname -s
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export HOMEBREW_NO_AUTO_UPDATE=1 ; fi # Don't let homebrew upgrade itself
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm -rf ~/.gnupg/; fi # https://github.com/rvm/rvm/issues/3110
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://rvm.io/mpapis.asc | gpg --import - ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://get.rvm.io | bash -s stable; fi # https://github.com/travis-ci/travis-ci/issues/6307
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm reload ; fi # for homebrew to have 2.6.3, which takes too long. instead we just use HOMEBREW_NO_AUTO_UPDATE=1
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm install ruby-2.6.3 ; fi # for homebrew
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm use 2.6 ; fi # for homebrew
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./build.sh deps-macosx ; else ./build.sh deps-apt-get ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew ls --versions snappy > /dev/null || brew install snappy; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew ls --versions cmake > /dev/null || brew install cmake; fi
@ -56,6 +45,10 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew services start redis; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew services start postgresql; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew services start memcached; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rm -rf ~/.gnupg/; fi # https://github.com/rvm/rvm/issues/3110
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://rvm.io/mpapis.asc | gpg --import - ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -sSL https://get.rvm.io | bash -s stable; fi # https://github.com/travis-ci/travis-ci/issues/6307
- if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
wget https://github.com/vmt/udis86/archive/v1.7.2.tar.gz && tar xzvf v1.7.2.tar.gz &&
( cd udis86-1.7.2/ && ./autogen.sh && ./configure --enable-shared=yes && make && sudo make install ) &&
@ -74,8 +67,8 @@ script:
- export CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
- echo "CI_BRANCH=${CI_BRANCH}"
- DEBUG=1 ./build.sh net-bootstrap < /dev/null
- "./factor -e='USING: memory vocabs.hierarchy tools.test namespaces ; \"zealot\" load f long-unit-tests-enabled? set-global save'"
- "./factor -e='USING: memory vocabs.hierarchy ; \"zealot\" load save'"
- './factor -run=zealot.cli-changed-vocabs'
- './factor -run=tools.test `./factor -run=zealot.cli-changed-vocabs | paste -s -d " " -`'
- './factor -run=zealot.help-lint `./factor -run=zealot.cli-changed-vocabs | paste -s -d " " -`'
- './factor -run=help.lint `./factor -run=zealot.cli-changed-vocabs | paste -s -d " " -`'
- "./factor -e='USING: modern.paths tools.test sequences system kernel math random ; core-vocabs os macosx? [ dup length 3 /i sample ] when [ test ] each'"

View File

@ -1,25 +1,12 @@
ifdef CONFIG
VERSION = 0.99
GIT_LABEL = $(shell echo `git describe --all`-`git rev-parse HEAD`)
BUNDLE = Factor.app
DEBUG ?= 0
REPRODUCIBLE ?= 0
# gmake's default CXX is g++, we prefer c++
SHELL_CXX = $(shell printenv CXX)
ifeq ($(SHELL_CXX),)
CXX=c++
else
CXX=$(SHELL_CXX)
endif
XCODE_PATH ?= /Applications/Xcode.app
MACOSX_32_SDK ?= MacOSX10.11.sdk
MACOSX_SDK ?= MacOSX10.13.sdk
include $(CONFIG)
CFLAGS += -Wall \
CFLAGS = -Wall \
-pedantic \
-DFACTOR_VERSION="$(VERSION)" \
-DFACTOR_GIT_LABEL="$(GIT_LABEL)" \
@ -27,16 +14,12 @@ ifdef CONFIG
CXXFLAGS += -std=c++11
ifneq ($(DEBUG), 0)
ifdef DEBUG
CFLAGS += -g -DFACTOR_DEBUG
else
CFLAGS += -O3
endif
ifneq ($(REPRODUCIBLE), 0)
CFLAGS += -DFACTOR_REPRODUCIBLE
endif
ENGINE = $(DLL_PREFIX)factor$(DLL_SUFFIX)$(DLL_EXTENSION)
EXECUTABLE = factor$(EXE_SUFFIX)$(EXE_EXTENSION)
CONSOLE_EXECUTABLE = factor$(EXE_SUFFIX)$(CONSOLE_EXTENSION)
@ -158,6 +141,7 @@ help:
@echo "linux-arm"
@echo "freebsd-x86-32"
@echo "freebsd-x86-64"
@echo "dragonflybsd-x86-64"
@echo "macosx-x86-32"
@echo "macosx-x86-64"
@echo "macosx-x86-fat"
@ -167,7 +151,6 @@ help:
@echo "Additional modifiers:"
@echo ""
@echo "DEBUG=1 compile VM with debugging information"
@echo "REPRODUCIBLE=1 compile VM without timestamp"
@echo "SITE_CFLAGS=... additional optimization flags"
@echo "X11=1 force link with X11 libraries instead of Cocoa (only on Mac OS X)"
@ -179,6 +162,9 @@ freebsd-x86-32:
freebsd-x86-64:
$(MAKE) $(ALL) CONFIG=vm/Config.freebsd.x86.64
dragonflybsd-x86-64:
$(MAKE) $(ALL) CONFIG=vm/Config.dragonflybsd.x86.64
macosx-x86-32:
$(MAKE) $(ALL) macosx.app CONFIG=vm/Config.macosx.x86.32

View File

@ -1,4 +1,4 @@
Copyright (c) 2020, Slava Pestov, et al.
Copyright (c) 2018, Slava Pestov, et al.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -8,21 +8,21 @@ VERSION = 0.99
!IF [git describe --all > git-describe.tmp] == 0
GIT_DESCRIBE = \
!INCLUDE <git-describe.tmp>
!IF [del git-describe.tmp] == 0
!IF [rm git-describe.tmp] == 0
!ENDIF
!ENDIF
!IF [git rev-parse HEAD > git-id.tmp] == 0
GIT_ID = \
!INCLUDE <git-id.tmp>
!IF [del git-id.tmp] == 0
!IF [rm git-id.tmp] == 0
!ENDIF
!ENDIF
!IF [git rev-parse --abbrev-ref HEAD > git-branch.tmp] == 0
GIT_BRANCH = \
!INCLUDE <git-branch.tmp>
!IF [del git-branch.tmp] == 0
!IF [rm git-branch.tmp] == 0
!ENDIF
!ENDIF
@ -58,13 +58,6 @@ CL_FLAGS = $(CL_FLAGS) $(CL_FLAGS_VISTA)
PLAF_DLL_OBJS = vm\os-windows-x86.64.obj vm\cpu-x86.obj
SUBSYSTEM_COM_FLAGS = console
SUBSYSTEM_EXE_FLAGS = windows
!ELSE
CL_FLAGS = $(CL_FLAGS) $(CL_FLAGS_VISTA)
PLAF_DLL_OBJS = vm\os-windows-x86.64.obj vm\cpu-x86.obj
SUBSYSTEM_COM_FLAGS = console
SUBSYSTEM_EXE_FLAGS = windows
!ENDIF
!IF DEFINED(DEBUG)
@ -72,10 +65,6 @@ LINK_FLAGS = $(LINK_FLAGS) /DEBUG
CL_FLAGS = $(CL_FLAGS) /Zi /DFACTOR_DEBUG
!ENDIF
!IF DEFINED(REPRODUCIBLE)
CL_FLAGS = $(CL_FLAGS) /DFACTOR_REPRODUCIBLE
!ENDIF
ML_FLAGS = /nologo /safeseh
EXE_OBJS = vm\main-windows.obj vm\factor.res
@ -150,16 +139,6 @@ factor.com: $(EXE_OBJS) $(DLL_OBJS)
factor.exe: $(EXE_OBJS) $(DLL_OBJS)
link $(LINK_FLAGS) /out:factor.exe /SUBSYSTEM:$(SUBSYSTEM_EXE_FLAGS) $(EXE_OBJS) $(DLL_OBJS)
# If we compile factor.exe, run mt.exe, and run factor.exe,
# then Windows caches the manifest. Even on a recompile without applying
# the mt.exe tool, if the factor.exe.manifest file is present, the manifest
# is applied. To avoid this, we delete the .manifest file on clean
# and copy it from a reference file on compilation and mt.exe.
#
factor.exe.manifest: factor.exe
copy factor.exe.manifest.in factor.exe.manifest
mt -manifest factor.exe.manifest -outputresource:"factor.exe;#1"
all: factor.com factor.exe factor.dll.lib libfactor-ffi-test.dll
!ENDIF
@ -191,15 +170,12 @@ clean:
if exist factor.lib del factor.lib
if exist factor.com del factor.com
if exist factor.exe del factor.exe
if exist factor.exe.manifest del factor.exe.manifest
if exist factor.exp del factor.exp
if exist factor.dll del factor.dll
if exist factor.dll.lib del factor.dll.lib
if exist factor.dll.exp del factor.dll.exp
if exist libfactor-ffi-test.dll del libfactor-ffi-test.dll
if exist libfactor-ffi-test.exp del libfactor-ffi-test.exp
if exist libfactor-ffi-test.lib del libfactor-ffi-test.lib
.PHONY: all default x86-32 x86-64 x86-32-vista x86-64-vista clean factor.exe.manifest
.PHONY: all default x86-32 x86-64 x86-32-vista x86-64-vista clean
.SUFFIXES: .rs

View File

@ -28,17 +28,17 @@ a boot image stored on factorcode.org.
To check out Factor:
* `git clone git://github.com/factor/factor.git`
* `git clone git://factorcode.org/git/factor.git`
* `cd factor`
To build the latest complete Factor system from git, either use the
build script:
* Unix: `./build.sh update`
* Windows: `build.cmd`
* Unix: `./build.sh update`
or download the correct boot image for your system from
http://downloads.factorcode.org/images/master/, put it in the `factor`
http://downloads.factorcode.org/images/master/, put it in the factor
directory and run:
* Unix: `make` and then `./factor -i=boot.unix-x86.64.image`
@ -127,25 +127,6 @@ The Factor source tree is organized as follows:
* `misc/` - editor modes, icons, etc
* `unmaintained/` - now at [factor-unmaintained](https://github.com/factor/factor-unmaintained)
## Source History
During Factor's lifetime, sourcecode has lived in many repositories. Unfortunately, the first import in Git did not keep history. History has been partially recreated from what could be salvaged. Due to the nature of Git, it's only possible to add history without disturbing upstream work, by using replace objects. These need to be manually fetched, or need to be explicitly added to your git remote configuration.
Use:
`git fetch origin 'refs/replace/*:refs/replace/*'`
or add the following line to your configuration file
```
[remote "origin"]
url = ...
fetch = +refs/heads/*:refs/remotes/origin/*
...
fetch = +refs/replace/*:refs/replace/*
```
Then subsequent fetches will automatically update any replace objects.
## Community
Factor developers meet in the `#concatenative` channel on
@ -154,7 +135,5 @@ anything related to Factor or language design in general.
* [Factor homepage](https://factorcode.org)
* [Concatenative languages wiki](https://concatenative.org)
* [Mailing list](factor-talk@lists.sourceforge.net)
* Search for "factorcode" on [Gitter](https://gitter.im/)
Have fun!

View File

@ -105,7 +105,7 @@ $nl
ARTICLE: "c-types.primitives" "Primitive C types"
"The following numerical types are defined in the " { $vocab-link "alien.c-types" } " vocabulary; a " { $snippet "u" } " prefix denotes an unsigned type:"
{ $table
{ { $strong "C type" } { $strong "Notes" } }
{ "C type" "Notes" }
{ { $link char } "always 1 byte" }
{ { $link uchar } { } }
{ { $link short } "always 2 bytes" }

View File

@ -41,8 +41,8 @@ HELP: memory>byte-array
HELP: cast-array
{ $values { "byte-array" byte-array } { "c-type" "a C type" } { "array" "a specialized array" } }
{ $description "Converts a " { $link byte-array } " into a specialized array by interpreting the bytes in it as machine-specific values. Code using this word is unportable." }
{ $notes "The appropriate specialized array vocabulary must be loaded, otherwise an error will be thrown. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
{ $description "Converts a byte array into a specialized array by interpreting the bytes in as machine-specific values. Code which uses this word is unportable." }
{ $notes "The appropriate specialized array vocabulary must be loaded; otherwise, an error will be thrown. See the " { $vocab-link "specialized-arrays" } " vocabulary for details on the underlying sequence type constructed." }
{ $errors "Throws an error if the type does not exist, the necessary specialized array vocabulary is not loaded, or the requested size is negative." } ;
HELP: malloc-array
@ -257,4 +257,4 @@ ARTICLE: "c-out-params" "Output parameters in C"
{ $code
"1234 { c-string } [ do_frob ] with-out-parameters"
}
"which would put the function's return value and error string on the stack." ;
"which would put the functions return value and error string on the stack." ;

View File

@ -1,4 +1,5 @@
USING: alien.libraries.finder sequences tools.test ;
IN: alien.libraries.finder.linux.tests
{ t } [ "libm.so" "m" find-library subseq? ] unit-test
{ t } [ "libc.so" "c" find-library subseq? ] unit-test

View File

@ -44,4 +44,4 @@ PRIVATE>
M: linux find-library*
"lib" prepend load-ldconfig-cache
[ ldconfig-matches? ] with find nip ?last ;
[ ldconfig-matches? ] with find nip ?first ;

View File

@ -1,6 +1,9 @@
USING: alien.libraries.finder alien.libraries.finder.macosx
USING: alien.libraries.finder
alien.libraries.finder.macosx.private sequences tools.test ;
IN: alien.libraries.finder.macosx
{
{
f

View File

@ -1,3 +0,0 @@
USING: alien.libraries.finder sequences tools.test ;
{ t } [ "kernel32.dll" "kernel32" find-library subseq? ] unit-test

View File

@ -1,9 +1,8 @@
USING: alien.libraries io.pathnames system windows.errors
windows.kernel32 ;
USING: alien.libraries io.pathnames system windows.errors ;
IN: alien.libraries.windows
M: windows >deployed-library-path
file-name ;
M: windows dlerror ( -- message )
GetLastError n>win32-error-string ;
win32-error-string ;

View File

@ -24,7 +24,7 @@ IN: ascii
[ [ 1 ] when-zero cut-slice swap ]
[ f 0 rot [ length ] keep <slice> ] if*
] produce nip ;
: capitalize ( str -- str' ) >lower 0 over [ ch>upper ] change-nth ;
: capitalize ( str -- str' ) unclip [ >lower ] [ ch>upper ] bi* prefix ;
: >title ( str -- title ) >words [ capitalize ] map concat ;
HINTS: >lower string ;

View File

@ -1,7 +1,5 @@
USING: base64 byte-arrays io.encodings.ascii io.encodings.string
kernel sequences splitting strings tools.test ;
{ t } [ 256 <iota> >byte-array dup >base64 base64> = ] unit-test
USING: base64 io.encodings.ascii io.encodings.string kernel
sequences splitting strings tools.test ;
{ "abcdefghijklmnopqrstuvwxyz" } [ "abcdefghijklmnopqrstuvwxyz" ascii encode >base64 base64> ascii decode
] unit-test
@ -41,9 +39,3 @@ kernel sequences splitting strings tools.test ;
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY"
"." split [ base64> ] map
] unit-test
{ "01a+b/cd" } [ "\xd3V\xbeo\xf7\x1d" >base64 "" like ] unit-test
{ "\xd3V\xbeo\xf7\x1d" } [ "01a+b/cd" base64> "" like ] unit-test
{ "01a-b_cd" } [ "\xd3V\xbeo\xf7\x1d" >urlsafe-base64 "" like ] unit-test
{ "\xd3V\xbeo\xf7\x1d" } [ "01a-b_cd" urlsafe-base64> "" like ] unit-test

View File

@ -1,9 +1,8 @@
! Copyright (C) 2008 Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs byte-arrays combinators fry growable io
io.encodings.binary io.streams.byte-array kernel kernel.private
literals locals math math.bitwise namespaces sbufs sequences
sequences.private ;
USING: arrays combinators fry io io.binary io.encodings.binary
io.streams.byte-array kernel literals math namespaces sbufs
sequences ;
IN: base64
ERROR: malformed-base64 ;
@ -11,10 +10,8 @@ ERROR: malformed-base64 ;
<PRIVATE
<<
CONSTANT: alphabet $[
CONSTANT: alphabet
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
>byte-array
]
: alphabet-inverse ( alphabet -- seq )
dup supremum 1 + f <array> [
@ -27,133 +24,79 @@ CONSTANT: alphabet $[
: base64>ch ( ch -- ch )
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
[ malformed-base64 ] unless* { fixnum } declare ; inline
[ malformed-base64 ] unless* ; inline
: encode3 ( x y z -- a b c d )
{ fixnum fixnum fixnum } declare {
[ [ -2 shift ch>base64 ] [ 2 bits 4 shift ] bi ]
[ [ -4 shift bitor ch>base64 ] [ 4 bits 2 shift ] bi ]
[ [ -6 shift bitor ch>base64 ] [ 6 bits ch>base64 ] bi ]
} spread ; inline
: (write-lines) ( column byte-array -- column' )
output-stream get dup '[
_ stream-write1 1 + dup 76 = [
drop B{ CHAR: \r CHAR: \n } _ stream-write 0
] when
] each ; inline
:: (stream-write-lines) ( column data stream -- column' )
column data over 71 > [
[
stream stream-write1 1 + dup 76 = [
drop 0
B{ CHAR: \r CHAR: \n } stream stream-write
] when
] each
] [
stream stream-write 4 +
] if ; inline
: write-lines ( column byte-array -- column' )
over [ (write-lines) ] [ write ] if ; inline
: stream-write-lines ( column data stream -- column' )
pick [ (stream-write-lines) ] [ stream-write ] if ; inline
: encode3 ( seq -- byte-array )
be> { -18 -12 -6 0 } '[
shift 0x3f bitand ch>base64
] with B{ } map-as ; inline
: write-lines ( column data -- column' )
output-stream get stream-write-lines ; inline
: encode-pad ( seq n -- byte-array )
[ 3 0 pad-tail encode3 ] [ 1 + ] bi* head-slice
4 CHAR: = pad-tail ; inline
:: (encode-base64) ( input output column -- )
4 <byte-array> :> data
column [ input stream-read1 dup ] [
input stream-read1
input stream-read1
[ [ 0 or ] bi@ encode3 ] 2keep [ 0 1 ? ] bi@ + {
{ 0 [ ] }
{ 1 [ drop CHAR: = ] }
{ 2 [ 2drop CHAR: = CHAR: = ] }
} case data (4sequence) output stream-write-lines
] while 2drop ; inline
: (encode-base64) ( stream column -- )
3 pick stream-read dup length {
{ 0 [ 3drop ] }
{ 3 [ encode3 write-lines (encode-base64) ] }
[ encode-pad write-lines (encode-base64) ]
} case ;
PRIVATE>
: encode-base64 ( -- )
input-stream get output-stream get f (encode-base64) ;
input-stream get f (encode-base64) ;
: encode-base64-lines ( -- )
input-stream get output-stream get 0 (encode-base64) ;
input-stream get 0 (encode-base64) ;
<PRIVATE
: read1-ignoring ( ignoring stream -- ch )
dup stream-read1 pick dupd member-eq?
dup stream-read1 pick dupd member?
[ drop read1-ignoring ] [ 2nip ] if ; inline recursive
: push-ignoring ( accum ch -- accum )
dup { f 0 } member-eq? [ drop ] [ suffix! ] if ; inline
: read-into-ignoring ( accum n ignoring stream -- accum )
'[ _ _ read1-ignoring push-ignoring ] times ; inline
: read-ignoring ( n ignoring stream -- accum )
pick <sbuf> [
'[ _ _ read1-ignoring [ ] _ push-if ] times
] keep ;
[ [ <sbuf> ] keep ] 2dip read-into-ignoring ; inline
: decode4 ( a b c d -- x y z )
{ fixnum fixnum fixnum fixnum } declare {
[ base64>ch 2 shift ]
[ base64>ch [ -4 shift bitor ] [ 4 bits 4 shift ] bi ]
[ base64>ch [ -2 shift bitor ] [ 2 bits 6 shift ] bi ]
[ base64>ch bitor ]
} spread ; inline
: decode4 ( seq -- )
[ 0 [ base64>ch swap 6 shift bitor ] reduce 3 >be ]
[ [ CHAR: = = ] count ] bi
[ write ] [ head-slice* write ] if-zero ; inline
:: (decode-base64) ( input output -- )
3 <byte-array> :> data
[ B{ CHAR: \n CHAR: \r } input read1-ignoring dup ] [
B{ CHAR: \n CHAR: \r } input read1-ignoring CHAR: = or
B{ CHAR: \n CHAR: \r } input read1-ignoring CHAR: = or
B{ CHAR: \n CHAR: \r } input read1-ignoring CHAR: = or
[ decode4 data (3sequence) ] 3keep
[ CHAR: = eq? 1 0 ? ] tri@ + +
[ head-slice* ] unless-zero
output stream-write
] while drop ;
: (decode-base64) ( stream -- )
4 "\n\r" pick read-ignoring dup length {
{ 0 [ 2drop ] }
{ 4 [ decode4 (decode-base64) ] }
[ drop 4 CHAR: = pad-tail decode4 (decode-base64) ]
} case ;
PRIVATE>
: decode-base64 ( -- )
input-stream get output-stream get (decode-base64) ;
<PRIVATE
: ensure-encode-length ( base64 -- base64 )
dup length 3 /mod zero? [ 1 + ] unless 4 *
output-stream get expand ;
: ensure-decode-length ( seq -- seq )
dup length 4 /mod zero? [ 1 + ] unless 3 *
output-stream get expand ;
PRIVATE>
input-stream get (decode-base64) ;
: >base64 ( seq -- base64 )
binary [
ensure-encode-length
binary [ encode-base64 ] with-byte-reader
] with-byte-writer ;
binary [ binary [ encode-base64 ] with-byte-reader ] with-byte-writer ;
: base64> ( base64 -- seq )
binary [
ensure-decode-length
binary [ decode-base64 ] with-byte-reader
] with-byte-writer ;
binary [ binary [ decode-base64 ] with-byte-reader ] with-byte-writer ;
: >base64-lines ( seq -- base64 )
binary [
ensure-encode-length
binary [ encode-base64-lines ] with-byte-reader
] with-byte-writer ;
: >urlsafe-base64 ( seq -- base64 )
>base64 H{
{ CHAR: + CHAR: - }
{ CHAR: / CHAR: _ }
} substitute ;
: urlsafe-base64> ( base64 -- seq )
H{
{ CHAR: - CHAR: + }
{ CHAR: _ CHAR: / }
} substitute base64> ;
: >urlsafe-base64-lines ( seq -- base64 )
>base64-lines H{
{ CHAR: + CHAR: - }
{ CHAR: / CHAR: _ }
} substitute ;
binary [ binary [ encode-base64-lines ] with-byte-reader ] with-byte-writer ;

View File

@ -1 +1 @@
Base64 encoding/decoding (RFC 3548)
Base64 encoding/decoding

View File

@ -1,2 +1 @@
algorithms
collections

View File

@ -1,8 +1,8 @@
! Copyright (C) 2007, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.accessors byte-arrays fry io.binary
kernel kernel.private locals math math.bitwise parser sequences
sequences.private vocabs.loader ;
kernel kernel.private locals math math.bitwise parser
prettyprint.custom sequences sequences.private ;
IN: bit-arrays
TUPLE: bit-array
@ -98,4 +98,6 @@ SYNTAX: ?{ \ } [ >bit-array ] parse-literal ;
INSTANCE: bit-array sequence
{ "bit-arrays" "prettyprint" } "bit-arrays.prettyprint" require-when
M: bit-array pprint-delims drop \ ?{ \ } ;
M: bit-array >pprint-sequence ;
M: bit-array pprint* pprint-object ;

View File

@ -1,6 +0,0 @@
USING: bit-arrays kernel prettyprint.custom ;
IN: bit-arrays.prettyprint
M: bit-array pprint-delims drop \ ?{ \ } ;
M: bit-array >pprint-sequence ;
M: bit-array pprint* pprint-object ;

View File

@ -1,7 +1,8 @@
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: bit-arrays classes.parser growable kernel parser
vectors.functor vocabs.loader ;
USING: arrays kernel kernel.private math sequences
sequences.private growable bit-arrays prettyprint.custom
parser accessors vectors.functor classes.parser ;
IN: bit-vectors
<< "bit-vector" create-class-in \ bit-array \ <bit-array> define-vector >>
@ -9,5 +10,6 @@ IN: bit-vectors
SYNTAX: ?V{ \ } [ >bit-vector ] parse-literal ;
M: bit-vector contract 2drop ;
{ "bit-vectors" "prettyprint" } "bit-vectors.prettyprint" require-when
M: bit-vector >pprint-sequence ;
M: bit-vector pprint-delims drop \ ?V{ \ } ;
M: bit-vector pprint* pprint-object ;

View File

@ -1,7 +0,0 @@
USING: bit-vectors kernel prettyprint.custom ;
IN: bit-vectors.prettyprint
M: bit-vector >pprint-sequence ;
M: bit-vector pprint-delims drop \ ?V{ \ } ;
M: bit-vector pprint* pprint-object ;

View File

@ -166,10 +166,10 @@ ERROR: not-enough-bits n bit-reader ;
bs bytes>> subseq endian> execute( seq -- x )
n bs subseq-endian execute( bignum n bs -- bits ) ;
M: lsb0-bit-reader peek
M: lsb0-bit-reader peek ( n bs -- bits )
\ le> \ subseq>bits-le (peek) ;
M: msb0-bit-reader peek
M: msb0-bit-reader peek ( n bs -- bits )
\ be> \ subseq>bits-be (peek) ;
:: bit-writer-bytes ( writer -- bytes )

View File

@ -46,7 +46,7 @@ HELP: sub-primitives
ARTICLE: "bootstrap.image" "Bootstrapping new images"
"A new image can be built from source; this is known as " { $emphasis "bootstrap" } ". Bootstrap is a two-step process. The first stage is the creation of a bootstrap image from a running Factor instance:"
{ $subsections make-image make-my-image }
{ $subsections make-image }
"The second bootstrapping stage is initiated by running the resulting bootstrap image:"
{ $code "./factor -i=boot.x86.32.image" }
"This stage loads additional code, compiles all words, and creates a final " { $snippet "factor.image" } "."

View File

@ -1,15 +1,15 @@
! Copyright (C) 2004, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs byte-arrays classes
classes.builtin classes.private classes.tuple
classes.tuple.private combinators combinators.short-circuit
combinators.smart command-line compiler.codegen.relocation
compiler.units fry generic generic.single.private grouping
hashtables hashtables.private io io.binary io.encodings.binary
io.files io.pathnames kernel kernel.private layouts locals make
math math.order namespaces namespaces.private parser
parser.notes prettyprint quotations sequences sequences.private
source-files strings system vectors vocabs words ;
USING: accessors arrays assocs byte-arrays classes classes.builtin
classes.private classes.tuple classes.tuple.private combinators
combinators.short-circuit combinators.smart
compiler.codegen.relocation compiler.units fry generic
generic.single.private grouping hashtables hashtables.private io
io.binary io.encodings.binary io.files io.pathnames kernel
kernel.private layouts locals make math math.order namespaces
namespaces.private parser parser.notes prettyprint quotations
sequences sequences.private source-files strings system vectors
vocabs words ;
IN: bootstrap.image
: arch-name ( os cpu -- arch )
@ -540,8 +540,3 @@ PRIVATE>
: make-my-image ( -- )
my-arch-name make-image ;
: make-image-main ( -- )
command-line get [ make-my-image ] [ [ make-image ] each ] if-empty ;
MAIN: make-image-main

View File

@ -778,8 +778,8 @@ CONSTANT: all-primitives {
{
"tools.profiler.sampling.private"
{
{ "set-profiling" ( n -- ) "set_profiling" { object } { } f }
{ "get-samples" ( -- samples/f ) "get_samples" { } { object } f }
{ "profiling" ( n -- ) "sampling_profiler" { object } { } f }
{ "(get-samples)" ( -- samples/f ) "get_samples" { } { object } f }
}
}
{

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008 Slava Pestov.
! Copyright (C) 2015 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image checksums checksums.openssl fry io
io.directories io.encodings.ascii io.encodings.utf8 io.files
USING: bootstrap.image checksums checksums.openssl cli.git fry
io io.directories io.encodings.ascii io.encodings.utf8 io.files
io.files.temp io.files.unique io.launcher io.pathnames kernel
make math.parser namespaces sequences splitting system unicode ;
make math.parser namespaces sequences splitting system ;
IN: bootstrap.image.upload
SYMBOL: upload-images-destination
@ -21,11 +21,7 @@ SYMBOL: build-images-destination
or ;
: factor-git-branch ( -- name )
image-path parent-directory [
{ "git" "rev-parse" "--abbrev-ref" "HEAD" }
utf8 <process-reader> stream-contents
[ blank? ] trim-tail
] with-directory ;
image-path parent-directory git-current-branch ;
: git-branch-destination ( -- dest )
build-images-destination get
@ -47,7 +43,14 @@ SYMBOL: build-images-destination
] each
] with-file-writer ;
: scp-name ( -- path ) "scp" ;
! Windows scp doesn't like pathnames with colons, it treats them as hostnames.
! Workaround for uploading checksums.txt created with temp-file.
! e.g. C:\Users\\Doug\\AppData\\Local\\Temp/factorcode.org\\Factor/checksums.txt
! ssh: Could not resolve hostname c: no address associated with name
HOOK: scp-name os ( -- path )
M: object scp-name "scp" ;
M: windows scp-name "pscp" ;
: upload-images ( -- )
[

View File

@ -38,9 +38,9 @@ M: cache-assoc dispose* clear-assoc ;
PRIVATE>
: purge-cache ( cache -- )
dup [ assoc>> ] [ max-age>> ] bi V{ } clone [
[ assoc>> ] [ max-age>> ] bi V{ } clone [
'[
nip dup age>> 1 + [ >>age ] keep
_ < [ drop t ] [ _ dispose-to f ] if
] assoc-filter >>assoc drop
] assoc-filter! drop
] keep [ last rethrow ] unless-empty ;

View File

@ -401,22 +401,6 @@ HELP: day-of-year
}
} ;
HELP: week-number
{ $values { "timestamp" timestamp } { "[1,53]" integer } }
{ $description "Calculates the ISO 8601 week number from 1 to 53 (leap years). See " { $snippet "https://en.wikipedia.org/wiki/ISO_week_date" } }
{ $examples
"Last day of 2018 is already in the first week of 2019."
{ $example "USING: calendar prettyprint ;"
"2018 12 31 <date> week-number ."
"1"
}
"2020 is a leap year with 53 weeks, and January 1st, 2021 is still in week 53 of 2020."
{ $example "USING: calendar prettyprint ;"
"2021 1 1 <date> week-number ."
"53"
}
} ;
HELP: sunday
{ $values { "timestamp" timestamp } { "new-timestamp" timestamp } }
{ $description "Returns the Sunday from the current week, which starts on a Sunday." } ;
@ -589,7 +573,6 @@ ARTICLE: "calendar-facts" "Calendar facts"
days-in-month
day-of-year
day-of-week
week-number
}
"Calculating a Julian day number:"
{ $subsections julian-day-number }

View File

@ -194,9 +194,3 @@ IN: calendar
! pm
[ now 30 pm ] [ not-in-interval? ] must-fail-with
{ 1 } [ 2018 12 31 <date> week-number ] unit-test
{ 16 } [ 2019 4 17 <date> week-number ] unit-test
{ 53 } [ 2021 1 1 <date> week-number ] unit-test

View File

@ -40,10 +40,10 @@ CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
GENERIC: leap-year? ( obj -- ? )
M: integer leap-year?
M: integer leap-year? ( year -- ? )
dup 100 divisor? 400 4 ? divisor? ;
M: timestamp leap-year?
M: timestamp leap-year? ( timestamp -- ? )
year>> leap-year? ;
: (days-in-month) ( year month -- n )
@ -121,10 +121,10 @@ GENERIC: easter ( obj -- obj' )
h l + 7 m * - 114 + 31 /mod 1 + ;
M: integer easter
M: integer easter ( year -- timestamp )
dup easter-month-day <date> ;
M: timestamp easter
M: timestamp easter ( timestamp -- timestamp )
clone
dup year>> easter-month-day
swapd >>day swap >>month ;
@ -167,52 +167,52 @@ GENERIC: +second ( timestamp x -- timestamp )
{ [ day>> 29 = ] [ month>> 2 = ] [ leap-year? not ] } 1&&
[ 3 >>month 1 >>day ] when ;
M: integer +year
M: integer +year ( timestamp n -- timestamp )
[ + ] curry change-year adjust-leap-year ;
M: real +year
M: real +year ( timestamp n -- timestamp )
[ float>whole-part swapd days-per-year * +day swap +year ] unless-zero ;
: months/years ( n -- months years )
12 /rem [ 1 - 12 ] when-zero swap ; inline
M: integer +month
M: integer +month ( timestamp n -- timestamp )
[ over month>> + months/years [ >>month ] dip +year ] unless-zero ;
M: real +month
M: real +month ( timestamp n -- timestamp )
[ float>whole-part swapd average-month * +day swap +month ] unless-zero ;
M: integer +day
M: integer +day ( timestamp n -- timestamp )
[
over >date< julian-day-number + julian-day-number>date
[ >>year ] [ >>month ] [ >>day ] tri*
] unless-zero ;
M: real +day
M: real +day ( timestamp n -- timestamp )
[ float>whole-part swapd 24 * +hour swap +day ] unless-zero ;
: hours/days ( n -- hours days )
24 /rem swap ;
M: integer +hour
M: integer +hour ( timestamp n -- timestamp )
[ over hour>> + hours/days [ >>hour ] dip +day ] unless-zero ;
M: real +hour
M: real +hour ( timestamp n -- timestamp )
float>whole-part swapd 60 * +minute swap +hour ;
: minutes/hours ( n -- minutes hours )
60 /rem swap ;
M: integer +minute
M: integer +minute ( timestamp n -- timestamp )
[ over minute>> + minutes/hours [ >>minute ] dip +hour ] unless-zero ;
M: real +minute
M: real +minute ( timestamp n -- timestamp )
[ float>whole-part swapd 60 * +second swap +minute ] unless-zero ;
: seconds/minutes ( n -- seconds minutes )
60 /rem swap >integer ;
M: number +second
M: number +second ( timestamp n -- timestamp )
[ over second>> + seconds/minutes [ >>second ] dip +minute ] unless-zero ;
: (time+) ( timestamp duration -- timestamp' duration )
@ -291,7 +291,8 @@ GENERIC: time- ( time1 time2 -- time3 )
[ neg +year 0 ] change-year drop
] if ;
M: timestamp <=> [ >gmt tuple-slots ] compare ;
M: timestamp <=> ( ts1 ts2 -- n )
[ >gmt tuple-slots ] compare ;
: same-day? ( ts1 ts2 -- ? )
[ >gmt >date< <date> ] same? ;
@ -375,9 +376,8 @@ M: duration time-
GENERIC: days-in-year ( obj -- n )
M: integer days-in-year leap-year? 366 365 ? ;
M: timestamp days-in-year year>> days-in-year ;
M: integer days-in-year ( year -- n ) leap-year? 366 365 ? ;
M: timestamp days-in-year ( timestamp -- n ) year>> days-in-year ;
: days-in-month ( timestamp -- n )
>date< drop (days-in-month) ;
@ -538,16 +538,6 @@ M: integer end-of-year 12 31 <date> ;
: unix-time>timestamp ( seconds -- timestamp )
[ unix-1970 ] dip +second ; inline
: (week-number) ( timestamp -- [0,53] )
[ day-of-year ] [ day-of-week [ 7 ] when-zero ] bi - 10 + 7 /i ;
: week-number ( timestamp -- [1,53] )
dup (week-number) {
{ 0 [ year>> 1 - end-of-year (week-number) ] }
{ 53 [ year>> 1 + <year> (week-number) 1 = 1 53 ? ] }
[ nip ]
} case ;
{
{ [ os unix? ] [ "calendar.unix" ] }
{ [ os windows? ] [ "calendar.windows" ] }

View File

@ -52,15 +52,15 @@ MACRO: formatted ( spec -- quot )
GENERIC: day. ( obj -- )
M: integer day.
M: integer day. ( n -- )
number>string dup length 2 < [ bl ] when write ;
M: timestamp day.
M: timestamp day. ( timestamp -- )
day>> day. ;
GENERIC: month. ( obj -- )
M: array month.
M: array month. ( pair -- )
first2
[ month-name write bl number>string print ]
[ 1 zeller-congruence ]
@ -71,15 +71,15 @@ M: array month.
1 + + 7 mod zero? [ nl ] [ bl ] if
] with each-integer nl ;
M: timestamp month.
M: timestamp month. ( timestamp -- )
[ year>> ] [ month>> ] bi 2array month. ;
GENERIC: year. ( obj -- )
M: integer year.
M: integer year. ( n -- )
12 [ 1 + 2array month. nl ] with each-integer ;
M: timestamp year.
M: timestamp year. ( timestamp -- )
year>> year. ;
: timestamp>mdtm ( timestamp -- str )

View File

@ -1 +0,0 @@
time

View File

@ -31,7 +31,7 @@ IN: calendar.unix
: timezone-name ( -- string )
get-time zone>> ;
M: unix gmt-offset
M: unix gmt-offset ( -- hours minutes seconds )
get-time gmtoff>> 3600 /mod 60 /mod ;
: current-timeval ( -- timeval )

View File

@ -28,10 +28,10 @@ IN: calendar.windows
[ [ wSecond>> ] [ wMilliseconds>> 1000 / ] bi + ]
} cleave instant <timestamp> ;
M: windows gmt-offset
M: windows gmt-offset ( -- hours minutes seconds )
TIME_ZONE_INFORMATION <struct>
dup GetTimeZoneInformation {
{ TIME_ZONE_ID_INVALID [ win32-error ] }
{ TIME_ZONE_ID_INVALID [ win32-error-string throw ] }
{ TIME_ZONE_ID_UNKNOWN [ Bias>> ] }
{ TIME_ZONE_ID_STANDARD [ Bias>> ] }
{ TIME_ZONE_ID_DAYLIGHT [ [ Bias>> ] [ DaylightBias>> ] bi + ] }

View File

@ -31,11 +31,11 @@ GENERIC: from ( channel -- value )
PRIVATE>
M: channel to
M: channel to ( value channel -- )
dup receivers>>
[ dup wait to ] [ nip (to) ] if-empty ;
M: channel from
M: channel from ( channel -- value )
[ self ] dip
notify senders>>
[ (from) ] unless-empty

View File

@ -60,10 +60,10 @@ C: <remote-channel> remote-channel
PRIVATE>
M: remote-channel to
M: remote-channel to ( value remote-channel -- )
[ id>> swap to-message boa ] keep send-message drop ;
M: remote-channel from
M: remote-channel from ( remote-channel -- value )
[ id>> from-message boa ] keep send-message ;
[

View File

@ -8,10 +8,10 @@ SINGLETON: adler-32
CONSTANT: adler-32-modulus 65521
M: adler-32 checksum-bytes
M: adler-32 checksum-bytes ( bytes checksum -- value )
drop
[ sum 1 + ]
[ [ dup length [1,b] <reversed> vdot ] [ length ] bi + ] bi
[ [ dup length [1,b] <reversed> v. ] [ length ] bi + ] bi
[ adler-32-modulus mod ] bi@ 16 shift bitor ;
INSTANCE: adler-32 checksum

View File

@ -5,7 +5,7 @@ IN: checksums.bsd
SINGLETON: bsd
M: bsd checksum-bytes
M: bsd checksum-bytes ( bytes checksum -- value )
drop 0 [
[ [ -1 shift ] [ 1 bitand 15 shift ] bi + ] dip
+ 0xffff bitand

View File

@ -38,67 +38,67 @@ CONSTANT: fnv1-256-basis 0xdd268dbcaac550362d98c384c4e576ccc8b1536847b6bbb31023b
CONSTANT: fnv1-512-basis 0xb86db0b1171f4416dca1e50f309990acac87d059c90000000000000000000d21e948f68a34c192f62ea79bc942dbe7ce182036415f56e34bac982aac4afe9fd9
CONSTANT: fnv1-1024-basis 0x5f7a76758ecc4d32e56d5a591028b74b29fc4223fdada16c3bf34eda3674da9a21d9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c6d7eb6e73802734510a555f256cc005ae556bde8cc9c6a93b21aff4b16c71ee90b3
M: fnv1-32 checksum-bytes
M: fnv1-32 checksum-bytes ( bytes checksum -- value )
drop
fnv1-32-basis swap
[ swap fnv1-32-prime * bitxor fnv1-32-mod bitand ] each ;
M: fnv1a-32 checksum-bytes
M: fnv1a-32 checksum-bytes ( bytes checksum -- value )
drop
fnv1-32-basis swap
[ bitxor fnv1-32-prime * fnv1-32-mod bitand ] each ;
M: fnv1-64 checksum-bytes
M: fnv1-64 checksum-bytes ( bytes checksum -- value )
drop
fnv1-64-basis swap
[ swap fnv1-64-prime * bitxor fnv1-64-mod bitand ] each ;
M: fnv1a-64 checksum-bytes
M: fnv1a-64 checksum-bytes ( bytes checksum -- value )
drop
fnv1-64-basis swap
[ bitxor fnv1-64-prime * fnv1-64-mod bitand ] each ;
M: fnv1-128 checksum-bytes
M: fnv1-128 checksum-bytes ( bytes checksum -- value )
drop
fnv1-128-basis swap
[ swap fnv1-128-prime * bitxor fnv1-128-mod bitand ] each ;
M: fnv1a-128 checksum-bytes
M: fnv1a-128 checksum-bytes ( bytes checksum -- value )
drop
fnv1-128-basis swap
[ bitxor fnv1-128-prime * fnv1-128-mod bitand ] each ;
M: fnv1-256 checksum-bytes
M: fnv1-256 checksum-bytes ( bytes checksum -- value )
drop
fnv1-256-basis swap
[ swap fnv1-256-prime * bitxor fnv1-256-mod bitand ] each ;
M: fnv1a-256 checksum-bytes
M: fnv1a-256 checksum-bytes ( bytes checksum -- value )
drop
fnv1-256-basis swap
[ bitxor fnv1-256-prime * fnv1-256-mod bitand ] each ;
M: fnv1-512 checksum-bytes
M: fnv1-512 checksum-bytes ( bytes checksum -- value )
drop
fnv1-512-basis swap
[ swap fnv1-512-prime * bitxor fnv1-512-mod bitand ] each ;
M: fnv1a-512 checksum-bytes
M: fnv1a-512 checksum-bytes ( bytes checksum -- value )
drop
fnv1-512-basis swap
[ bitxor fnv1-512-prime * fnv1-512-mod bitand ] each ;
M: fnv1-1024 checksum-bytes
M: fnv1-1024 checksum-bytes ( bytes checksum -- value )
drop
fnv1-1024-basis swap
[ swap fnv1-1024-prime * bitxor fnv1-1024-mod bitand ] each ;
M: fnv1a-1024 checksum-bytes
M: fnv1a-1024 checksum-bytes ( bytes checksum -- value )
drop
fnv1-1024-basis swap
[ bitxor fnv1-1024-prime * fnv1-1024-mod bitand ] each ;

View File

@ -47,7 +47,7 @@ CONSTANT: n 0xe6546b64
PRIVATE>
M: murmur3-32 checksum-bytes
M: murmur3-32 checksum-bytes ( bytes checksum -- value )
seed>> 32 bits main-loop end-case avalanche ;
INSTANCE: murmur3-32 checksum

View File

@ -38,13 +38,13 @@ M: evp-md-context dispose*
: set-digest ( name ctx -- )
handle>> swap digest-named f EVP_DigestInit_ex ssl-error ;
M: openssl-checksum initialize-checksum-state
M: openssl-checksum initialize-checksum-state ( checksum -- evp-md-context )
maybe-init-ssl name>> <evp-md-context> [ set-digest ] keep ;
M: evp-md-context add-checksum-bytes
M: evp-md-context add-checksum-bytes ( ctx bytes -- ctx' )
[ dup handle>> ] dip dup length EVP_DigestUpdate ssl-error ;
M: evp-md-context get-checksum
M: evp-md-context get-checksum ( ctx -- value )
handle>>
{ { int EVP_MAX_MD_SIZE } int }
[ EVP_DigestFinal_ex ssl-error ] with-out-parameters

View File

@ -116,7 +116,7 @@ M: struct-mirror delete-at
M: struct-mirror clear-assoc
object>> reset-struct-slots ;
M: struct-mirror >alist
M: struct-mirror >alist ( mirror -- alist )
object>> [
[ drop "underlying" ] [ >c-ptr ] bi 2array 1array
] [

View File

@ -1,11 +1,9 @@
! Copyright (C) 2006, 2009 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax classes.struct cocoa.runtime
core-graphics.types kernel literals layouts ;
core-graphics.types ;
IN: cocoa.types
CONSTANT: NSNotFound $[ 32bit? 0x7fffffff 0x7fffffffffffffff ? ]
TYPEDEF: long NSInteger
TYPEDEF: ulong NSUInteger

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -7,7 +7,7 @@ TUPLE: gray < color { gray read-only } { alpha read-only } ;
C: <gray> gray
M: gray >rgba
M: gray >rgba ( gray -- rgba )
[ gray>> dup dup ] [ alpha>> ] bi <rgba> ; inline
M: gray red>> gray>> ;

View File

@ -1 +0,0 @@
colors

View File

@ -6,15 +6,12 @@ lexer math math.parser sequences ;
IN: colors.hex
ERROR: invalid-hex-color hex ;
: hex>rgba ( hex -- rgba )
dup length {
{ 6 [ 2 group [ hex> 255 /f ] map first3 1.0 ] }
{ 8 [ 2 group [ hex> 255 /f ] map first4 ] }
{ 3 [ [ digit> 15 /f ] { } map-as first3 1.0 ] }
{ 4 [ [ digit> 15 /f ] { } map-as first4 ] }
[ drop invalid-hex-color ]
} case <rgba> ;
: rgba>hex ( rgba -- hex )

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -29,7 +29,7 @@ C: <hsva> hsva
PRIVATE>
M: hsva >rgba
M: hsva >rgba ( hsva -- rgba )
[
dup Hi
{

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1 +0,0 @@
colors

View File

@ -1,11 +1,11 @@
USING: help.markup help.syntax io.pathnames strings system vocabs vocabs.loader ;
USING: help.markup help.syntax strings system vocabs vocabs.loader ;
IN: command-line
HELP: run-bootstrap-init
{ $description "Runs the bootstrap initialization file in the user's " { $link home } " directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-boot-rc" } "." } ;
{ $description "Runs the bootstrap initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-boot-rc" } "." } ;
HELP: run-user-init
{ $description "Runs the startup initialization file in the user's " { $link home } " directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } "." } ;
{ $description "Runs the startup initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } "." } ;
HELP: load-vocab-roots
{ $description "Loads the newline-separated list of additional vocabulary roots from the file named " { $snippet ".factor-roots" } "." } ;
@ -91,7 +91,6 @@ $nl
ARTICLE: "standard-cli-args" "Command line switches for general usage"
"The following command line switches can be passed to a bootstrapped Factor image:"
{ $table
{ { $snippet "-help" } { "Show help for the command line switches." } }
{ { $snippet "-e=" { $emphasis "code" } } { "This specifies a code snippet to evaluate and then exit Factor." } }
{ { $snippet "-run=" { $emphasis "vocab" } } { { $snippet { $emphasis "vocab" } } " is the name of a vocabulary with a " { $link POSTPONE: MAIN: } " hook to run on startup, for example " { $vocab-link "listener" } " or " { $vocab-link "ui.tools" } "." } }
{ { $snippet "-no-user-init" } { "Inhibits the running of user initialization files on startup. See " { $link "rc-files" } "." } }
@ -117,7 +116,7 @@ $nl
{ $subsections load-vocab-roots } ;
ARTICLE: "rc-files" "Running code on startup"
"Factor looks for three optional files in the user's " { $link home } " directory."
"Factor looks for three optional files in your home directory."
{ $subsections
".factor-boot-rc"
".factor-rc"
@ -125,6 +124,12 @@ ARTICLE: "rc-files" "Running code on startup"
}
"The " { $snippet "-no-user-init" } " command line switch will inhibit loading running of these files."
$nl
"If you are unsure where the files should be located, evaluate the following code:"
{ $code
"USE: command-line"
"\".factor-rc\" rc-path print"
"\".factor-boot-rc\" rc-path print"
}
"Here is an example " { $snippet ".factor-boot-rc" } " which sets up your developer name:"
{ $code
"USING: tools.scaffold namespaces ;"
@ -133,8 +138,8 @@ $nl
ARTICLE: "command-line" "Command line arguments"
"Factor command line usage:"
{ $code "factor [options] [script] [arguments]" }
"Zero or more options can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
{ $code "factor [VM args...] [script] [args...]" }
"Zero or more VM arguments can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
{ $subsections command-line }
"Instead of running a script, it is also possible to run a vocabulary; this invokes the vocabulary's " { $link POSTPONE: MAIN: } " word:"
{ $code "factor [system switches...] -run=<vocab name>" }

View File

@ -24,6 +24,9 @@ SYMBOL: command-line
: (command-line) ( -- args )
OBJ-ARGS special-object sift [ alien>native-string ] map ;
: rc-path ( name -- path )
home prepend-path ;
: try-user-init ( file -- )
"user-init" get swap '[
_ [ ?run-file ] [
@ -34,14 +37,14 @@ SYMBOL: command-line
] when ;
: run-bootstrap-init ( -- )
"~/.factor-boot-rc" try-user-init ;
".factor-boot-rc" rc-path try-user-init ;
: run-user-init ( -- )
"~/.factor-rc" try-user-init ;
".factor-rc" rc-path try-user-init ;
: load-vocab-roots ( -- )
"user-init" get [
"~/.factor-roots" dup exists? [
".factor-roots" rc-path dup exists? [
utf8 file-lines harvest [ add-vocab-root ] each
] [ drop ] if
"roots" get [

View File

@ -1,62 +1,56 @@
! Copyright (C) 2011 Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators command-line eval io io.pathnames kernel
layouts math math.parser namespaces system vocabs.loader ;
USING: command-line eval io io.pathnames kernel namespaces
sequences system vocabs.loader ;
IN: command-line.startup
: help? ( -- ? )
"help" get "h" get or
os windows? [ script get "/?" = or ] when ;
: cli-usage ( -- )
"Usage: " write vm-path file-name write " [Factor arguments] [script] [script arguments]
: help. ( -- )
"Usage: " write vm-path file-name write " [options] [script] [arguments]
Options:
Factor arguments:
-help print this message and exit
-version print the Factor version and exit
-i=<image> load Factor image file <image> [" write vm-path file-stem write ".image]
-i=<image> load Factor image file <image> (default " write vm-path file-stem write ".image)
-run=<vocab> run the MAIN: entry point of <vocab>
-run=listener run terminal listener
-run=ui.tools run Factor development UI
-e=<code> evaluate <code>
-no-user-init suppress loading of .factor-rc
-datastack=<int> datastack size in KiB [" write cell 32 * number>string write "]
-retainstack=<int> retainstack size in KiB [" write cell 32 * number>string write "]
-callstack=<int> callstack size in KiB [" write cell cpu ppc? 256 128 ? * number>string write "]
-callbacks=<int> callback heap size in KiB [256]
-young=<int> young gc generation 0 size in MiB [" write cell 4 / number>string write "]
-aging=<int> aging gc generation 1 size in MiB [" write cell 2 / number>string write "]
-tenured=<int> tenured gc generation 2 size in MiB [" write cell 24 * number>string write "]
-codeheap=<int> codeheap size in MiB [64]
-pic=<int> max pic size [3]
-datastack=<int> datastack size in KiB
-retainstack=<int> retainstack size in KiB
-callstack=<int> callstack size in KiB
-callbacks=<int> callback heap size in KiB
-young=<int> young gc generation 0 size in MiB
-aging=<int> aging gc generation 1 size in MiB
-tenured=<int> tenured gc generation 2 size in MiB
-codeheap=<int> codeheap size in MiB
-pic=<int> max pic size
-fep enter fep mode immediately
-no-signals turn off OS signal handling
-roots=<paths> '" write os windows? ";" ":" ? write "'-separated list of extra vocab root directories
-console open console if possible
-roots=<paths> a list of \"" write os windows? ";" ":" ? write "\"-delimited extra vocab roots
Enter
\"command-line\" help
from within Factor for more information.
" write ;
: version? ( -- ? ) "version" get ;
: version. ( -- ) "Factor " write vm-version print ;
: help? ( -- ? )
"help" get "h" get or
os windows? [ script get "/?" = or ] when ;
: command-line-startup ( -- )
(command-line) parse-command-line {
{ [ help? ] [ help. ] }
{ [ version? ] [ version. ] }
[
load-vocab-roots
run-user-init
"e" get script get or [
"e" get [ eval( -- ) ] when*
script get [ run-script ] when*
] [
"run" get run
] if
]
} cond
(command-line) parse-command-line
help? [ cli-usage ] [
load-vocab-roots
run-user-init
"e" get script get or [
"e" get [ eval( -- ) ] when*
script get [ run-script ] when*
] [
"run" get run
] if
] if
output-stream get [ stream-flush ] when*
0 exit ;

View File

@ -15,8 +15,6 @@ IN: compiler.cfg.builder.alien
0 stack-params set
V{ } clone reg-values set
V{ } clone stack-values set
0 int-reg-reps set
0 float-reg-reps set
@
reg-values get
stack-values get
@ -95,7 +93,7 @@ IN: compiler.cfg.builder.alien
[ stack-params get [ caller-stack-cleanup ] keep ]
} cleave ;
M: #alien-invoke emit-node
M: #alien-invoke emit-node ( block node -- block' )
params>>
[
[ params>alien-insn-params ]
@ -104,7 +102,7 @@ M: #alien-invoke emit-node
]
[ caller-return ] bi ;
M: #alien-indirect emit-node
M: #alien-indirect emit-node ( block node -- block' )
params>>
[
[ ds-pop ^^unbox-any-c-ptr ] dip
@ -113,7 +111,7 @@ M: #alien-indirect emit-node
]
[ caller-return ] bi ;
M: #alien-assembly emit-node
M: #alien-assembly emit-node ( block node -- block' )
params>>
[
[ params>alien-insn-params ]
@ -167,7 +165,7 @@ M: #alien-assembly emit-node
: emit-callback-outputs ( block params -- )
[ emit-callback-return ] keep callback-stack-cleanup ;
M: #alien-callback emit-node
M: #alien-callback emit-node ( block node -- block' )
dup params>> xt>> dup
[
t cfg get frame-pointer?<<

View File

@ -10,30 +10,19 @@ IN: compiler.cfg.builder.alien.boxing
SYMBOL: struct-return-area
SYMBOLS: int-reg-reps float-reg-reps ;
: reg-reps ( reps -- int-reps float-reps )
[ second ] reject [ [ first int-rep? ] count ] [ length over - ] bi ;
: record-reg-reps ( reps -- reps )
dup reg-reps [ int-reg-reps +@ ] [ float-reg-reps +@ ] bi* ;
: unrecord-reg-reps ( reps -- reps )
dup reg-reps [ neg int-reg-reps +@ ] [ neg float-reg-reps +@ ] bi* ;
GENERIC: flatten-c-type ( c-type -- pairs )
M: c-type flatten-c-type
rep>> f f 3array 1array record-reg-reps ;
rep>> f f 3array 1array ;
M: long-long-type flatten-c-type
drop 2 [ int-rep long-long-on-stack? f 3array ] replicate record-reg-reps ;
drop 2 [ int-rep long-long-on-stack? f 3array ] replicate ;
HOOK: flatten-struct-type cpu ( type -- pairs )
HOOK: flatten-struct-type-return cpu ( type -- pairs )
M: object flatten-struct-type
heap-size cell align cell /i { int-rep f f } <array> record-reg-reps ;
heap-size cell align cell /i { int-rep f f } <array> ;
M: struct-c-type flatten-c-type
flatten-struct-type ;
@ -81,14 +70,14 @@ M: c-type unbox
[ swap ^^unbox ]
} case 1array
]
[ drop f f 3array 1array ] 2bi record-reg-reps ;
[ drop f f 3array 1array ] 2bi ;
M: long-long-type unbox
[ next-vreg next-vreg 2dup ] 2dip unboxer>> ##unbox-long-long, 2array
int-rep long-long-on-stack? long-long-odd-register? 3array
int-rep long-long-on-stack? f 3array 2array record-reg-reps ;
int-rep long-long-on-stack? f 3array 2array ;
M: struct-c-type unbox
M: struct-c-type unbox ( src c-type -- vregs reps )
[ ^^unbox-any-c-ptr ] dip explode-struct ;
: frob-struct ( c-type -- c-type )

View File

@ -8,11 +8,11 @@ SYMBOL: stack-params
GENERIC: alloc-stack-param ( rep -- n )
M: object alloc-stack-param
M: object alloc-stack-param ( rep -- n )
stack-params get
[ rep-size cell align stack-params +@ ] dip ;
M: float-rep alloc-stack-param
M: float-rep alloc-stack-param ( rep -- n )
stack-params get swap rep-size
[ cell align stack-params +@ ] keep
float-right-align-on-stack? [ + ] [ drop ] if ;

View File

@ -71,7 +71,7 @@ GENERIC: emit-node ( block node -- block' )
##branch, [ begin-basic-block ] dip
[ label>> id>> loops get set-at ] [ child>> emit-nodes ] 2bi ;
M: #recursive emit-node
M: #recursive emit-node ( block node -- block' )
dup label>> loop?>> [ emit-loop ] [ emit-recursive ] if ;
! #if
@ -109,28 +109,28 @@ M: #recursive emit-node
! loc>vreg sync
ds-pop any-rep ^^copy f cc/= ##compare-imm-branch, emit-if ;
M: #if emit-node
M: #if emit-node ( block node -- block' )
{
{ [ dup trivial-if? ] [ drop emit-trivial-if ] }
{ [ dup trivial-not-if? ] [ drop emit-trivial-not-if ] }
[ emit-actual-if ]
} cond ;
M: #dispatch emit-node
M: #dispatch emit-node ( block node -- block' )
! Inputs to the final instruction need to be copied because of
! loc>vreg sync. ^^offset>slot always returns a fresh vreg,
! though.
ds-pop ^^offset>slot next-vreg ##dispatch, emit-if ;
M: #call emit-node
M: #call emit-node ( block node -- block' )
dup word>> dup "intrinsic" word-prop [
nip call( block #call -- block' )
] [ swap call-height emit-call ] if* ;
M: #call-recursive emit-node
M: #call-recursive emit-node ( block node -- block' )
[ label>> id>> ] [ call-height ] bi emit-call ;
M: #push emit-node
M: #push emit-node ( block node -- block )
literal>> ^^load-literal ds-push ;
! #shuffle
@ -157,7 +157,7 @@ M: #push emit-node
[ make-input-map ] [ mapping>> ] [ extract-outputs ] tri
[ [ of of peek-loc ] 2with map ] 2with map ;
M: #shuffle emit-node
M: #shuffle emit-node ( block node -- block )
[ out-vregs/stack ] keep store-height-changes
first2 [ ds-loc store-vregs ] [ rs-loc store-vregs ] bi* ;
@ -167,14 +167,14 @@ M: #shuffle emit-node
t >>kill-block?
##safepoint, ##epilogue, ##return, ;
M: #return emit-node
M: #return emit-node ( block node -- block' )
drop end-word ;
M: #return-recursive emit-node
M: #return-recursive emit-node ( block node -- block' )
label>> id>> loops get key? [ ] [ end-word ] if ;
! #terminate
M: #terminate emit-node
M: #terminate emit-node ( block node -- block' )
drop ##no-tco, end-basic-block f ;
! No-op nodes

View File

@ -7,41 +7,41 @@ IN: compiler.cfg
HELP: basic-block
{ $class-description
"Factors representation of a basic block in the Call Flow Graph (CFG). A basic block is a sequence of instructions that always are executed sequentially and doesn't contain any internal branching. It has the following slots:"
{ $slots
{ $table
{
"number"
{ $slot "number" }
{ "The blocks sequence number. Generated by calling " { $link number-blocks } "." }
}
{
"successors"
{ $slot "successors" }
{ "A " { $link vector } " of basic blocks that may be executed directly after this block. Most blocks only have one successor but a block that checks where an if-condition should branch to would have two for example." }
}
{
"predecessors"
{ $slot "predecessors" }
{ "The opposite of successors -- a " { $link vector } " of basic blocks from which the execution may have arrived into this block." }
}
{
"instructions"
{ $slot "instructions" }
{ "A " { $link vector } " of " { $link insn } " tuples which form the instructions of the basic block." }
}
{
"kill-block?"
{ $slot "kill-block?" }
{ "The first and the last block in a cfg and all blocks containing " { $link ##call } " instructions are kill blocks. Kill blocks can't be optimized so they are omitted from certain optimization steps." }
}
{
"height"
{ $slot "height" }
"Block's height as a " { $link height-state } ". What the heights of the block was at entry and how much they were increased in the block."
}
{
"replaces"
{ $slot "replaces" }
{ "Used by " { $vocab-link "compiler.cfg.stacks.local" } " for local stack analysis." }
}
{
"peeks"
{ $slot "peeks" }
{ "Used by " { $vocab-link "compiler.cfg.stacks.local" } " for local stack analysis." }
}
{
"kills"
{ $slot "kills" }
{ "Used by " { $vocab-link "compiler.cfg.stacks.local" } " for local stack analysis." }
}
}
@ -60,12 +60,12 @@ HELP: <cfg>
HELP: cfg
{ $class-description
"Call flow graph. It has the following slots:"
{ $slots
{ "entry" { "Root " { $link basic-block } " of the graph." } }
{ "word" { "The " { $link word } " the cfg is produced from." } }
{ "post-order" { "The blocks of the cfg in a post order traversal " { $link sequence } "." } }
{ "stack-frame" { { $link stack-frame } " of the cfg." } }
{ "frame-pointer?" { "Whether the cfg needs a frame pointer. Only cfgs generated for " { $link #alien-callback } " nodes does need it. If the slot is " { $link t } ", then the frame pointer register (" { $link RBP } " on x86.64 archs) will not be clobbered by register allocation. See " { $vocab-link "compiler.cfg.linear-scan" } " for details." } }
{ $table
{ { $slot "entry" } { "Root " { $link basic-block } " of the graph." } }
{ { $slot "word" } { "The " { $link word } " the cfg is produced from." } }
{ { $slot "post-order" } { "The blocks of the cfg in a post order traversal " { $link sequence } "." } }
{ { $slot "stack-frame" } { { $link stack-frame } " of the cfg." } }
{ { $slot "frame-pointer?" } { "Whether the cfg needs a frame pointer. Only cfgs generated for " { $link #alien-callback } " nodes does need it. If the slot is " { $link t } ", then the frame pointer register (" { $link RBP } " on x86.64 archs) will not be clobbered by register allocation. See " { $vocab-link "compiler.cfg.linear-scan" } " for details." } }
}
}
{ $see-also <cfg> post-order } ;

View File

@ -9,27 +9,27 @@ IN: compiler.cfg.instructions
HELP: ##alien-invoke
{ $class-description
"An instruction for calling a function in a dynamically linked library. It has the following slots:"
{ $slots
{ $table
{
"dead-outputs"
{ $slot "dead-outputs" }
{ "A sequence of return values from the function that the compiler.cfg.dce pass has figured out are not used." }
}
{
"reg-inputs"
{ $slot "reg-inputs" }
{ "Registers to use for the arguments to the function call. Each sequence item is a 3-tuple consisting of a " { $link spill-slot } ", register representation and a register. When the function is called, the parameter is copied from the spill slot to the given register." }
}
{
"stack-inputs"
{ $slot "stack-inputs" }
{ "Stack slots used for the arguments to the function call." }
}
{
"reg-outputs"
{ $slot "reg-outputs" }
{ "If the called function returns a value, then this slot is a one-element sequence containing a 3-tuple describing which register is used for the return value." }
}
{ "symbols" { "Name of the function to call." } }
{ "dll" { "A dll handle or " { $link f } "." } }
{ { $slot "symbols" } { "Name of the function to call." } }
{ { $slot "dll" } { "A dll handle or " { $link f } "." } }
{
"gc-map"
{ $slot "gc-map" }
{
"If the invoked C function calls Factor code which triggers a GC, then a "
{ $link gc-map }
@ -44,9 +44,9 @@ HELP: ##alien-invoke
HELP: ##alien-indirect
{ $class-description
"An instruction representing an indirect alien call. The first item on the datastack is a pointer to the function to call and the parameters follows. It has the following slots:"
{ $slots
{ "src" { "Spill slot containing the function pointer." } }
{ "reg-outputs" { "Sequence of output values passed in registers." } }
{ $table
{ { $slot "src" } { "Spill slot containing the function pointer." } }
{ { $slot "reg-outputs" } { "Sequence of output values passed in registers." } }
}
}
{ $see-also alien-indirect %alien-indirect } ;
@ -54,11 +54,11 @@ HELP: ##alien-indirect
HELP: ##allot
{ $class-description
"An instruction for allocating memory in the nursery. Usually the instruction is preceded by " { $link ##check-nursery-branch } " which checks that there is enough room in the nursery to allocate. It has the following slots:"
{ $slots
{ "dst" { "Register to put the pointer to the memory in." } }
{ "size" { "Number of bytes to allocate." } }
{ "class-of" { "Class of object to allocate, e.g " { $link tuple } " or " { $link array } "." } }
{ "temp" { "Temporary register to clobber." } }
{ $table
{ { $slot "dst" } { "Register to put the pointer to the memory in." } }
{ { $slot "size" } { "Number of bytes to allocate." } }
{ { $slot "class-of" } { "Class of object to allocate, e.g " { $link tuple } " or " { $link array } "." } }
{ { $slot "temp" } { "Temporary register to clobber." } }
}
} ;
@ -79,8 +79,8 @@ HELP: ##box-alien
HELP: ##call
{ $class-description
"An instruction for calling a Factor word."
{ $slots
{ "word" { "The word called." } }
{ $table
{ { $slot "word" } { "The word called." } }
}
} ;
@ -89,11 +89,11 @@ HELP: ##check-nursery-branch
"Instruction that inserts a conditional branch to a " { $link basic-block } " that garbage collects the nursery. The " { $vocab-link "compiler.cfg.gc-checks" } " vocab goes through each block in the " { $link cfg } " and checks if it allocates memory. If it does, then this instruction is inserted in the cfg before that block and checks if there is enough available space in the nursery. If it isn't, then a basic block containing code for garbage collecting the nursery is executed."
$nl
"It has the following slots:"
{ $slots
{ "size" { "Number of bytes the next block in the cfg will allocate." } }
{ "cc" { "A comparison symbol." } }
{ "temp1" { "First register that will be clobbered." } }
{ "temp2" { "Second register that will be clobbered." } }
{ $table
{ { $slot "size" } { "Number of bytes the next block in the cfg will allocate." } }
{ { $slot "cc" } { "A comparison symbol." } }
{ { $slot "temp1" } { "First register that will be clobbered." } }
{ { $slot "temp2" } { "Second register that will be clobbered." } }
}
}
{ $see-also %check-nursery-branch } ;
@ -101,8 +101,8 @@ HELP: ##check-nursery-branch
HELP: ##compare-float-ordered-branch
{ $class-description
"It has the following slots:"
{ $slots
{ "cc" { "Comparison symbol." } }
{ $table
{ { $slot "cc" } { "Comparison symbol." } }
}
} ;
@ -119,8 +119,8 @@ HELP: ##compare-integer
HELP: ##copy
{ $class-description "Instruction that copies a value from one register to another of the same type. For example, you can copy between two gprs or two simd registers but not across. It has the following slots:"
{ $slots
{ "rep" { "Value representation. Both the source and destination register must have the same representation." } }
{ $table
{ { $slot "rep" } { "Value representation. Both the source and destination register must have the same representation." } }
}
} ;
@ -139,8 +139,8 @@ HELP: ##inc
HELP: ##jump
{ $class-description
"An uncondiation jump instruction. It has the following slots:"
{ $slots
{ "word" { "Word whose address the instruction is jumping to." } }
{ $table
{ { $slot "word" } { "Word whose address the instruction is jumping to." } }
}
"Note that the optimizer is sometimes able to optimize away a " { $link ##call } " and " { $link ##return } " pair into one ##jump instruction."
} ;
@ -156,9 +156,9 @@ HELP: ##load-memory-imm
HELP: ##load-reference
{ $class-description
"An instruction for loading a pointer to an object into a register. It has the following slots:"
{ $slots
{ "dst" { "Register to load the pointer into." } }
{ "obj" { "A Factor object." } }
{ $table
{ { $slot "dst" } { "Register to load the pointer into." } }
{ { $slot "obj" } { "A Factor object." } }
}
} ;
@ -174,10 +174,10 @@ HELP: ##load-vector
HELP: ##local-allot
{ $class-description
"An instruction for allocating memory in the words own stack frame. It's mostly used for receiving data from alien calls. It has the following slots:"
{ $slots
{ "dst" { "Register into which a pointer to the stack allocated memory is put." } }
{ "size" { "Number of bytes to allocate." } }
{ "offset" { } }
{ $table
{ { $slot "dst" } { "Register into which a pointer to the stack allocated memory is put." } }
{ { $slot "size" } { "Number of bytes to allocate." } }
{ { $slot "offset" } { } }
}
}
{ $see-also ##allot } ;
@ -191,8 +191,8 @@ HELP: ##no-tco
HELP: ##parallel-copy
{ $class-description "An instruction for performing multiple copies. It allows for optimizations or (or prunings) if more than one source or destination vreg is the same. They are transformed into " { $link ##copy } " instructions in " { $link destruct-ssa } ". It has the following slots:"
{ $slots
{ "values" { "An assoc mapping source vregs to destinations." } }
{ $table
{ { $slot "values" } { "An assoc mapping source vregs to destinations." } }
}
} ;
@ -205,9 +205,9 @@ HELP: ##peek
HELP: ##phi
{ $class-description
"A special kind of instruction used to mark control flow. It is inserted by the " { $vocab-link "compiler.cfg.ssa.construction" } " vocab. It has the following slots:"
{ $slots
{ "inputs" { "An assoc containing as keys the blocks/block numbers where the vreg was defined and as values the vreg. Why care about the blocks?" } }
{ "dst" { "A merged vreg for the value." } }
{ $table
{ { $slot "inputs" } { "An assoc containing as keys the blocks/block numbers where the vreg was defined and as values the vreg. Why care about the blocks?" } }
{ { $slot "dst" } { "A merged vreg for the value." } }
}
} ;
@ -241,22 +241,22 @@ HELP: ##save-context
HELP: ##set-slot
{ $class-description
"An instruction for the non-primitive, non-immediate variant of " { $link set-slot } ". It has the following slots:"
{ $slots
{ "src" { "Object to put in the slot." } }
{ "obj" { "Object to set the slot on." } }
{ "slot" { "Slot index." } }
{ "tag" { "Type tag for obj." } }
{ $table
{ { $slot "src" } { "Object to put in the slot." } }
{ { $slot "obj" } { "Object to set the slot on." } }
{ { $slot "slot" } { "Slot index." } }
{ { $slot "tag" } { "Type tag for obj." } }
}
} ;
HELP: ##set-slot-imm
{ $class-description
"An instruction for what? It has the following slots:"
{ $slots
{ "src" { "Register containing the value to put in the slot." } }
{ "obj" { "Register containing the object to set the slot on.." } }
{ "slot" { "Slot index." } }
{ "tag" { "Type tag for obj." } }
{ $table
{ { $slot "src" } { "Register containing the value to put in the slot." } }
{ { $slot "obj" } { "Register containing the object to set the slot on.." } }
{ { $slot "slot" } { "Slot index." } }
{ { $slot "tag" } { "Type tag for obj." } }
}
}
{ $see-also ##set-slot %set-slot-imm } ;
@ -268,10 +268,10 @@ HELP: ##single>double-float
HELP: ##shuffle-vector-imm
{ $class-description "Shuffles the vector in a SSE register according to the given shuffle pattern. It is used to extract a given element of the vector."
{ $slots
{ "dst" { "Destination register to shuffle the vector to." } }
{ "src" { "Source register." } }
{ "shuffle" { "Shuffling pattern." } }
{ $table
{ { $slot "dst" } { "Destination register to shuffle the vector to." } }
{ { $slot "src" } { "Source register." } }
{ { $slot "shuffle" } { "Shuffling pattern." } }
}
}
{ $see-also %shuffle-vector-imm } ;
@ -279,31 +279,31 @@ HELP: ##shuffle-vector-imm
HELP: ##slot-imm
{ $class-description
"Instruction for reading a slot with a given index from an object."
{ $slots
{ "dst" { "Register to read the slot value into." } }
{ "obj" { "Register containing the object with the slot." } }
{ "slot" { "Slot index." } }
{ "tag" { "Type tag for obj." } }
{ $table
{ { $slot "dst" } { "Register to read the slot value into." } }
{ { $slot "obj" } { "Register containing the object with the slot." } }
{ { $slot "slot" } { "Slot index." } }
{ { $slot "tag" } { "Type tag for obj." } }
}
} { $see-also %slot-imm } ;
HELP: ##spill
{ $class-description "Instruction that copies a value from a register to a " { $link spill-slot } "."
{ $slots
{ "rep" { "Register representation which is necessary when spilling SIMD registers." } }
{ $table
{ { $slot "rep" } { "Register representation which is necessary when spilling SIMD registers." } }
}
} { $see-also ##reload } ;
HELP: ##store-memory-imm
{ $class-description "Instruction that copies an 8 byte value from a XMM register to a memory location addressed by a normal register. This instruction is often turned into a cheaper " { $link ##store-memory } " instruction in the " { $link value-numbering } " pass."
{ $slots
{ "base" { "Vreg that contains the base address." } }
{ $table
{ { $slot "base" } { "Vreg that contains the base address." } }
{
"offset"
{ $slot "offset" }
{ "Offset in bytes from the address to where the data should be written." }
}
{ "rep" { "Value representation in the vector register." } }
{ "src" { "Vreg that contains the item to set." } }
{ { $slot "rep" } { "Value representation in the vector register." } }
{ { $slot "src" } { "Vreg that contains the item to set." } }
}
}
{ $see-also %store-memory-imm } ;
@ -314,9 +314,9 @@ HELP: ##test-branch
HELP: ##unbox-any-c-ptr
{ $class-description "Instruction that unboxes a pointer in a register so that it can be fed to a C FFI function. For example, if 'src' points to a " { $link byte-array } ", then in 'dst' will be put a pointer to the first byte of that byte array."
{ $slots
{ "dst" { "Destination register." } }
{ "src" { "Source register." } }
{ $table
{ { $slot "dst" } { "Destination register." } }
{ { $slot "src" } { "Source register." } }
}
}
{ $see-also %unbox-any-c-ptr } ;
@ -327,10 +327,10 @@ HELP: ##unbox-long-long
HELP: ##vector>scalar
{ $class-description
"This instruction is very similar to " { $link ##copy } "."
{ $slots
{ "dst" { "destination vreg" } }
{ "src" { "source vreg" } }
{ "rep" { "representation for the source vreg" } }
{ $table
{ { $slot "dst" } { "destination vreg" } }
{ { $slot "src" } { "source vreg" } }
{ { $slot "rep" } { "representation for the source vreg" } }
}
}
{ $notes "The two vregs must not necessarily share the same representation." }
@ -338,9 +338,9 @@ HELP: ##vector>scalar
HELP: ##vm-field
{ $class-description "Instruction for loading a pointer to a vm field."
{ $slots
{ "dst" { "Register to load the field into." } }
{ "offset" { "Offset of the field relative to the vm address." } }
{ $table
{ { $slot "dst" } { "Register to load the field into." } }
{ { $slot "offset" } { "Offset of the field relative to the vm address." } }
}
}
{ $see-also %vm-field } ;
@ -348,13 +348,13 @@ HELP: ##vm-field
HELP: ##write-barrier
{ $class-description
"An instruction for inserting a write barrier. This instruction is almost always inserted after a " { $link ##set-slot } " instruction. If the container object is in an older generation than the item inserted, this instruction guarantees that the item will not be garbage collected. It has the following slots:"
{ $slots
{ "src" { "Object to which the writer barrier refers." } }
{ "slot" { "Slot index of the object." } }
{ "scale" { "No idea." } }
{ "tag" { "Type tag for obj." } }
{ "temp1" { "First temporary register to clobber." } }
{ "temp2" { "Second temporary register to clobber." } }
{ $table
{ { $slot "src" } { "Object to which the writer barrier refers." } }
{ { $slot "slot" } { "Slot index of the object." } }
{ { $slot "scale" } { "No idea." } }
{ { $slot "tag" } { "Type tag for obj." } }
{ { $slot "temp1" } { "First temporary register to clobber." } }
{ { $slot "temp2" } { "Second temporary register to clobber." } }
}
} ;
@ -396,13 +396,13 @@ HELP: gc-map-insn
HELP: gc-map
{ $class-description "A tuple that holds info necessary for a gc cycle to figure out where the gc root pointers are. It has the following slots:"
{ $slots
{ $table
{
"gc-roots"
{ $slot "gc-roots" }
{ { $link sequence } " of vregs or spill-slots" }
}
{
"derived-roots"
{ $slot "derived-roots" }
{ "An " { $link assoc } " of pairs of vregs or spill slots." } }
}
"The 'gc-roots' and 'derived-roots' slots are initially vreg integers referencing objects that are live during the gc call and needs to be spilled so that they can be traced. In the " { $link emit-gc-map-insn } " word in " { $vocab-link "compiler.cfg.linear-scan.assignment" } " they are converted to spill slots which the collector is able to trace."

View File

@ -238,13 +238,13 @@ M: horizontal-cpu %horizontal-add-vector-reps signed-reps ;
M: horizontal-cpu %unpack-vector-head-reps signed-reps ;
M: horizontal-cpu %unpack-vector-tail-reps signed-reps ;
! vdot
! v.
{ { ##dot-vector } }
[ dot-cpu float-4-rep [ emit-simd-vdot ] test-emit ]
[ dot-cpu float-4-rep [ emit-simd-v. ] test-emit ]
unit-test
{ { ##mul-vector ##horizontal-add-vector ##horizontal-add-vector ##vector>scalar } }
[ horizontal-cpu float-4-rep [ emit-simd-vdot ] test-emit ]
[ horizontal-cpu float-4-rep [ emit-simd-v. ] test-emit ]
unit-test
{ {
@ -253,7 +253,7 @@ unit-test
##merge-vector-head ##merge-vector-tail ##add-vector
##vector>scalar
} }
[ simple-ops-cpu float-4-rep [ emit-simd-vdot ] test-emit ]
[ simple-ops-cpu float-4-rep [ emit-simd-v. ] test-emit ]
unit-test
! vsqrt

View File

@ -417,7 +417,7 @@ PREDICATE: fixnum-vector-rep < int-vector-rep
] }
} emit-vv-vector-op ;
: emit-simd-vdot ( node -- )
: emit-simd-v. ( node -- )
{
[ ^^dot-vector ]
{ float-vector-rep [ [ ^^mul-vector ] [ ^sum-vector ] bi ] }
@ -667,7 +667,7 @@ PREDICATE: fixnum-vector-rep < int-vector-rep
{ (simd-vmin) [ emit-simd-vmin ] }
{ (simd-vmax) [ emit-simd-vmax ] }
{ (simd-vavg) [ emit-simd-vavg ] }
{ (simd-vdot) [ emit-simd-vdot ] }
{ (simd-v.) [ emit-simd-v. ] }
{ (simd-vsad) [ emit-simd-vsad ] }
{ (simd-vsqrt) [ emit-simd-vsqrt ] }
{ (simd-sum) [ emit-simd-sum ] }

View File

@ -76,27 +76,26 @@ HELP: last-use?
HELP: live-interval-state
{ $class-description "A class encoding the \"liveness\" of a virtual register. It has the following slots:"
{ $slots
{ "vreg" { "The vreg this live interval state is bound to." } }
{ $table
{ { $slot "vreg" } { "The vreg this live interval state is bound to." } }
{
"reg"
{ $slot "reg" }
{ "The allocated register, set in the " { $link allocate-registers } " step." }
}
{
"spill-rep"
{ $slot "spill-rep" }
{ { $link representation } " the vreg will have when it is spilled." }
}
{
"spill-to"
{ $slot "spill-to" }
{ { $link spill-slot } " to use for spilling, if it needs to be spilled." }
}
{
"ranges"
{ $slot "ranges" }
{ "Inclusive ranges where the live interval is live. This is because the [start,end] interval can have gaps." }
}
{
"uses"
{ "sequence of insn# numbers which reference insructions that use the register in the live interval." }
{ $slot "uses" } { "sequence of insn# numbers which reference insructions that use the register in the live interval." }
}
}
}
@ -119,9 +118,9 @@ HELP: record-temp
HELP: sync-point
{ $class-description "A location where all live registers have to be spilled. For example when garbage collection is run or an alien ffi call is invoked. Figuring out where in the " { $link cfg } " the sync points are is done in the " { $link compute-live-intervals } " step. The tuple has the following slots:"
{ $slots
{ "n" { "Set from an instructions sequence number." } }
{ "keep-dst?" { "Boolean that determines whether registers are spilled around this sync point." } }
{ $table
{ { $slot "n" } { "Set from an instructions sequence number." } }
{ { $slot "keep-dst?" } { "Boolean that determines whether registers are spilled around this sync point." } }
}
}
{ $see-also cfg>sync-points clobber-insn hairy-clobber-insn insn } ;

View File

@ -35,7 +35,7 @@ GENERIC: visit-insn ( live-set insn -- )
: gen-uses ( live-set insn -- )
uses-vregs [ swap conjoin ] with each ; inline
M: vreg-insn visit-insn
M: vreg-insn visit-insn ( live-set insn -- )
[ kill-defs ] [ gen-uses ] 2bi ;
DEFER: lookup-base-pointer
@ -98,7 +98,7 @@ M: vreg-insn lookup-base-pointer* 2drop f ;
: fill-gc-map ( live-set gc-map -- )
[ gc-roots ] dip [ gc-roots<< ] [ derived-roots<< ] bi ;
M: gc-map-insn visit-insn
M: gc-map-insn visit-insn ( live-set insn -- )
[ kill-defs ] [ gc-map>> fill-gc-map ] [ gen-uses ] 2tri ;
M: ##phi visit-insn kill-defs ;

View File

@ -8,9 +8,9 @@ HELP: sets-interfere?
HELP: vreg-info
{ $class-description
"Slots:"
{ $slots
{ "vreg" { "The vreg the vreg-info is the info for." } }
{ "bb" { "The " { $link basic-block } " in which the vreg is defined." } }
{ $table
{ { $slot "vreg" } { "The vreg the vreg-info is the info for." } }
{ { $slot "bb" } { "The " { $link basic-block } " in which the vreg is defined." } }
}
} ;

View File

@ -11,15 +11,15 @@ HELP: stack-frame
{ "One final " { $link cell } " of padding." }
}
"The stack frame is also aligned to a 16 byte boundary. It has the following slots:"
{ $slots
{ "total-size" { "Total size of the stack frame." } }
{ "params" { "Reserved parameter space." } }
{ "allot-area-base" { "Base offset of the allocation area." } }
{ "allot-area-size" { "Number of bytes requires for the allocation area." } }
{ "allot-area-align" { "This slot is always at least " { $link cell } " bytes." } }
{ "spill-area-base" { "Base offset for the spill area." } }
{ "spill-area-size" { "Number of bytes requires for all spill slots." } }
{ "spill-area-align" { "This slot is always at least " { $link cell } " bytes." } }
{ $table
{ { $slot "total-size" } { "Total size of the stack frame." } }
{ { $slot "params" } { "Reserved parameter space." } }
{ { $slot "allot-area-base" } { "Base offset of the allocation area." } }
{ { $slot "allot-area-size" } { "Number of bytes requires for the allocation area." } }
{ { $slot "allot-area-align" } { "This slot is always at least " { $link cell } " bytes." } }
{ { $slot "spill-area-base" } { "Base offset for the spill area." } }
{ { $slot "spill-area-size" } { "Number of bytes requires for all spill slots." } }
{ { $slot "spill-area-align" } { "This slot is always at least " { $link cell } " bytes." } }
}
}
{ $see-also align-stack } ;

View File

@ -29,21 +29,21 @@ HELP: global-loc>local
HELP: height-state
{ $description "A tuple which keeps track of the stacks heights and increments of a " { $link basic-block } " during local analysis. The idea is that if the stack change instructions are tracked, then multiple changes can be folded into one. It has the following slots:"
{ $slots
{ $table
{
"ds-begin"
{ $slot "ds-begin" }
"Datastack height at the beginning of the block."
}
{
"rs-begin"
{ $slot "rs-begin" }
"Retainstack height at the beginning of the block."
}
{
"ds-inc"
{ $slot "ds-inc" }
"Datastack change during the block."
}
{
"rs-inc"
{ $slot "rs-inc" }
"Retainstack change during the block."
}
}
@ -103,10 +103,10 @@ HELP: replaces
ARTICLE: "compiler.cfg.stacks.local" "Local stack analysis"
"For each " { $link basic-block } " in the " { $link cfg } ", local stack analysis is performed. The analysis is started right after the block is created with " { $link begin-local-analysis } " and finished with " { $link end-local-analysis } ", when the construction of the block is complete. During the analysis, three sets containing stack locations are built:"
{ $slots
{ "peeks" { " all stack locations that the block reads before writing" } }
{ "replaces" { " all stack locations that the block writes" } }
{ "kills" { " all stack locations which become unavailable after the block ends because of the stack height being decremented. For example, if the block contains " { $link drop } ", then D: 0 will be contained in kills because that stack location will not be live anymore." } }
{ $list
{ { $slot "peeks" } " all stack locations that the block reads before writing" }
{ { $slot "replaces" } " all stack locations that the block writes" }
{ { $slot "kills" } " all stack locations which become unavailable after the block ends because of the stack height being decremented. For example, if the block contains " { $link drop } ", then D: 0 will be contained in kills because that stack location will not be live anymore." }
}
"This is done while constructing the CFG. These sets are then used by the " { $link end-stack-analysis } " word to emit optimal sequences of " { $link ##peek } " and " { $link ##replace } " instructions to the cfg."
$nl

View File

@ -33,7 +33,7 @@ T{ error-type-holder
{ type +compiler-error+ }
{ word ":errors" }
{ plural "compiler errors" }
{ icon "vocab:ui/tools/error-list/icons/compiler-error.png" }
{ icon "vocab:ui/tools/error-list/icons/compiler-error.tiff" }
{ quot [ compiler-errors get values ] }
{ forget-quot [ compiler-errors get delete-at ] }
} define-error-type
@ -51,7 +51,7 @@ T{ error-type-holder
{ type +linkage-error+ }
{ word ":linkage" }
{ plural "linkage errors" }
{ icon "vocab:ui/tools/error-list/icons/linkage-error.png" }
{ icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" }
{ quot [ linkage-errors get values ] }
{ forget-quot [ linkage-errors get delete-at ] }
{ fatal? f }
@ -77,7 +77,7 @@ T{ error-type-holder
{ type +user-init-error+ }
{ word ":user-init-errors" }
{ plural "rc file errors" }
{ icon "vocab:ui/tools/error-list/icons/user-init-error.png" }
{ icon "vocab:ui/tools/error-list/icons/user-init-error.tiff" }
{ quot [ user-init-errors get-global values ] }
{ forget-quot [ user-init-errors get-global delete-at ] }
} define-error-type

View File

@ -2,7 +2,7 @@ USING: accessors alien alien.c-types alien.complex alien.data alien.libraries
alien.syntax arrays byte-arrays classes classes.struct combinators
combinators.extras compiler compiler.test concurrency.promises continuations
destructors effects generalizations io io.backend io.pathnames
io.streams.string kernel kernel.private libc layouts locals math math.bitwise
io.streams.string kernel kernel.private libc layouts math math.bitwise
math.private memory namespaces namespaces.private random parser quotations
sequences slots.private specialized-arrays stack-checker stack-checker.errors
system threads tools.test words ;
@ -963,117 +963,3 @@ FUNCTION: void* bug1021_test_3 ( c-string a )
{ } [
10000 [ 0 doit 33 assert= ] times
] unit-test
! Tests for System V AMD64 ABI
STRUCT: test_struct_66 { mem1 ulong } { mem2 ulong } ;
STRUCT: test_struct_68 { mem1 ulong } { mem2 ulong } { mem3 ulong } ;
STRUCT: test_struct_69 { mem1 float } { mem2 ulong } { mem3 ulong } ;
FUNCTION: ulong ffi_test_66 ( ulong a, ulong b, ulong c, test_struct_66 d, test_struct_66 e )
FUNCTION: ulong ffi_test_67 ( ulong a, ulong b, ulong c, test_struct_66 d, test_struct_66 e ulong _f )
FUNCTION: ulong ffi_test_68 ( ulong a, ulong b, ulong c, test_struct_66 d, test_struct_68 e test_struct_66 _f )
FUNCTION: ulong ffi_test_69 ( ulong a, ulong b, ulong c, test_struct_66 d, test_struct_69 e test_struct_66 _f )
FUNCTION: ulong ffi_test_70 ( test_struct_68 a test_struct_68 b, test_struct_66 c )
{ 28 } [ 1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_66 f 6 7 } ffi_test_66 ] unit-test
: callback-14 ( -- callback )
ulong { ulong ulong ulong test_struct_66 test_struct_66 } cdecl
[| a b c d e |
a b + c +
d [ mem1>> + ] [ mem2>> + ] bi
e [ mem1>> + ] [ mem2>> + ] bi
] alien-callback ;
: callback-14-test ( a b c d e callback -- result )
ulong { ulong ulong ulong test_struct_66 test_struct_66 } cdecl alien-indirect ;
{ 28 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_66 f 6 7 } callback-14 [
callback-14-test
] with-callback
] unit-test
{ 44 } [ 1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_66 f 6 7 } 8 ffi_test_67 ] unit-test
: callback-15 ( -- callback )
ulong { ulong ulong ulong test_struct_66 test_struct_66 ulong } cdecl
[| a b c d e _f |
a b + c +
d [ mem1>> + ] [ mem2>> + ] bi
e [ mem1>> + ] [ mem2>> + ] bi
_f 2 * +
] alien-callback ;
: callback-15-test ( a b c d e _f callback -- result )
ulong { ulong ulong ulong test_struct_66 test_struct_66 ulong } cdecl alien-indirect ;
{ 44 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_66 f 6 7 } 8 callback-15 [
callback-15-test
] with-callback
] unit-test
{ 55 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_68 f 6 7 8 } S{ test_struct_66 f 9 10 } ffi_test_68
] unit-test
: callback-16 ( -- callback )
ulong { ulong ulong ulong test_struct_66 test_struct_68 test_struct_66 } cdecl
[| a b c d e _f |
a b + c +
d [ mem1>> + ] [ mem2>> + ] bi
e [ mem1>> + ] [ mem2>> + ] [ mem3>> + ] tri
_f [ mem1>> + ] [ mem2>> + ] bi
] alien-callback ;
: callback-16-test ( a b c d e _f callback -- result )
ulong { ulong ulong ulong test_struct_66 test_struct_68 test_struct_66 } cdecl alien-indirect ;
{ 55 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_68 f 6 7 8 } S{ test_struct_66 f 9 10 } callback-16 [
callback-16-test
] with-callback
] unit-test
{ 55 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_69 f 6.0 7 8 } S{ test_struct_66 f 9 10 } ffi_test_69
] unit-test
: callback-17 ( -- callback )
ulong { ulong ulong ulong test_struct_66 test_struct_69 test_struct_66 } cdecl
[| a b c d e _f |
a b + c +
d [ mem1>> + ] [ mem2>> + ] bi
e [ mem1>> >integer + ] [ mem2>> + ] [ mem3>> + ] tri
_f [ mem1>> + ] [ mem2>> + ] bi
] alien-callback ;
: callback-17-test ( a b c d e _f callback -- result )
ulong { ulong ulong ulong test_struct_66 test_struct_69 test_struct_66 } cdecl alien-indirect ;
{ 55 } [
1 2 3 S{ test_struct_66 f 4 5 } S{ test_struct_69 f 6.0 7 8 } S{ test_struct_66 f 9 10 } callback-17 [
callback-17-test
] with-callback
] unit-test
{ 36 } [
S{ test_struct_68 f 1 2 3 } S{ test_struct_68 f 4 5 6 } S{ test_struct_66 f 7 8 } ffi_test_70
] unit-test
: callback-18 ( -- callback )
ulong { test_struct_68 test_struct_68 test_struct_66 } cdecl
[| a b c |
a [ mem1>> ] [ mem2>> + ] [ mem3>> + ] tri
b [ mem1>> + ] [ mem2>> + ] [ mem3>> + ] tri
c [ mem1>> + ] [ mem2>> + ] bi
] alien-callback ;
: callback-18-test ( a b c callback -- result )
ulong { test_struct_68 test_struct_68 test_struct_66 } cdecl alien-indirect ;
{ 36 } [
S{ test_struct_68 f 1 2 3 } S{ test_struct_68 f 4 5 6 } S{ test_struct_66 f 7 8 } callback-18 [
callback-18-test
] with-callback
] unit-test

View File

@ -9,7 +9,7 @@ IN: compiler.tree.escape-analysis.branches
M: #branch escape-analysis*
[ in-d>> add-escaping-values ]
[ live-children [ [ (escape-analysis) ] when* ] each ]
[ live-children sift [ (escape-analysis) ] each ]
bi ;
: (merge-allocations) ( values -- allocation )

View File

@ -34,7 +34,7 @@ M: true-constraint satisfied?
TUPLE: false-constraint value ;
: =f ( value -- constraint ) resolve-copy false-constraint boa ;
: =f ( value -- constriant ) resolve-copy false-constraint boa ;
M: false-constraint assume*
[ \ f <class-info> swap value>> refine-value-info ]

View File

@ -28,17 +28,17 @@ HELP: value-info
{ $description "Gets the value info for the given SSA value. If none is found then a null empty interval is returned." } ;
HELP: value-info<=
{ $values { "info1" value-info-state } { "info2" value-info-state } { "?" boolean } }
{ $values { "info1" value-info } { "info2" value-info } { "?" boolean } }
{ $description "Checks if the first value info is equal to, or smaller than the second one." } ;
HELP: value-info-state
{ $class-description "Represents constraints the compiler knows about the input and output variables to an SSA tree node. It has the following slots:"
{ $slots
{ "class" { "Class of values the variable can take." } }
{ "interval" { "Range of values the variable can take." } }
{ "literal" { "Literal value, if present." } }
{ "literal?" { "Whether the value of the variable is known at compile-time or not." } }
{ "slots" { "If the value is a literal tuple or fixed length type, then slots is a " { $link sequence } " of " { $link value-info-state } " encoding what is known about its slots at compile-time." } }
{ $table
{ { $slot "class" } { "Class of values the variable can take." } }
{ { $slot "interval" } { "Range of values the variable can take." } }
{ { $slot "literal" } { "Literal value, if present." } }
{ { $slot "literal?" } { "Whether the value of the variable is known at compile-time or not." } }
{ { $slot "slots" } { "If the value is a literal tuple or fixed length type, then slots is a " { $link sequence } " of " { $link value-info-state } " encoding what is known about its slots at compile-time." } }
}
"Don't mutate value infos you receive, always construct new ones. We don't declare the slots read-only to allow cloning followed by writing, and to simplify constructors."
} ;

View File

@ -83,7 +83,7 @@ UNION: fixed-length array byte-array string ;
: empty-set? ( info -- ? )
{
[ class>> null-class? ]
[ [ interval>> empty-interval? ] [ class>> real class<= ] bi and ]
[ [ interval>> empty-interval eq? ] [ class>> real class<= ] bi and ]
} 1|| ;
! Hardcoding classes is kind of a hack.

View File

@ -358,7 +358,7 @@ generic-comparison-ops [
\ instance? [
! We need to force the caller word to recompile when the class
! is redefined, since now we're making assumptions about the
! is redefined, since now we're making assumptions but the
! class definition itself.
dup literal>> classoid?
[

View File

@ -1059,7 +1059,8 @@ M: tuple-with-read-only-slot clone
! Output range for string-nth now that string-nth is a library word and
! not a primitive
{ t } [
[ string-nth ] final-info first interval>> 0 23 2^ 1 - [a,b] =
! Should actually be 0 23 2^ 1 - [a,b]
[ string-nth ] final-info first interval>> 0 23 2^ [a,b] =
] unit-test
! Non-zero displacement for <displaced-alien> restricts the output type

View File

@ -27,7 +27,7 @@ IN: compiler.tree.propagation.recursive
interval class counter-class :> class
{
{ [ interval initial-interval interval-subset? ] [ initial-interval ] }
{ [ interval empty-interval? ] [ initial-interval ] }
{ [ interval empty-interval eq? ] [ initial-interval ] }
{
[ interval initial-interval interval>= t eq? ]
[ class max-value [a,a] initial-interval interval-union ]

View File

@ -64,7 +64,7 @@ CONSTANT: vector>vector-intrinsics
CONSTANT: vector-other-intrinsics
{
(simd-vdot)
(simd-v.)
(simd-vsad)
(simd-sum)
(simd-vany?)
@ -96,7 +96,7 @@ vector>vector-intrinsics [ { byte-array } "default-output-classes" set-word-prop
\ (simd-sum) [ nip scalar-output-class ] "outputs" set-word-prop
\ (simd-vdot) [ 2nip scalar-output-class ] "outputs" set-word-prop
\ (simd-v.) [ 2nip scalar-output-class ] "outputs" set-word-prop
{
(simd-vany?)

View File

@ -47,6 +47,9 @@ IN: compiler.tree.propagation.slots
[ swap slot <literal-info> ]
} 2&& ;
: length-accessor? ( slot info -- ? )
[ 1 = ] [ length>> ] bi* and ;
: value-info-slot ( slot info -- info' )
{
{ [ over 0 = ] [ 2drop fixnum <class-info> ] }

View File

@ -196,8 +196,7 @@ ERROR: bad-partial-eval quot word ;
dup classoid?
[
predicate-def
! union{ and intersection{ and not{ have useless
! expansions, and recurse infinitely
! union{ and intersection{ have useless expansions, and recurse infinitely
dup { [ length 2 >= ] [ second \ instance? = ] } 1&& [
drop f
] when

View File

@ -18,13 +18,13 @@ HELP: #alien-callback
HELP: #call
{ $class-description "SSA tree node that calls a word. It has the following slots:"
{ $slots
{ "word" { "The " { $link word } " to call." } }
{ "in-d" { "Sequence of input variables to the call. The items are ordered from top to bottom of the stack." } }
{ "out-d" { "Output values of the call." } }
{ "method" { "If the called word is generic and inlined here, then 'method' contains the inlined " { $link quotation } "." } }
{ "body" { "If the called word is generic and inlined, then 'body' is a sequence of SSA nodes built from the inlined method." } }
{ "info" { "If the called word is generic and inlined, then the info slot contains an assoc of value infos for the body of the inlined generic. It is set during the propagation pass of the optimizer." } }
{ $table
{ { $slot "word" } { "The " { $link word } " to call." } }
{ { $slot "in-d" } { "Sequence of input variables to the call. The items are ordered from top to bottom of the stack." } }
{ { $slot "out-d" } { "Output values of the call." } }
{ { $slot "method" } { "If the called word is generic and inlined here, then 'method' contains the inlined " { $link quotation } "." } }
{ { $slot "body" } { "If the called word is generic and inlined, then 'body' is a sequence of SSA nodes built from the inlined method." } }
{ { $slot "info" } { "If the called word is generic and inlined, then the info slot contains an assoc of value infos for the body of the inlined generic. It is set during the propagation pass of the optimizer." } }
}
} ;
@ -34,8 +34,8 @@ HELP: #call-recursive
HELP: #declare
{ $class-description "SSA tree node emitted when " { $link declare } " declarations are encountered. It has the following slots:"
{ $slots
{ "declaration" { { $link assoc } " that maps values to the types they are declared as." } }
{ $table
{ { $slot "declaration" } { { $link assoc } " that maps values to the types they are declared as." } }
}
} ;
@ -45,8 +45,8 @@ HELP: #enter-recursive
HELP: #if
{ $class-description "SSA tree node that implements conditional branching. It has the following slots:"
{ $slots
{ "children"
{ $table
{ { $slot "children" }
{ "A two item " { $link sequence } ". The first item holds the instructions executed if the condition is true and the second those that are executed if it is not true." }
}
}
@ -54,8 +54,8 @@ HELP: #if
HELP: #introduce
{ $class-description "SSA tree node that puts an input value from the \"outside\" on the stack. It is used to \"introduce\" data stack parameter whenever they are needed. It has the following slots:"
{ $slots
{ "out-d" { "Array of values of the parameters being introduced." } }
{ $table
{ { $slot "out-d" } { "Array of values of the parameters being introduced." } }
}
} ;
@ -64,25 +64,25 @@ HELP: #phi
HELP: #push
{ $class-description "SSA tree node that puts a literal value on the stack. It has the following slots:"
{ $slots
{ "out-d" { "A one item array containing the " { $link <value> } " of the literal being pushed." } }
{ $table
{ { $slot "out-d" } { "A one item array containing the " { $link <value> } " of the literal being pushed." } }
}
}
{ $notes "A " { $link quotation } " is also a literal." } ;
HELP: #recursive
{ $class-description "Instruction which encodes a loop. It has the following slots:"
{ $slots
{ "child" { "A sequence of nodes representing the body of the loop." } }
{ "loop?" { "If " { $link t } ", the recursion is implemented using a jump, otherwise as a call back to the word." } }
{ $table
{ { $slot "child" } { "A sequence of nodes representing the body of the loop." } }
{ { $slot "loop?" } { "If " { $link t } ", the recursion is implemented using a jump, otherwise as a call back to the word." } }
}
}
{ $see-also inline-recursive-word } ;
HELP: #shuffle
{ $class-description "SSA tree node that represents a stack shuffling operation such as " { $link swap } ". It has the following slots:"
{ $slots
{ "mapping" { "An " { $link assoc } " that shows how the shuffle output values (the keys) correspond to their inputs (the values)." } }
{ $table
{ { $slot "mapping" } { "An " { $link assoc } " that shows how the shuffle output values (the keys) correspond to their inputs (the values)." } }
}
} ;

View File

@ -13,7 +13,7 @@ IN: compression.run-length
:: run-length-uncompress-bitmap4 ( byte-array m n -- byte-array' )
byte-array <sequence-parser> :> sp
m 1 + n <zero-matrix> :> matrix
m 1 + n zero-matrix :> matrix
n 4 mod n + :> stride
0 :> i!
0 :> j!
@ -45,7 +45,7 @@ IN: compression.run-length
:: run-length-uncompress-bitmap8 ( byte-array m n -- byte-array' )
byte-array <sequence-parser> :> sp
m 1 + n <zero-matrix> :> matrix
m 1 + n zero-matrix :> matrix
n 4 mod n + :> stride
0 :> i!
0 :> j!

View File

@ -60,7 +60,7 @@ C: <connection> connection
[ stream>> dispose ] [ drop ] if ;
: with-connection ( remote-thread quot -- )
'[ connect @ ] over [ disconnect ] curry finally ; inline
'[ connect @ ] over [ disconnect ] curry [ ] cleanup ; inline
: send-remote-message ( message node -- )
binary [ serialize ] with-client ;
@ -68,11 +68,11 @@ C: <connection> connection
: send-to-connection ( message connection -- )
stream>> [ serialize flush ] with-stream* ;
M: remote-thread send
M: remote-thread send ( message thread -- )
[ id>> 2array ] [ node>> ] [ thread-connections at ] tri
[ nip send-to-connection ] [ send-remote-message ] if* ;
M: thread (serialize)
M: thread (serialize) ( obj -- )
id>> [ local-node get insecure>> ] dip <remote-thread> (serialize) ;
: stop-node ( -- )

View File

@ -27,7 +27,7 @@ TUPLE: lock threads owner reentrant? ;
:: do-lock ( lock timeout quot acquire release -- )
lock timeout acquire call
quot lock release curry finally ; inline
quot lock release curry [ ] cleanup ; inline
: (with-lock) ( lock timeout quot -- )
[ acquire-lock ] [ release-lock ] do-lock ; inline

View File

@ -13,7 +13,7 @@ M: thread mailbox-of
[ { mailbox } declare ]
[ <mailbox> [ >>mailbox drop ] keep ] ?if ; inline
M: thread send
M: thread send ( message thread -- )
mailbox-of mailbox-put ;
: my-mailbox ( -- mailbox ) self mailbox-of ; inline

View File

@ -32,7 +32,7 @@ M: negative-count-semaphore summary
:: with-semaphore-timeout ( semaphore timeout quot -- )
semaphore timeout acquire-timeout
quot [ semaphore release ] finally ; inline
quot [ semaphore release ] [ ] cleanup ; inline
: with-semaphore ( semaphore quot -- )
swap dup acquire '[ _ release ] finally ; inline
swap dup acquire '[ _ release ] [ ] cleanup ; inline

View File

@ -1,12 +1,11 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data alien.syntax arrays
assocs cache classes colors combinators core-foundation
assocs cache colors combinators core-foundation
core-foundation.attributed-strings core-foundation.strings
core-graphics core-graphics.types core-text.fonts destructors
fonts init kernel locals make math math.functions math.order
math.vectors memoize namespaces sequences strings
io.encodings.utf16n io.encodings.string ;
math.vectors memoize namespaces sequences strings ;
IN: core-text
TYPEDEF: void* CTLineRef
@ -34,6 +33,8 @@ FUNCTION: CGRect CTLineGetImageBounds ( CTLineRef line, CGContextRef context )
SYMBOL: retina?
ERROR: not-a-string object ;
MEMO: make-attributes ( open-font color -- hashtable )
[
kCTForegroundColorAttributeName ,,
@ -44,7 +45,7 @@ MEMO: make-attributes ( open-font color -- hashtable )
[
[
dup selection? [ string>> ] when
string check-instance
dup string? [ not-a-string ] unless
] 2dip
make-attributes <CFAttributedString> &CFRelease
CTLineCreateWithAttributedString
@ -77,7 +78,9 @@ render-loc render-dim ;
compute-height ;
: metrics>dim ( bounds -- dim )
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi 2array ;
[ width>> ] [ [ ascent>> ] [ descent>> ] bi + ] bi
[ ceiling >integer ]
bi@ 2array ;
: fill-background ( context font dim -- )
[ background>> >rgba-components CGContextSetRGBFillColor ]
@ -85,9 +88,7 @@ render-loc render-dim ;
bi-curry* bi ;
: selection-rect ( dim line selection -- rect )
[let [ start>> ] [ end>> ] [ string>> ] tri :> ( start end string )
start end [ 0 swap string subseq utf16n encode length 2 /i ] bi@
]
[ start>> ] [ end>> ] bi
[ f CTLineGetOffsetForStringIndex round ] bi-curry@ bi
[ drop nip 0 ] [ swap - swap second ] 3bi <CGRect> ;

View File

@ -524,7 +524,7 @@ HOOK: immediate-bitwise? cpu ( n -- ? )
HOOK: immediate-comparand? cpu ( n -- ? )
HOOK: immediate-store? cpu ( n -- ? )
M: object immediate-comparand?
M: object immediate-comparand? ( n -- ? )
{
{ [ dup fixnum? ] [ tag-fixnum immediate-arithmetic? ] }
{ [ dup not ] [ drop t ] }

View File

@ -5,13 +5,13 @@ compiler.cfg.builder.alien.boxing sequences arrays
alien.c-types cpu.architecture cpu.ppc alien.complex ;
IN: cpu.ppc.32.linux
M: linux lr-save 1 cells ;
M: linux lr-save ( -- n ) 1 cells ;
M: linux has-toc f ;
M: linux has-toc ( -- ? ) f ;
M: linux reserved-area-size 2 cells ;
M: linux reserved-area-size ( -- n ) 2 cells ;
M: linux allows-null-dereference f ;
M: linux allows-null-dereference ( -- ? ) f ;
M: ppc param-regs
drop {
@ -35,7 +35,7 @@ M: ppc long-long-odd-register? t ;
M: ppc float-right-align-on-stack? f ;
M: ppc flatten-struct-type
M: ppc flatten-struct-type ( type -- seq )
{
{ [ dup lookup-c-type complex-double lookup-c-type = ]
[ drop { { int-rep f f } { int-rep f f }

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