Commit Graph

126 Commits

Author SHA1 Message Date
Ben Noordhuis
6573fc3502 src: pass node_isolate to Integer::New 2013-01-07 17:39:57 +01:00
Ben Noordhuis
a329729537 buffer: speed up base64 encoding by 20%
Remove a lot of branches from the inner loop. Speeds up buf.toString('base64')
by about 20%.

Before:

  $ time out/Release/node benchmark/buffer-base64-encode.js
  real    0m6.607s
  user    0m5.508s
  sys     0m1.088s

After:

  $ time out/Release/node benchmark/buffer-base64-encode.js
  real    0m5.520s
  user    0m4.520s
  sys     0m0.992s
2012-12-28 13:20:07 +01:00
isaacs
6c5356bfe2 Revert "buffer: allocate memory with mmap()"
Also Revert "buffer: use MAP_ANON, fix OS X build"

This reverts commit ddb15603e7.
This reverts commit 2433ec8276.
2012-12-17 10:47:17 -08:00
Ben Noordhuis
ddb15603e7 buffer: use MAP_ANON, fix OS X build 2012-12-17 11:29:03 +01:00
Ben Noordhuis
2433ec8276 buffer: allocate memory with mmap()
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.
2012-12-16 10:19:09 +01:00
Ben Noordhuis
c08e947fbd buffer: remove unused #includes 2012-12-06 04:45:11 +01:00
Nathan Rajlich
4b238b4c2a Merge remote-tracking branch 'origin/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/test/runner-win.c
	doc/api/process.markdown
	lib/repl.js
	src/node_crypto.cc
	src/node_version.h
2012-10-13 16:16:56 -07:00
Ben Noordhuis
6a128e037e buffer: report proper retained size in profiler
Make buffers report the proper retained size in heap snapshots.

Before this commit, Buffer objects would show up in the heap profiler as being
only a few hundred bytes large, even if the actual buffer was many megabytes.
2012-10-11 01:05:18 +02:00
Pavel Lang
7ab4a77d6f buffer: update constructor prototype
Change Buffer::New(char*, size_t) to Buffer::New(const char*, size_t).
2012-09-13 16:31:04 +02:00
Bert Belder
9263213d8e Avoid compiler warning about negating unsigned value 2012-08-17 01:08:06 +02:00
isaacs
a26bee8fa1 MakeCallback: Consistent symbol usage 2012-04-17 13:14:54 -07:00
Ben Noordhuis
b82b4f2993 buffer: fix signedness compiler warnings 2012-03-30 14:52:38 +02:00
ssuda
249c3c165a Avoiding unnecessary ToString() calls
String::Utf8Value and String::AsciiValue constructors take Handle<Value>
So no need to convert to Handle<String>
2012-03-23 01:02:59 +01:00
Ben Noordhuis
ff4a9d381d core: use proper #include directives 2012-03-10 00:14:14 +01:00
Ben Noordhuis
8c02f9b7c8 buffer: throw from constructor if length > kMaxLength
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.
2012-03-09 23:57:03 +01:00
Ben Noordhuis
b92a919500 Remove unused variables. 2012-02-23 04:11:07 -08:00
Ben Noordhuis
b9127eb0a5 buffer: support decoding of URL-safe base64 2012-02-21 15:33:14 +01:00
isaacs
116835561d Merge remote-tracking branch 'ry/v0.6'
Conflicts:
	ChangeLog
	deps/v8/src/version.cc
	deps/v8/tools/gyp/v8.gyp
	doc/about/index.html
	doc/community/index.html
	doc/index.html
	doc/logos/index.html
	doc/template.html
	lib/path.js
	lib/querystring.js
	src/node_version.h
2012-02-06 15:43:21 -08:00
Ben Noordhuis
74a8215a86 Revert support for isolates.
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.
2012-02-06 15:44:42 +01:00
Ben Noordhuis
7e40c7ddc9 buffers: fix intermittent out of bounds error
The base64 decoder would intermittently throw an out-of-bounds exception when
the buffer in `buf.write('', 'base64')` was a zero-sized buffer located at the
end of the slab.

Fixes #2657.
2012-02-02 19:14:06 +01:00
Ben Noordhuis
f101f7c9ba buffers: honor length argument in base64 decoder
Honor the length argument in `buf.write(s, 0, buf.length, 'base64')`. Before
this commit, the length argument was ignored. The decoder would keep writing
until it hit the end of the buffer. Since most buffers in Node are slices of
a parent buffer (the slab), this bug would overwrite the content of adjacent
buffers.

The bug is trivially demonstrated with the following test case:

    var assert = require('assert');
    var a = Buffer(3);
    var b = Buffer('xxx');
    a.write('aaaaaaaa', 'base64');
    assert.equal(b.toString(), 'xxx');

