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

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

Issue 284773004: Skip write barriers when updating the weak hash table. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 years, 7 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 | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 22 matching lines...) Expand all
33 #include "compilation-cache.h" 33 #include "compilation-cache.h"
34 #include "execution.h" 34 #include "execution.h"
35 #include "factory.h" 35 #include "factory.h"
36 #include "macro-assembler.h" 36 #include "macro-assembler.h"
37 #include "global-handles.h" 37 #include "global-handles.h"
38 #include "stub-cache.h" 38 #include "stub-cache.h"
39 #include "cctest.h" 39 #include "cctest.h"
40 40
41 using namespace v8::internal; 41 using namespace v8::internal;
42 42
43
44 // Go through all incremental marking steps in one swoop. 43 // Go through all incremental marking steps in one swoop.
45 static void SimulateIncrementalMarking() { 44 static void SimulateIncrementalMarking() {
46 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); 45 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
47 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 46 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
48 if (collector->IsConcurrentSweepingInProgress()) { 47 if (collector->IsConcurrentSweepingInProgress()) {
49 collector->WaitUntilSweepingCompleted(); 48 collector->WaitUntilSweepingCompleted();
50 } 49 }
51 CHECK(marking->IsMarking() || marking->IsStopped()); 50 CHECK(marking->IsMarking() || marking->IsStopped());
52 if (marking->IsStopped()) { 51 if (marking->IsStopped()) {
53 marking->Start(); 52 marking->Start();
(...skipping 3827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 3880
3882 // Now make sure that a gc should get rid of the function 3881 // Now make sure that a gc should get rid of the function
3883 for (int i = 0; i < 4; i++) { 3882 for (int i = 0; i < 4; i++) {
3884 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 3883 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
3885 } 3884 }
3886 3885
3887 ASSERT(code->marked_for_deoptimization()); 3886 ASSERT(code->marked_for_deoptimization());
3888 } 3887 }
3889 3888
3890 3889
3890 TEST(NoWeakHashTableLeakWithIncrementalMarking) {
3891 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
3892 if (!i::FLAG_incremental_marking) return;
3893 i::FLAG_weak_embedded_objects_in_optimized_code = true;
3894 i::FLAG_allow_natives_syntax = true;
3895 i::FLAG_compilation_cache = false;
3896 CcTest::InitializeVM();
3897 Isolate* isolate = CcTest::i_isolate();
3898 v8::internal::Heap* heap = CcTest::heap();
3899
3900 if (!isolate->use_crankshaft()) return;
3901 HandleScope outer_scope(heap->isolate());
3902 for (int i = 0; i < 3; i++) {
3903 SimulateIncrementalMarking();
3904 {
3905 LocalContext context;
3906 HandleScope scope(heap->isolate());
3907 EmbeddedVector<char, 256> source;
3908 OS::SNPrintF(source,
3909 "function bar%d() {"
3910 " return foo%d(1);"
3911 "};"
3912 "function foo%d(x) { with (x) { return 1 + x; } };"
3913 "bar%d();"
3914 "bar%d();"
3915 "bar%d();"
3916 "%OptimizeFunctionOnNextCall(bar%d);"
3917 "bar%d();", i, i, i, i, i, i, i, i);
3918 CompileRun(source.start());
3919 }
3920 heap->CollectAllGarbage(i::Heap::kNoGCFlags);
3921 }
3922 WeakHashTable* table = WeakHashTable::cast(heap->weak_object_to_code_table());
3923 CHECK_EQ(0, table->NumberOfElements());
3924 }
3925
3891 3926
3892 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { 3927 static Handle<JSFunction> OptimizeDummyFunction(const char* name) {
3893 EmbeddedVector<char, 256> source; 3928 EmbeddedVector<char, 256> source;
3894 OS::SNPrintF(source, 3929 OS::SNPrintF(source,
3895 "function %s() { return 0; }" 3930 "function %s() { return 0; }"
3896 "%s(); %s();" 3931 "%s(); %s();"
3897 "%%OptimizeFunctionOnNextCall(%s);" 3932 "%%OptimizeFunctionOnNextCall(%s);"
3898 "%s();", name, name, name, name, name); 3933 "%s();", name, name, name, name, name);
3899 CompileRun(source.start()); 3934 CompileRun(source.start());
3900 Handle<JSFunction> fun = 3935 Handle<JSFunction> fun =
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
4205 "array;"); 4240 "array;");
4206 4241
4207 Handle<JSObject> o = 4242 Handle<JSObject> o =
4208 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 4243 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
4209 CHECK(heap->InOldPointerSpace(o->elements())); 4244 CHECK(heap->InOldPointerSpace(o->elements()));
4210 CHECK(heap->InOldPointerSpace(*o)); 4245 CHECK(heap->InOldPointerSpace(*o));
4211 Page* page = Page::FromAddress(o->elements()->address()); 4246 Page* page = Page::FromAddress(o->elements()->address());
4212 CHECK(page->WasSwept() || 4247 CHECK(page->WasSwept() ||
4213 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); 4248 Marking::IsBlack(Marking::MarkBitFrom(o->elements())));
4214 } 4249 }
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698