Commit 87dd16e3 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Revert "Return MaybeHandle from NewConsString."

This reverts r20473.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/223593004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c21cf2d3
...@@ -5459,9 +5459,10 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { ...@@ -5459,9 +5459,10 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
LOG_API(isolate, "String::New(char)"); LOG_API(isolate, "String::New(char)");
ENTER_V8(isolate); ENTER_V8(isolate);
i::Handle<i::String> right_string = Utils::OpenHandle(*right); i::Handle<i::String> right_string = Utils::OpenHandle(*right);
i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
right_string);
// We do not expect this to fail. Change this if it does. // We do not expect this to fail. Change this if it does.
i::Handle<i::String> result = isolate->factory()->NewConsString( CHECK(!result.is_null());
left_string, right_string).ToHandleChecked();
return Utils::ToLocal(result); return Utils::ToLocal(result);
} }
...@@ -7032,15 +7033,15 @@ Handle<String> CpuProfileNode::GetFunctionName() const { ...@@ -7032,15 +7033,15 @@ Handle<String> CpuProfileNode::GetFunctionName() const {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
const i::CodeEntry* entry = node->entry(); const i::CodeEntry* entry = node->entry();
i::Handle<i::String> name =
isolate->factory()->InternalizeUtf8String(entry->name());
if (!entry->has_name_prefix()) { if (!entry->has_name_prefix()) {
return ToApiHandle<String>(name); return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(entry->name()));
} else { } else {
// We do not expect this to fail. Change this if it does.
i::Handle<i::String> cons = isolate->factory()->NewConsString( i::Handle<i::String> cons = isolate->factory()->NewConsString(
isolate->factory()->InternalizeUtf8String(entry->name_prefix()), isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
name).ToHandleChecked(); isolate->factory()->InternalizeUtf8String(entry->name()));
// We do not expect this to fail. Change this if it does.
CHECK(!cons.is_null());
return ToApiHandle<String>(cons); return ToApiHandle<String>(cons);
} }
} }
......
...@@ -334,7 +334,7 @@ Handle<ConsString> Factory::NewRawConsString(String::Encoding encoding) { ...@@ -334,7 +334,7 @@ Handle<ConsString> Factory::NewRawConsString(String::Encoding encoding) {
} }
MaybeHandle<String> Factory::NewConsString(Handle<String> left, Handle<String> Factory::NewConsString(Handle<String> left,
Handle<String> right) { Handle<String> right) {
int left_length = left->length(); int left_length = left->length();
if (left_length == 0) return right; if (left_length == 0) return right;
...@@ -352,8 +352,8 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left, ...@@ -352,8 +352,8 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left,
// Make sure that an out of memory exception is thrown if the length // Make sure that an out of memory exception is thrown if the length
// of the new cons string is too large. // of the new cons string is too large.
if (length > String::kMaxLength || length < 0) { if (length > String::kMaxLength || length < 0) {
return isolate()->Throw<String>( isolate()->ThrowInvalidStringLength();
isolate()->factory()->NewInvalidStringLengthError()); return Handle<String>::null();
} }
bool left_is_one_byte = left->IsOneByteRepresentation(); bool left_is_one_byte = left->IsOneByteRepresentation();
......
...@@ -140,7 +140,7 @@ class Factory V8_FINAL { ...@@ -140,7 +140,7 @@ class Factory V8_FINAL {
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
// Create a new cons string object which consists of a pair of strings. // Create a new cons string object which consists of a pair of strings.
MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left, Handle<String> NewConsString(Handle<String> left,
Handle<String> right); Handle<String> right);
Handle<ConsString> NewRawConsString(String::Encoding encoding); Handle<ConsString> NewRawConsString(String::Encoding encoding);
...@@ -436,11 +436,6 @@ class Factory V8_FINAL { ...@@ -436,11 +436,6 @@ class Factory V8_FINAL {
Vector< Handle<Object> > args); Vector< Handle<Object> > args);
Handle<Object> NewRangeError(Handle<String> message); Handle<Object> NewRangeError(Handle<String> message);
Handle<Object> NewInvalidStringLengthError() {
return NewRangeError("invalid_string_length",
HandleVector<Object>(NULL, 0));
}
Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args); Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args);
Handle<Object> NewSyntaxError(Handle<String> message); Handle<Object> NewSyntaxError(Handle<String> message);
......
...@@ -86,9 +86,10 @@ Handle<String> FuncNameInferrer::MakeNameFromStackHelper(int pos, ...@@ -86,9 +86,10 @@ Handle<String> FuncNameInferrer::MakeNameFromStackHelper(int pos,
Handle<String> name = names_stack_.at(pos).name; Handle<String> name = names_stack_.at(pos).name;
if (prev->length() + name->length() + 1 > String::kMaxLength) return prev; if (prev->length() + name->length() + 1 > String::kMaxLength) return prev;
Factory* factory = isolate()->factory(); Factory* factory = isolate()->factory();
Handle<String> curr = Handle<String> curr = factory->NewConsString(factory->dot_string(), name);
factory->NewConsString(factory->dot_string(), name).ToHandleChecked(); CHECK_NOT_EMPTY_HANDLE(isolate(), curr);
curr = factory->NewConsString(prev, curr).ToHandleChecked(); curr = factory->NewConsString(prev, curr);
CHECK_NOT_EMPTY_HANDLE(isolate(), curr);
return MakeNameFromStackHelper(pos + 1, curr); return MakeNameFromStackHelper(pos + 1, curr);
} else { } else {
return MakeNameFromStackHelper(pos + 1, names_stack_.at(pos).name); return MakeNameFromStackHelper(pos + 1, names_stack_.at(pos).name);
......
...@@ -37,7 +37,6 @@ namespace internal { ...@@ -37,7 +37,6 @@ namespace internal {
// A Handle can be converted into a MaybeHandle. Converting a MaybeHandle // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle
// into a Handle requires checking that it does not point to NULL. This // into a Handle requires checking that it does not point to NULL. This
// ensures NULL checks before use. // ensures NULL checks before use.
// Do not use MaybeHandle as argument type.
template<typename T> template<typename T>
class MaybeHandle { class MaybeHandle {
......
...@@ -179,7 +179,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList; ...@@ -179,7 +179,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
#define RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \ #define RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value) \
do { \ do { \
if ((call).is_null()) { \ if (call.is_null()) { \
ASSERT((isolate)->has_pending_exception()); \ ASSERT((isolate)->has_pending_exception()); \
return value; \ return value; \
} \ } \
......
...@@ -501,11 +501,8 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric( ...@@ -501,11 +501,8 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeGeneric(
part_length_ = kInitialPartLength; // Allocate conservatively. part_length_ = kInitialPartLength; // Allocate conservatively.
Extend(); // Attach current part and allocate new part. Extend(); // Attach current part and allocate new part.
// Attach result string to the accumulator. // Attach result string to the accumulator.
Handle<String> cons; Handle<String> cons = factory_->NewConsString(accumulator(), result_string);
ASSIGN_RETURN_ON_EXCEPTION_VALUE( RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, cons, EXCEPTION);
isolate_, cons,
factory_->NewConsString(accumulator(), result_string),
EXCEPTION);
set_accumulator(cons); set_accumulator(cons);
return SUCCESS; return SUCCESS;
} }
...@@ -734,8 +731,7 @@ void BasicJsonStringifier::Accumulate() { ...@@ -734,8 +731,7 @@ void BasicJsonStringifier::Accumulate() {
set_accumulator(factory_->empty_string()); set_accumulator(factory_->empty_string());
overflowed_ = true; overflowed_ = true;
} else { } else {
set_accumulator(factory_->NewConsString(accumulator(), set_accumulator(factory_->NewConsString(accumulator(), current_part_));
current_part_).ToHandleChecked());
} }
} }
......
...@@ -2974,11 +2974,9 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { ...@@ -2974,11 +2974,9 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
// TODO(keuchel): Move the temporary variable to the block scope, after // TODO(keuchel): Move the temporary variable to the block scope, after
// implementing stack allocated block scoped variables. // implementing stack allocated block scoped variables.
Factory* heap_factory = isolate()->factory(); Factory* heap_factory = isolate()->factory();
Handle<String> tempstr; Handle<String> tempstr =
ASSIGN_RETURN_ON_EXCEPTION_VALUE( heap_factory->NewConsString(heap_factory->dot_for_string(), name);
isolate(), tempstr, RETURN_IF_EMPTY_HANDLE_VALUE(isolate(), tempstr, 0);
heap_factory->NewConsString(heap_factory->dot_for_string(), name),
0);
Handle<String> tempname = heap_factory->InternalizeString(tempstr); Handle<String> tempname = heap_factory->InternalizeString(tempstr);
Variable* temp = scope_->DeclarationScope()->NewTemporary(tempname); Variable* temp = scope_->DeclarationScope()->NewTemporary(tempname);
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
......
...@@ -4236,34 +4236,35 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { ...@@ -4236,34 +4236,35 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) {
} }
// This may return an empty MaybeHandle if an exception is thrown or Handle<String> StringReplaceOneCharWithString(Isolate* isolate,
// we abort due to reaching the recursion limit.
MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate,
Handle<String> subject, Handle<String> subject,
Handle<String> search, Handle<String> search,
Handle<String> replace, Handle<String> replace,
bool* found, bool* found,
int recursion_limit) { int recursion_limit) {
if (recursion_limit == 0) return MaybeHandle<String>(); if (recursion_limit == 0) return Handle<String>::null();
recursion_limit--;
if (subject->IsConsString()) { if (subject->IsConsString()) {
ConsString* cons = ConsString::cast(*subject); ConsString* cons = ConsString::cast(*subject);
Handle<String> first = Handle<String>(cons->first()); Handle<String> first = Handle<String>(cons->first());
Handle<String> second = Handle<String>(cons->second()); Handle<String> second = Handle<String>(cons->second());
Handle<String> new_first; Handle<String> new_first =
if (!StringReplaceOneCharWithString( StringReplaceOneCharWithString(isolate,
isolate, first, search, replace, found, recursion_limit) first,
.ToHandle(&new_first)) { search,
return MaybeHandle<String>(); replace,
} found,
recursion_limit - 1);
if (new_first.is_null()) return new_first;
if (*found) return isolate->factory()->NewConsString(new_first, second); if (*found) return isolate->factory()->NewConsString(new_first, second);
Handle<String> new_second; Handle<String> new_second =
if (!StringReplaceOneCharWithString( StringReplaceOneCharWithString(isolate,
isolate, second, search, replace, found, recursion_limit) second,
.ToHandle(&new_second)) { search,
return MaybeHandle<String>(); replace,
} found,
recursion_limit - 1);
if (new_second.is_null()) return new_second;
if (*found) return isolate->factory()->NewConsString(first, new_second); if (*found) return isolate->factory()->NewConsString(first, new_second);
return subject; return subject;
...@@ -4272,11 +4273,8 @@ MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate, ...@@ -4272,11 +4273,8 @@ MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate,
if (index == -1) return subject; if (index == -1) return subject;
*found = true; *found = true;
Handle<String> first = isolate->factory()->NewSubString(subject, 0, index); Handle<String> first = isolate->factory()->NewSubString(subject, 0, index);
Handle<String> cons1; Handle<String> cons1 = isolate->factory()->NewConsString(first, replace);
ASSIGN_RETURN_ON_EXCEPTION( RETURN_IF_EMPTY_HANDLE_VALUE(isolate, cons1, Handle<String>());
isolate, cons1,
isolate->factory()->NewConsString(first, replace),
String);
Handle<String> second = Handle<String> second =
isolate->factory()->NewSubString(subject, index + 1, subject->length()); isolate->factory()->NewSubString(subject, index + 1, subject->length());
return isolate->factory()->NewConsString(cons1, second); return isolate->factory()->NewConsString(cons1, second);
...@@ -4295,20 +4293,20 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { ...@@ -4295,20 +4293,20 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) {
// retry with a flattened subject string. // retry with a flattened subject string.
const int kRecursionLimit = 0x1000; const int kRecursionLimit = 0x1000;
bool found = false; bool found = false;
Handle<String> result; Handle<String> result = StringReplaceOneCharWithString(isolate,
if (StringReplaceOneCharWithString( subject,
isolate, subject, search, replace, &found, kRecursionLimit) search,
.ToHandle(&result)) { replace,
return *result; &found,
} kRecursionLimit);
if (!result.is_null()) return *result;
if (isolate->has_pending_exception()) return Failure::Exception(); if (isolate->has_pending_exception()) return Failure::Exception();
return *StringReplaceOneCharWithString(isolate,
subject = FlattenGetString(subject); FlattenGetString(subject),
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( search,
isolate, result, replace,
StringReplaceOneCharWithString( &found,
isolate, subject, search, replace, &found, kRecursionLimit)); kRecursionLimit);
return *result;
} }
...@@ -6297,13 +6295,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { ...@@ -6297,13 +6295,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) {
CONVERT_ARG_HANDLE_CHECKED(String, source, 0); CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
Handle<String> string = FlattenGetString(source); Handle<String> string = FlattenGetString(source);
ASSERT(string->IsFlat()); ASSERT(string->IsFlat());
Handle<String> result; return string->IsOneByteRepresentationUnderneath()
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ? *URIUnescape::Unescape<uint8_t>(isolate, source)
isolate, result, : *URIUnescape::Unescape<uc16>(isolate, source);
string->IsOneByteRepresentationUnderneath()
? URIUnescape::Unescape<uint8_t>(isolate, source)
: URIUnescape::Unescape<uc16>(isolate, source));
return *result;
} }
...@@ -7073,9 +7067,8 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { ...@@ -7073,9 +7067,8 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) {
CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); CONVERT_ARG_HANDLE_CHECKED(String, str2, 1);
isolate->counters()->string_add_runtime()->Increment(); isolate->counters()->string_add_runtime()->Increment();
Handle<String> result; Handle<String> result = isolate->factory()->NewConsString(str1, str2);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( RETURN_IF_EMPTY_HANDLE(isolate, result);
isolate, result, isolate->factory()->NewConsString(str1, str2));
return *result; return *result;
} }
......
...@@ -61,13 +61,13 @@ Vector<const uc16> GetCharVector(Handle<String> string) { ...@@ -61,13 +61,13 @@ Vector<const uc16> GetCharVector(Handle<String> string) {
class URIUnescape : public AllStatic { class URIUnescape : public AllStatic {
public: public:
template<typename Char> template<typename Char>
static MaybeHandle<String> Unescape(Isolate* isolate, Handle<String> source); static Handle<String> Unescape(Isolate* isolate, Handle<String> source);
private: private:
static const signed char kHexValue['g']; static const signed char kHexValue['g'];
template<typename Char> template<typename Char>
static MaybeHandle<String> UnescapeSlow( static Handle<String> UnescapeSlow(
Isolate* isolate, Handle<String> string, int start_index); Isolate* isolate, Handle<String> string, int start_index);
static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2)); static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2));
...@@ -91,8 +91,7 @@ const signed char URIUnescape::kHexValue[] = { ...@@ -91,8 +91,7 @@ const signed char URIUnescape::kHexValue[] = {
template<typename Char> template<typename Char>
MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> source) {
Handle<String> source) {
int index; int index;
{ DisallowHeapAllocation no_allocation; { DisallowHeapAllocation no_allocation;
StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%")); StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%"));
...@@ -104,7 +103,7 @@ MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, ...@@ -104,7 +103,7 @@ MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate,
template <typename Char> template <typename Char>
MaybeHandle<String> URIUnescape::UnescapeSlow( Handle<String> URIUnescape::UnescapeSlow(
Isolate* isolate, Handle<String> string, int start_index) { Isolate* isolate, Handle<String> string, int start_index) {
bool one_byte = true; bool one_byte = true;
int length = string->length(); int length = string->length();
......
...@@ -445,8 +445,7 @@ TEST(HeapSnapshotConsString) { ...@@ -445,8 +445,7 @@ TEST(HeapSnapshotConsString) {
factory->NewStringFromAscii(i::CStrVector("0123456789")); factory->NewStringFromAscii(i::CStrVector("0123456789"));
i::Handle<i::String> second = i::Handle<i::String> second =
factory->NewStringFromAscii(i::CStrVector("0123456789")); factory->NewStringFromAscii(i::CStrVector("0123456789"));
i::Handle<i::String> cons_string = i::Handle<i::String> cons_string = factory->NewConsString(first, second);
factory->NewConsString(first, second).ToHandleChecked();
global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string));
......
...@@ -447,7 +447,7 @@ static Handle<String> ConstructRandomString(ConsStringGenerationData* data, ...@@ -447,7 +447,7 @@ static Handle<String> ConstructRandomString(ConsStringGenerationData* data,
left = ConstructRandomString(data, max_recursion - 1); left = ConstructRandomString(data, max_recursion - 1);
} }
// Build the cons string. // Build the cons string.
Handle<String> root = factory->NewConsString(left, right).ToHandleChecked(); Handle<String> root = factory->NewConsString(left, right);
CHECK(root->IsConsString() && !root->IsFlat()); CHECK(root->IsConsString() && !root->IsFlat());
// Special work needed for flat string. // Special work needed for flat string.
if (flat) { if (flat) {
...@@ -467,8 +467,7 @@ static Handle<String> ConstructLeft( ...@@ -467,8 +467,7 @@ static Handle<String> ConstructLeft(
data->stats_.leaves_++; data->stats_.leaves_++;
for (int i = 0; i < depth; i++) { for (int i = 0; i < depth; i++) {
Handle<String> block = data->block(i); Handle<String> block = data->block(i);
Handle<String> next = Handle<String> next = factory->NewConsString(answer, block);
factory->NewConsString(answer, block).ToHandleChecked();
if (next->IsConsString()) data->stats_.leaves_++; if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length(); data->stats_.chars_ += block->length();
answer = next; answer = next;
...@@ -486,8 +485,7 @@ static Handle<String> ConstructRight( ...@@ -486,8 +485,7 @@ static Handle<String> ConstructRight(
data->stats_.leaves_++; data->stats_.leaves_++;
for (int i = depth - 1; i >= 0; i--) { for (int i = depth - 1; i >= 0; i--) {
Handle<String> block = data->block(i); Handle<String> block = data->block(i);
Handle<String> next = Handle<String> next = factory->NewConsString(block, answer);
factory->NewConsString(block, answer).ToHandleChecked();
if (next->IsConsString()) data->stats_.leaves_++; if (next->IsConsString()) data->stats_.leaves_++;
data->stats_.chars_ += block->length(); data->stats_.chars_ += block->length();
answer = next; answer = next;
...@@ -510,8 +508,7 @@ static Handle<String> ConstructBalancedHelper( ...@@ -510,8 +508,7 @@ static Handle<String> ConstructBalancedHelper(
if (to - from == 2) { if (to - from == 2) {
data->stats_.chars_ += data->block(from)->length(); data->stats_.chars_ += data->block(from)->length();
data->stats_.chars_ += data->block(from+1)->length(); data->stats_.chars_ += data->block(from+1)->length();
return factory->NewConsString(data->block(from), data->block(from+1)) return factory->NewConsString(data->block(from), data->block(from+1));
.ToHandleChecked();
} }
Handle<String> part1 = Handle<String> part1 =
ConstructBalancedHelper(data, from, from + ((to - from) / 2)); ConstructBalancedHelper(data, from, from + ((to - from) / 2));
...@@ -519,7 +516,7 @@ static Handle<String> ConstructBalancedHelper( ...@@ -519,7 +516,7 @@ static Handle<String> ConstructBalancedHelper(
ConstructBalancedHelper(data, from + ((to - from) / 2), to); ConstructBalancedHelper(data, from + ((to - from) / 2), to);
if (part1->IsConsString()) data->stats_.left_traversals_++; if (part1->IsConsString()) data->stats_.left_traversals_++;
if (part2->IsConsString()) data->stats_.right_traversals_++; if (part2->IsConsString()) data->stats_.right_traversals_++;
return factory->NewConsString(part1, part2).ToHandleChecked(); return factory->NewConsString(part1, part2);
} }
...@@ -713,8 +710,7 @@ static Handle<String> BuildEdgeCaseConsString( ...@@ -713,8 +710,7 @@ static Handle<String> BuildEdgeCaseConsString(
data->stats_.chars_ += data->block(0)->length(); data->stats_.chars_ += data->block(0)->length();
data->stats_.chars_ += data->block(1)->length(); data->stats_.chars_ += data->block(1)->length();
data->stats_.leaves_ += 2; data->stats_.leaves_ += 2;
return factory->NewConsString(data->block(0), data->block(1)) return factory->NewConsString(data->block(0), data->block(1));
.ToHandleChecked();
case 6: case 6:
// Simple flattened tree. // Simple flattened tree.
data->stats_.chars_ += data->block(0)->length(); data->stats_.chars_ += data->block(0)->length();
...@@ -723,8 +719,7 @@ static Handle<String> BuildEdgeCaseConsString( ...@@ -723,8 +719,7 @@ static Handle<String> BuildEdgeCaseConsString(
data->stats_.empty_leaves_ += 1; data->stats_.empty_leaves_ += 1;
{ {
Handle<String> string = Handle<String> string =
factory->NewConsString(data->block(0), data->block(1)) factory->NewConsString(data->block(0), data->block(1));
.ToHandleChecked();
FlattenString(string); FlattenString(string);
return string; return string;
} }
...@@ -738,10 +733,9 @@ static Handle<String> BuildEdgeCaseConsString( ...@@ -738,10 +733,9 @@ static Handle<String> BuildEdgeCaseConsString(
data->stats_.left_traversals_ += 1; data->stats_.left_traversals_ += 1;
{ {
Handle<String> left = Handle<String> left =
factory->NewConsString(data->block(0), data->block(1)) factory->NewConsString(data->block(0), data->block(1));
.ToHandleChecked();
FlattenString(left); FlattenString(left);
return factory->NewConsString(left, data->block(2)).ToHandleChecked(); return factory->NewConsString(left, data->block(2));
} }
case 8: case 8:
// Left node and right node flattened. // Left node and right node flattened.
...@@ -755,14 +749,12 @@ static Handle<String> BuildEdgeCaseConsString( ...@@ -755,14 +749,12 @@ static Handle<String> BuildEdgeCaseConsString(
data->stats_.right_traversals_ += 1; data->stats_.right_traversals_ += 1;
{ {
Handle<String> left = Handle<String> left =
factory->NewConsString(data->block(0), data->block(1)) factory->NewConsString(data->block(0), data->block(1));
.ToHandleChecked();
FlattenString(left); FlattenString(left);
Handle<String> right = Handle<String> right =
factory->NewConsString(data->block(2), data->block(2)) factory->NewConsString(data->block(2), data->block(2));
.ToHandleChecked();
FlattenString(right); FlattenString(right);
return factory->NewConsString(left, right).ToHandleChecked(); return factory->NewConsString(left, right);
} }
} }
UNREACHABLE(); UNREACHABLE();
...@@ -874,10 +866,9 @@ TEST(DeepAscii) { ...@@ -874,10 +866,9 @@ TEST(DeepAscii) {
factory->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH)); factory->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH));
Handle<String> foo_string = factory->NewStringFromAscii(CStrVector("foo")); Handle<String> foo_string = factory->NewStringFromAscii(CStrVector("foo"));
for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) { for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) {
string = factory->NewConsString(string, foo_string).ToHandleChecked(); string = factory->NewConsString(string, foo_string);
} }
Handle<String> flat_string = Handle<String> flat_string = factory->NewConsString(string, foo_string);
factory->NewConsString(string, foo_string).ToHandleChecked();
FlattenString(flat_string); FlattenString(flat_string);
for (int i = 0; i < 500; i++) { for (int i = 0; i < 500; i++) {
...@@ -1101,8 +1092,7 @@ TEST(SliceFromCons) { ...@@ -1101,8 +1092,7 @@ TEST(SliceFromCons) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Handle<String> string = Handle<String> string =
factory->NewStringFromAscii(CStrVector("parentparentparent")); factory->NewStringFromAscii(CStrVector("parentparentparent"));
Handle<String> parent = Handle<String> parent = factory->NewConsString(string, string);
factory->NewConsString(string, string).ToHandleChecked();
CHECK(parent->IsConsString()); CHECK(parent->IsConsString());
CHECK(!parent->IsFlat()); CHECK(!parent->IsFlat());
Handle<String> slice = factory->NewSubString(parent, 1, 25); Handle<String> slice = factory->NewSubString(parent, 1, 25);
......
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