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

Side by Side Diff: src/mark-compact.cc

Issue 1700: Do not shortcut cons string symbols during garbage collection.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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 | « no previous file | src/objects.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // have been reached and marked but their children have not been visited yet. 214 // have been reached and marked but their children have not been visited yet.
215 // After emptying the marking stack, we clear the overflow flag and traverse 215 // After emptying the marking stack, we clear the overflow flag and traverse
216 // the heap looking for objects marked as overflowed, push them on the stack, 216 // the heap looking for objects marked as overflowed, push them on the stack,
217 // and continue with marking. This process repeats until all reachable 217 // and continue with marking. This process repeats until all reachable
218 // objects have been marked. 218 // objects have been marked.
219 219
220 static MarkingStack marking_stack; 220 static MarkingStack marking_stack;
221 221
222 222
223 inline HeapObject* ShortCircuitConsString(Object** p) { 223 inline HeapObject* ShortCircuitConsString(Object** p) {
224 // Optimization: If the heap object pointed to by p is a cons string whose 224 // Optimization: If the heap object pointed to by p is a non-symbol
225 // right substring is Heap::empty_string, update it in place to its left 225 // cons string whose right substring is Heap::empty_string, update
226 // substring. Return the updated value. 226 // it in place to its left substring. Return the updated value.
227 // 227 //
228 // Here we assume that if we change *p, we replace it with a heap object 228 // Here we assume that if we change *p, we replace it with a heap object
229 // (ie, the left substring of a cons string is always a heap object). 229 // (ie, the left substring of a cons string is always a heap object).
230 // 230 //
231 // The check performed is: 231 // The check performed is:
232 // object->IsConsString() && 232 // object->IsConsString() && !object->IsSymbol() &&
233 // (ConsString::cast(object)->second() == Heap::empty_string()) 233 // (ConsString::cast(object)->second() == Heap::empty_string())
234 // except the maps for the object and its possible substrings might be 234 // except the maps for the object and its possible substrings might be
235 // marked. 235 // marked.
236 HeapObject* object = HeapObject::cast(*p); 236 HeapObject* object = HeapObject::cast(*p);
237 MapWord map_word = object->map_word(); 237 MapWord map_word = object->map_word();
238 map_word.ClearMark(); 238 map_word.ClearMark();
239 InstanceType type = map_word.ToMap()->instance_type(); 239 InstanceType type = map_word.ToMap()->instance_type();
240 if (type >= FIRST_NONSTRING_TYPE) return object; 240 if (type >= FIRST_NONSTRING_TYPE || (type & kIsSymbolMask) != 0) {
241 return object;
242 }
241 243
242 StringRepresentationTag rep = 244 StringRepresentationTag rep =
243 static_cast<StringRepresentationTag>(type & kStringRepresentationMask); 245 static_cast<StringRepresentationTag>(type & kStringRepresentationMask);
244 if (rep != kConsStringTag) return object; 246 if (rep != kConsStringTag) return object;
245 247
246 Object* second = reinterpret_cast<ConsString*>(object)->second(); 248 Object* second = reinterpret_cast<ConsString*>(object)->second();
247 if (reinterpret_cast<String*>(second) != Heap::empty_string()) return object; 249 if (reinterpret_cast<String*>(second) != Heap::empty_string()) return object;
248 250
249 // Since we don't have the object's start, it is impossible to update the 251 // Since we don't have the object's start, it is impossible to update the
250 // remembered set. Therefore, we only replace the string with its left 252 // remembered set. Therefore, we only replace the string with its left
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1779
1778 void MarkCompactCollector::RebuildRSets() { 1780 void MarkCompactCollector::RebuildRSets() {
1779 #ifdef DEBUG 1781 #ifdef DEBUG
1780 ASSERT(state_ == RELOCATE_OBJECTS); 1782 ASSERT(state_ == RELOCATE_OBJECTS);
1781 state_ = REBUILD_RSETS; 1783 state_ = REBUILD_RSETS;
1782 #endif 1784 #endif
1783 Heap::RebuildRSets(); 1785 Heap::RebuildRSets();
1784 } 1786 }
1785 1787
1786 } } // namespace v8::internal 1788 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698