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 20532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20543 | 20543 |
20544 | 20544 |
20545 TEST(CallCompletedCallbackTwoExceptions) { | 20545 TEST(CallCompletedCallbackTwoExceptions) { |
20546 LocalContext env; | 20546 LocalContext env; |
20547 v8::HandleScope scope(env->GetIsolate()); | 20547 v8::HandleScope scope(env->GetIsolate()); |
20548 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 20548 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
20549 CompileRun("throw 'first exception';"); | 20549 CompileRun("throw 'first exception';"); |
20550 } | 20550 } |
20551 | 20551 |
20552 | 20552 |
20553 void ExternalMicrotaskOne() { | |
Sven Panne
2014/02/10 14:22:02
Nit: static. Reduces the probability of linker cla
rafaelw
2014/02/11 00:28:52
Done.
| |
20554 v8::HandleScope scope(CcTest::isolate()); | |
Sven Panne
2014/02/10 14:22:03
Calling CcTest::isolate() is a strong indicator th
rafaelw
2014/02/11 00:28:52
Good to know. Done.
| |
20555 CompileRun("ext1Calls++;"); | |
20556 } | |
20557 | |
20558 | |
20559 void ExternalMicrotaskTwo() { | |
20560 v8::HandleScope scope(CcTest::isolate()); | |
20561 CompileRun("ext2Calls++;"); | |
20562 } | |
20563 | |
20564 | |
20565 TEST(EnqueueExternalMicrotask) { | |
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::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne); | |
20576 CompileRun("1+1;"); | |
20577 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); | |
20578 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); | |
20579 | |
20580 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne); | |
20581 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo); | |
20582 CompileRun("1+1;"); | |
20583 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20584 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); | |
20585 | |
20586 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo); | |
20587 CompileRun("1+1;"); | |
20588 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20589 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | |
20590 | |
20591 CompileRun("1+1;"); | |
20592 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20593 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | |
20594 } | |
20595 | |
20596 | |
20597 TEST(SetAutorunMicrotasks) { | |
20598 LocalContext env; | |
20599 v8::HandleScope scope(env->GetIsolate()); | |
20600 CompileRun( | |
20601 "var ext1Calls = 0;" | |
20602 "var ext2Calls = 0;"); | |
20603 CompileRun("1+1;"); | |
20604 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value()); | |
20605 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); | |
20606 | |
20607 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne); | |
20608 CompileRun("1+1;"); | |
20609 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); | |
20610 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); | |
20611 | |
20612 V8::SetAutorunMicrotasks(env->GetIsolate(), false); | |
20613 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskOne); | |
20614 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo); | |
20615 CompileRun("1+1;"); | |
20616 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value()); | |
20617 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value()); | |
20618 | |
20619 V8::RunMicrotasks(env->GetIsolate()); | |
20620 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20621 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); | |
20622 | |
20623 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo); | |
20624 CompileRun("1+1;"); | |
20625 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20626 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value()); | |
20627 | |
20628 V8::RunMicrotasks(env->GetIsolate()); | |
20629 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20630 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | |
20631 | |
20632 V8::SetAutorunMicrotasks(env->GetIsolate(), true); | |
20633 v8::V8::EnqueueExternalMicrotask(env->GetIsolate(), ExternalMicrotaskTwo); | |
20634 CompileRun("1+1;"); | |
20635 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | |
20636 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value()); | |
20637 } | |
20638 | |
20639 | |
20553 static int probes_counter = 0; | 20640 static int probes_counter = 0; |
20554 static int misses_counter = 0; | 20641 static int misses_counter = 0; |
20555 static int updates_counter = 0; | 20642 static int updates_counter = 0; |
20556 | 20643 |
20557 | 20644 |
20558 static int* LookupCounter(const char* name) { | 20645 static int* LookupCounter(const char* name) { |
20559 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { | 20646 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { |
20560 return &probes_counter; | 20647 return &probes_counter; |
20561 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { | 20648 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { |
20562 return &misses_counter; | 20649 return &misses_counter; |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21975 | 22062 |
21976 | 22063 |
21977 TEST(TestFunctionCallOptimization) { | 22064 TEST(TestFunctionCallOptimization) { |
21978 i::FLAG_allow_natives_syntax = true; | 22065 i::FLAG_allow_natives_syntax = true; |
21979 ApiCallOptimizationChecker checker; | 22066 ApiCallOptimizationChecker checker; |
21980 checker.Run(true, true); | 22067 checker.Run(true, true); |
21981 checker.Run(false, true); | 22068 checker.Run(false, true); |
21982 checker.Run(true, false); | 22069 checker.Run(true, false); |
21983 checker.Run(false, false); | 22070 checker.Run(false, false); |
21984 } | 22071 } |
OLD | NEW |