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

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

Issue 117483002: Make cells pointing to JSObjects weak in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Set number of gcs to 4 Created 6 years, 11 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/objects-visiting-inl.h ('k') | tools/v8heapconst.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index fa7ef48ebdbf0882a4ed0adf5de6ab1348d7626a..198c6df8a37734182c765c822e3d0c28c18c7862 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -3664,3 +3664,87 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) {
int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup);
CHECK(!(site->dependent_code()->is_code_at(index)));
}
+
+
+TEST(CellsInOptimizedCodeAreWeak) {
+ if (i::FLAG_always_opt || !i::FLAG_crankshaft) 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("bar = (function() {"
+ " function bar() {"
+ " return foo(1);"
+ " };"
+ " var foo = function(x) { with (x) { return 1 + x; } };"
+ " bar(foo);"
+ " bar(foo);"
+ " bar(foo);"
+ " %OptimizeFunctionOnNextCall(bar);"
+ " bar(foo);"
+ " return bar;})();");
+
+ Handle<JSFunction> bar =
+ v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(
+ CcTest::global()->Get(v8_str("bar"))));
+ 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(Heap::kAbortIncrementalMarkingMask);
+ }
+
+ ASSERT(code->marked_for_deoptimization());
+}
+
+
+TEST(ObjectsInOptimizedCodeAreWeak) {
+ if (i::FLAG_always_opt || !i::FLAG_crankshaft) 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("function bar() {"
+ " return foo(1);"
+ "};"
+ "function foo(x) { with (x) { return 1 + x; } };"
+ "bar();"
+ "bar();"
+ "bar();"
+ "%OptimizeFunctionOnNextCall(bar);"
+ "bar();");
+
+ Handle<JSFunction> bar =
+ v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(
+ CcTest::global()->Get(v8_str("bar"))));
+ 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(Heap::kAbortIncrementalMarkingMask);
+ }
+
+ ASSERT(code->marked_for_deoptimization());
+}
« no previous file with comments | « src/objects-visiting-inl.h ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698