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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mark-compact.cc
===================================================================
--- src/mark-compact.cc (revision 1251)
+++ src/mark-compact.cc (working copy)
@@ -390,6 +390,34 @@
// Visit all HeapObject pointers in [start, end).
for (Object** p = start; p < end; p++) {
if ((*p)->IsHeapObject() && !HeapObject::cast(*p)->IsMarked()) {
+ // Check if the symbol being pruned is an external symbol. We need to
+ // delete the associated external data as this symbol is going away.
+
+ // Since the object is not marked we can access its map word safely
+ // without having to worry about marking bits in the object header.
+ Map* map = HeapObject::cast(*p)->map();
+ // Since no objects have yet been moved we can safely access the map of
+ // the object.
+ uint32_t type = map->instance_type();
+ bool is_external = (type & kStringRepresentationMask) ==
+ kExternalStringTag;
+ if (is_external) {
+ bool is_two_byte = (type & kStringEncodingMask) == kTwoByteStringTag;
+ byte* resource_addr = reinterpret_cast<byte*>(*p) +
+ ExternalString::kResourceOffset -
+ kHeapObjectTag;
+ if (is_two_byte) {
+ v8::String::ExternalStringResource* resource =
+ *reinterpret_cast<v8::String::ExternalStringResource**>
+ (resource_addr);
+ delete resource;
+ } else {
+ v8::String::ExternalAsciiStringResource* resource =
+ *reinterpret_cast<v8::String::ExternalAsciiStringResource**>
+ (resource_addr);
+ delete resource;
+ }
+ }
// Set the entry to null_value (as deleted).
*p = Heap::null_value();
pointers_removed_++;
« 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