From 5ccdff48f3c9cbc16c10ef05b1519a6756cd8e29 Mon Sep 17 00:00:00 2001 From: koichik Date: Thu, 17 Mar 2011 04:59:55 +0900 Subject: [PATCH 01/13] Document 'ucs2' encoding for Buffer --- doc/api/buffers.markdown | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/api/buffers.markdown b/doc/api/buffers.markdown index 9c26b61a12..d752892405 100644 --- a/doc/api/buffers.markdown +++ b/doc/api/buffers.markdown @@ -17,7 +17,10 @@ method. Here are the different string encodings; * `'ascii'` - for 7 bit ASCII data only. This encoding method is very fast, and will strip the high bit if set. -* `'utf8'` - Unicode characters. Many web pages and other document formats use UTF-8. +* `'utf8'` - Multi byte encoded Unicode characters. Many web pages and other document formats use UTF-8. + +* `'ucs2'` - 2-bytes, little endian encoded Unicode characters. It can encode +only BMP(Basic Multilingual Plane, U+0000 - U+FFFF). * `'base64'` - Base64 string encoding. From aeed966fe05e63b725eed604ed79558abbb52a66 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 18 Mar 2011 11:39:44 -0700 Subject: [PATCH 02/13] Don't call GetMemoryUsage every 5 seconds --- src/node.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node.cc b/src/node.cc index 11bfd92b66..fa2fab2ab1 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1483,9 +1483,10 @@ static void CheckStatus(EV_P_ ev_timer *watcher, int revents) { assert(revents == EV_TIMEOUT); // check memory - size_t rss, vsize; - if (!ev_is_active(&gc_idle) && Platform::GetMemory(&rss, &vsize) == 0) { - if (rss > 1024*1024*128) { + if (!ev_is_active(&gc_idle)) { + HeapStatistics stats; + V8::GetHeapStatistics(&stats); + if (stats.total_heap_size() > 1024 * 1024 * 128) { // larger than 128 megs, just start the idle watcher ev_idle_start(EV_A_ &gc_idle); return; From 53dc74e12f87c49515082f409c9cdc5e6e67974c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 18 Mar 2011 14:22:52 -0700 Subject: [PATCH 03/13] Upgrade V8 to 3.1.8.3 --- deps/v8/src/arm/codegen-arm.cc | 8 +++-- deps/v8/src/arm/debug-arm.cc | 2 +- deps/v8/src/parser.cc | 30 +++++++++-------- deps/v8/src/parser.h | 4 +-- deps/v8/src/scopes.cc | 51 ++++++++++++++++++----------- deps/v8/src/scopes.h | 18 +++++----- deps/v8/src/version.cc | 2 +- deps/v8/test/mjsunit/bitops-info.js | 8 ++++- 8 files changed, 74 insertions(+), 49 deletions(-) diff --git a/deps/v8/src/arm/codegen-arm.cc b/deps/v8/src/arm/codegen-arm.cc index 8bb576ded7..0fcaa0b09d 100644 --- a/deps/v8/src/arm/codegen-arm.cc +++ b/deps/v8/src/arm/codegen-arm.cc @@ -1153,7 +1153,7 @@ void DeferredInlineSmiOperation::GenerateNonSmiInput() { } // Check that the *signed* result fits in a smi. Not necessary for AND, SAR // if the shift if more than 0 or SHR if the shit is more than 1. - if (!( (op_ == Token::AND) || + if (!( (op_ == Token::AND && value_ >= 0) || ((op_ == Token::SAR) && (shift_value > 0)) || ((op_ == Token::SHR) && (shift_value > 1)))) { __ add(r3, int32, Operand(0x40000000), SetCC); @@ -1414,8 +1414,10 @@ void CodeGenerator::SmiOperation(Token::Value op, default: UNREACHABLE(); } deferred->BindExit(); - TypeInfo result_type = - (op == Token::BIT_AND) ? TypeInfo::Smi() : TypeInfo::Integer32(); + TypeInfo result_type = TypeInfo::Integer32(); + if (op == Token::BIT_AND && int_value >= 0) { + result_type = TypeInfo::Smi(); + } frame_->EmitPush(tos, result_type); } break; diff --git a/deps/v8/src/arm/debug-arm.cc b/deps/v8/src/arm/debug-arm.cc index f19e69396e..22640ca1c5 100644 --- a/deps/v8/src/arm/debug-arm.cc +++ b/deps/v8/src/arm/debug-arm.cc @@ -115,7 +115,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() { patcher.masm()->mov(v8::internal::lr, v8::internal::pc); patcher.masm()->ldr(v8::internal::pc, MemOperand(v8::internal::pc, -4)); #endif - patcher.Emit(Debug::debug_break_return()->entry()); + patcher.Emit(Debug::debug_break_slot()->entry()); } diff --git a/deps/v8/src/parser.cc b/deps/v8/src/parser.cc index 8560310702..04e2407e01 100644 --- a/deps/v8/src/parser.cc +++ b/deps/v8/src/parser.cc @@ -703,38 +703,40 @@ FunctionLiteral* Parser::DoParseProgram(Handle source, return result; } -FunctionLiteral* Parser::ParseLazy(Handle info) { +FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) { CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); HistogramTimerScope timer(&Counters::parse_lazy); Handle source(String::cast(script_->source())); Counters::total_parse_size.Increment(source->length()); + Handle shared_info = info->shared_info(); // Initialize parser state. source->TryFlatten(); if (source->IsExternalTwoByteString()) { ExternalTwoByteStringUC16CharacterStream stream( Handle::cast(source), - info->start_position(), - info->end_position()); + shared_info->start_position(), + shared_info->end_position()); FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); return result; } else { GenericStringUC16CharacterStream stream(source, - info->start_position(), - info->end_position()); + shared_info->start_position(), + shared_info->end_position()); FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope); return result; } } -FunctionLiteral* Parser::ParseLazy(Handle info, +FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, UC16CharacterStream* source, ZoneScope* zone_scope) { + Handle shared_info = info->shared_info(); scanner_.Initialize(source); ASSERT(target_stack_ == NULL); - Handle name(String::cast(info->name())); + Handle name(String::cast(shared_info->name())); fni_ = new FuncNameInferrer(); fni_->PushEnclosingName(name); @@ -746,18 +748,20 @@ FunctionLiteral* Parser::ParseLazy(Handle info, { // Parse the function literal. Handle no_name = Factory::empty_symbol(); - Scope* scope = - NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); + Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); + if (!info->closure().is_null()) { + scope = Scope::DeserializeScopeChain(info, scope); + } LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, scope); TemporaryScope temp_scope(&this->temp_scope_); - if (info->strict_mode()) { + if (shared_info->strict_mode()) { temp_scope.EnableStrictMode(); } FunctionLiteralType type = - info->is_expression() ? EXPRESSION : DECLARATION; + shared_info->is_expression() ? EXPRESSION : DECLARATION; bool ok = true; result = ParseFunctionLiteral(name, false, // Strict mode name already checked. @@ -775,7 +779,7 @@ FunctionLiteral* Parser::ParseLazy(Handle info, zone_scope->DeleteOnExit(); if (stack_overflow_) Top::StackOverflow(); } else { - Handle inferred_name(info->inferred_name()); + Handle inferred_name(shared_info->inferred_name()); result->set_inferred_name(inferred_name); } return result; @@ -5133,7 +5137,7 @@ bool ParserApi::Parse(CompilationInfo* info) { Handle