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

Side by Side Diff: test/cctest/test-mementos.cc

Issue 132963012: Pretenure call new support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/allocation-site-info.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 TEST(BadMementoAfterTopForceScavenge) { 70 TEST(BadMementoAfterTopForceScavenge) {
71 CcTest::InitializeVM(); 71 CcTest::InitializeVM();
72 if (!i::FLAG_allocation_site_pretenuring) return; 72 if (!i::FLAG_allocation_site_pretenuring) return;
73 v8::HandleScope scope(CcTest::isolate()); 73 v8::HandleScope scope(CcTest::isolate());
74 74
75 SetUpNewSpaceWithPoisonedMementoAtTop(); 75 SetUpNewSpaceWithPoisonedMementoAtTop();
76 76
77 // Force GC to test the poisoned memento handling 77 // Force GC to test the poisoned memento handling
78 CcTest::i_isolate()->heap()->CollectGarbage(i::NEW_SPACE); 78 CcTest::i_isolate()->heap()->CollectGarbage(i::NEW_SPACE);
79 } 79 }
80
81
82 TEST(PretenuringCallNew) {
83 CcTest::InitializeVM();
84 if (!i::FLAG_allocation_site_pretenuring) return;
85 if (!i::FLAG_pretenuring_call_new) return;
86
87 v8::HandleScope scope(CcTest::isolate());
88 Isolate* isolate = CcTest::i_isolate();
89 Heap* heap = isolate->heap();
90
91 // We need to create several instances to get past the slack-tracking
92 // phase, where mementos aren't emitted.
93 int call_count = 10;
94 CHECK_GE(call_count, SharedFunctionInfo::kGenerousAllocationCount);
95 i::ScopedVector<char> test_buf(1024);
96 const char* program =
97 "function f() {"
98 " this.a = 3;"
99 " this.b = {};"
100 " return this;"
101 "};"
102 "var a;"
103 "for(var i = 0; i < %d; i++) {"
104 " a = new f();"
105 "}"
106 "a;";
107 i::OS::SNPrintF(test_buf, program, call_count);
108 v8::Local<v8::Value> res = CompileRun(test_buf.start());
109 Handle<JSObject> o =
110 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
111
112 // The object of class f should have a memento secreted behind it.
113 Address memento_address = o->address() + o->map()->instance_size();
114 AllocationMemento* memento =
115 reinterpret_cast<AllocationMemento*>(memento_address + kHeapObjectTag);
116 CHECK_EQ(memento->map(), heap->allocation_memento_map());
117
118 // Furthermore, how many mementos did we create? The count should match
119 // call_count - SharedFunctionInfo::kGenerousAllocationCount.
120 AllocationSite* site = memento->GetAllocationSite();
121 CHECK_EQ(call_count - SharedFunctionInfo::kGenerousAllocationCount,
122 site->pretenure_create_count()->value());
123 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/allocation-site-info.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698