Reviewers: Hannes Payer,

Message:
Committed patchset #2 (id:20001) manually as 23794 (presubmit successful).

Description:
Turn old space cons strings into regular external strings (not short).

[email protected]
BUG=v8:3530
LOG=N

Committed: https://code.google.com/p/v8/source/detail?r=23794

Please review this at https://codereview.chromium.org/368223002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+30, -20 lines):
  M src/heap/heap-inl.h
  M src/objects.cc
  A test/mjsunit/regress/regress-sliced-external-cons-regexp.js


Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index adb6e25bb710c581d8a6ae7b571b5eddc4732908..0a899d525c991e7715412e3a79a1dbdba284f0ac 100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -461,8 +461,7 @@ bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) {
       return dst == src || dst == TargetSpaceId(type);
     case OLD_POINTER_SPACE:
return dst == src && (dst == TargetSpaceId(type) || obj->IsFiller() | |
-                            (obj->IsExternalString() &&
-                             ExternalString::cast(obj)->is_short()));
+                            obj->IsExternalString());
     case OLD_DATA_SPACE:
       return dst == src && dst == TargetSpaceId(type);
     case CODE_SPACE:
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index ac4982d4fe4088e7fcd90c286b9f9c4c4689d405..2769f7f98f11f8d62efabd0ebe17aaf1048efc62 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1029,18 +1029,13 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
   bool is_internalized = this->IsInternalizedString();

   // Morph the string to an external string by replacing the map and
-  // reinitializing the fields.  This won't work if
-  // - the space the existing string occupies is too small for a regular
-  //   external string.
-  // - the existing string is in old pointer space and the backing store of
-  //   the external string is not aligned.  The GC cannot deal with a field
-  //   containing a possibly unaligned address to outside of V8's heap.
-  // In either case we resort to a short external string instead, omitting
+  // reinitializing the fields.  This won't work if the space the existing
+  // string occupies is too small for a regular  external string.
+  // Instead, we resort to a short external string instead, omitting
   // the field caching the address of the backing store.  When we encounter
// short external strings in generated code, we need to bailout to runtime.
   Map* new_map;
-  if (size < ExternalString::kSize ||
-      heap->old_pointer_space()->Contains(this)) {
+  if (size < ExternalString::kSize) {
     new_map = is_internalized
         ? (is_ascii
             ? heap->
@@ -1103,18 +1098,13 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
   bool is_internalized = this->IsInternalizedString();

   // Morph the string to an external string by replacing the map and
-  // reinitializing the fields.  This won't work if
-  // - the space the existing string occupies is too small for a regular
-  //   external string.
-  // - the existing string is in old pointer space and the backing store of
-  //   the external string is not aligned.  The GC cannot deal with a field
-  //   containing a possibly unaligned address to outside of V8's heap.
-  // In either case we resort to a short external string instead, omitting
+  // reinitializing the fields.  This won't work if the space the existing
+  // string occupies is too small for a regular  external string.
+  // Instead, we resort to a short external string instead, omitting
   // the field caching the address of the backing store.  When we encounter
// short external strings in generated code, we need to bailout to runtime.
   Map* new_map;
-  if (size < ExternalString::kSize ||
-      heap->old_pointer_space()->Contains(this)) {
+  if (size < ExternalString::kSize) {
     new_map = is_internalized
         ? heap->short_external_ascii_internalized_string_map()
         : heap->short_external_ascii_string_map();
Index: test/mjsunit/regress/regress-sliced-external-cons-regexp.js
diff --git a/test/mjsunit/regress/regress-sliced-external-cons-regexp.js b/test/mjsunit/regress/regress-sliced-external-cons-regexp.js
new file mode 100644
index 0000000000000000000000000000000000000000..145c831896a9b1433035de19bfbdd6daa8757b1b
--- /dev/null
+++ b/test/mjsunit/regress/regress-sliced-external-cons-regexp.js
@@ -0,0 +1,21 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-externalize-string --expose-gc
+
+var re = /(B)/;
+var cons1 = "0123456789" + "ABCDEFGHIJ";
+var cons2 = "0123456789\u1234" + "ABCDEFGHIJ";
+gc();
+gc();  // Promote cons.
+
+try { externalizeString(cons1, false); } catch (e) { }
+try { externalizeString(cons2, true); } catch (e) { }
+
+var slice1 = cons1.slice(1,-1);
+var slice2 = cons2.slice(1,-1);
+for (var i = 0; i < 10; i++) {
+  assertEquals(["B", "B"], re.exec(slice1));
+  assertEquals(["B", "B"], re.exec(slice2));
+}


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to