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

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

Issue 1884133002: [Interpreter] Add support for FunctionEntryHook. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make test stricter Created 4 years, 8 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 | « test/cctest/cctest.status ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 14385 matching lines...) Expand 10 before | Expand all | Expand 10 after
14396 continue; 14396 continue;
14397 } 14397 }
14398 14398
14399 // It matches add the invocation count to the tally. 14399 // It matches add the invocation count to the tally.
14400 invocations += it->second; 14400 invocations += it->second;
14401 } 14401 }
14402 14402
14403 return invocations; 14403 return invocations;
14404 } 14404 }
14405 14405
14406
14407 void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) { 14406 void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) {
14408 v8::HandleScope outer(isolate); 14407 v8::HandleScope outer(isolate);
14409 v8::Local<Context> env = Context::New(isolate); 14408 v8::Local<Context> env = Context::New(isolate);
14410 env->Enter(); 14409 env->Enter();
14411 14410
14412 Local<ObjectTemplate> t = ObjectTemplate::New(isolate); 14411 Local<ObjectTemplate> t = ObjectTemplate::New(isolate);
14413 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback)); 14412 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback));
14414 CHECK(env->Global() 14413 CHECK(env->Global()
14415 ->Set(env, v8_str("obj"), t->NewInstance(env).ToLocalChecked()) 14414 ->Set(env, v8_str("obj"), t->NewInstance(env).ToLocalChecked())
14416 .FromJust()); 14415 .FromJust());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
14454 create_params.entry_hook = EntryHook; 14453 create_params.entry_hook = EntryHook;
14455 create_params.code_event_handler = JitEvent; 14454 create_params.code_event_handler = JitEvent;
14456 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); 14455 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
14457 v8::Isolate* isolate = v8::Isolate::New(create_params); 14456 v8::Isolate* isolate = v8::Isolate::New(create_params);
14458 14457
14459 { 14458 {
14460 v8::Isolate::Scope scope(isolate); 14459 v8::Isolate::Scope scope(isolate);
14461 14460
14462 RunLoopInNewEnv(isolate); 14461 RunLoopInNewEnv(isolate);
14463 14462
14464 // Check the exepected invocation counts. 14463 // Check the expected invocation counts.
14465 CHECK_EQ(2, CountInvocations(NULL, "bar")); 14464 if (!i::FLAG_ignition) {
14466 CHECK_EQ(200, CountInvocations("bar", "foo")); 14465 CHECK_EQ(2, CountInvocations(NULL, "bar"));
14467 CHECK_EQ(200, CountInvocations(NULL, "foo")); 14466 CHECK_EQ(200, CountInvocations("bar", "foo"));
14467 CHECK_EQ(200, CountInvocations(NULL, "foo"));
14468 } else {
14469 // For ignition we don't see the actual functions being called, instead
14470 // we see the IterpreterEntryTrampoline at least 102 times
14471 // (100 unoptimized calls to foo, and 2 calls to bar).
14472 CHECK_LE(102, CountInvocations(NULL, "InterpreterEntryTrampoline"));
14473 // We should also see the calls to the optimized function foo.
14474 CHECK_EQ(100, CountInvocations(NULL, "foo"));
14475 }
14468 14476
14469 // Verify that we have an entry hook on some specific stubs. 14477 // Verify that we have an entry hook on some specific stubs.
14470 CHECK_NE(0, CountInvocations(NULL, "CEntryStub")); 14478 CHECK_NE(0, CountInvocations(NULL, "CEntryStub"));
14471 CHECK_NE(0, CountInvocations(NULL, "JSEntryStub")); 14479 CHECK_NE(0, CountInvocations(NULL, "JSEntryStub"));
14472 CHECK_NE(0, CountInvocations(NULL, "JSEntryTrampoline")); 14480 CHECK_NE(0, CountInvocations(NULL, "JSEntryTrampoline"));
14473 } 14481 }
14474 isolate->Dispose(); 14482 isolate->Dispose();
14475 14483
14476 Reset(); 14484 Reset();
14477 14485
(...skipping 10500 matching lines...) Expand 10 before | Expand all | Expand 10 after
24978 } 24986 }
24979 delete garbage; 24987 delete garbage;
24980 // Check that moderate memory pressure notification sets GC into memory 24988 // Check that moderate memory pressure notification sets GC into memory
24981 // optimizing mode. 24989 // optimizing mode.
24982 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); 24990 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate);
24983 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); 24991 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage());
24984 // Check that disabling memory pressure returns GC into normal mode. 24992 // Check that disabling memory pressure returns GC into normal mode.
24985 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); 24993 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone);
24986 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); 24994 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage());
24987 } 24995 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698