| 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 6769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6780 | 6780 |
| 6781 static void ForceMarkSweep1( | 6781 static void ForceMarkSweep1( |
| 6782 const v8::WeakCallbackInfo<FlagAndPersistent>& data) { | 6782 const v8::WeakCallbackInfo<FlagAndPersistent>& data) { |
| 6783 data.GetParameter()->handle.Reset(); | 6783 data.GetParameter()->handle.Reset(); |
| 6784 data.SetSecondPassCallback(ForceMarkSweep2); | 6784 data.SetSecondPassCallback(ForceMarkSweep2); |
| 6785 } | 6785 } |
| 6786 | 6786 |
| 6787 | 6787 |
| 6788 THREADED_TEST(GCFromWeakCallbacks) { | 6788 THREADED_TEST(GCFromWeakCallbacks) { |
| 6789 v8::Isolate* isolate = CcTest::isolate(); | 6789 v8::Isolate* isolate = CcTest::isolate(); |
| 6790 v8::Locker locker(CcTest::isolate()); |
| 6790 v8::HandleScope scope(isolate); | 6791 v8::HandleScope scope(isolate); |
| 6791 v8::Handle<Context> context = Context::New(isolate); | 6792 v8::Handle<Context> context = Context::New(isolate); |
| 6792 Context::Scope context_scope(context); | 6793 Context::Scope context_scope(context); |
| 6793 | 6794 |
| 6794 static const int kNumberOfGCTypes = 2; | 6795 static const int kNumberOfGCTypes = 2; |
| 6795 typedef v8::WeakCallbackInfo<FlagAndPersistent>::Callback Callback; | 6796 typedef v8::WeakCallbackInfo<FlagAndPersistent>::Callback Callback; |
| 6796 Callback gc_forcing_callback[kNumberOfGCTypes] = {&ForceScavenge1, | 6797 Callback gc_forcing_callback[kNumberOfGCTypes] = {&ForceScavenge1, |
| 6797 &ForceMarkSweep1}; | 6798 &ForceMarkSweep1}; |
| 6798 | 6799 |
| 6799 typedef void (*GCInvoker)(); | 6800 typedef void (*GCInvoker)(); |
| (...skipping 5116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11916 | 11917 |
| 11917 | 11918 |
| 11918 void HandleCreatingCallback1( | 11919 void HandleCreatingCallback1( |
| 11919 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { | 11920 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { |
| 11920 data.GetParameter()->Reset(); | 11921 data.GetParameter()->Reset(); |
| 11921 data.SetSecondPassCallback(HandleCreatingCallback2); | 11922 data.SetSecondPassCallback(HandleCreatingCallback2); |
| 11922 } | 11923 } |
| 11923 | 11924 |
| 11924 | 11925 |
| 11925 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 11926 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
| 11927 v8::Locker locker(CcTest::isolate()); |
| 11926 LocalContext context; | 11928 LocalContext context; |
| 11927 v8::Isolate* isolate = context->GetIsolate(); | 11929 v8::Isolate* isolate = context->GetIsolate(); |
| 11928 | 11930 |
| 11929 v8::Persistent<v8::Object> handle1, handle2, handle3; | 11931 v8::Persistent<v8::Object> handle1, handle2, handle3; |
| 11930 { | 11932 { |
| 11931 v8::HandleScope scope(isolate); | 11933 v8::HandleScope scope(isolate); |
| 11932 handle3.Reset(isolate, v8::Object::New(isolate)); | 11934 handle3.Reset(isolate, v8::Object::New(isolate)); |
| 11933 handle2.Reset(isolate, v8::Object::New(isolate)); | 11935 handle2.Reset(isolate, v8::Object::New(isolate)); |
| 11934 handle1.Reset(isolate, v8::Object::New(isolate)); | 11936 handle1.Reset(isolate, v8::Object::New(isolate)); |
| 11935 } | 11937 } |
| (...skipping 4622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16558 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); | 16560 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); |
| 16559 CcTest::heap()->CollectAllGarbage( | 16561 CcTest::heap()->CollectAllGarbage( |
| 16560 i::Heap::kAbortIncrementalMarkingMask); | 16562 i::Heap::kAbortIncrementalMarkingMask); |
| 16561 CHECK_EQ(1, prologue_call_count_alloc); | 16563 CHECK_EQ(1, prologue_call_count_alloc); |
| 16562 CHECK_EQ(1, epilogue_call_count_alloc); | 16564 CHECK_EQ(1, epilogue_call_count_alloc); |
| 16563 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc); | 16565 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc); |
| 16564 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc); | 16566 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc); |
| 16565 } | 16567 } |
| 16566 | 16568 |
| 16567 | 16569 |
| 16568 THREADED_TEST(AddToJSFunctionResultCache) { | |
| 16569 i::FLAG_stress_compaction = false; | |
| 16570 i::FLAG_allow_natives_syntax = true; | |
| 16571 v8::HandleScope scope(CcTest::isolate()); | |
| 16572 | |
| 16573 LocalContext context; | |
| 16574 | |
| 16575 const char* code = | |
| 16576 "(function() {" | |
| 16577 " var key0 = 'a';" | |
| 16578 " var key1 = 'b';" | |
| 16579 " var r0 = %_GetFromCache(0, key0);" | |
| 16580 " var r1 = %_GetFromCache(0, key1);" | |
| 16581 " var r0_ = %_GetFromCache(0, key0);" | |
| 16582 " if (r0 !== r0_)" | |
| 16583 " return 'Different results for ' + key0 + ': ' + r0 + ' vs. ' + r0_;" | |
| 16584 " var r1_ = %_GetFromCache(0, key1);" | |
| 16585 " if (r1 !== r1_)" | |
| 16586 " return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;" | |
| 16587 " return 'PASSED';" | |
| 16588 "})()"; | |
| 16589 CcTest::heap()->ClearJSFunctionResultCaches(); | |
| 16590 ExpectString(code, "PASSED"); | |
| 16591 } | |
| 16592 | |
| 16593 | |
| 16594 THREADED_TEST(FillJSFunctionResultCache) { | |
| 16595 i::FLAG_allow_natives_syntax = true; | |
| 16596 LocalContext context; | |
| 16597 v8::HandleScope scope(context->GetIsolate()); | |
| 16598 | |
| 16599 const char* code = | |
| 16600 "(function() {" | |
| 16601 " var k = 'a';" | |
| 16602 " var r = %_GetFromCache(0, k);" | |
| 16603 " for (var i = 0; i < 16; i++) {" | |
| 16604 " %_GetFromCache(0, 'a' + i);" | |
| 16605 " };" | |
| 16606 " if (r === %_GetFromCache(0, k))" | |
| 16607 " return 'FAILED: k0CacheSize is too small';" | |
| 16608 " return 'PASSED';" | |
| 16609 "})()"; | |
| 16610 CcTest::heap()->ClearJSFunctionResultCaches(); | |
| 16611 ExpectString(code, "PASSED"); | |
| 16612 } | |
| 16613 | |
| 16614 | |
| 16615 THREADED_TEST(RoundRobinGetFromCache) { | |
| 16616 i::FLAG_allow_natives_syntax = true; | |
| 16617 LocalContext context; | |
| 16618 v8::HandleScope scope(context->GetIsolate()); | |
| 16619 | |
| 16620 const char* code = | |
| 16621 "(function() {" | |
| 16622 " var keys = [];" | |
| 16623 " for (var i = 0; i < 16; i++) keys.push(i);" | |
| 16624 " var values = [];" | |
| 16625 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" | |
| 16626 " for (var i = 0; i < 16; i++) {" | |
| 16627 " var v = %_GetFromCache(0, keys[i]);" | |
| 16628 " if (v.toString() !== values[i].toString())" | |
| 16629 " return 'Wrong value for ' + " | |
| 16630 " keys[i] + ': ' + v + ' vs. ' + values[i];" | |
| 16631 " };" | |
| 16632 " return 'PASSED';" | |
| 16633 "})()"; | |
| 16634 CcTest::heap()->ClearJSFunctionResultCaches(); | |
| 16635 ExpectString(code, "PASSED"); | |
| 16636 } | |
| 16637 | |
| 16638 | |
| 16639 THREADED_TEST(ReverseGetFromCache) { | |
| 16640 i::FLAG_allow_natives_syntax = true; | |
| 16641 LocalContext context; | |
| 16642 v8::HandleScope scope(context->GetIsolate()); | |
| 16643 | |
| 16644 const char* code = | |
| 16645 "(function() {" | |
| 16646 " var keys = [];" | |
| 16647 " for (var i = 0; i < 16; i++) keys.push(i);" | |
| 16648 " var values = [];" | |
| 16649 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" | |
| 16650 " for (var i = 15; i >= 16; i--) {" | |
| 16651 " var v = %_GetFromCache(0, keys[i]);" | |
| 16652 " if (v !== values[i])" | |
| 16653 " return 'Wrong value for ' + " | |
| 16654 " keys[i] + ': ' + v + ' vs. ' + values[i];" | |
| 16655 " };" | |
| 16656 " return 'PASSED';" | |
| 16657 "})()"; | |
| 16658 CcTest::heap()->ClearJSFunctionResultCaches(); | |
| 16659 ExpectString(code, "PASSED"); | |
| 16660 } | |
| 16661 | |
| 16662 | |
| 16663 THREADED_TEST(TestEviction) { | |
| 16664 i::FLAG_allow_natives_syntax = true; | |
| 16665 LocalContext context; | |
| 16666 v8::HandleScope scope(context->GetIsolate()); | |
| 16667 | |
| 16668 const char* code = | |
| 16669 "(function() {" | |
| 16670 " for (var i = 0; i < 2*16; i++) {" | |
| 16671 " %_GetFromCache(0, 'a' + i);" | |
| 16672 " };" | |
| 16673 " return 'PASSED';" | |
| 16674 "})()"; | |
| 16675 CcTest::heap()->ClearJSFunctionResultCaches(); | |
| 16676 ExpectString(code, "PASSED"); | |
| 16677 } | |
| 16678 | |
| 16679 | |
| 16680 THREADED_TEST(TwoByteStringInOneByteCons) { | 16570 THREADED_TEST(TwoByteStringInOneByteCons) { |
| 16681 // See Chromium issue 47824. | 16571 // See Chromium issue 47824. |
| 16682 LocalContext context; | 16572 LocalContext context; |
| 16683 v8::HandleScope scope(context->GetIsolate()); | 16573 v8::HandleScope scope(context->GetIsolate()); |
| 16684 | 16574 |
| 16685 const char* init_code = | 16575 const char* init_code = |
| 16686 "var str1 = 'abelspendabel';" | 16576 "var str1 = 'abelspendabel';" |
| 16687 "var str2 = str1 + str1 + str1;" | 16577 "var str2 = str1 + str1 + str1;" |
| 16688 "str2;"; | 16578 "str2;"; |
| 16689 Local<Value> result = CompileRun(init_code); | 16579 Local<Value> result = CompileRun(init_code); |
| (...skipping 5240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21930 | 21820 |
| 21931 v8::TryCatch try_catch(CcTest::isolate()); | 21821 v8::TryCatch try_catch(CcTest::isolate()); |
| 21932 timeout_thread.Start(); | 21822 timeout_thread.Start(); |
| 21933 | 21823 |
| 21934 CompileRun( | 21824 CompileRun( |
| 21935 "var ab = new SharedArrayBuffer(4);" | 21825 "var ab = new SharedArrayBuffer(4);" |
| 21936 "var i32a = new Int32Array(ab);" | 21826 "var i32a = new Int32Array(ab);" |
| 21937 "Atomics.futexWait(i32a, 0, 0);"); | 21827 "Atomics.futexWait(i32a, 0, 0);"); |
| 21938 CHECK(try_catch.HasTerminated()); | 21828 CHECK(try_catch.HasTerminated()); |
| 21939 } | 21829 } |
| OLD | NEW |