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

Unified Diff: test/cctest/test-mementos.cc

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 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 | « test/cctest/test-mark-compact.cc ('k') | test/cctest/test-microtask-delivery.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-mementos.cc
diff --git a/test/cctest/test-ast.cc b/test/cctest/test-mementos.cc
similarity index 50%
copy from test/cctest/test-ast.cc
copy to test/cctest/test-mementos.cc
index 299f2a896086d58f479a4eb6269eb349954d34e6..9662effa50fdff501aa52add25fc7f3472554f1d 100644
--- a/test/cctest/test-ast.cc
+++ b/test/cctest/test-mementos.cc
@@ -1,4 +1,4 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
+// Copyright 2014 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,36 +25,55 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
-
-#include "v8.h"
-
-#include "ast.h"
#include "cctest.h"
using namespace v8::internal;
-TEST(List) {
- v8::internal::V8::Initialize(NULL);
- List<AstNode*>* list = new List<AstNode*>(0);
- CHECK_EQ(0, list->length());
+static void SetUpNewSpaceWithPoisonedMementoAtTop() {
Isolate* isolate = CcTest::i_isolate();
- Zone zone(isolate);
- AstNodeFactory<AstNullVisitor> factory(isolate, &zone);
- AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition);
- list->Add(node);
- CHECK_EQ(1, list->length());
- CHECK_EQ(node, list->at(0));
- CHECK_EQ(node, list->last());
-
- const int kElements = 100;
- for (int i = 0; i < kElements; i++) {
- list->Add(node);
- }
- CHECK_EQ(1 + kElements, list->length());
-
- list->Clear();
- CHECK_EQ(0, list->length());
- delete list;
+ Heap* heap = isolate->heap();
+ NewSpace* new_space = heap->new_space();
+
+ // Make sure we can allocate some objects without causing a GC later.
+ heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+
+ // Allocate a string, the GC may suspect a memento behind the string.
+ Handle<SeqOneByteString> string = isolate->factory()->NewRawOneByteString(12);
+ CHECK(*string);
+
+ // Create an allocation memento behind the string with a garbage allocation
+ // site pointer.
+ AllocationMemento* memento =
+ reinterpret_cast<AllocationMemento*>(new_space->top() + kHeapObjectTag);
+ memento->set_map_no_write_barrier(heap->allocation_memento_map());
+ memento->set_allocation_site(
+ reinterpret_cast<AllocationSite*>(kHeapObjectTag), SKIP_WRITE_BARRIER);
+}
+
+
+TEST(Regress340063) {
+ CcTest::InitializeVM();
+ if (!i::FLAG_allocation_site_pretenuring) return;
+ v8::HandleScope scope(CcTest::isolate());
+
+
+ SetUpNewSpaceWithPoisonedMementoAtTop();
+
+ // Call GC to see if we can handle a poisonous memento right after the
+ // current new space top pointer.
+ CcTest::i_isolate()->heap()->CollectAllGarbage(
+ Heap::kAbortIncrementalMarkingMask);
+}
+
+
+TEST(BadMementoAfterTopForceScavenge) {
+ CcTest::InitializeVM();
+ if (!i::FLAG_allocation_site_pretenuring) return;
+ v8::HandleScope scope(CcTest::isolate());
+
+ SetUpNewSpaceWithPoisonedMementoAtTop();
+
+ // Force GC to test the poisoned memento handling
+ CcTest::i_isolate()->heap()->CollectGarbage(i::NEW_SPACE);
}
« no previous file with comments | « test/cctest/test-mark-compact.cc ('k') | test/cctest/test-microtask-delivery.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698