Commit 451ed2f2 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Remove some ascii checks in advance of latin-1 release

BUG=

Review URL: https://chromiumcodereview.appspot.com/11880017
Patch from Dan Carney <dcarney@google.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13399 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 10436443
......@@ -633,20 +633,24 @@ void ExternalStringTable::Verify() {
// TODO(yangguo): check that the object is indeed an external string.
ASSERT(heap_->InNewSpace(obj));
ASSERT(obj != HEAP->the_hole_value());
#ifndef ENABLE_LATIN_1
if (obj->IsExternalAsciiString()) {
ExternalAsciiString* string = ExternalAsciiString::cast(obj);
ASSERT(String::IsAscii(string->GetChars(), string->length()));
}
#endif
}
for (int i = 0; i < old_space_strings_.length(); ++i) {
Object* obj = Object::cast(old_space_strings_[i]);
// TODO(yangguo): check that the object is indeed an external string.
ASSERT(!heap_->InNewSpace(obj));
ASSERT(obj != HEAP->the_hole_value());
#ifndef ENABLE_LATIN_1
if (obj->IsExternalAsciiString()) {
ExternalAsciiString* string = ExternalAsciiString::cast(obj);
ASSERT(String::IsAscii(string->GetChars(), string->length()));
}
#endif
}
#endif
}
......
......@@ -2025,7 +2025,6 @@ Object* LiveObjectList::PrintObj(int obj_id) {
MemoryMappedExternalResource* resource =
new MemoryMappedExternalResource(temp_filename.start(), true);
if (resource->exists() && !resource->is_empty()) {
ASSERT(resource->IsAscii());
Handle<String> dump_string =
factory->NewExternalStringFromAscii(resource);
heap->external_string_table()->AddString(*dump_string);
......@@ -2232,7 +2231,6 @@ Object* LiveObjectList::GetPathPrivate(HeapObject* obj1, HeapObject* obj2) {
MemoryMappedExternalResource* resource =
new MemoryMappedExternalResource(temp_filename.start(), true);
if (resource->exists() && !resource->is_empty()) {
ASSERT(resource->IsAscii());
Handle<String> path_string =
factory->NewExternalStringFromAscii(resource);
heap->external_string_table()->AddString(*path_string);
......
......@@ -315,55 +315,4 @@ void MemoryMappedExternalResource::Init(const char* filename) {
}
}
bool MemoryMappedExternalResource::EnsureIsAscii(bool abort_if_failed) const {
bool is_ascii = true;
int line_no = 1;
const char* start_of_line = data_;
const char* end = data_ + length_;
for (const char* p = data_; p < end; p++) {
char c = *p;
if ((c & 0x80) != 0) {
// Non-ASCII detected:
is_ascii = false;
// Report the error and abort if appropriate:
if (abort_if_failed) {
int char_no = static_cast<int>(p - start_of_line) - 1;
ASSERT(filename_ != NULL);
PrintF("\n\n\n"
"Abort: Non-Ascii character 0x%.2x in file %s line %d char %d",
c, filename_, line_no, char_no);
// Allow for some context up to kNumberOfLeadingContextChars chars
// before the offending non-ASCII char to help the user see where
// the offending char is.
const int kNumberOfLeadingContextChars = 10;
const char* err_context = p - kNumberOfLeadingContextChars;
if (err_context < data_) {
err_context = data_;
}
// Compute the length of the error context and print it.
int err_context_length = static_cast<int>(p - err_context);
if (err_context_length != 0) {
PrintF(" after \"%.*s\"", err_context_length, err_context);
}
PrintF(".\n\n\n");
OS::Abort();
}
break; // Non-ASCII detected. No need to continue scanning.
}
if (c == '\n') {
start_of_line = p;
line_no++;
}
}
return is_ascii;
}
} } // namespace v8::internal
......@@ -280,10 +280,6 @@ class MemoryMappedExternalResource: public
bool exists() const { return file_ != NULL; }
bool is_empty() const { return length_ == 0; }
bool EnsureIsAscii(bool abort_if_failed) const;
bool EnsureIsAscii() const { return EnsureIsAscii(true); }
bool IsAscii() const { return EnsureIsAscii(false); }
private:
void Init(const char* filename);
......
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