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

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

Issue 154283002: V8 Microtask Queue & API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cleanup Created 6 years, 10 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
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 20473 matching lines...) Expand 10 before | Expand all | Expand 10 after
20484 20484
20485 20485
20486 TEST(CallCompletedCallbackTwoExceptions) { 20486 TEST(CallCompletedCallbackTwoExceptions) {
20487 LocalContext env; 20487 LocalContext env;
20488 v8::HandleScope scope(env->GetIsolate()); 20488 v8::HandleScope scope(env->GetIsolate());
20489 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); 20489 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException);
20490 CompileRun("throw 'first exception';"); 20490 CompileRun("throw 'first exception';");
20491 } 20491 }
20492 20492
20493 20493
20494 static void ExternalMicrotaskOne(v8::Isolate* isolate) {
20495 v8::HandleScope scope(isolate);
20496 CompileRun("ext1Calls++;");
20497 }
20498
20499
20500
20501 static void ExternalMicrotaskTwo(v8::Isolate* isolate) {
20502 v8::HandleScope scope(isolate);
20503 CompileRun("ext2Calls++;");
20504 }
20505
20506
20507 TEST(EnqueueExternalMicrotask) {
20508 LocalContext env;
20509 v8::HandleScope scope(env->GetIsolate());
20510 CompileRun(
20511 "var ext1Calls = 0;"
20512 "var ext2Calls = 0;");
20513 CompileRun("1+1;");
20514 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
20515 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20516
20517 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
20518 CompileRun("1+1;");
20519 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20520 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20521
20522 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
20523 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
20524 CompileRun("1+1;");
20525 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20526 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20527
20528 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
20529 CompileRun("1+1;");
20530 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20531 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20532
20533 CompileRun("1+1;");
20534 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20535 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20536 }
20537
20538
20539 TEST(SetAutorunMicrotasks) {
20540 LocalContext env;
20541 v8::HandleScope scope(env->GetIsolate());
20542 CompileRun(
20543 "var ext1Calls = 0;"
20544 "var ext2Calls = 0;");
20545 CompileRun("1+1;");
20546 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
20547 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20548
20549 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
20550 CompileRun("1+1;");
20551 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20552 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20553
20554 V8::SetAutorunMicrotasks(env->GetIsolate(), false);
20555 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne);
20556 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
20557 CompileRun("1+1;");
20558 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20559 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20560
20561 V8::RunMicrotasks(env->GetIsolate());
20562 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20563 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20564
20565 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
20566 CompileRun("1+1;");
20567 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20568 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20569
20570 V8::RunMicrotasks(env->GetIsolate());
20571 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20572 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20573
20574 V8::SetAutorunMicrotasks(env->GetIsolate(), true);
20575 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo);
20576 CompileRun("1+1;");
20577 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20578 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
20579 }
20580
20581
20494 static int probes_counter = 0; 20582 static int probes_counter = 0;
20495 static int misses_counter = 0; 20583 static int misses_counter = 0;
20496 static int updates_counter = 0; 20584 static int updates_counter = 0;
20497 20585
20498 20586
20499 static int* LookupCounter(const char* name) { 20587 static int* LookupCounter(const char* name) {
20500 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { 20588 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
20501 return &probes_counter; 20589 return &probes_counter;
20502 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { 20590 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
20503 return &misses_counter; 20591 return &misses_counter;
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
21958 22046
21959 22047
21960 TEST(TestFunctionCallOptimization) { 22048 TEST(TestFunctionCallOptimization) {
21961 i::FLAG_allow_natives_syntax = true; 22049 i::FLAG_allow_natives_syntax = true;
21962 ApiCallOptimizationChecker checker; 22050 ApiCallOptimizationChecker checker;
21963 checker.Run(true, true); 22051 checker.Run(true, true);
21964 checker.Run(false, true); 22052 checker.Run(false, true);
21965 checker.Run(true, false); 22053 checker.Run(true, false);
21966 checker.Run(false, false); 22054 checker.Run(false, false);
21967 } 22055 }
OLDNEW
« src/api.cc ('K') | « test/cctest/cctest.gyp ('k') | test/cctest/test-microtask-delivery.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698