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

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

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments Created 7 years, 10 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') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return chars == str.length(); 105 return chars == str.length();
106 } 106 }
107 107
108 108
109 template<> 109 template<>
110 bool inline Heap::IsOneByte(String* str, int chars) { 110 bool inline Heap::IsOneByte(String* str, int chars) {
111 return str->IsOneByteRepresentation(); 111 return str->IsOneByteRepresentation();
112 } 112 }
113 113
114 114
115 MaybeObject* Heap::AllocateSymbolFromUtf8(Vector<const char> str, 115 MaybeObject* Heap::AllocateInternalizedStringFromUtf8(
116 int chars, 116 Vector<const char> str, int chars, uint32_t hash_field) {
117 uint32_t hash_field) {
118 if (IsOneByte(str, chars)) { 117 if (IsOneByte(str, chars)) {
119 return AllocateOneByteSymbol(Vector<const uint8_t>::cast(str), hash_field); 118 return AllocateOneByteInternalizedString(
119 Vector<const uint8_t>::cast(str), hash_field);
120 } 120 }
121 return AllocateInternalSymbol<false>(str, chars, hash_field); 121 return AllocateInternalizedStringImpl<false>(str, chars, hash_field);
122 } 122 }
123 123
124 124
125 template<typename T> 125 template<typename T>
126 MaybeObject* Heap::AllocateInternalSymbol(T t, int chars, uint32_t hash_field) { 126 MaybeObject* Heap::AllocateInternalizedStringImpl(
127 T t, int chars, uint32_t hash_field) {
127 if (IsOneByte(t, chars)) { 128 if (IsOneByte(t, chars)) {
128 return AllocateInternalSymbol<true>(t, chars, hash_field); 129 return AllocateInternalizedStringImpl<true>(t, chars, hash_field);
129 } 130 }
130 return AllocateInternalSymbol<false>(t, chars, hash_field); 131 return AllocateInternalizedStringImpl<false>(t, chars, hash_field);
131 } 132 }
132 133
133 134
134 MaybeObject* Heap::AllocateOneByteSymbol(Vector<const uint8_t> str, 135 MaybeObject* Heap::AllocateOneByteInternalizedString(Vector<const uint8_t> str,
135 uint32_t hash_field) { 136 uint32_t hash_field) {
136 if (str.length() > SeqOneByteString::kMaxLength) { 137 if (str.length() > SeqOneByteString::kMaxLength) {
137 return Failure::OutOfMemoryException(0x2); 138 return Failure::OutOfMemoryException(0x2);
138 } 139 }
139 // Compute map and object size. 140 // Compute map and object size.
140 Map* map = ascii_symbol_map(); 141 Map* map = ascii_internalized_string_map();
141 int size = SeqOneByteString::SizeFor(str.length()); 142 int size = SeqOneByteString::SizeFor(str.length());
142 143
143 // Allocate string. 144 // Allocate string.
144 Object* result; 145 Object* result;
145 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) 146 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
146 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) 147 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
147 : old_data_space_->AllocateRaw(size); 148 : old_data_space_->AllocateRaw(size);
148 if (!maybe_result->ToObject(&result)) return maybe_result; 149 if (!maybe_result->ToObject(&result)) return maybe_result;
149 } 150 }
150 151
151 // String maps are all immortal immovable objects. 152 // String maps are all immortal immovable objects.
152 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); 153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map);
153 // Set length and hash fields of the allocated string. 154 // Set length and hash fields of the allocated string.
154 String* answer = String::cast(result); 155 String* answer = String::cast(result);
155 answer->set_length(str.length()); 156 answer->set_length(str.length());
156 answer->set_hash_field(hash_field); 157 answer->set_hash_field(hash_field);
157 158
158 ASSERT_EQ(size, answer->Size()); 159 ASSERT_EQ(size, answer->Size());
159 160
160 // Fill in the characters. 161 // Fill in the characters.
161 memcpy(answer->address() + SeqOneByteString::kHeaderSize, 162 memcpy(answer->address() + SeqOneByteString::kHeaderSize,
162 str.start(), str.length()); 163 str.start(), str.length());
163 164
164 return answer; 165 return answer;
165 } 166 }
166 167
167 168
168 MaybeObject* Heap::AllocateTwoByteSymbol(Vector<const uc16> str, 169 MaybeObject* Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
169 uint32_t hash_field) { 170 uint32_t hash_field) {
170 if (str.length() > SeqTwoByteString::kMaxLength) { 171 if (str.length() > SeqTwoByteString::kMaxLength) {
171 return Failure::OutOfMemoryException(0x3); 172 return Failure::OutOfMemoryException(0x3);
172 } 173 }
173 // Compute map and object size. 174 // Compute map and object size.
174 Map* map = symbol_map(); 175 Map* map = internalized_string_map();
175 int size = SeqTwoByteString::SizeFor(str.length()); 176 int size = SeqTwoByteString::SizeFor(str.length());
176 177
177 // Allocate string. 178 // Allocate string.
178 Object* result; 179 Object* result;
179 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize) 180 { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
180 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) 181 ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
181 : old_data_space_->AllocateRaw(size); 182 : old_data_space_->AllocateRaw(size);
182 if (!maybe_result->ToObject(&result)) return maybe_result; 183 if (!maybe_result->ToObject(&result)) return maybe_result;
183 } 184 }
184 185
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 AssertNoAllocation::~AssertNoAllocation() { } 859 AssertNoAllocation::~AssertNoAllocation() { }
859 DisableAssertNoAllocation::DisableAssertNoAllocation() { } 860 DisableAssertNoAllocation::DisableAssertNoAllocation() { }
860 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } 861 DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
861 862
862 #endif 863 #endif
863 864
864 865
865 } } // namespace v8::internal 866 } } // namespace v8::internal
866 867
867 #endif // V8_HEAP_INL_H_ 868 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698