diff options
author | Trevor Norris <trev.norris@gmail.com> | 2015-05-26 21:42:14 +0300 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 21:56:10 +0300 |
commit | 63da0dfd3a4460e117240e84b57af2137469497e (patch) | |
tree | 4806693f7d89ba36ebbe4ff1ab5f34e1b3cf90ea /src/util-inl.h | |
parent | 23be6ca189e1ebad24a814ed1c8c1c241fee354e (diff) |
buffer: implement Uint8Array backed Buffer
With V8 4.4 removing the external array data API currently used by
Buffer, the new implementation uses the Uint8Array to back Buffer.
Buffers now have a maximum size of Smi::kMaxLength, as defined by V8.
Which is ~2 GB on 64 bit and ~1 GB on 32 bit.
The flag --use-old-buffer allows using the old Buffer implementation.
This flag will be removed once V8 4.4 has landed.
The two JS Buffer implementations have been split into two files for
simplicity.
Use getter to return expected .parent/.offset values for backwards
compatibility.
PR-URL: https://github.com/nodejs/io.js/pull/1825
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index 75bdb4784aa..308c9b2787d 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -198,6 +198,14 @@ TypeName* Unwrap(v8::Local<v8::Object> object) { return static_cast<TypeName*>(pointer); } +inline bool IsValidSmi(int64_t value) { + if (sizeof(int32_t) == sizeof(intptr_t)) { + return value >= -0x40000000LL && value <= 0x3fffffffLL; + } else { + return value >= -0x80000000LL && value <= 0x7fffffffLL; + } +} + } // namespace node #endif // SRC_UTIL_INL_H_ |