OLD | NEW |
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 Loading... |
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 MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) { |
| 20495 v8::HandleScope scope(info.GetIsolate()); |
| 20496 CompileRun("ext1Calls++;"); |
| 20497 } |
| 20498 |
| 20499 |
| 20500 static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) { |
| 20501 v8::HandleScope scope(info.GetIsolate()); |
| 20502 CompileRun("ext2Calls++;"); |
| 20503 } |
| 20504 |
| 20505 |
| 20506 TEST(EnqueueMicrotask) { |
| 20507 LocalContext env; |
| 20508 v8::HandleScope scope(env->GetIsolate()); |
| 20509 CompileRun( |
| 20510 "var ext1Calls = 0;" |
| 20511 "var ext2Calls = 0;"); |
| 20512 CompileRun("1+1;"); |
| 20513 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value()); |
| 20514 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
| 20515 |
| 20516 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20517 Function::New(env->GetIsolate(), MicrotaskOne)); |
| 20518 CompileRun("1+1;"); |
| 20519 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); |
| 20520 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
| 20521 |
| 20522 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20523 Function::New(env->GetIsolate(), MicrotaskOne)); |
| 20524 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20525 Function::New(env->GetIsolate(), MicrotaskTwo)); |
| 20526 CompileRun("1+1;"); |
| 20527 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20528 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); |
| 20529 |
| 20530 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20531 Function::New(env->GetIsolate(), MicrotaskTwo)); |
| 20532 CompileRun("1+1;"); |
| 20533 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20534 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
| 20535 |
| 20536 CompileRun("1+1;"); |
| 20537 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20538 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
| 20539 } |
| 20540 |
| 20541 |
| 20542 TEST(SetAutorunMicrotasks) { |
| 20543 LocalContext env; |
| 20544 v8::HandleScope scope(env->GetIsolate()); |
| 20545 CompileRun( |
| 20546 "var ext1Calls = 0;" |
| 20547 "var ext2Calls = 0;"); |
| 20548 CompileRun("1+1;"); |
| 20549 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value()); |
| 20550 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
| 20551 |
| 20552 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20553 Function::New(env->GetIsolate(), MicrotaskOne)); |
| 20554 CompileRun("1+1;"); |
| 20555 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); |
| 20556 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
| 20557 |
| 20558 V8::SetAutorunMicrotasks(env->GetIsolate(), false); |
| 20559 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20560 Function::New(env->GetIsolate(), MicrotaskOne)); |
| 20561 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20562 Function::New(env->GetIsolate(), MicrotaskTwo)); |
| 20563 CompileRun("1+1;"); |
| 20564 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); |
| 20565 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); |
| 20566 |
| 20567 V8::RunMicrotasks(env->GetIsolate()); |
| 20568 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20569 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); |
| 20570 |
| 20571 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20572 Function::New(env->GetIsolate(), MicrotaskTwo)); |
| 20573 CompileRun("1+1;"); |
| 20574 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20575 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); |
| 20576 |
| 20577 V8::RunMicrotasks(env->GetIsolate()); |
| 20578 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20579 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
| 20580 |
| 20581 V8::SetAutorunMicrotasks(env->GetIsolate(), true); |
| 20582 v8::V8::EnqueueMicrotask(env->GetIsolate(), |
| 20583 Function::New(env->GetIsolate(), MicrotaskTwo)); |
| 20584 CompileRun("1+1;"); |
| 20585 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
| 20586 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value()); |
| 20587 } |
| 20588 |
| 20589 |
20494 static int probes_counter = 0; | 20590 static int probes_counter = 0; |
20495 static int misses_counter = 0; | 20591 static int misses_counter = 0; |
20496 static int updates_counter = 0; | 20592 static int updates_counter = 0; |
20497 | 20593 |
20498 | 20594 |
20499 static int* LookupCounter(const char* name) { | 20595 static int* LookupCounter(const char* name) { |
20500 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { | 20596 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { |
20501 return &probes_counter; | 20597 return &probes_counter; |
20502 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { | 20598 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { |
20503 return &misses_counter; | 20599 return &misses_counter; |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21958 | 22054 |
21959 | 22055 |
21960 TEST(TestFunctionCallOptimization) { | 22056 TEST(TestFunctionCallOptimization) { |
21961 i::FLAG_allow_natives_syntax = true; | 22057 i::FLAG_allow_natives_syntax = true; |
21962 ApiCallOptimizationChecker checker; | 22058 ApiCallOptimizationChecker checker; |
21963 checker.Run(true, true); | 22059 checker.Run(true, true); |
21964 checker.Run(false, true); | 22060 checker.Run(false, true); |
21965 checker.Run(true, false); | 22061 checker.Run(true, false); |
21966 checker.Run(false, false); | 22062 checker.Run(false, false); |
21967 } | 22063 } |
OLD | NEW |