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

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

Issue 10857030: Add basic support for Latin1 to the API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: removed MakeExternal(ExternalLatin1StringResource*) and added counters. Created 8 years, 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 77
78 void PromotionQueue::ActivateGuardIfOnTheSamePage() { 78 void PromotionQueue::ActivateGuardIfOnTheSamePage() {
79 guard_ = guard_ || 79 guard_ = guard_ ||
80 heap_->new_space()->active_space()->current_page()->address() == 80 heap_->new_space()->active_space()->current_page()->address() ==
81 GetHeadPage()->address(); 81 GetHeadPage()->address();
82 } 82 }
83 83
84 84
85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, 85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
86 PretenureFlag pretenure) { 86 PretenureFlag pretenure,
87 // Check for ASCII first since this is the common case. 87 String::AsciiHint ascii_hint) {
88 if (String::IsAscii(str.start(), str.length())) { 88 if ((ascii_hint == String::MAYBE_ASCII &&
89 String::IsAscii(str.start(), str.length())) ||
90 ascii_hint == String::STRICT_ASCII) {
91 // Assert that the strict ascii hint is correct.
Erik Corry 2012/08/21 12:21:34 ascii -> ASCII here and below
Yang 2012/08/21 13:06:20 Done.
92 ASSERT(ascii_hint != String::STRICT_ASCII ||
93 String::IsAscii(str.start(), str.length()));
89 // If the string is ASCII, we do not need to convert the characters 94 // If the string is ASCII, we do not need to convert the characters
90 // since UTF8 is backwards compatible with ASCII. 95 // since UTF8 is backwards compatible with ASCII.
91 return AllocateStringFromAscii(str, pretenure); 96 return AllocateStringFromAscii(str, pretenure);
92 } 97 }
93 // Non-ASCII and we need to decode. 98 // Non-ASCII and we need to decode.
94 return AllocateStringFromUtf8Slow(str, pretenure); 99 return AllocateStringFromUtf8Slow(str, pretenure);
95 } 100 }
96 101
97 102
103 MaybeObject* Heap::AllocateStringFromLatin1(Vector<const char> str,
104 PretenureFlag pretenure,
105 String::AsciiHint ascii_hint) {
106 if ((ascii_hint == String::MAYBE_ASCII &&
107 String::IsAscii(str.start(), str.length())) ||
108 ascii_hint == String::STRICT_ASCII) {
109 // Assert that the strict ascii hint is correct.
110 ASSERT(ascii_hint != String::STRICT_ASCII ||
111 String::IsAscii(str.start(), str.length()));
112 // If the string is ASCII, we do not need to convert the characters
113 // since Latin1 is backwards compatible with ASCII.
114 return AllocateStringFromAscii(str, pretenure);
115 }
116 // Non-ASCII and we need to decode.
117 return AllocateStringFromLatin1Slow(str, pretenure);
118 }
119
120
98 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, 121 MaybeObject* Heap::AllocateSymbol(Vector<const char> str,
99 int chars, 122 int chars,
100 uint32_t hash_field) { 123 uint32_t hash_field) {
101 unibrow::Utf8InputBuffer<> buffer(str.start(), 124 unibrow::Utf8InputBuffer<> buffer(str.start(),
102 static_cast<unsigned>(str.length())); 125 static_cast<unsigned>(str.length()));
103 return AllocateInternalSymbol(&buffer, chars, hash_field); 126 return AllocateInternalSymbol(&buffer, chars, hash_field);
104 } 127 }
105 128
106 129
107 MaybeObject* Heap::AllocateAsciiSymbol(Vector<const char> str, 130 MaybeObject* Heap::AllocateAsciiSymbol(Vector<const char> str,
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 AssertNoAllocation::~AssertNoAllocation() { } 842 AssertNoAllocation::~AssertNoAllocation() { }
820 DisableAssertNoAllocation::DisableAssertNoAllocation() { } 843 DisableAssertNoAllocation::DisableAssertNoAllocation() { }
821 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } 844 DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
822 845
823 #endif 846 #endif
824 847
825 848
826 } } // namespace v8::internal 849 } } // namespace v8::internal
827 850
828 #endif // V8_HEAP_INL_H_ 851 #endif // V8_HEAP_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698