Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Unified Diff: src/factory.cc

Issue 223573002: Return MaybeHandle from NewRaw???String. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/handles.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 52a194180be30b9c675b83ef45d7ce06f137f45e..044e5eacd9f73e5bc86a1e8bb5ffdb6235872a3f 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -255,8 +255,8 @@ Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
}
-Handle<SeqOneByteString> Factory::NewRawOneByteString(int length,
- PretenureFlag pretenure) {
+MaybeHandle<SeqOneByteString> Factory::NewRawOneByteString(
+ int length, PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateRawOneByteString(length, pretenure),
@@ -264,8 +264,8 @@ Handle<SeqOneByteString> Factory::NewRawOneByteString(int length,
}
-Handle<SeqTwoByteString> Factory::NewRawTwoByteString(int length,
- PretenureFlag pretenure) {
+MaybeHandle<SeqTwoByteString> Factory::NewRawTwoByteString(
+ int length, PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
@@ -298,13 +298,15 @@ static inline Handle<String> MakeOrFindTwoCharacterString(Isolate* isolate,
if (static_cast<unsigned>(c1 | c2) <= String::kMaxOneByteCharCodeU) {
// We can do this.
ASSERT(IsPowerOf2(String::kMaxOneByteCharCodeU + 1)); // because of this.
- Handle<SeqOneByteString> str = isolate->factory()->NewRawOneByteString(2);
+ Handle<SeqOneByteString> str =
+ isolate->factory()->NewRawOneByteString(2).ToHandleChecked();
uint8_t* dest = str->GetChars();
dest[0] = static_cast<uint8_t>(c1);
dest[1] = static_cast<uint8_t>(c2);
return str;
} else {
- Handle<SeqTwoByteString> str = isolate->factory()->NewRawTwoByteString(2);
+ Handle<SeqTwoByteString> str =
+ isolate->factory()->NewRawTwoByteString(2).ToHandleChecked();
uc16* dest = str->GetChars();
dest[0] = c1;
dest[1] = c2;
@@ -380,7 +382,8 @@ Handle<String> Factory::NewConsString(Handle<String> left,
STATIC_ASSERT(ConsString::kMinLength <= String::kMaxLength);
if (is_one_byte) {
- Handle<SeqOneByteString> result = NewRawOneByteString(length);
+ Handle<SeqOneByteString> result =
+ NewRawOneByteString(length).ToHandleChecked();
DisallowHeapAllocation no_gc;
uint8_t* dest = result->GetChars();
// Copy left part.
@@ -397,8 +400,10 @@ Handle<String> Factory::NewConsString(Handle<String> left,
}
return (is_one_byte_data_in_two_byte_string)
- ? ConcatStringContent<uint8_t>(NewRawOneByteString(length), left, right)
- : ConcatStringContent<uc16>(NewRawTwoByteString(length), left, right);
+ ? ConcatStringContent<uint8_t>(
+ NewRawOneByteString(length).ToHandleChecked(), left, right)
+ : ConcatStringContent<uc16>(
+ NewRawTwoByteString(length).ToHandleChecked(), left, right);
}
Handle<ConsString> result = NewRawConsString(
@@ -422,10 +427,10 @@ Handle<String> Factory::NewFlatConcatString(Handle<String> first,
int total_length = first->length() + second->length();
if (first->IsOneByteRepresentation() && second->IsOneByteRepresentation()) {
return ConcatStringContent<uint8_t>(
- NewRawOneByteString(total_length), first, second);
+ NewRawOneByteString(total_length).ToHandleChecked(), first, second);
} else {
return ConcatStringContent<uc16>(
- NewRawTwoByteString(total_length), first, second);
+ NewRawTwoByteString(total_length).ToHandleChecked(), first, second);
}
}
@@ -463,15 +468,15 @@ Handle<String> Factory::NewProperSubString(Handle<String> str,
if (!FLAG_string_slices || length < SlicedString::kMinLength) {
if (str->IsOneByteRepresentation()) {
- Handle<SeqOneByteString> result = NewRawOneByteString(length);
- ASSERT(!result.is_null());
+ Handle<SeqOneByteString> result =
+ NewRawOneByteString(length).ToHandleChecked();
uint8_t* dest = result->GetChars();
DisallowHeapAllocation no_gc;
String::WriteToFlat(*str, dest, begin, end);
return result;
} else {
- Handle<SeqTwoByteString> result = NewRawTwoByteString(length);
- ASSERT(!result.is_null());
+ Handle<SeqTwoByteString> result =
+ NewRawTwoByteString(length).ToHandleChecked();
uc16* dest = result->GetChars();
DisallowHeapAllocation no_gc;
String::WriteToFlat(*str, dest, begin, end);
« no previous file with comments | « src/factory.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698