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

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

Issue 2045263002: [heap] Avoid the use of cells to point from code to new-space objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: The IsSmi check in mov(HeapObject) lets some tests fail. Created 4 years, 6 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 | « src/x87/assembler-x87-inl.h ('k') | test/cctest/test-serialize.cc » ('j') | 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 524a553a151a5326bdc7b0aaa0305a6feaf4107b..ab7ae8ac3b8561c9a93c9410800f5001665c48c1 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -4817,6 +4817,67 @@ TEST(ObjectsInOptimizedCodeAreWeak) {
CHECK(code->marked_for_deoptimization());
}
+TEST(NewSpaceObjectsInOptimizedCode) {
+ if (i::FLAG_always_opt || !i::FLAG_crankshaft || i::FLAG_turbo) return;
+ i::FLAG_weak_embedded_objects_in_optimized_code = true;
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ v8::internal::Heap* heap = CcTest::heap();
+
+ if (!isolate->use_crankshaft()) return;
+ HandleScope outer_scope(heap->isolate());
+ Handle<Code> code;
+ {
+ LocalContext context;
+ HandleScope scope(heap->isolate());
+
+ CompileRun(
+ "var foo;"
+ "var bar;"
+ "(function() {"
+ " function foo_func(x) { with (x) { return 1 + x; } };"
+ " %NeverOptimizeFunction(foo_func);"
+ " function bar_func() {"
+ " return foo(1);"
+ " };"
+ " bar = bar_func;"
+ " foo = foo_func;"
+ " bar_func();"
+ " bar_func();"
+ " bar_func();"
+ " %OptimizeFunctionOnNextCall(bar_func);"
+ " bar_func();"
+ "})();");
+
+ Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("bar"))
+ .ToLocalChecked())));
+
+ Handle<JSFunction> foo = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("foo"))
+ .ToLocalChecked())));
+
+ CHECK(heap->InNewSpace(*foo));
+ heap->CollectGarbage(NEW_SPACE);
+ heap->CollectGarbage(NEW_SPACE);
+ CHECK(!heap->InNewSpace(*foo));
+#ifdef VERIFY_HEAP
+ heap->Verify();
+#endif
+ CHECK(!bar->code()->marked_for_deoptimization());
+ code = scope.CloseAndEscape(Handle<Code>(bar->code()));
+ }
+
+ // Now make sure that a gc should get rid of the function
+ for (int i = 0; i < 4; i++) {
+ heap->CollectAllGarbage();
+ }
+
+ CHECK(code->marked_for_deoptimization());
+}
TEST(NoWeakHashTableLeakWithIncrementalMarking) {
if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
« no previous file with comments | « src/x87/assembler-x87-inl.h ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698