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

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

Issue 334043: Add a test which verifies that weak reference callbacks cannot be invoked whi... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 | « no previous file | 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 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 "}" 3150 "}"
3151 "gc();" 3151 "gc();"
3152 "4"; 3152 "4";
3153 v8::Handle<Value> result = CompileRun(code); 3153 v8::Handle<Value> result = CompileRun(code);
3154 CHECK_EQ(4.0, result->NumberValue()); 3154 CHECK_EQ(4.0, result->NumberValue());
3155 3155
3156 context.Dispose(); 3156 context.Dispose();
3157 } 3157 }
3158 3158
3159 3159
3160 static bool in_scavenge = false;
3161 static int last = -1;
3162
3163 static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) {
3164 CHECK_EQ(-1, last);
3165 last = 0;
3166 obj.Dispose();
3167 obj.Clear();
3168 in_scavenge = true;
3169 i::Heap::PerformScavenge();
3170 in_scavenge = false;
3171 *(reinterpret_cast<bool*>(data)) = true;
3172 }
3173
3174 static void CheckIsNotInvokedInScavenge(v8::Persistent<v8::Value> obj, void* dat a) {
3175 CHECK_EQ(0, last);
3176 last = 1;
3177 *(reinterpret_cast<bool*>(data)) = in_scavenge;
3178 obj.Dispose();
3179 obj.Clear();
3180 }
3181
3182 THREADED_TEST(NoWeakRefCallbacksInScavenge) {
3183 // Test verifies that scavenge cannot invoke WeakReferenceCallbacks.
3184 v8::Persistent<Context> context = Context::New();
3185 Context::Scope context_scope(context);
3186
3187 v8::Persistent<v8::Object> object_a;
3188 v8::Persistent<v8::Object> object_b;
3189
3190 {
3191 v8::HandleScope handle_scope;
3192 object_b = v8::Persistent<v8::Object>::New(v8::Object::New());
3193 object_a = v8::Persistent<v8::Object>::New(v8::Object::New());
3194 }
3195
3196 bool object_a_disposed = false;
3197 object_a.MakeWeak(&object_a_disposed, &ForceScavenge);
3198 bool released_in_scavenge = false;
3199 object_b.MakeWeak(&released_in_scavenge, &CheckIsNotInvokedInScavenge);
3200
3201 while (!object_a_disposed) {
3202 i::Heap::CollectAllGarbage(false);
3203 }
3204 CHECK(!released_in_scavenge);
3205 }
3206
3207
3160 v8::Handle<Function> args_fun; 3208 v8::Handle<Function> args_fun;
3161 3209
3162 3210
3163 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { 3211 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) {
3164 ApiTestFuzzer::Fuzz(); 3212 ApiTestFuzzer::Fuzz();
3165 CHECK_EQ(args_fun, args.Callee()); 3213 CHECK_EQ(args_fun, args.Callee());
3166 CHECK_EQ(3, args.Length()); 3214 CHECK_EQ(3, args.Length());
3167 CHECK_EQ(v8::Integer::New(1), args[0]); 3215 CHECK_EQ(v8::Integer::New(1), args[0]);
3168 CHECK_EQ(v8::Integer::New(2), args[1]); 3216 CHECK_EQ(v8::Integer::New(2), args[1]);
3169 CHECK_EQ(v8::Integer::New(3), args[2]); 3217 CHECK_EQ(v8::Integer::New(3), args[2]);
(...skipping 5318 matching lines...) Expand 10 before | Expand all | Expand 10 after
8488 THREADED_TEST(GetHeapStatistics) { 8536 THREADED_TEST(GetHeapStatistics) {
8489 v8::HandleScope scope; 8537 v8::HandleScope scope;
8490 LocalContext c1; 8538 LocalContext c1;
8491 v8::HeapStatistics heap_statistics; 8539 v8::HeapStatistics heap_statistics;
8492 CHECK_EQ(heap_statistics.total_heap_size(), 0); 8540 CHECK_EQ(heap_statistics.total_heap_size(), 0);
8493 CHECK_EQ(heap_statistics.used_heap_size(), 0); 8541 CHECK_EQ(heap_statistics.used_heap_size(), 0);
8494 v8::V8::GetHeapStatistics(&heap_statistics); 8542 v8::V8::GetHeapStatistics(&heap_statistics);
8495 CHECK_NE(heap_statistics.total_heap_size(), 0); 8543 CHECK_NE(heap_statistics.total_heap_size(), 0);
8496 CHECK_NE(heap_statistics.used_heap_size(), 0); 8544 CHECK_NE(heap_statistics.used_heap_size(), 0);
8497 } 8545 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698