summaryrefslogtreecommitdiff
path: root/src/node_buffer.h
Commit message (Collapse)AuthorAgeFilesLines
* src: remove `node_isolate` from sourceFedor Indutny2014-02-221-5/+35
| | | | fix #6899
* Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine2014-02-081-0/+15
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: deps/v8/src/preparser.cc deps/v8/src/win32-math.h doc/api/http.markdown src/node_buffer.h src/node_crypto.cc src/node_file.cc src/node_http_parser.cc
| * src: refactor buffer bounds checkingTimothy J Fontaine2014-02-081-0/+14
| | | | | | | | | | Consolidate buffer bounds checking logic into Buffer namespace and use it consistently throughout the source.
* | src: add multi-context supportBen Noordhuis2013-09-061-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
* | src: move includes inside include guardBen Noordhuis2013-08-191-3/+3
| | | | | | | | | | Having the includes in src/node_buffer.h outside of the include guard is not really harmful but it's inconsistent with other header files.
* | src: lint c++ codeFedor Indutny2013-07-311-5/+3
| |
* | buffer: write strings directly from callTrevor Norris2013-06-191-1/+2
| | | | | | | | | | | | | | | | Buffer(<String>) used to pass the string to js where it would then be passed back to cpp for processing. Now only the buffer object instantiation is done in js and the string is processed in cpp. Also added a Buffer api that also accepts the encoding.
* | buffer: proper API export for WindowsTrevor Norris2013-06-181-14/+15
| | | | | | | | | | So that Windows users can properly include smalloc and node_buffer, NODE_EXTERN was added to the headers that export this functionality.
* | buffer: use smalloc as backing data storeTrevor Norris2013-06-181-131/+34
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memory allocations are now done through smalloc. The Buffer cc class has been removed completely, but for backwards compatibility have left the namespace as Buffer. The .parent attribute is only set if the Buffer is a slice of an allocation. Which is then set to the alloc object (not a Buffer). The .offset attribute is now a ReadOnly set to 0, for backwards compatibility. I'd like to remove it in the future (pre v1.0). A few alterations have been made to how arguments are either coerced or thrown. All primitives will now be coerced to their respective values, and (most) all out of range index requests will throw. The indexes that are coerced were left for backwards compatibility. For example: Buffer slice operates more like Array slice, and coerces instead of throwing out of range indexes. This may change in the future. The reason for wanting to throw for out of range indexes is because giving js access to raw memory has high potential risk. To mitigate that it's easier to make sure the developer is always quickly alerted to the fact that their code is attempting to access beyond memory bounds. Because SlowBuffer will be deprecated, and simply returns a new Buffer instance, all tests on SlowBuffer have been removed. Heapdumps will now show usage under "smalloc" instead of "Buffer". ParseArrayIndex was added to node_internals to support proper uint argument checking/coercion for external array data indexes. SlabAllocator had to be updated since handle_ no longer exists.
* buffer: DRY string encoding using StringBytesisaacs2013-05-141-0/+6
| | | | | | | This also templatizes the Buffer::*Slice functions, and the template function probably cannot be safely used outside of Node. However, it also SHOULD not be used outside of Node, so this is arguably a feature as well as a caveat.
* buffer: optimize Buffer.prototype.write(s, 'hex')Ben Noordhuis2013-02-021-0/+1
| | | | | | | | | | | | Move the implementation to C++ land. This is similar to commit 3f65916 but this time for the write() function and the Buffer(s, 'hex') constructor. Speeds up the benchmark below about 24x (2.6s vs 1:02m). var s = 'f'; for (var i = 0; i < 26; ++i) s += s; // 64 MB Buffer(s, 'hex');
* buffer: optimize Buffer.prototype.toString('hex')Ben Noordhuis2013-02-011-0/+1
| | | | | | | | | | | | | Move the implementation to C++ land. The old JS implementation used string concatenation, was dog slow and consumed copious amounts of memory for large buffers. Example: var buf = Buffer(0x1000000); // 16 MB buf.toString('hex') // Used 3+ GB of memory. The new implementation operates in O(n) time and space. Fixes #4700.
* buffer: floating point read/write improvementsTrevor Norris2013-01-161-0/+8
| | | | | | | | | | | | | | | Improvements: * floating point operations are approx 4x's faster * Now write quiet NaN's * all read/write on floating point now done in C, so no more need for lib/buffer_ieee754.js * float values have more accurate min/max value checks * add additional benchmarks for buffers read/write * created benchmark/_bench_timer.js which is a simple library that can be included into any benchmark and provides an intelligent tracker for sync and async tests * add benchmarks for DataView set methods * add checks and tests to make sure offset is greater than 0
* src: use static_cast where appropriateBen Noordhuis2013-01-051-1/+1
| | | | | | | | Use static_cast instead of reinterpret_cast when casting from void* to another type. This is mostly an aesthetic change but may help catch bugs when the affected code is modified.
* Revert "buffer: allocate memory with mmap()"isaacs2012-12-171-3/+0
| | | | | | | Also Revert "buffer: use MAP_ANON, fix OS X build" This reverts commit ddb15603e74e9aa865f3e1099dc2cc5886f9c46e. This reverts commit 2433ec8276838e90136669d5b1215ba597f15fdd.
* buffer: allocate memory with mmap()Ben Noordhuis2012-12-161-0/+3
| | | | | | | | Work around an issue with the glibc malloc() implementation where memory blocks are never returned to the operating system when they are allocated with brk() and have overlapping lifecycles. Fixes #4283.
* buffer: update constructor prototypePavel Lang2012-09-131-3/+7
| | | | Change Buffer::New(char*, size_t) to Buffer::New(const char*, size_t).
* buffer: change prototype of Data() and Length()Ben Noordhuis2012-09-111-4/+9
| | | | Make Buffer:Data() and Buffer::Length() accept a Value instead of an Object.
* buffer: fix signedness compiler warningsBen Noordhuis2012-03-301-1/+1
|
* core: use proper #include directivesBen Noordhuis2012-03-101-3/+3
|
* buffer: throw from constructor if length > kMaxLengthBen Noordhuis2012-03-091-0/+3
| | | | | | | | | | Throw, don't abort. `new Buffer(0x3fffffff + 1)` used to bring down the process with the following error message: FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData() length exceeds max acceptable value Fixes #2280.
* Revert support for isolates.Ben Noordhuis2012-02-061-0/+1
| | | | | | | | | | | | It was decided that the performance benefits that isolates offer (faster spin-up times for worker processes, faster inter-worker communication, possibly a lower memory footprint) are not actual bottlenecks for most people and do not outweigh the potential stability issues and intrusive changes to the code base that first-class support for isolates requires. Hence, this commit backs out all isolates-related changes. Good bye, isolates. We hardly knew ye.
* Move node_buffer.cc globals to structRyan Dahl2011-12-071-2/+0
|
* Windows: make Buffer and ObjectWrap available to compiled extensionsBert Belder2011-11-171-1/+1
| | | | Closes GH-2036
* Fix line endings and trailing whitespaceBert Belder2011-11-041-1/+1
|
* Remove confusing comment in node_buffer.hRyan Dahl2011-06-141-3/+0
|
* Add Buffer::fill method to do memsetKonstantin Käfer2011-05-061-0/+1
| | | | Fixes #477.
* Update copyright headersRyan Dahl2011-03-141-0/+21
|
* Buffer::Length(Buffer*) should not invoke itself recursively.Ben Noordhuis2011-03-101-1/+1
| | | | Closes GH-759.
* UCS-2 supportKonstantin Käfer2011-02-071-0/+2
| | | | Closes GH-644.
* Add C++ Buffer migration tipsRyan Dahl2011-01-041-9/+47
|
* Revert "Merge branch 'writev'"Ryan Dahl2010-11-201-3/+1
| | | | | | | This reverts commit cd9515efd99dfa6510e72342a2621bb4b291a89c, reversing changes made to df46c8e698b9400abaabd77ec836c7cdadf9735c. Too slow. Needs more work.
* Inline Buffer::Length and Buffer::DataRyan Dahl2010-11-201-2/+7
|
* Small clean upsRyan Dahl2010-11-181-1/+1
|
* Support encodingRyan Dahl2010-11-181-1/+3
|
* Remove old buffer apiRyan Dahl2010-11-011-11/+1
|
* Add C++ API for constructing fast buffer from stringRyan Dahl2010-10-261-0/+3
|
* Provide a C++ Buffer constructor for external storage.Stéphan Kochen2010-10-221-1/+8
| | | | | | | | | In order to do this, buffer data management was moved out of the JS entry-point New, and into Replace. Secondly, the constructor makes an immediate call to Replace, and in order for ArrayData calls to work, wrapping must already be set up. Now, the constructor takes the wrappee as a parameter.
* Remove old interface remains from Buffer.Stéphan Kochen2010-10-221-21/+2
| | | | These were all lacking implementation, so deprecating wouldn't help.
* Add char* constructor for BufferRyan Dahl2010-10-101-0/+1
|
* Warnings for new C++ buffer APIRyan Dahl2010-10-091-2/+11
|
* Remove blobs, simplify SlowBufferRyan Dahl2010-09-091-4/+3
| | | | Implement SlowBuffer.prototype.slice in js
* Work to get C++ fast buffers. incompleteRyan Dahl2010-09-091-5/+4
|
* Fix buffer bindingRyan Dahl2010-09-091-1/+0
|
* FastBuffer implementation. API needs migrationTim-Smart2010-09-091-0/+1
|
* Improve appendix markdownRyan Dahl2010-08-211-0/+1
|
* Implement buffer.write for base64Ryan Dahl2010-07-231-0/+1
| | | | There might be an off-by-one on the returned value.
* Implement buffer.toString('base64')Ryan Dahl2010-07-231-0/+1
|
* Create a public Buffer constructor for use in addons.Ryan Dahl2010-05-241-8/+9
|
* Make buffer's c++ constructor publicRyan Dahl2010-05-201-5/+6
|