Fix assertion failure caused by external strings.

This fixes two issues:
- Update externalize-string-extension to the behavior of the API (see r18285)
- Convert cons strings in old pointer space to short external strings as
  expected by Heap::AllowedToBeMigrated, regardless of alignment.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/189663011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19755 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-03-10 12:08:17 +00:00
parent 710ee827b5
commit b2134319e0
2 changed files with 8 additions and 10 deletions

View File

@ -107,7 +107,7 @@ void ExternalizeStringExtension::Externalize(
SimpleAsciiStringResource* resource = new SimpleAsciiStringResource( SimpleAsciiStringResource* resource = new SimpleAsciiStringResource(
reinterpret_cast<char*>(data), string->length()); reinterpret_cast<char*>(data), string->length());
result = string->MakeExternal(resource); result = string->MakeExternal(resource);
if (result && !string->IsInternalizedString()) { if (result) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
isolate->heap()->external_string_table()->AddString(*string); isolate->heap()->external_string_table()->AddString(*string);
} }
@ -118,7 +118,7 @@ void ExternalizeStringExtension::Externalize(
SimpleTwoByteStringResource* resource = new SimpleTwoByteStringResource( SimpleTwoByteStringResource* resource = new SimpleTwoByteStringResource(
data, string->length()); data, string->length());
result = string->MakeExternal(resource); result = string->MakeExternal(resource);
if (result && !string->IsInternalizedString()) { if (result) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
isolate->heap()->external_string_table()->AddString(*string); isolate->heap()->external_string_table()->AddString(*string);
} }

View File

@ -1280,14 +1280,13 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
// - the space the existing string occupies is too small for a regular // - the space the existing string occupies is too small for a regular
// external string. // external string.
// - the existing string is in old pointer space and the backing store of // - the existing string is in old pointer space and the backing store of
// the external string is not aligned. The GC cannot deal with fields // the external string is not aligned. The GC cannot deal with a field
// containing an unaligned address that points to outside of V8's heap. // containing a possibly unaligned address to outside of V8's heap.
// In either case we resort to a short external string instead, omitting // In either case we resort to a short external string instead, omitting
// the field caching the address of the backing store. When we encounter // the field caching the address of the backing store. When we encounter
// short external strings in generated code, we need to bailout to runtime. // short external strings in generated code, we need to bailout to runtime.
if (size < ExternalString::kSize || if (size < ExternalString::kSize ||
(!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) && heap->old_pointer_space()->Contains(this)) {
heap->old_pointer_space()->Contains(this))) {
this->set_map_no_write_barrier( this->set_map_no_write_barrier(
is_internalized is_internalized
? (is_ascii ? (is_ascii
@ -1351,14 +1350,13 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
// - the space the existing string occupies is too small for a regular // - the space the existing string occupies is too small for a regular
// external string. // external string.
// - the existing string is in old pointer space and the backing store of // - the existing string is in old pointer space and the backing store of
// the external string is not aligned. The GC cannot deal with fields // the external string is not aligned. The GC cannot deal with a field
// containing an unaligned address that points to outside of V8's heap. // containing a possibly unaligned address to outside of V8's heap.
// In either case we resort to a short external string instead, omitting // In either case we resort to a short external string instead, omitting
// the field caching the address of the backing store. When we encounter // the field caching the address of the backing store. When we encounter
// short external strings in generated code, we need to bailout to runtime. // short external strings in generated code, we need to bailout to runtime.
if (size < ExternalString::kSize || if (size < ExternalString::kSize ||
(!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) && heap->old_pointer_space()->Contains(this)) {
heap->old_pointer_space()->Contains(this))) {
this->set_map_no_write_barrier( this->set_map_no_write_barrier(
is_internalized ? heap->short_external_ascii_internalized_string_map() is_internalized ? heap->short_external_ascii_internalized_string_map()
: heap->short_external_ascii_string_map()); : heap->short_external_ascii_string_map());