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

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: heapconst 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-microtask-delivery.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 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 20496 matching lines...) Expand 10 before | Expand all | Expand 10 after
20507 20507
20508 20508
20509 TEST(CallCompletedCallbackTwoExceptions) { 20509 TEST(CallCompletedCallbackTwoExceptions) {
20510 LocalContext env; 20510 LocalContext env;
20511 v8::HandleScope scope(env->GetIsolate()); 20511 v8::HandleScope scope(env->GetIsolate());
20512 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); 20512 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException);
20513 CompileRun("throw 'first exception';"); 20513 CompileRun("throw 'first exception';");
20514 } 20514 }
20515 20515
20516 20516
20517 static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) {
20518 v8::HandleScope scope(info.GetIsolate());
20519 CompileRun("ext1Calls++;");
20520 }
20521
20522
20523 static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) {
20524 v8::HandleScope scope(info.GetIsolate());
20525 CompileRun("ext2Calls++;");
20526 }
20527
20528
20529 TEST(EnqueueMicrotask) {
20530 LocalContext env;
20531 v8::HandleScope scope(env->GetIsolate());
20532 CompileRun(
20533 "var ext1Calls = 0;"
20534 "var ext2Calls = 0;");
20535 CompileRun("1+1;");
20536 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
20537 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20538
20539 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20540 Function::New(env->GetIsolate(), MicrotaskOne));
20541 CompileRun("1+1;");
20542 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20543 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20544
20545 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20546 Function::New(env->GetIsolate(), MicrotaskOne));
20547 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20548 Function::New(env->GetIsolate(), MicrotaskTwo));
20549 CompileRun("1+1;");
20550 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20551 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20552
20553 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20554 Function::New(env->GetIsolate(), MicrotaskTwo));
20555 CompileRun("1+1;");
20556 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20557 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20558
20559 CompileRun("1+1;");
20560 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20561 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20562 }
20563
20564
20565 TEST(SetAutorunMicrotasks) {
20566 LocalContext env;
20567 v8::HandleScope scope(env->GetIsolate());
20568 CompileRun(
20569 "var ext1Calls = 0;"
20570 "var ext2Calls = 0;");
20571 CompileRun("1+1;");
20572 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value());
20573 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20574
20575 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20576 Function::New(env->GetIsolate(), MicrotaskOne));
20577 CompileRun("1+1;");
20578 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20579 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20580
20581 V8::SetAutorunMicrotasks(env->GetIsolate(), false);
20582 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20583 Function::New(env->GetIsolate(), MicrotaskOne));
20584 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20585 Function::New(env->GetIsolate(), MicrotaskTwo));
20586 CompileRun("1+1;");
20587 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value());
20588 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value());
20589
20590 V8::RunMicrotasks(env->GetIsolate());
20591 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20592 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20593
20594 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20595 Function::New(env->GetIsolate(), MicrotaskTwo));
20596 CompileRun("1+1;");
20597 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20598 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value());
20599
20600 V8::RunMicrotasks(env->GetIsolate());
20601 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20602 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value());
20603
20604 V8::SetAutorunMicrotasks(env->GetIsolate(), true);
20605 v8::V8::EnqueueMicrotask(env->GetIsolate(),
20606 Function::New(env->GetIsolate(), MicrotaskTwo));
20607 CompileRun("1+1;");
20608 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value());
20609 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value());
20610 }
20611
20612
20517 static int probes_counter = 0; 20613 static int probes_counter = 0;
20518 static int misses_counter = 0; 20614 static int misses_counter = 0;
20519 static int updates_counter = 0; 20615 static int updates_counter = 0;
20520 20616
20521 20617
20522 static int* LookupCounter(const char* name) { 20618 static int* LookupCounter(const char* name) {
20523 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { 20619 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
20524 return &probes_counter; 20620 return &probes_counter;
20525 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { 20621 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
20526 return &misses_counter; 20622 return &misses_counter;
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
22006 Local<Object> ApiCallOptimizationChecker::holder; 22102 Local<Object> ApiCallOptimizationChecker::holder;
22007 Local<Object> ApiCallOptimizationChecker::callee; 22103 Local<Object> ApiCallOptimizationChecker::callee;
22008 int ApiCallOptimizationChecker::count = 0; 22104 int ApiCallOptimizationChecker::count = 0;
22009 22105
22010 22106
22011 TEST(TestFunctionCallOptimization) { 22107 TEST(TestFunctionCallOptimization) {
22012 i::FLAG_allow_natives_syntax = true; 22108 i::FLAG_allow_natives_syntax = true;
22013 ApiCallOptimizationChecker checker; 22109 ApiCallOptimizationChecker checker;
22014 checker.RunAll(); 22110 checker.RunAll();
22015 } 22111 }
OLDNEW
« no previous file with comments | « 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