Commit fb4a2d16 authored by lrn@chromium.org's avatar lrn@chromium.org

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
parent 17c2a7a5
...@@ -179,21 +179,21 @@ Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, ...@@ -179,21 +179,21 @@ Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
} }
Handle<String> Factory::NewRawAsciiString(int length, Handle<SeqAsciiString> Factory::NewRawAsciiString(int length,
PretenureFlag pretenure) { PretenureFlag pretenure) {
CALL_HEAP_FUNCTION( CALL_HEAP_FUNCTION(
isolate(), isolate(),
isolate()->heap()->AllocateRawAsciiString(length, pretenure), isolate()->heap()->AllocateRawAsciiString(length, pretenure),
String); SeqAsciiString);
} }
Handle<String> Factory::NewRawTwoByteString(int length, Handle<SeqTwoByteString> Factory::NewRawTwoByteString(int length,
PretenureFlag pretenure) { PretenureFlag pretenure) {
CALL_HEAP_FUNCTION( CALL_HEAP_FUNCTION(
isolate(), isolate(),
isolate()->heap()->AllocateRawTwoByteString(length, pretenure), isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
String); SeqTwoByteString);
} }
...@@ -214,7 +214,7 @@ Handle<String> Factory::NewSubString(Handle<String> str, ...@@ -214,7 +214,7 @@ Handle<String> Factory::NewSubString(Handle<String> str,
} }
Handle<String> Factory::NewStrictSubString(Handle<String> str, Handle<String> Factory::NewProperSubString(Handle<String> str,
int begin, int begin,
int end) { int end) {
ASSERT(begin > 0 || end < str->length()); ASSERT(begin > 0 || end < str->length());
......
...@@ -117,10 +117,10 @@ class Factory { ...@@ -117,10 +117,10 @@ class Factory {
// Allocates and partially initializes an ASCII or TwoByte String. The // Allocates and partially initializes an ASCII or TwoByte String. The
// characters of the string are uninitialized. Currently used in regexp code // characters of the string are uninitialized. Currently used in regexp code
// only, where they are pretenured. // only, where they are pretenured.
Handle<String> NewRawAsciiString( Handle<SeqAsciiString> NewRawAsciiString(
int length, int length,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
Handle<String> NewRawTwoByteString( Handle<SeqTwoByteString> NewRawTwoByteString(
int length, int length,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
...@@ -133,8 +133,8 @@ class Factory { ...@@ -133,8 +133,8 @@ class Factory {
int begin, int begin,
int end); int end);
// Create a new string object which holds a strict substring of a string. // Create a new string object which holds a proper substring of a string.
Handle<String> NewStrictSubString(Handle<String> str, Handle<String> NewProperSubString(Handle<String> str,
int begin, int begin,
int end); int end);
......
...@@ -413,7 +413,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonNumber() { ...@@ -413,7 +413,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonNumber() {
template <bool seq_ascii> template <bool seq_ascii>
Handle<String> JsonParser<seq_ascii>::SlowScanJsonString(int beg_pos) { Handle<String> JsonParser<seq_ascii>::SlowScanJsonString(int beg_pos) {
// The currently scanned ascii characters. // The currently scanned ascii characters.
Handle<String> ascii(isolate()->factory()->NewStrictSubString(source_, Handle<String> ascii(isolate()->factory()->NewProperSubString(source_,
beg_pos, beg_pos,
position_)); position_));
Handle<String> two_byte = Handle<String> two_byte =
...@@ -532,7 +532,7 @@ Handle<String> JsonParser<seq_ascii>::ScanJsonString() { ...@@ -532,7 +532,7 @@ Handle<String> JsonParser<seq_ascii>::ScanJsonString() {
beg_pos, beg_pos,
end_pos - beg_pos); end_pos - beg_pos);
} else { } else {
return isolate()->factory()->NewStrictSubString(source_, return isolate()->factory()->NewProperSubString(source_,
beg_pos, beg_pos,
end_pos); end_pos);
} }
......
...@@ -2274,24 +2274,24 @@ class ReplacementStringBuilder { ...@@ -2274,24 +2274,24 @@ class ReplacementStringBuilder {
Handle<String> joined_string; Handle<String> joined_string;
if (is_ascii_) { if (is_ascii_) {
joined_string = NewRawAsciiString(character_count_); Handle<SeqAsciiString> seq = NewRawAsciiString(character_count_);
AssertNoAllocation no_alloc; AssertNoAllocation no_alloc;
SeqAsciiString* seq = SeqAsciiString::cast(*joined_string);
char* char_buffer = seq->GetChars(); char* char_buffer = seq->GetChars();
StringBuilderConcatHelper(*subject_, StringBuilderConcatHelper(*subject_,
char_buffer, char_buffer,
*array_builder_.array(), *array_builder_.array(),
array_builder_.length()); array_builder_.length());
joined_string = Handle<String>::cast(seq);
} else { } else {
// Non-ASCII. // Non-ASCII.
joined_string = NewRawTwoByteString(character_count_); Handle<SeqTwoByteString> seq = NewRawTwoByteString(character_count_);
AssertNoAllocation no_alloc; AssertNoAllocation no_alloc;
SeqTwoByteString* seq = SeqTwoByteString::cast(*joined_string);
uc16* char_buffer = seq->GetChars(); uc16* char_buffer = seq->GetChars();
StringBuilderConcatHelper(*subject_, StringBuilderConcatHelper(*subject_,
char_buffer, char_buffer,
*array_builder_.array(), *array_builder_.array(),
array_builder_.length()); array_builder_.length());
joined_string = Handle<String>::cast(seq);
} }
return joined_string; return joined_string;
} }
...@@ -2309,15 +2309,13 @@ class ReplacementStringBuilder { ...@@ -2309,15 +2309,13 @@ class ReplacementStringBuilder {
} }
private: private:
Handle<String> NewRawAsciiString(int size) { Handle<SeqAsciiString> NewRawAsciiString(int length) {
CALL_HEAP_FUNCTION(heap_->isolate(), return heap_->isolate()->factory()->NewRawAsciiString(length);
heap_->AllocateRawAsciiString(size), String);
} }
Handle<String> NewRawTwoByteString(int size) { Handle<SeqTwoByteString> NewRawTwoByteString(int length) {
CALL_HEAP_FUNCTION(heap_->isolate(), return heap_->isolate()->factory()->NewRawTwoByteString(length);
heap_->AllocateRawTwoByteString(size), String);
} }
...@@ -3172,7 +3170,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { ...@@ -3172,7 +3170,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
int from = offsets.at(i * 2); int from = offsets.at(i * 2);
int to = offsets.at(i * 2 + 1); int to = offsets.at(i * 2 + 1);
Handle<String> substring = isolate->factory()-> Handle<String> substring = isolate->factory()->
NewStrictSubString(subject, from, to); NewProperSubString(subject, from, to);
elements->set(i, *substring); elements->set(i, *substring);
} }
Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements);
...@@ -3342,7 +3340,7 @@ static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple( ...@@ -3342,7 +3340,7 @@ static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple(
match_end = register_vector[1]; match_end = register_vector[1];
HandleScope loop_scope(isolate); HandleScope loop_scope(isolate);
if (!first) { if (!first) {
builder->Add(*isolate->factory()->NewStrictSubString(subject, builder->Add(*isolate->factory()->NewProperSubString(subject,
match_start, match_start,
match_end)); match_end));
} else { } else {
...@@ -3434,7 +3432,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple( ...@@ -3434,7 +3432,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple(
isolate->factory()->NewFixedArray(3 + capture_count); isolate->factory()->NewFixedArray(3 + capture_count);
Handle<String> match; Handle<String> match;
if (!first) { if (!first) {
match = isolate->factory()->NewStrictSubString(subject, match = isolate->factory()->NewProperSubString(subject,
match_start, match_start,
match_end); match_end);
} else { } else {
...@@ -3450,7 +3448,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple( ...@@ -3450,7 +3448,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple(
ASSERT(start <= end); ASSERT(start <= end);
Handle<String> substring; Handle<String> substring;
if (!first) { if (!first) {
substring = isolate->factory()->NewStrictSubString(subject, substring = isolate->factory()->NewProperSubString(subject,
start, start,
end); end);
} else { } else {
...@@ -5855,7 +5853,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { ...@@ -5855,7 +5853,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
HandleScope local_loop_handle; HandleScope local_loop_handle;
int part_end = indices.at(i); int part_end = indices.at(i);
Handle<String> substring = Handle<String> substring =
isolate->factory()->NewStrictSubString(subject, part_start, part_end); isolate->factory()->NewProperSubString(subject, part_start, part_end);
elements->set(i, *substring); elements->set(i, *substring);
part_start = part_end + pattern_length; part_start = part_end + pattern_length;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment