Commit Graph

22611 Commits (7b4e62b87ff342322cdd577f60eed33e32f028cc)

Author SHA1 Message Date
Joe Groff 7b4e62b87f io.streams.c: remove -seek and -tell methods
M: c-stream stream-seek was broken and bootstrap doesn't need it so save some code.
2011-10-17 21:23:10 -07:00
Joe Groff d35c67dde4 more stream-seekable? and stream-length methods
- limited-streams and throw-on-eof-streams
- string-readers and byte-readers
2011-10-17 21:23:09 -07:00
Joe Groff 10bcb933db io: document new words 2011-10-17 21:23:09 -07:00
Joe Groff 0c225d1e8d io.streams.c: help-lint 2011-10-17 21:23:08 -07:00
Joe Groff a3bc7195e8 delegate.protocols: clean up input-stream-protocol 2011-10-17 21:23:08 -07:00
Joe Groff 21e2fdc25c io: stream-read-into and stream-read-partial-into
Safe user-facing wrappers for stream-read-unsafe.
2011-10-17 21:23:08 -07:00
Joe Groff 17760cbbb8 io.ports: stream-seekable? and stream-length
io.files.windows, io.backend.unix: platform-specific backends for those methods
2011-10-17 21:23:08 -07:00
Joe Groff 440130d618 io.encodings: stream-contents method for decoder
stream-contents on decoder is much faster implemented using a read1 loop than with the default implementation.
2011-10-17 21:23:07 -07:00
Joe Groff 372f7c6614 io: stream-contents, -seekable?, -length generics
stream-contents is extremely slow on decoder streams when implemented with each-block, and it can be implemented very quickly for streams of known length using stream-read-unsafe. Make it generic and provide some off-the-shelf implementations using each-block, a read1 loop, or length + read-unsafe. Provide new stream-seekable? and stream-length generics that can be implemented by stream implementations that know their size.
2011-10-17 21:23:07 -07:00
Joe Groff d54de50dd6 unix.stat: bind to fstat 2011-10-17 21:23:07 -07:00
Joe Groff c4d9599a00 io: get variables out of stream-copy loop 2011-10-17 21:23:07 -07:00
Joe Groff 7cf22250ce clean up forwarding stream-read-partial-unsafe
Now that "io" provides a method on object for stream-read-partial-unsafe that forwards to stream-read-unsafe, individual stream class that don't implement partial reads don't need to provide such a method themselves.
2011-10-17 21:23:06 -07:00
Joe Groff 2e1f72697f io: default methods for extended stream protocols
Provide default implementations of all the input-stream methods in terms of stream-read1 and of all the output-stream methods in terms of stream-write1.
2011-10-17 21:23:06 -07:00
Joe Groff 6f47c1c430 io.streams.peek: test with memory-stream
Some binary stream types use memcpy to implement read-unsafe, while element-agnostic wrapper streams have to use copy. Make sure peek-stream works with both when it has to divide a read between the peek buffer and the underlying buffer (it does).
2011-10-17 21:23:06 -07:00
Joe Groff e7009459bf specialized-arrays: direct-slice for byte-arrays
Implement nth-c-ptr and direct-like for byte-arrays so that direct-slice over a byte-array makes a uchar-array{ } over a part of the byte-array
2011-10-17 21:23:06 -07:00
Joe Groff 28af1529bc io: add read-unsafe and read-partial-unsafe words
Add shortcut words to operate on the input-stream like the other stream methods have. Make all those words inline too just for fun.
2011-10-17 21:23:05 -07:00
Joe Groff 0303d4d1de ui.tools.listener: fix stream-read-unsafe
It was returning the number of requested bytes even if eof was encountered.
2011-10-17 21:23:05 -07:00
Joe Groff 1e37b525a3 kill noncopying-reader mixin, stream-read generic
Now that all streams have been updated to implement the stream-read-unsafe protocol, take out the noncopying-reader shim. Turn stream-read and stream-read-partial into plain functions over the -unsafe generics.
2011-10-17 21:23:05 -07:00
Joe Groff fcfbcde5a1 mongodb.gridfs: leave an unmaintained-reason.txt 2011-10-17 21:23:04 -07:00
Joe Groff 5f47ec2d57 io.streams.peek: read-unsafe protocol 2011-10-17 21:23:04 -07:00
Joe Groff a0d49d9ff3 ui.tools.listener: read-unsafe for interactor†
†there's a failing test with this patch that needs investigation:

===
resource:basis/ui/tools/listener/listener-tests.factor: 90

Unit Test: { [ t ] [ "promise" get 2 seconds ?promise-timeout text = ] }

