summaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-02-03 16:32:00 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-02-06 15:44:42 +0100
commit74a8215a8699f89ee4b82ca616a4eafa3b11203b (patch)
tree1f2c8a7c47eae80a043c4b3ccf7372f4e8c7e292 /src/node_buffer.cc
parenta9723df1b76777899a3819839cb7e8f0e2efaef1 (diff)
downloadnodejs-74a8215a8699f89ee4b82ca616a4eafa3b11203b.tar.gz
nodejs-74a8215a8699f89ee4b82ca616a4eafa3b11203b.tar.bz2
nodejs-74a8215a8699f89ee4b82ca616a4eafa3b11203b.zip
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.
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index 71e7ff36c..924eff3b8 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -36,12 +36,6 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#include <node_vars.h>
-#define length_symbol NODE_VAR(length_symbol)
-#define chars_written_sym NODE_VAR(chars_written_sym)
-#define write_sym NODE_VAR(write_sym)
-#define buffer_constructor_template NODE_VAR(buffer_constructor_template)
-
namespace node {
using namespace v8;
@@ -67,6 +61,10 @@ using namespace v8;
}
+static Persistent<String> length_symbol;
+static Persistent<String> chars_written_sym;
+static Persistent<String> write_sym;
+Persistent<FunctionTemplate> Buffer::constructor_template;
static inline size_t base64_decoded_size(const char *src, size_t size) {
@@ -132,7 +130,7 @@ Buffer* Buffer::New(size_t length) {
HandleScope scope;
Local<Value> arg = Integer::NewFromUnsigned(length);
- Local<Object> b = buffer_constructor_template->GetFunction()->NewInstance(1, &arg);
+ Local<Object> b = constructor_template->GetFunction()->NewInstance(1, &arg);
if (b.IsEmpty()) return NULL;
return ObjectWrap::Unwrap<Buffer>(b);
@@ -143,7 +141,7 @@ Buffer* Buffer::New(char* data, size_t length) {
HandleScope scope;
Local<Value> arg = Integer::NewFromUnsigned(0);
- Local<Object> obj = buffer_constructor_template->GetFunction()->NewInstance(1, &arg);
+ Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj);
buffer->Replace(data, length, NULL, NULL);
@@ -157,7 +155,7 @@ Buffer* Buffer::New(char *data, size_t length,
HandleScope scope;
Local<Value> arg = Integer::NewFromUnsigned(0);
- Local<Object> obj = buffer_constructor_template->GetFunction()->NewInstance(1, &arg);
+ Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg);
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(obj);
buffer->Replace(data, length, callback, hint);
@@ -168,7 +166,7 @@ Buffer* Buffer::New(char *data, size_t length,
Handle<Value> Buffer::New(const Arguments &args) {
if (!args.IsConstructCall()) {
- return FromConstructorTemplate(buffer_constructor_template, args);
+ return FromConstructorTemplate(constructor_template, args);
}
HandleScope scope;
@@ -470,7 +468,7 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
int length = s->Length();
if (length == 0) {
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(0));
return scope.Close(Integer::New(0));
}
@@ -494,7 +492,7 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
(String::HINT_MANY_WRITES_EXPECTED |
String::NO_NULL_TERMINATION));
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(char_written));
return scope.Close(Integer::New(written));
@@ -532,7 +530,7 @@ Handle<Value> Buffer::Ucs2Write(const Arguments &args) {
(String::HINT_MANY_WRITES_EXPECTED |
String::NO_NULL_TERMINATION));
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written));
return scope.Close(Integer::New(written * 2));
@@ -571,7 +569,7 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
(String::HINT_MANY_WRITES_EXPECTED |
String::NO_NULL_TERMINATION));
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written));
return scope.Close(Integer::New(written));
@@ -661,7 +659,7 @@ Handle<Value> Buffer::Base64Write(const Arguments &args) {
*dst++ = ((c & 0x03) << 6) | (d & 0x3F);
}
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(s.length()));
return scope.Close(Integer::New(dst - start));
@@ -695,7 +693,7 @@ Handle<Value> Buffer::BinaryWrite(const Arguments &args) {
int written = DecodeWrite(p, max_length, s, BINARY);
- buffer_constructor_template->GetFunction()->Set(chars_written_sym,
+ constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written));
return scope.Close(Integer::New(written));
@@ -747,7 +745,7 @@ bool Buffer::HasInstance(v8::Handle<v8::Value> val) {
return true;
// Also check for SlowBuffers that are empty.
- if (buffer_constructor_template->HasInstance(obj))
+ if (constructor_template->HasInstance(obj))
return true;
return false;
@@ -761,35 +759,35 @@ void Buffer::Initialize(Handle<Object> target) {
chars_written_sym = Persistent<String>::New(String::NewSymbol("_charsWritten"));
Local<FunctionTemplate> t = FunctionTemplate::New(Buffer::New);
- buffer_constructor_template = Persistent<FunctionTemplate>::New(t);
- buffer_constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
- buffer_constructor_template->SetClassName(String::NewSymbol("SlowBuffer"));
+ constructor_template = Persistent<FunctionTemplate>::New(t);
+ constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
+ constructor_template->SetClassName(String::NewSymbol("SlowBuffer"));
// copy free
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "binarySlice", Buffer::BinarySlice);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "asciiSlice", Buffer::AsciiSlice);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "base64Slice", Buffer::Base64Slice);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "ucs2Slice", Buffer::Ucs2Slice);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "binarySlice", Buffer::BinarySlice);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "asciiSlice", Buffer::AsciiSlice);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "base64Slice", Buffer::Base64Slice);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucs2Slice", Buffer::Ucs2Slice);
// TODO NODE_SET_PROTOTYPE_METHOD(t, "utf16Slice", Utf16Slice);
// copy
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "utf8Slice", Buffer::Utf8Slice);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "utf8Slice", Buffer::Utf8Slice);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "utf8Write", Buffer::Utf8Write);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "asciiWrite", Buffer::AsciiWrite);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "binaryWrite", Buffer::BinaryWrite);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "base64Write", Buffer::Base64Write);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "ucs2Write", Buffer::Ucs2Write);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "fill", Buffer::Fill);
- NODE_SET_PROTOTYPE_METHOD(buffer_constructor_template, "copy", Buffer::Copy);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "utf8Write", Buffer::Utf8Write);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "asciiWrite", Buffer::AsciiWrite);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "binaryWrite", Buffer::BinaryWrite);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "base64Write", Buffer::Base64Write);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucs2Write", Buffer::Ucs2Write);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "fill", Buffer::Fill);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "copy", Buffer::Copy);
- NODE_SET_METHOD(buffer_constructor_template->GetFunction(),
+ NODE_SET_METHOD(constructor_template->GetFunction(),
"byteLength",
Buffer::ByteLength);
- NODE_SET_METHOD(buffer_constructor_template->GetFunction(),
+ NODE_SET_METHOD(constructor_template->GetFunction(),
"makeFastBuffer",
Buffer::MakeFastBuffer);
- target->Set(String::NewSymbol("SlowBuffer"), buffer_constructor_template->GetFunction());
+ target->Set(String::NewSymbol("SlowBuffer"), constructor_template->GetFunction());
}