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

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

Issue 174141: Do not finish GlobalHandles::PostGarbageCollectionProcessing if weak callback... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« src/heap.cc ('K') | « src/heap.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 6228 matching lines...) Expand 10 before | Expand all | Expand 10 after
6239 // Note: order is implementation dependent alas: currently 6239 // Note: order is implementation dependent alas: currently
6240 // global handle nodes are processed by PostGarbageCollectionProcessing 6240 // global handle nodes are processed by PostGarbageCollectionProcessing
6241 // in reverse allocation order, so if second allocated handle is deleted, 6241 // in reverse allocation order, so if second allocated handle is deleted,
6242 // weak callback of the first handle would be able to 'reallocate' it. 6242 // weak callback of the first handle would be able to 'reallocate' it.
6243 handle1.MakeWeak(NULL, NewPersistentHandleCallback); 6243 handle1.MakeWeak(NULL, NewPersistentHandleCallback);
6244 handle2.Dispose(); 6244 handle2.Dispose();
6245 i::Heap::CollectAllGarbage(); 6245 i::Heap::CollectAllGarbage();
6246 } 6246 }
6247 6247
6248 6248
6249 v8::Persistent<v8::Object> to_be_disposed;
6250
6251 void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) {
6252 to_be_disposed.Dispose();
6253 i::Heap::CollectAllGarbage();
6254 }
6255
6256
6257 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
6258 LocalContext context;
6259
6260 v8::Persistent<v8::Object> handle1, handle2;
6261 {
6262 v8::HandleScope scope;
6263 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
6264 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
6265 }
6266 handle1.MakeWeak(NULL, DisposeAndForceGcCallback);
6267 to_be_disposed = handle2;
6268 i::Heap::CollectAllGarbage();
6269 }
6270
6271
6249 THREADED_TEST(CheckForCrossContextObjectLiterals) { 6272 THREADED_TEST(CheckForCrossContextObjectLiterals) {
6250 v8::V8::Initialize(); 6273 v8::V8::Initialize();
6251 6274
6252 const int nof = 2; 6275 const int nof = 2;
6253 const char* sources[nof] = { 6276 const char* sources[nof] = {
6254 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", 6277 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }",
6255 "Object()" 6278 "Object()"
6256 }; 6279 };
6257 6280
6258 for (int i = 0; i < nof; i++) { 6281 for (int i = 0; i < nof; i++) {
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
7788 LocalContext context; 7811 LocalContext context;
7789 v8::TryCatch try_catch; 7812 v8::TryCatch try_catch;
7790 const char *source = "function foo() { FAIL.FAIL; }; foo();"; 7813 const char *source = "function foo() { FAIL.FAIL; }; foo();";
7791 v8::Handle<v8::String> src = v8::String::New(source); 7814 v8::Handle<v8::String> src = v8::String::New(source);
7792 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test"); 7815 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test");
7793 v8::Script::New(src, origin)->Run(); 7816 v8::Script::New(src, origin)->Run();
7794 CHECK(try_catch.HasCaught()); 7817 CHECK(try_catch.HasCaught());
7795 v8::String::Utf8Value stack(try_catch.StackTrace()); 7818 v8::String::Utf8Value stack(try_catch.StackTrace());
7796 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); 7819 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL);
7797 } 7820 }
OLDNEW
« src/heap.cc ('K') | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698