wait-timeout
===
2011-10-17 21:23:04 -07:00
Joe Groff df6140eb93 delegate.protocols: update input-stream-protocol
Add stream-read-unsafe and stream-read-partial-unsafe to input-stream-protocol.
2011-10-17 21:23:04 -07:00
Joe Groff e2e9ce991d io: remove each-block* because it's not useful 2011-10-17 21:23:03 -07:00
Joe Groff af370097a4 io.encodings: decoders can't really seek or tell 2011-10-17 21:23:03 -07:00
Joe Groff 92edf6f98a io.encodings: re-encrypt into stack-ese for core 2011-10-17 21:23:03 -07:00
Joe Groff 991e08c880 io.encodings: read-unsafe for decoders†
† currently uses locals, so not bootstrappable
2011-10-17 21:23:02 -07:00
Joe Groff f188f203a0 io.encodings.string: faster decode and encode
stream-contents is apparently way slow for decoders. Write decode out more directly as a read1/push loop so it's faster. encode isn't quite as bad, but we can still get a 25% speed improvement by writing to an appropriately sized byte-vector.
2011-10-17 21:23:02 -07:00
Joe Groff 9fc11e5853 io.encodings: encoded/decoded length hints
Add guess-encoded-length and guess-decoded-length generics that encodings can implement to provide hints as to how large the translation product will be, for sizing vectors and things like that.
2011-10-17 21:23:02 -07:00
Joe Groff b3d7c1575d io: tweak each-block* to be byte- or char-agnostic 2011-10-17 21:23:02 -07:00
Joe Groff fa386228d7 vm: no-op reallot_array with same size, for real 2011-10-17 21:23:01 -07:00
Joe Groff 96278b25a1 mongodb.gridfs: move to unmaintained
It has no tests and nothing appears to use it, so I don't want to mess with it to make it implement the stream-read-unsafe interface.
2011-10-17 21:23:01 -07:00
Joe Groff cb0f50029a io: nab io.streams.peek's stream-exemplar-growable
Rename stream-element-examplar to stream-exemplar to match.
2011-10-17 21:23:01 -07:00
Joe Groff 3ce5dd1ed1 vm: make reallot_array for same size a no-op 2011-10-17 21:23:01 -07:00
Joe Groff 46c9858114 io.streams.(limited,throwing): read-unsafe methods 2011-10-17 21:23:00 -07:00
Joe Groff dcc17306cf io.streams.null: read-unsafe methods 2011-10-17 21:23:00 -07:00
Joe Groff 65b3984490 io: non-copying each-block and contents variants
each-(stream-)block* is like each-block but takes a buffer object and reads into it repeatedly. (stream-)contents* determines the stream length then does a single stream-read-unsafe into a preallocated buffers. Both functions currently only work for byte-arrays (and contents* only for seekable streams), so they can't replace the non-starred versions completely just yet.
2011-10-17 21:23:00 -07:00
Joe Groff f9e69023c9 io.ports: implement read-unsafe operations 2011-10-17 21:22:59 -07:00
Joe Groff f3fe3d43e3 io.buffers: factor out buffer-read-unsafe word
buffer-read-unsafe returns a length and a pointer into the buffer instead of a copy.
2011-10-17 21:22:59 -07:00
Joe Groff f6b54c50cc io.streams.memory: implement stream-read-unsafe
(The actual method is in alien.data due to bootstrap load order issues.)
2011-10-17 21:22:59 -07:00
Joe Groff 9737ca956f io.streams.sequence: change to provide read-unsafe
Change io.streams.sequence and its children io.streams.byte-array and io.streams.string to implement the -unsafe protocol and mixin noncopying-reader.
2011-10-17 21:22:59 -07:00
Joe Groff db68af8df5 io, io.streams.c: factor noncopying-reader mixin
Instances of the mixin implement stream-read and stream-read-partial in terms of stream-read-unsafe and stream-read-partial-unsafe, respectively.
2011-10-17 21:22:58 -07:00
Joe Groff 0497bbb365 io.streams.c: Document fputc primitive 2011-10-17 21:22:58 -07:00
Joe Groff 3bd23a9840 bootstrap, io.streams.c: use new fread primitive
Change the fread primitive to fread-unsafe, matching the new primitive in the VM, and update the implementation of c-reader to implement stream-read-unsafe and stream-read in terms of fread-unsafe
2011-10-17 21:22:58 -07:00
Joe Groff d8f5004776 io: non-copying binary stream read generics
Add generics stream-read-unsafe and stream-read-partial-unsafe, which take a buffer pointer and return a count of bytes read instead of returning a freshly allocated byte array.
2011-10-17 21:22:57 -07:00
Joe Groff a1fafbd6ec vm: non-copying primitive_fread
primitive_fread now takes a buffer pointer argument and returns a count of bytes read instead of allocating a byte array.
2011-10-17 21:22:57 -07:00
John Benediktsson 046f2b7d9c math.functions: improve stack effect names for gcd*. 2011-10-17 20:37:36 -07:00
John Benediktsson 302cd52c74 math.functions: faster gcd means faster ratios. 2011-10-17 20:36:28 -07:00
Doug Coleman 4f81cc4fbc find-dlist-node was returning duplicated information -- node/f tells you enough, no need for another boolean return value 2011-10-17 18:58:14 -07:00
John Benediktsson 0ee0c2fbc2 benchmarks: tcp/udp should take less time for now (until it gets sped up). 2011-10-17 17:47:28 -07:00
Doug Coleman a6bc5e9a56 A little ambitious on the tcp-echo2 benchmark. Reduce 20mil to 20k 2011-10-17 16:47:21 -07:00