This repository has been archived by the owner. It is now read-only.
Please sign in to comment.
buffer: use smalloc as backing data store
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.
- Loading branch information...
Showing with 695 additions and 1,286 deletions.
- +65 −68 doc/api/buffer.markdown
- +187 −467 lib/buffer.js
- +0 −1 src/node.js
- +317 −406 src/node_buffer.cc
- +34 −131 src/node_buffer.h
- +7 −21 src/node_crypto.cc
- +24 −0 src/node_internals.h
- +1 −4 src/slab_allocator.cc
- +1 −1 src/string_bytes.cc
- +5 −6 src/tls_wrap.cc
- +0 −30 test/simple/test-buffer-regress-GH-2659.js
- +54 −127 test/simple/test-buffer.js
- +0 −2 test/simple/test-readdouble.js
- +0 −2 test/simple/test-readfloat.js
- +0 −4 test/simple/test-readint.js
- +0 −4 test/simple/test-readuint.js
- +0 −2 test/simple/test-writedouble.js
- +0 −2 test/simple/test-writefloat.js
- +0 −4 test/simple/test-writeint.js
- +0 −4 test/simple/test-writeuint.js
Oops, something went wrong.