Reviewers: Yang,

Description:
Regression test for existing bug in String::MakeExternal.

[email protected]

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

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

Affected files:
  M test/cctest/cctest.status
  M test/cctest/test-api.cc


Index: test/cctest/cctest.status
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index 0d3ff150c6f2f3d25896ea1eab87e2d41d811fd5..d58d70798a6d3028070ba4e8a1548c7449cdce37 100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -42,6 +42,9 @@ test-serialize/DependentTestThatAlwaysFails: FAIL
# This test always fails. It tests that LiveEdit causes abort when turned off.
 test-debug/LiveEditDisabled: FAIL

+# TODO(yangguo,mstarzinger): Fix bug in String::MakeExternal.
+test-api/MakingExternalUnalignedAsciiString: PASS || CRASH
+
 # TODO(gc): Temporarily disabled in the GC branch.
 test-log/EquivalenceOfLoggingAndTraversal: PASS || FAIL

Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 3895e524f4b2736486c665b949338043bdb6f376..724eb6a2fc2793f10fa8fbf341d0f67c6e42b316 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -621,6 +621,33 @@ TEST(MakingExternalAsciiStringConditions) {
 }


+TEST(MakingExternalUnalignedAsciiString) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+
+  // Create a cons string that will land in old pointer space.
+  Local<String> string = Local<String>::Cast(CompileRun(
+      "function cons(a, b) { return a + b; }"
+      "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
+
+  // Trigger GCs so that the newly allocated string moves to old gen.
+  SimulateFullSpace(HEAP->old_pointer_space());
+  HEAP->CollectGarbage(i::NEW_SPACE);  // in survivor space now
+  HEAP->CollectGarbage(i::NEW_SPACE);  // in old gen now
+
+  // Turn into external string with unaligned resource data.
+  int dispose_count = 0;
+  const char* c_source = "_abcdefghijklmnopqrstuvwxyz";
+  bool success = string->MakeExternal(
+      new TestAsciiResource(i::StrDup(c_source) + 1, &dispose_count));
+  CHECK(success);
+
+  // Trigger GCs and force evacuation.
+  HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
+  HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
+}
+
+
 THREADED_TEST(UsingExternalString) {
   i::Factory* factory = i::Isolate::Current()->factory();
   {


--
--
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/groups/opt_out.


Reply via email to