aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-mementos.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-03-31 14:38:28 +0200
committerFedor Indutny <fedor@indutny.com>2014-04-02 00:05:24 +0400
commit67e078094b53861a5aa7e9354e33487d0bd4f73b (patch)
tree09a706adee1ddb59c1507ee3320de9cb6896135b /deps/v8/test/cctest/test-mementos.cc
parentf984555d47298cfb01b3e55c2861066379306fc3 (diff)
downloadandroid-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.tar.gz
android-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.tar.bz2
android-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.zip
deps: upgrade v8 to 3.25.30
Diffstat (limited to 'deps/v8/test/cctest/test-mementos.cc')
-rw-r--r--deps/v8/test/cctest/test-mementos.cc74
1 files changed, 69 insertions, 5 deletions
diff --git a/deps/v8/test/cctest/test-mementos.cc b/deps/v8/test/cctest/test-mementos.cc
index f59eef9485..1dc38f9af5 100644
--- a/deps/v8/test/cctest/test-mementos.cc
+++ b/deps/v8/test/cctest/test-mementos.cc
@@ -29,11 +29,8 @@
using namespace v8::internal;
-TEST(Regress340063) {
- CcTest::InitializeVM();
- if (!i::FLAG_allocation_site_pretenuring) return;
- v8::HandleScope scope(CcTest::isolate());
+static void SetUpNewSpaceWithPoisonedMementoAtTop() {
Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap();
NewSpace* new_space = heap->new_space();
@@ -52,8 +49,75 @@ TEST(Regress340063) {
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.
- heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ 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);
+}
+
+
+TEST(PretenuringCallNew) {
+ CcTest::InitializeVM();
+ if (!i::FLAG_allocation_site_pretenuring) return;
+ if (!i::FLAG_pretenuring_call_new) return;
+
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+
+ // We need to create several instances to get past the slack-tracking
+ // phase, where mementos aren't emitted.
+ int call_count = 10;
+ CHECK_GE(call_count, SharedFunctionInfo::kGenerousAllocationCount);
+ i::ScopedVector<char> test_buf(1024);
+ const char* program =
+ "function f() {"
+ " this.a = 3;"
+ " this.b = {};"
+ " return this;"
+ "};"
+ "var a;"
+ "for(var i = 0; i < %d; i++) {"
+ " a = new f();"
+ "}"
+ "a;";
+ i::OS::SNPrintF(test_buf, program, call_count);
+ v8::Local<v8::Value> res = CompileRun(test_buf.start());
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+
+ // The object of class f should have a memento secreted behind it.
+ Address memento_address = o->address() + o->map()->instance_size();
+ AllocationMemento* memento =
+ reinterpret_cast<AllocationMemento*>(memento_address + kHeapObjectTag);
+ CHECK_EQ(memento->map(), heap->allocation_memento_map());
+
+ // Furthermore, how many mementos did we create? The count should match
+ // call_count - SharedFunctionInfo::kGenerousAllocationCount.
+ AllocationSite* site = memento->GetAllocationSite();
+ CHECK_EQ(call_count - SharedFunctionInfo::kGenerousAllocationCount,
+ site->pretenure_create_count()->value());
}