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

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

Issue 1165004: New GCCallbacks with additional parameters. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « 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-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 9938 matching lines...) Expand 10 before | Expand all | Expand 10 after
9949 // This compile will get the code from the compilation cache. 9949 // This compile will get the code from the compilation cache.
9950 CompileRun(source); 9950 CompileRun(source);
9951 9951
9952 script = v8::Script::Compile(v8_str("new C1();")); 9952 script = v8::Script::Compile(v8_str("new C1();"));
9953 for (int i = 0; i < 10; i++) { 9953 for (int i = 0; i < 10; i++) {
9954 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run()); 9954 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
9955 CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value()); 9955 CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value());
9956 CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value()); 9956 CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value());
9957 } 9957 }
9958 } 9958 }
9959
9960 int prologue_call_count = 0;
9961 int epilogue_call_count = 0;
9962 int prologue_call_count_second = 0;
9963 int epilogue_call_count_second = 0;
9964
9965 void PrologueCallback(v8::GCType, v8::GCCallbackFlags) {
9966 ++prologue_call_count;
9967 }
9968
9969 void EpilogueCallback(v8::GCType, v8::GCCallbackFlags) {
9970 ++epilogue_call_count;
9971 }
9972
9973 void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
9974 ++prologue_call_count_second;
9975 }
9976
9977 void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
9978 ++epilogue_call_count_second;
9979 }
9980
9981 TEST(GCCallbacks) {
9982 LocalContext context;
9983
9984 v8::V8::AddGCPrologueCallback(PrologueCallback);
9985 v8::V8::AddGCEpilogueCallback(EpilogueCallback);
9986 CHECK_EQ(0, prologue_call_count);
9987 CHECK_EQ(0, epilogue_call_count);
9988 i::Heap::CollectAllGarbage(false);
9989 CHECK_EQ(1, prologue_call_count);
9990 CHECK_EQ(1, epilogue_call_count);
9991 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond);
9992 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond);
9993 i::Heap::CollectAllGarbage(false);
9994 CHECK_EQ(2, prologue_call_count);
9995 CHECK_EQ(2, epilogue_call_count);
9996 CHECK_EQ(1, prologue_call_count_second);
9997 CHECK_EQ(1, epilogue_call_count_second);
9998 v8::V8::RemoveGCPrologueCallback(PrologueCallback);
9999 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback);
10000 i::Heap::CollectAllGarbage(false);
10001 CHECK_EQ(2, prologue_call_count);
10002 CHECK_EQ(2, epilogue_call_count);
10003 CHECK_EQ(2, prologue_call_count_second);
10004 CHECK_EQ(2, epilogue_call_count_second);
10005 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
10006 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
10007 i::Heap::CollectAllGarbage(false);
10008 CHECK_EQ(2, prologue_call_count);
10009 CHECK_EQ(2, epilogue_call_count);
10010 CHECK_EQ(2, prologue_call_count_second);
10011 CHECK_EQ(2, epilogue_call_count_second);
10012 }
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698