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

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

Issue 555072: Merge ObjectIterator::has_next and ObjectIterator::next methods.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/spaces-inl.h ('k') | test/cctest/test-debug.cc » ('j') | 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 6218 matching lines...) Expand 10 before | Expand all | Expand 10 after
6229 env->Global()->Set(v8_str("unlock_for_a_moment"), fun); 6229 env->Global()->Set(v8_str("unlock_for_a_moment"), fun);
6230 Local<Script> script = v8_compile("(function () {" 6230 Local<Script> script = v8_compile("(function () {"
6231 " unlock_for_a_moment();" 6231 " unlock_for_a_moment();"
6232 " return 42;" 6232 " return 42;"
6233 "})();"); 6233 "})();");
6234 CHECK_EQ(42, script->Run()->Int32Value()); 6234 CHECK_EQ(42, script->Run()->Int32Value());
6235 } 6235 }
6236 } 6236 }
6237 6237
6238 6238
6239 static int GetGlobalObjectsCount() {
6240 int count = 0;
6241 v8::internal::HeapIterator it;
6242 for (i::HeapObject* object = it.next(); object != NULL; object = it.next())
6243 if (object->IsJSGlobalObject()) count++;
6244 return count;
6245 }
6246
6247
6239 static int GetSurvivingGlobalObjectsCount() { 6248 static int GetSurvivingGlobalObjectsCount() {
6240 int count = 0;
6241 // We need to collect all garbage twice to be sure that everything 6249 // We need to collect all garbage twice to be sure that everything
6242 // has been collected. This is because inline caches are cleared in 6250 // has been collected. This is because inline caches are cleared in
6243 // the first garbage collection but some of the maps have already 6251 // the first garbage collection but some of the maps have already
6244 // been marked at that point. Therefore some of the maps are not 6252 // been marked at that point. Therefore some of the maps are not
6245 // collected until the second garbage collection. 6253 // collected until the second garbage collection.
6246 v8::internal::Heap::CollectAllGarbage(false); 6254 v8::internal::Heap::CollectAllGarbage(false);
6247 v8::internal::Heap::CollectAllGarbage(false); 6255 v8::internal::Heap::CollectAllGarbage(false);
6248 v8::internal::HeapIterator it; 6256 int count = GetGlobalObjectsCount();
6249 while (it.has_next()) {
6250 v8::internal::HeapObject* object = it.next();
6251 if (object->IsJSGlobalObject()) {
6252 count++;
6253 }
6254 }
6255 #ifdef DEBUG 6257 #ifdef DEBUG
6256 if (count > 0) v8::internal::Heap::TracePathToGlobal(); 6258 if (count > 0) v8::internal::Heap::TracePathToGlobal();
6257 #endif 6259 #endif
6258 return count; 6260 return count;
6259 } 6261 }
6260 6262
6261 6263
6262 TEST(DontLeakGlobalObjects) { 6264 TEST(DontLeakGlobalObjects) {
6263 // Regression test for issues 1139850 and 1174891. 6265 // Regression test for issues 1139850 and 1174891.
6264 6266
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
8614 " }" 8616 " }"
8615 " }" 8617 " }"
8616 "};" 8618 "};"
8617 "s(o);"); 8619 "s(o);");
8618 CHECK(try_catch.HasCaught()); 8620 CHECK(try_catch.HasCaught());
8619 v8::String::Utf8Value value(try_catch.Exception()); 8621 v8::String::Utf8Value value(try_catch.Exception());
8620 CHECK_EQ(0, strcmp(*value, "Hey!")); 8622 CHECK_EQ(0, strcmp(*value, "Hey!"));
8621 } 8623 }
8622 8624
8623 8625
8624 static int GetGlobalObjectsCount() {
8625 int count = 0;
8626 v8::internal::HeapIterator it;
8627 while (it.has_next()) {
8628 v8::internal::HeapObject* object = it.next();
8629 if (object->IsJSGlobalObject()) count++;
8630 }
8631 return count;
8632 }
8633
8634
8635 TEST(Regress528) { 8626 TEST(Regress528) {
8636 v8::V8::Initialize(); 8627 v8::V8::Initialize();
8637 8628
8638 v8::HandleScope scope; 8629 v8::HandleScope scope;
8639 v8::Persistent<Context> context; 8630 v8::Persistent<Context> context;
8640 v8::Persistent<Context> other_context; 8631 v8::Persistent<Context> other_context;
8641 int gc_count; 8632 int gc_count;
8642 8633
8643 // Create a context used to keep the code from aging in the compilation 8634 // Create a context used to keep the code from aging in the compilation
8644 // cache. 8635 // cache.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
8712 CompileRun(source_exception); 8703 CompileRun(source_exception);
8713 other_context->Exit(); 8704 other_context->Exit();
8714 v8::internal::Heap::CollectAllGarbage(false); 8705 v8::internal::Heap::CollectAllGarbage(false);
8715 if (GetGlobalObjectsCount() == 1) break; 8706 if (GetGlobalObjectsCount() == 1) break;
8716 } 8707 }
8717 CHECK_GE(2, gc_count); 8708 CHECK_GE(2, gc_count);
8718 CHECK_EQ(1, GetGlobalObjectsCount()); 8709 CHECK_EQ(1, GetGlobalObjectsCount());
8719 8710
8720 other_context.Dispose(); 8711 other_context.Dispose();
8721 } 8712 }
OLDNEW
« no previous file with comments | « src/spaces-inl.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698