Reviewers: Kasper Lund, Description: If an external string enters the symbol table, make sure to set the resource to NULL when removing it from the symbol table. This makes sure that the debugger can recognize the external string as being "deleted". Now, whenever an external resource is deleted, the resource pointer is set to NULL.
This is really a workaround of a debugger problem. We need to make sure that the debugger only finds scripts in the heap that are actually live. Please review this at http://codereview.chromium.org/69029 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/mark-compact.cc M src/objects-inl.h M src/objects.cc M src/runtime.cc Index: src/objects.cc =================================================================== --- src/objects.cc (revision 1724) +++ src/objects.cc (working copy) @@ -3593,7 +3593,7 @@ while (chars_read < max_chars) { uint16_t c = data[offset]; if (c <= kMaxAsciiCharCode) { - // Fast case for ASCII characters. Cursor is an input output argument. + // Fast case for ASCII characters. Cursor is an input output argument. if (!unibrow::CharacterStream::EncodeAsciiCharacter(c, rbb->util_buffer, rbb->capacity, Index: src/runtime.cc =================================================================== --- src/runtime.cc (revision 1724) +++ src/runtime.cc (working copy) @@ -6525,9 +6525,9 @@ return true; } if (StringShape(String::cast(str)).IsAsciiRepresentation()) { - return ExternalAsciiString::cast(str)->resource() != 0; + return ExternalAsciiString::cast(str)->resource() != NULL; } else if (StringShape(String::cast(str)).IsTwoByteRepresentation()) { - return ExternalTwoByteString::cast(str)->resource() != 0; + return ExternalTwoByteString::cast(str)->resource() != NULL; } else { return true; } Index: src/objects-inl.h =================================================================== --- src/objects-inl.h (revision 1724) +++ src/objects-inl.h (working copy) @@ -263,8 +263,7 @@ bool StringShape::IsSequentialTwoByte() { - return (type_ & (kStringRepresentationMask | kStringEncodingMask)) == - (kSeqStringTag | kTwoByteStringTag); + return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag); } @@ -274,8 +273,7 @@ bool StringShape::IsExternalTwoByte() { - return (type_ & (kStringRepresentationMask | kStringEncodingMask)) == - (kExternalStringTag | kTwoByteStringTag); + return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); } Index: src/mark-compact.cc =================================================================== --- src/mark-compact.cc (revision 1724) +++ src/mark-compact.cc (working copy) @@ -404,15 +404,19 @@ ExternalString::kResourceOffset - kHeapObjectTag; if (is_two_byte) { - v8::String::ExternalStringResource* resource = - *reinterpret_cast<v8::String::ExternalStringResource**> + v8::String::ExternalStringResource** resource = + reinterpret_cast<v8::String::ExternalStringResource**> (resource_addr); - delete resource; + delete *resource; + // Clear the resource pointer in the symbol. + *resource = NULL; } else { - v8::String::ExternalAsciiStringResource* resource = - *reinterpret_cast<v8::String::ExternalAsciiStringResource**> + v8::String::ExternalAsciiStringResource** resource = + reinterpret_cast<v8::String::ExternalAsciiStringResource**> (resource_addr); - delete resource; + delete *resource; + // Clear the resource pointer in the symbol. + *resource = NULL; } } // Set the entry to null_value (as deleted). --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