This commit coincidentally also fixes a bug where Buffer._charsWritten was not
updated for zero length buffers.
2012-02-02 19:13:56 +01:00
Igor Zinkovsky
500c8f45f5 Remove platform files, and use uv platform api 2011-12-15 18:01:22 -08:00
Ryan Dahl
59055b227a Move node_buffer.cc globals to struct 2011-12-07 16:01:46 -08:00
Ben Noordhuis
cdcb1118c8 Remove stray NODE_MODULE() semi-colons. 2011-11-09 16:34:09 +01:00
koichik
6a72e52520 buffer: use NO_NULL_TERMINATION flag
Refs #394.
Fixes #1902.
2011-10-19 15:03:00 +09:00
Ryan Dahl
52044fd1b1 Merge remote branch 'origin/v0.4'
Conflicts:
	lib/net.js
	test/simple/test-buffer.js
2011-09-07 17:51:33 -07:00
koichik
3e853e627e buffer: write() should always set _charsWritten.
Refs #1633.
2011-09-03 11:48:27 +09:00
koichik
96ede8cc9b buffer: Avoid overrun with 'binary' encoding.
Fixes #1624.
2011-09-02 09:56:58 +09:00
Ryan Dahl
7d38a3b81c Fix build - due to V8 API change 2011-08-26 13:20:27 -07:00
Bert Belder
91ecfbcae8 Remove platform_win32_winsock 2011-08-02 18:38:34 +02:00
Ben Noordhuis
2d65f3c59a Include "platform.h", not <platform.h> - conflicts with system headers
Fixes #1003.
2011-07-26 22:09:03 +02:00
Ben Noordhuis
a7bdaabf60 Include "platform.h", not <platform.h> - conflicts with system headers
Fixes #1003.
2011-07-26 22:05:08 +02:00
Ryan Dahl
041c983290 Merge branch 'v0.4'
Conflicts:
	deps/libev/wscript
	doc/api/modules.markdown
2011-07-14 15:52:08 -07:00
koichik
5208abe723 Fix Buffer drops last null character in UTF-8
Reproduce:

    $ node
    > buf = new Buffer('\0')
    <Buffer >
    > buf.length
    0
    > buf = new Buffer(1)
    <Buffer 28>
    > buf.write('\0')
    0

Fixes #394.
Fixes #1210.
2011-07-14 02:21:56 +09:00
Ryan Dahl
59274e8a33 Merge branch 'v0.4'
Conflicts:
	lib/crypto.js
	lib/tls.js
2011-05-20 10:29:16 -07:00
Ryan Dahl
5e409c2f1a makeFastBuffer should not segfault but rather throw on non-buffer 2011-05-19 12:13:48 -07:00
Konstantin Käfer
5e1b7cadb4 Add Buffer::fill method to do memset
Fixes #477.
2011-05-06 13:39:12 -07:00
Ryan Dahl
598792ba91 Merge branch 'v0.4'
Conflicts:
	src/platform_sunos.cc
	test/simple/test-os.js
2011-04-14 01:11:21 +00:00
koichik
9533e879f0 Fix Buffer.write() with UCS-2 should not be write partial char
closes #916.
2011-04-13 09:55:49 -07:00
Ryan Dahl
7a8c729830 Merge branch 'v0.4'
Conflicts:
	src/node_version.h
2011-03-22 13:12:07 -07:00
Ryan Dahl
8b33a1d8e4 Guard failed buffer constructions.
Thanks to Jeremy Barnes for pointing it out.
2011-03-22 13:10:53 -07:00
Ryan Dahl
247d880113 Merge branch 'v0.4'
Conflicts:
	src/node_version.h
2011-03-14 17:45:15 -07:00
Ryan Dahl
55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
isaacs
0aa1a8a005 Closes GH-695 Add 'hex' encoding to Buffer 2011-02-19 19:24:23 -08:00
Ryan Dahl
0474ce6790 Revert "buffer.toString() shouldn't include null values"
This reverts commit 909a5b39d2.

Will fix inside V8's String::New instead.
2011-02-15 12:07:43 -08:00
Ryan Dahl
909a5b39d2 buffer.toString() shouldn't include null values 2011-02-14 14:27:02 -08:00
Konstantin Käfer
9e101f2b01 UCS-2 support
Closes GH-644.
2011-02-07 13:35:06 -08:00
Bert Belder
e0f47be9d0 Clean up the way windows headers are included
Plus make inclusion order a little more consistent in general
2011-01-18 04:58:11 +01:00
Bert Belder
4a2cb07808 Fix whitespace errors introduced by porting efforts 2010-12-20 23:51:25 +01:00
Bert Belder
6d1af51de6 Fix header files for node_buffer.cc 2010-12-20 23:50:35 +01:00