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

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

Issue 6072004: Avoid decoding overhead when allocating ascii strings.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 12 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 #include "v8-counters.h" 33 #include "v8-counters.h"
34 34
35 namespace v8 { 35 namespace v8 {
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,
44 PretenureFlag pretenure) {
45 // Check for ascii first since this is the common case.
Lasse Reichstein 2010/12/21 12:48:12 ASCII is an acronym, even though we might not resp
Mads Ager (chromium) 2010/12/21 12:55:52 Done.
46 for (int i = 0; i < str.length(); ++i) {
47 if (static_cast<uc16>(str[i]) > String::kMaxAsciiCharCode) {
Lasse Reichstein 2010/12/21 12:48:12 Just cast to uint8_t, and compare to String:kMaxAs
Mads Ager (chromium) 2010/12/21 12:55:52 Done.
48 // Non-ascii and we need to decode.
49 return AllocateStringFromUtf8Slow(str, pretenure);
50 }
51 }
52 // If the string is ascii, we do not need to convert the characters
53 // since UTF8 is backwards compatible with ascii.
54 return AllocateStringFromAscii(str, pretenure);
55 }
56
57
43 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, 58 MaybeObject* Heap::AllocateSymbol(Vector<const char> str,
44 int chars, 59 int chars,
45 uint32_t hash_field) { 60 uint32_t hash_field) {
46 unibrow::Utf8InputBuffer<> buffer(str.start(), 61 unibrow::Utf8InputBuffer<> buffer(str.start(),
47 static_cast<unsigned>(str.length())); 62 static_cast<unsigned>(str.length()));
48 return AllocateInternalSymbol(&buffer, chars, hash_field); 63 return AllocateInternalSymbol(&buffer, chars, hash_field);
49 } 64 }
50 65
51 66
52 MaybeObject* Heap::CopyFixedArray(FixedArray* src) { 67 MaybeObject* Heap::CopyFixedArray(FixedArray* src) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 515
501 516
502 void ExternalStringTable::ShrinkNewStrings(int position) { 517 void ExternalStringTable::ShrinkNewStrings(int position) {
503 new_space_strings_.Rewind(position); 518 new_space_strings_.Rewind(position);
504 Verify(); 519 Verify();
505 } 520 }
506 521
507 } } // namespace v8::internal 522 } } // namespace v8::internal
508 523
509 #endif // V8_HEAP_INL_H_ 524 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698