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 4452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4463 new_head = scope.CloseAndEscape(immortal); | 4463 new_head = scope.CloseAndEscape(immortal); |
4464 } | 4464 } |
4465 heap->CollectAllAvailableGarbage(); | 4465 heap->CollectAllAvailableGarbage(); |
4466 // Now mortal code should be dead. | 4466 // Now mortal code should be dead. |
4467 CHECK_EQ(*old_head, new_head->next_code_link()); | 4467 CHECK_EQ(*old_head, new_head->next_code_link()); |
4468 } | 4468 } |
4469 | 4469 |
4470 | 4470 |
4471 static bool weak_ic_cleared = false; | 4471 static bool weak_ic_cleared = false; |
4472 | 4472 |
4473 static void ClearWeakIC(const v8::WeakCallbackData<v8::Object, void>& data) { | 4473 static void ClearWeakIC( |
| 4474 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { |
4474 printf("clear weak is called\n"); | 4475 printf("clear weak is called\n"); |
4475 weak_ic_cleared = true; | 4476 weak_ic_cleared = true; |
4476 v8::Persistent<v8::Value>* p = | 4477 data.GetParameter()->Reset(); |
4477 reinterpret_cast<v8::Persistent<v8::Value>*>(data.GetParameter()); | |
4478 CHECK(p->IsNearDeath()); | |
4479 p->Reset(); | |
4480 } | 4478 } |
4481 | 4479 |
4482 | 4480 |
4483 TEST(WeakFunctionInConstructor) { | 4481 TEST(WeakFunctionInConstructor) { |
4484 if (i::FLAG_always_opt) return; | 4482 if (i::FLAG_always_opt) return; |
4485 i::FLAG_stress_compaction = false; | 4483 i::FLAG_stress_compaction = false; |
4486 CcTest::InitializeVM(); | 4484 CcTest::InitializeVM(); |
4487 v8::Isolate* isolate = CcTest::isolate(); | 4485 v8::Isolate* isolate = CcTest::isolate(); |
4488 v8::HandleScope scope(isolate); | 4486 v8::HandleScope scope(isolate); |
4489 CompileRun( | 4487 CompileRun( |
(...skipping 10 matching lines...) Expand all Loading... |
4500 const char* source = | 4498 const char* source = |
4501 " (function() {" | 4499 " (function() {" |
4502 " function hat() { this.x = 5; }" | 4500 " function hat() { this.x = 5; }" |
4503 " createObj(hat);" | 4501 " createObj(hat);" |
4504 " createObj(hat);" | 4502 " createObj(hat);" |
4505 " return hat;" | 4503 " return hat;" |
4506 " })();"; | 4504 " })();"; |
4507 garbage.Reset(isolate, CompileRun(source)->ToObject(isolate)); | 4505 garbage.Reset(isolate, CompileRun(source)->ToObject(isolate)); |
4508 } | 4506 } |
4509 weak_ic_cleared = false; | 4507 weak_ic_cleared = false; |
4510 garbage.SetWeak(static_cast<void*>(&garbage), &ClearWeakIC); | 4508 garbage.SetWeak(&garbage, &ClearWeakIC, v8::WeakCallbackType::kParameter); |
4511 Heap* heap = CcTest::i_isolate()->heap(); | 4509 Heap* heap = CcTest::i_isolate()->heap(); |
4512 heap->CollectAllGarbage(); | 4510 heap->CollectAllGarbage(); |
4513 CHECK(weak_ic_cleared); | 4511 CHECK(weak_ic_cleared); |
4514 | 4512 |
4515 // We've determined the constructor in createObj has had it's weak cell | 4513 // We've determined the constructor in createObj has had it's weak cell |
4516 // cleared. Now, verify that one additional call with a new function | 4514 // cleared. Now, verify that one additional call with a new function |
4517 // allows monomorphicity. | 4515 // allows monomorphicity. |
4518 Handle<TypeFeedbackVector> feedback_vector = Handle<TypeFeedbackVector>( | 4516 Handle<TypeFeedbackVector> feedback_vector = Handle<TypeFeedbackVector>( |
4519 createObj->shared()->feedback_vector(), CcTest::i_isolate()); | 4517 createObj->shared()->feedback_vector(), CcTest::i_isolate()); |
4520 for (int i = 0; i < 20; i++) { | 4518 for (int i = 0; i < 20; i++) { |
(...skipping 18 matching lines...) Expand all Loading... |
4539 i::FLAG_stress_compaction = false; | 4537 i::FLAG_stress_compaction = false; |
4540 CcTest::InitializeVM(); | 4538 CcTest::InitializeVM(); |
4541 v8::Isolate* isolate = CcTest::isolate(); | 4539 v8::Isolate* isolate = CcTest::isolate(); |
4542 v8::HandleScope scope(isolate); | 4540 v8::HandleScope scope(isolate); |
4543 v8::Persistent<v8::Object> garbage; | 4541 v8::Persistent<v8::Object> garbage; |
4544 { | 4542 { |
4545 v8::HandleScope scope(isolate); | 4543 v8::HandleScope scope(isolate); |
4546 garbage.Reset(isolate, CompileRun(source)->ToObject(isolate)); | 4544 garbage.Reset(isolate, CompileRun(source)->ToObject(isolate)); |
4547 } | 4545 } |
4548 weak_ic_cleared = false; | 4546 weak_ic_cleared = false; |
4549 garbage.SetWeak(static_cast<void*>(&garbage), &ClearWeakIC); | 4547 garbage.SetWeak(&garbage, &ClearWeakIC, v8::WeakCallbackType::kParameter); |
4550 Heap* heap = CcTest::i_isolate()->heap(); | 4548 Heap* heap = CcTest::i_isolate()->heap(); |
4551 heap->CollectAllGarbage(); | 4549 heap->CollectAllGarbage(); |
4552 CHECK(weak_ic_cleared); | 4550 CHECK(weak_ic_cleared); |
4553 } | 4551 } |
4554 | 4552 |
4555 | 4553 |
4556 // Each of the following "weak IC" tests creates an IC that embeds a map with | 4554 // Each of the following "weak IC" tests creates an IC that embeds a map with |
4557 // the prototype pointing to _proto_ and checks that the _proto_ dies on GC. | 4555 // the prototype pointing to _proto_ and checks that the _proto_ dies on GC. |
4558 TEST(WeakMapInMonomorphicLoadIC) { | 4556 TEST(WeakMapInMonomorphicLoadIC) { |
4559 CheckWeakness("function loadIC(obj) {" | 4557 CheckWeakness("function loadIC(obj) {" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5362 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8, 6); | 5360 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8, 6); |
5363 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8 - 1, 6); | 5361 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 8 - 1, 6); |
5364 | 5362 |
5365 // 32-bit cases. | 5363 // 32-bit cases. |
5366 TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16, 3); | 5364 TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16, 3); |
5367 TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16 - 3, 3); | 5365 TestRightTrimFixedTypedArray(i::kExternalUint8Array, 16 - 3, 3); |
5368 TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8, 3); | 5366 TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8, 3); |
5369 TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8 - 1, 3); | 5367 TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8 - 1, 3); |
5370 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 4, 3); | 5368 TestRightTrimFixedTypedArray(i::kExternalUint32Array, 4, 3); |
5371 } | 5369 } |
OLD | NEW |