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

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

Issue 21117: Allow the morphing of strings to external strings to avoid having to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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/objects.h » ('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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 384
385 // Helper class for pruning the symbol table. 385 // Helper class for pruning the symbol table.
386 class SymbolTableCleaner : public ObjectVisitor { 386 class SymbolTableCleaner : public ObjectVisitor {
387 public: 387 public:
388 SymbolTableCleaner() : pointers_removed_(0) { } 388 SymbolTableCleaner() : pointers_removed_(0) { }
389 void VisitPointers(Object** start, Object** end) { 389 void VisitPointers(Object** start, Object** end) {
390 // Visit all HeapObject pointers in [start, end). 390 // Visit all HeapObject pointers in [start, end).
391 for (Object** p = start; p < end; p++) { 391 for (Object** p = start; p < end; p++) {
392 if ((*p)->IsHeapObject() && !HeapObject::cast(*p)->IsMarked()) { 392 if ((*p)->IsHeapObject() && !HeapObject::cast(*p)->IsMarked()) {
393 // Check if the symbol being pruned is an external symbol. We need to
394 // delete the associated external data as this symbol is going away.
395
396 // Since the object is not marked we can access its map word safely
397 // without having to worry about marking bits in the object header.
398 Map* map = HeapObject::cast(*p)->map();
399 // Since no objects have yet been moved we can safely access the map of
400 // the object.
401 uint32_t type = map->instance_type();
402 bool is_external = (type & kStringRepresentationMask) ==
403 kExternalStringTag;
404 if (is_external) {
405 bool is_two_byte = (type & kStringEncodingMask) == kTwoByteStringTag;
406 byte* resource_addr = reinterpret_cast<byte*>(*p) +
407 ExternalString::kResourceOffset -
408 kHeapObjectTag;
409 if (is_two_byte) {
410 v8::String::ExternalStringResource* resource =
411 *reinterpret_cast<v8::String::ExternalStringResource**>
412 (resource_addr);
413 delete resource;
414 } else {
415 v8::String::ExternalAsciiStringResource* resource =
416 *reinterpret_cast<v8::String::ExternalAsciiStringResource**>
417 (resource_addr);
418 delete resource;
419 }
420 }
393 // Set the entry to null_value (as deleted). 421 // Set the entry to null_value (as deleted).
394 *p = Heap::null_value(); 422 *p = Heap::null_value();
395 pointers_removed_++; 423 pointers_removed_++;
396 } 424 }
397 } 425 }
398 } 426 }
399 427
400 int PointersRemoved() { 428 int PointersRemoved() {
401 return pointers_removed_; 429 return pointers_removed_;
402 } 430 }
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 1755
1728 void MarkCompactCollector::RebuildRSets() { 1756 void MarkCompactCollector::RebuildRSets() {
1729 #ifdef DEBUG 1757 #ifdef DEBUG
1730 ASSERT(state_ == RELOCATE_OBJECTS); 1758 ASSERT(state_ == RELOCATE_OBJECTS);
1731 state_ = REBUILD_RSETS; 1759 state_ = REBUILD_RSETS;
1732 #endif 1760 #endif
1733 Heap::RebuildRSets(); 1761 Heap::RebuildRSets();
1734 } 1762 }
1735 1763
1736 } } // namespace v8::internal 1764 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698