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

Side by Side Diff: src/heap-inl.h

Issue 5963003: Clean up is-ASCII checks. (Closed)
Patch Set: Created 10 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. 1 // Copyright 2006-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 25 matching lines...) Expand all
36 namespace internal { 36 namespace internal {
37 37
38 int Heap::MaxObjectSizeInPagedSpace() { 38 int Heap::MaxObjectSizeInPagedSpace() {
39 return Page::kMaxHeapObjectSize; 39 return Page::kMaxHeapObjectSize;
40 } 40 }
41 41
42 42
43 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, 43 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
44 PretenureFlag pretenure) { 44 PretenureFlag pretenure) {
45 // Check for ASCII first since this is the common case. 45 // Check for ASCII first since this is the common case.
46 for (int i = 0; i < str.length(); ++i) { 46 if (String::IsAscii(str.start(), str.length())) {
47 if (static_cast<uint8_t>(str[i]) > String::kMaxAsciiCharCodeU) { 47 // If the string is ASCII, we do not need to convert the characters
48 // Non-ASCII and we need to decode. 48 // since UTF8 is backwards compatible with ASCII.
49 return AllocateStringFromUtf8Slow(str, pretenure); 49 return AllocateStringFromAscii(str, pretenure);
50 }
51 } 50 }
52 // If the string is ASCII, we do not need to convert the characters 51 // Non-ASCII and we need to decode.
53 // since UTF8 is backwards compatible with ASCII. 52 return AllocateStringFromUtf8Slow(str, pretenure);
54 return AllocateStringFromAscii(str, pretenure);
55 } 53 }
56 54
57 55
58 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, 56 MaybeObject* Heap::AllocateSymbol(Vector<const char> str,
59 int chars, 57 int chars,
60 uint32_t hash_field) { 58 uint32_t hash_field) {
61 unibrow::Utf8InputBuffer<> buffer(str.start(), 59 unibrow::Utf8InputBuffer<> buffer(str.start(),
62 static_cast<unsigned>(str.length())); 60 static_cast<unsigned>(str.length()));
63 return AllocateInternalSymbol(&buffer, chars, hash_field); 61 return AllocateInternalSymbol(&buffer, chars, hash_field);
64 } 62 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 513
516 514
517 void ExternalStringTable::ShrinkNewStrings(int position) { 515 void ExternalStringTable::ShrinkNewStrings(int position) {
518 new_space_strings_.Rewind(position); 516 new_space_strings_.Rewind(position);
519 Verify(); 517 Verify();
520 } 518 }
521 519
522 } } // namespace v8::internal 520 } } // namespace v8::internal
523 521
524 #endif // V8_HEAP_INL_H_ 522 #endif // V8_HEAP_INL_H_
OLDNEW
« src/heap.cc ('K') | « src/heap.cc ('k') | src/ia32/regexp-macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698