From fb4a2d160dcd22cc51e4f9b5f1b612d8b919c9f3 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Mon, 27 Jun 2011 09:02:34 +0000 Subject: [PATCH] Cleanup of return types and names in factory. Review URL: http://codereview.chromium.org/7240025 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8426 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/factory.cc | 14 +++++++------- src/factory.h | 8 ++++---- src/json-parser.h | 4 ++-- src/runtime.cc | 28 +++++++++++++--------------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/factory.cc b/src/factory.cc index f654b5aa83..405cebe45f 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -179,21 +179,21 @@ Handle Factory::NewStringFromTwoByte(Vector string, } -Handle Factory::NewRawAsciiString(int length, - PretenureFlag pretenure) { +Handle Factory::NewRawAsciiString(int length, + PretenureFlag pretenure) { CALL_HEAP_FUNCTION( isolate(), isolate()->heap()->AllocateRawAsciiString(length, pretenure), - String); + SeqAsciiString); } -Handle Factory::NewRawTwoByteString(int length, - PretenureFlag pretenure) { +Handle Factory::NewRawTwoByteString(int length, + PretenureFlag pretenure) { CALL_HEAP_FUNCTION( isolate(), isolate()->heap()->AllocateRawTwoByteString(length, pretenure), - String); + SeqTwoByteString); } @@ -214,7 +214,7 @@ Handle Factory::NewSubString(Handle str, } -Handle Factory::NewStrictSubString(Handle str, +Handle Factory::NewProperSubString(Handle str, int begin, int end) { ASSERT(begin > 0 || end < str->length()); diff --git a/src/factory.h b/src/factory.h index 8511915dbd..fa385e2e78 100644 --- a/src/factory.h +++ b/src/factory.h @@ -117,10 +117,10 @@ class Factory { // Allocates and partially initializes an ASCII or TwoByte String. The // characters of the string are uninitialized. Currently used in regexp code // only, where they are pretenured. - Handle NewRawAsciiString( + Handle NewRawAsciiString( int length, PretenureFlag pretenure = NOT_TENURED); - Handle NewRawTwoByteString( + Handle NewRawTwoByteString( int length, PretenureFlag pretenure = NOT_TENURED); @@ -133,8 +133,8 @@ class Factory { int begin, int end); - // Create a new string object which holds a strict substring of a string. - Handle NewStrictSubString(Handle str, + // Create a new string object which holds a proper substring of a string. + Handle NewProperSubString(Handle str, int begin, int end); diff --git a/src/json-parser.h b/src/json-parser.h index f772f56ff0..d505ecfd5a 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -413,7 +413,7 @@ Handle JsonParser::ParseJsonNumber() { template Handle JsonParser::SlowScanJsonString(int beg_pos) { // The currently scanned ascii characters. - Handle ascii(isolate()->factory()->NewStrictSubString(source_, + Handle ascii(isolate()->factory()->NewProperSubString(source_, beg_pos, position_)); Handle two_byte = @@ -532,7 +532,7 @@ Handle JsonParser::ScanJsonString() { beg_pos, end_pos - beg_pos); } else { - return isolate()->factory()->NewStrictSubString(source_, + return isolate()->factory()->NewProperSubString(source_, beg_pos, end_pos); } diff --git a/src/runtime.cc b/src/runtime.cc index f11d745d8f..29d4ecd77d 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2274,24 +2274,24 @@ class ReplacementStringBuilder { Handle joined_string; if (is_ascii_) { - joined_string = NewRawAsciiString(character_count_); + Handle seq = NewRawAsciiString(character_count_); AssertNoAllocation no_alloc; - SeqAsciiString* seq = SeqAsciiString::cast(*joined_string); char* char_buffer = seq->GetChars(); StringBuilderConcatHelper(*subject_, char_buffer, *array_builder_.array(), array_builder_.length()); + joined_string = Handle::cast(seq); } else { // Non-ASCII. - joined_string = NewRawTwoByteString(character_count_); + Handle seq = NewRawTwoByteString(character_count_); AssertNoAllocation no_alloc; - SeqTwoByteString* seq = SeqTwoByteString::cast(*joined_string); uc16* char_buffer = seq->GetChars(); StringBuilderConcatHelper(*subject_, char_buffer, *array_builder_.array(), array_builder_.length()); + joined_string = Handle::cast(seq); } return joined_string; } @@ -2309,15 +2309,13 @@ class ReplacementStringBuilder { } private: - Handle NewRawAsciiString(int size) { - CALL_HEAP_FUNCTION(heap_->isolate(), - heap_->AllocateRawAsciiString(size), String); + Handle NewRawAsciiString(int length) { + return heap_->isolate()->factory()->NewRawAsciiString(length); } - Handle NewRawTwoByteString(int size) { - CALL_HEAP_FUNCTION(heap_->isolate(), - heap_->AllocateRawTwoByteString(size), String); + Handle NewRawTwoByteString(int length) { + return heap_->isolate()->factory()->NewRawTwoByteString(length); } @@ -3172,7 +3170,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { int from = offsets.at(i * 2); int to = offsets.at(i * 2 + 1); Handle substring = isolate->factory()-> - NewStrictSubString(subject, from, to); + NewProperSubString(subject, from, to); elements->set(i, *substring); } Handle result = isolate->factory()->NewJSArrayWithElements(elements); @@ -3342,7 +3340,7 @@ static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple( match_end = register_vector[1]; HandleScope loop_scope(isolate); if (!first) { - builder->Add(*isolate->factory()->NewStrictSubString(subject, + builder->Add(*isolate->factory()->NewProperSubString(subject, match_start, match_end)); } else { @@ -3434,7 +3432,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple( isolate->factory()->NewFixedArray(3 + capture_count); Handle match; if (!first) { - match = isolate->factory()->NewStrictSubString(subject, + match = isolate->factory()->NewProperSubString(subject, match_start, match_end); } else { @@ -3450,7 +3448,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple( ASSERT(start <= end); Handle substring; if (!first) { - substring = isolate->factory()->NewStrictSubString(subject, + substring = isolate->factory()->NewProperSubString(subject, start, end); } else { @@ -5855,7 +5853,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { HandleScope local_loop_handle; int part_end = indices.at(i); Handle substring = - isolate->factory()->NewStrictSubString(subject, part_start, part_end); + isolate->factory()->NewProperSubString(subject, part_start, part_end); elements->set(i, *substring); part_start = part_end + pattern_length; }