Commit 13dd915a authored by lrn@chromium.org's avatar lrn@chromium.org

Fix typo in assert.

Also remove the requirement to have an AssertNoAllocation object when getting the flat content. We actually do allow allocation, it's just GC's we don't allow.

Review URL: http://codereview.chromium.org/7710018

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9001 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2e1e5fc0
......@@ -617,7 +617,7 @@ Handle<FixedArray> CalculateLineEnds(Handle<String> src,
{
AssertNoAllocation no_heap_allocation; // ensure vectors stay valid.
// Dispatch on type of strings.
String::FlatContent content = src->GetFlatContent(no_heap_allocation);
String::FlatContent content = src->GetFlatContent();
ASSERT(content.IsFlat());
if (content.IsAscii()) {
CalculateLineEnds(isolate,
......
......@@ -778,8 +778,7 @@ void HHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
void HTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
value()->PrintNameTo(stream);
stream->Add(" == ");
AssertNoAllocation no_alloc;
stream->Add(type_literal_->GetFlatContent(no_alloc).ToAsciiVector());
stream->Add(type_literal_->GetFlatContent().ToAsciiVector());
}
......
......@@ -635,7 +635,7 @@ bool IrregexpInterpreter::Match(Isolate* isolate,
AssertNoAllocation a;
const byte* code_base = code_array->GetDataStartAddress();
uc16 previous_char = '\n';
String::FlatContent subject_content = subject->GetFlatContent(a);
String::FlatContent subject_content = subject->GetFlatContent();
if (subject_content.IsAscii()) {
Vector<const char> subject_vector = subject_content.ToAsciiVector();
if (start_position != 0) previous_char = subject_vector[start_position - 1];
......
......@@ -235,10 +235,8 @@ Handle<Object> RegExpImpl::AtomExec(Handle<JSRegExp> re,
return isolate->factory()->null_value();
}
String::FlatContent needle_content =
needle->GetFlatContent(no_heap_allocation);
String::FlatContent subject_content =
subject->GetFlatContent(no_heap_allocation);
String::FlatContent needle_content = needle->GetFlatContent();
String::FlatContent subject_content = subject->GetFlatContent();
ASSERT(needle_content.IsFlat());
ASSERT(subject_content.IsFlat());
// dispatch on type of strings
......
......@@ -5038,9 +5038,7 @@ int String::Utf8Length() {
}
String::FlatContent String::GetFlatContent(const AssertNoAllocation& promise) {
// Argument isn't used, it's only there to ensure that the user is
// aware that the extracted vectors may not survive a GC.
String::FlatContent String::GetFlatContent() {
int length = this->length();
StringShape shape(this);
String* string = this;
......@@ -5519,9 +5517,8 @@ void FlatStringReader::PostGarbageCollection() {
if (str_ == NULL) return;
Handle<String> str(str_);
ASSERT(str->IsFlat());
AssertNoAllocation no_alloc;
String::FlatContent content = str->GetFlatContent(no_alloc);
ASSERT(content.is_flat());
String::FlatContent content = str->GetFlatContent();
ASSERT(content.IsFlat());
is_ascii_ = content.IsAscii();
if (is_ascii_) {
start_ = content.ToAsciiVector().start();
......@@ -5846,8 +5843,7 @@ template <typename IteratorA>
static inline bool CompareStringContentsPartial(Isolate* isolate,
IteratorA* ia,
String* b) {
AssertNoAllocation no_alloc;
String::FlatContent content = b->GetFlatContent(no_alloc);
String::FlatContent content = b->GetFlatContent();
if (content.IsFlat()) {
if (content.IsAscii()) {
VectorIterator<char> ib(content.ToAsciiVector());
......@@ -5883,8 +5879,6 @@ bool String::SlowEquals(String* other) {
String* lhs = this->TryFlattenGetString();
String* rhs = other->TryFlattenGetString();
AssertNoAllocation no_alloc;
if (StringShape(lhs).IsSequentialAscii() &&
StringShape(rhs).IsSequentialAscii()) {
const char* str1 = SeqAsciiString::cast(lhs)->GetChars();
......@@ -5894,8 +5888,8 @@ bool String::SlowEquals(String* other) {
}
Isolate* isolate = GetIsolate();
String::FlatContent lhs_content = lhs->GetFlatContent(no_alloc);
String::FlatContent rhs_content = rhs->GetFlatContent(no_alloc);
String::FlatContent lhs_content = lhs->GetFlatContent();
String::FlatContent rhs_content = rhs->GetFlatContent();
if (lhs_content.IsFlat()) {
if (lhs_content.IsAscii()) {
Vector<const char> vec1 = lhs_content.ToAsciiVector();
......@@ -5973,10 +5967,9 @@ bool String::IsEqualTo(Vector<const char> str) {
bool String::IsAsciiEqualTo(Vector<const char> str) {
AssertNoAllocation no_alloc;
int slen = length();
if (str.length() != slen) return false;
FlatContent content = GetFlatContent(no_alloc);
FlatContent content = GetFlatContent();
if (content.IsAscii()) {
return CompareChars(content.ToAsciiVector().start(),
str.start(), slen) == 0;
......@@ -5989,10 +5982,9 @@ bool String::IsAsciiEqualTo(Vector<const char> str) {
bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
AssertNoAllocation no_alloc;
int slen = length();
if (str.length() != slen) return false;
FlatContent content = GetFlatContent(no_alloc);
FlatContent content = GetFlatContent();
if (content.IsTwoByte()) {
return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
}
......
......@@ -5919,7 +5919,7 @@ class String: public HeapObject {
// If the string isn't flat, and therefore doesn't have flat content, the
// returned structure will report so, and can't provide a vector of either
// kind.
FlatContent GetFlatContent(const AssertNoAllocation& safety_promise);
FlatContent GetFlatContent();
// Mark the string as an undetectable object. It only applies to
// ascii and two byte string types.
......
......@@ -2665,7 +2665,7 @@ void CompiledReplacement::Compile(Handle<String> replacement,
int subject_length) {
{
AssertNoAllocation no_alloc;
String::FlatContent content = replacement->GetFlatContent(no_alloc);
String::FlatContent content = replacement->GetFlatContent();
ASSERT(content.IsFlat());
if (content.IsAscii()) {
ParseReplacementPattern(&parts_,
......@@ -3050,8 +3050,8 @@ int Runtime::StringMatch(Isolate* isolate,
AssertNoAllocation no_heap_allocation; // ensure vectors stay valid
// Extract flattened substrings of cons strings before determining asciiness.
String::FlatContent seq_sub = sub->GetFlatContent(no_heap_allocation);
String::FlatContent seq_pat = pat->GetFlatContent(no_heap_allocation);
String::FlatContent seq_sub = sub->GetFlatContent();
String::FlatContent seq_pat = pat->GetFlatContent();
// dispatch on type of strings
if (seq_pat.IsAscii()) {
......@@ -3161,8 +3161,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) {
int position = -1;
AssertNoAllocation no_heap_allocation; // ensure vectors stay valid
String::FlatContent sub_content = sub->GetFlatContent(no_heap_allocation);
String::FlatContent pat_content = pat->GetFlatContent(no_heap_allocation);
String::FlatContent sub_content = sub->GetFlatContent();
String::FlatContent pat_content = pat->GetFlatContent();
if (pat_content.IsAscii()) {
Vector<const char> pat_vector = pat_content.ToAsciiVector();
......@@ -3400,8 +3400,8 @@ static bool SearchStringMultiple(Isolate* isolate,
for (;;) { // Break when search complete.
builder->EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
AssertNoAllocation no_gc;
String::FlatContent subject_content = subject->GetFlatContent(no_gc);
String::FlatContent pattern_content = pattern->GetFlatContent(no_gc);
String::FlatContent subject_content = subject->GetFlatContent();
String::FlatContent pattern_content = pattern->GetFlatContent();
if (subject_content.IsAscii()) {
Vector<const char> subject_vector = subject_content.ToAsciiVector();
if (pattern_content.IsAscii()) {
......@@ -5419,8 +5419,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) {
str = String::cast(flat);
ASSERT(str->IsFlat());
}
AssertNoAllocation no_alloc;
String::FlatContent flat = str->GetFlatContent(no_alloc);
String::FlatContent flat = str->GetFlatContent();
ASSERT(flat.IsFlat());
if (flat.IsTwoByte()) {
return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate,
......@@ -5444,8 +5443,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) {
str = String::cast(flat);
ASSERT(str->IsFlat());
}
AssertNoAllocation no_alloc;
String::FlatContent flat = str->GetFlatContent(no_alloc);
String::FlatContent flat = str->GetFlatContent();
if (flat.IsTwoByte()) {
return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate,
flat.ToUC16Vector());
......@@ -5486,7 +5484,7 @@ static MaybeObject* QuoteJsonStringArray(Isolate* isolate,
for (int i = 0; i < length; i++) {
if (i != 0) *(write_cursor++) = ',';
String* str = String::cast(array->get(i));
String::FlatContent content = str->GetFlatContent(no_gc);
String::FlatContent content = str->GetFlatContent();
ASSERT(content.IsFlat());
if (content.IsTwoByte()) {
write_cursor = WriteQuoteJsonString<Char, uc16>(isolate,
......@@ -5975,8 +5973,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
// No allocation block.
{
AssertNoAllocation no_gc;
String::FlatContent subject_content = subject->GetFlatContent(no_gc);
String::FlatContent pattern_content = pattern->GetFlatContent(no_gc);
String::FlatContent subject_content = subject->GetFlatContent();
String::FlatContent pattern_content = pattern->GetFlatContent();
ASSERT(subject_content.IsFlat());
ASSERT(pattern_content.IsFlat());
if (subject_content.IsAscii()) {
......@@ -6062,7 +6060,7 @@ static int CopyCachedAsciiCharsToArray(Heap* heap,
const char* chars,
FixedArray* elements,
int length) {
AssertNoAllocation nogc;
AssertNoAllocation no_gc;
FixedArray* ascii_cache = heap->single_character_string_cache();
Object* undefined = heap->undefined_value();
int i;
......@@ -6107,9 +6105,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) {
isolate->heap()->AllocateUninitializedFixedArray(length);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
AssertNoAllocation no_alloc;
elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);
String::FlatContent content = s->GetFlatContent(no_alloc);
String::FlatContent content = s->GetFlatContent();
if (content.IsAscii()) {
Vector<const char> chars = content.ToAsciiVector();
// Note, this will initialize all elements (not only the prefix)
......@@ -6930,7 +6927,6 @@ static Object* StringInputBufferCompare(RuntimeState* state,
static Object* FlatStringCompare(String* x, String* y) {
ASSERT(x->IsFlat());
ASSERT(y->IsFlat());
AssertNoAllocation no_alloc;
Object* equal_prefix_result = Smi::FromInt(EQUAL);
int prefix_length = x->length();
if (y->length() < prefix_length) {
......@@ -6940,8 +6936,8 @@ static Object* FlatStringCompare(String* x, String* y) {
equal_prefix_result = Smi::FromInt(LESS);
}
int r;
String::FlatContent x_content = x->GetFlatContent(no_alloc);
String::FlatContent y_content = y->GetFlatContent(no_alloc);
String::FlatContent x_content = x->GetFlatContent();
String::FlatContent y_content = y->GetFlatContent();
if (x_content.IsAscii()) {
Vector<const char> x_chars = x_content.ToAsciiVector();
if (y_content.IsAscii()) {
......@@ -8838,7 +8834,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
FixedArray* output_array = FixedArray::cast(output->elements());
RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
bool result;
String::FlatContent str_content = str->GetFlatContent(no_allocation);
String::FlatContent str_content = str->GetFlatContent();
if (str_content.IsAscii()) {
result = DateParser::Parse(str_content.ToAsciiVector(),
output_array,
......@@ -12823,10 +12819,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
ASSERT(args.length() == 2);
AssertNoAllocation no_alloc;
CONVERT_CHECKED(String, format, args[0]);
CONVERT_CHECKED(JSArray, elms, args[1]);
String::FlatContent format_content = format->GetFlatContent(no_alloc);
String::FlatContent format_content = format->GetFlatContent();
RUNTIME_ASSERT(format_content.IsAscii());
Vector<const char> chars = format_content.ToAsciiVector();
LOGGER->LogRuntime(chars, elms);
......
......@@ -117,13 +117,14 @@ assertEquals(["a", "b", "c"], "abc".split("", numberObj(3)));
assertEquals(["a", "b", "c"], "abc".split("", 4));
assertEquals(["a", "b", "c"], "abc".split("", numberObj(4)));
var all_ascii_chars = [];
for (var i = 0; i < 128; i++) all_ascii_chars[i] = String.fromCharCode(i);
var all_ascii_string = all_ascii_chars.join("");
var all_ascii_codes = [];
for (var i = 0; i < 128; i++) all_ascii_codes[i] = i;
var all_ascii_string = String.fromCharCode.apply(String, all_ascii_codes);
var split_chars = all_ascii_string.split("");
assertEquals(128, split_chars.length);
for (var i = 0; i < 128; i++) {
assertEquals(1, split_chars[i].length);
assertEquals(i, split_chars[i].charCodeAt(0));
}
\ No newline at end of file
}
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