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

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

Issue 2203783002: [heap] Record references in the new code objects in heap::CopyCode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Init tmp pointer to avoid compiler warning Created 4 years, 4 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/heap/heap-tester.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index f76b6ba7a4cde08c7c3a331ebb477b52f2222d9c..d4ebd04898bea1c8e024c534115c3ab52faa6240 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -99,6 +99,48 @@ static void CheckNumber(Isolate* isolate, double value, const char* string) {
CHECK(String::cast(*print_string)->IsUtf8EqualTo(CStrVector(string)));
}
+void CheckEmbeddedObjectsAreEqual(Handle<Code> lhs, Handle<Code> rhs) {
+ int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
+ RelocIterator lhs_it(*lhs, mode_mask);
+ RelocIterator rhs_it(*rhs, mode_mask);
+ while (!lhs_it.done() && !rhs_it.done()) {
+ CHECK(lhs_it.rinfo()->target_object() == rhs_it.rinfo()->target_object());
+
+ lhs_it.next();
+ rhs_it.next();
+ }
+ CHECK(lhs_it.done() == rhs_it.done());
+}
+
+HEAP_TEST(TestNewSpaceRefsInCopiedCode) {
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
+ HandleScope sc(isolate);
+
+ Handle<Object> value = factory->NewNumber(1.000123);
+ CHECK(heap->InNewSpace(*value));
+
+ i::byte buffer[i::Assembler::kMinimalBufferSize];
+ MacroAssembler masm(isolate, buffer, sizeof(buffer),
+ v8::internal::CodeObjectRequired::kYes);
+ // Add a new-space reference to the code.
+ masm.Push(value);
+
+ CodeDesc desc;
+ masm.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+ Code* tmp = nullptr;
+ heap->CopyCode(*code).To(&tmp);
+ Handle<Code> copy(tmp);
+
+ CheckEmbeddedObjectsAreEqual(code, copy);
+ heap->CollectAllAvailableGarbage();
+ CheckEmbeddedObjectsAreEqual(code, copy);
+}
static void CheckFindCodeObject(Isolate* isolate) {
// Test FindCodeObject
« no previous file with comments | « test/cctest/heap/heap-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698