Chromium Code Reviews| Index: test/cctest/test-api.cc |
| =================================================================== |
| --- test/cctest/test-api.cc (revision 10860) |
| +++ test/cctest/test-api.cc (working copy) |
| @@ -16102,3 +16102,79 @@ |
| v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
| CompileRun("throw 'first exception';"); |
| } |
| + |
| + |
| +static int probes_counter = 0; |
| +static int misses_counter = 0; |
| +static int updates_counter = 0; |
| + |
| + |
| +static int* LookupCounter(const char* name) { |
|
Sven Panne
2012/02/29 09:37:42
It seems that all those statics here are only used
Erik Corry
2012/02/29 10:45:59
It does not complain about probes_counter etc. but
|
| + if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { |
| + return &probes_counter; |
| + } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { |
| + return &misses_counter; |
| + } else if (strcmp(name, "c:V8.MegamorphicStubCacheUpdates") == 0) { |
| + return &updates_counter; |
| + } |
| + return NULL; |
| +} |
| + |
| + |
| +static const char* kMegamorphicTestProgram = |
| + "function ClassA() { };" |
| + "function ClassB() { };" |
| + "ClassA.prototype.foo = function() { };" |
| + "ClassB.prototype.foo = function() { };" |
| + "function fooify(obj) { obj.foo(); };" |
| + "var a = new ClassA();" |
| + "var b = new ClassB();" |
| + "for (var i = 0; i < 10000; i++) {" |
| + " fooify(a);" |
| + " fooify(b);" |
| + "}"; |
| + |
| + |
| +TEST(SecondaryStubCache) { |
|
Sven Panne
2012/02/29 09:37:42
This differs from TEST(PrimaryStubCache) only in a
Erik Corry
2012/02/29 10:45:59
Done
|
| +#ifdef DEBUG |
| + i::FLAG_native_code_counters = true; |
| + i::FLAG_test_secondary_stub_cache = true; |
| + i::FLAG_crankshaft = false; |
| + V8::SetCounterFunction(LookupCounter); |
| + v8::HandleScope scope; |
| + LocalContext env; |
| + int initial_probes = probes_counter; |
| + int initial_misses = misses_counter; |
| + int initial_updates = updates_counter; |
| + CompileRun(kMegamorphicTestProgram); |
| + int probes = probes_counter - initial_probes; |
| + int misses = misses_counter - initial_misses; |
| + int updates = updates_counter - initial_updates; |
| + CHECK_LT(updates, 10); |
| + CHECK_LT(misses, 10); |
| + CHECK_GE(probes, 10000); |
| +#endif |
| +} |
| + |
| + |
| +TEST(PrimaryStubCache) { |
| +#ifdef DEBUG |
| + i::FLAG_native_code_counters = true; |
| + i::FLAG_test_primary_stub_cache = true; |
| + i::FLAG_crankshaft = false; |
| + V8::SetCounterFunction(LookupCounter); |
| + v8::HandleScope scope; |
| + LocalContext env; |
| + int initial_probes = probes_counter; |
| + int initial_misses = misses_counter; |
| + int initial_updates = updates_counter; |
| + CompileRun(kMegamorphicTestProgram); |
| + int probes = probes_counter - initial_probes; |
| + int misses = misses_counter - initial_misses; |
| + int updates = updates_counter - initial_updates; |
| + CHECK_LT(updates, 10); |
| + CHECK_LT(misses, 10); |
| + CHECK_GE(probes, 10000); |
| +#endif |
| +} |
| + |