OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 "#9 main.<anonymous closure> (test-lib:37:14)\n" | 3326 "#9 main.<anonymous closure> (test-lib:37:14)\n" |
3327 "#10 main (test-lib:37:24)"); | 3327 "#10 main (test-lib:37:24)"); |
3328 } | 3328 } |
3329 | 3329 |
3330 | 3330 |
3331 TEST_CASE(WeakProperty_PreserveCrossGen) { | 3331 TEST_CASE(WeakProperty_PreserveCrossGen) { |
3332 Isolate* isolate = Isolate::Current(); | 3332 Isolate* isolate = Isolate::Current(); |
3333 WeakProperty& weak = WeakProperty::Handle(); | 3333 WeakProperty& weak = WeakProperty::Handle(); |
3334 { | 3334 { |
3335 // Weak property and value in new. Key in old. | 3335 // Weak property and value in new. Key in old. |
3336 HANDLESCOPE(isolate); | 3336 HANDLESCOPE(thread); |
3337 String& key = String::Handle(); | 3337 String& key = String::Handle(); |
3338 key ^= OneByteString::New("key", Heap::kOld); | 3338 key ^= OneByteString::New("key", Heap::kOld); |
3339 String& value = String::Handle(); | 3339 String& value = String::Handle(); |
3340 value ^= OneByteString::New("value", Heap::kNew); | 3340 value ^= OneByteString::New("value", Heap::kNew); |
3341 weak ^= WeakProperty::New(Heap::kNew); | 3341 weak ^= WeakProperty::New(Heap::kNew); |
3342 weak.set_key(key); | 3342 weak.set_key(key); |
3343 weak.set_value(value); | 3343 weak.set_value(value); |
3344 key ^= OneByteString::null(); | 3344 key ^= OneByteString::null(); |
3345 value ^= OneByteString::null(); | 3345 value ^= OneByteString::null(); |
3346 } | 3346 } |
3347 isolate->heap()->CollectAllGarbage(); | 3347 isolate->heap()->CollectAllGarbage(); |
3348 // Weak property key and value should survive due to cross-generation | 3348 // Weak property key and value should survive due to cross-generation |
3349 // pointers. | 3349 // pointers. |
3350 EXPECT(weak.key() != Object::null()); | 3350 EXPECT(weak.key() != Object::null()); |
3351 EXPECT(weak.value() != Object::null()); | 3351 EXPECT(weak.value() != Object::null()); |
3352 { | 3352 { |
3353 // Weak property and value in old. Key in new. | 3353 // Weak property and value in old. Key in new. |
3354 HANDLESCOPE(isolate); | 3354 HANDLESCOPE(thread); |
3355 String& key = String::Handle(); | 3355 String& key = String::Handle(); |
3356 key ^= OneByteString::New("key", Heap::kNew); | 3356 key ^= OneByteString::New("key", Heap::kNew); |
3357 String& value = String::Handle(); | 3357 String& value = String::Handle(); |
3358 value ^= OneByteString::New("value", Heap::kOld); | 3358 value ^= OneByteString::New("value", Heap::kOld); |
3359 weak ^= WeakProperty::New(Heap::kOld); | 3359 weak ^= WeakProperty::New(Heap::kOld); |
3360 weak.set_key(key); | 3360 weak.set_key(key); |
3361 weak.set_value(value); | 3361 weak.set_value(value); |
3362 key ^= OneByteString::null(); | 3362 key ^= OneByteString::null(); |
3363 value ^= OneByteString::null(); | 3363 value ^= OneByteString::null(); |
3364 } | 3364 } |
3365 isolate->heap()->CollectAllGarbage(); | 3365 isolate->heap()->CollectAllGarbage(); |
3366 // Weak property key and value should survive due to cross-generation | 3366 // Weak property key and value should survive due to cross-generation |
3367 // pointers. | 3367 // pointers. |
3368 EXPECT(weak.key() != Object::null()); | 3368 EXPECT(weak.key() != Object::null()); |
3369 EXPECT(weak.value() != Object::null()); | 3369 EXPECT(weak.value() != Object::null()); |
3370 { | 3370 { |
3371 // Weak property and value in new. Key is a Smi. | 3371 // Weak property and value in new. Key is a Smi. |
3372 HANDLESCOPE(isolate); | 3372 HANDLESCOPE(thread); |
3373 Integer& key = Integer::Handle(); | 3373 Integer& key = Integer::Handle(); |
3374 key ^= Integer::New(31); | 3374 key ^= Integer::New(31); |
3375 String& value = String::Handle(); | 3375 String& value = String::Handle(); |
3376 value ^= OneByteString::New("value", Heap::kNew); | 3376 value ^= OneByteString::New("value", Heap::kNew); |
3377 weak ^= WeakProperty::New(Heap::kNew); | 3377 weak ^= WeakProperty::New(Heap::kNew); |
3378 weak.set_key(key); | 3378 weak.set_key(key); |
3379 weak.set_value(value); | 3379 weak.set_value(value); |
3380 key ^= Integer::null(); | 3380 key ^= Integer::null(); |
3381 value ^= OneByteString::null(); | 3381 value ^= OneByteString::null(); |
3382 } | 3382 } |
3383 isolate->heap()->CollectAllGarbage(); | 3383 isolate->heap()->CollectAllGarbage(); |
3384 // Weak property key and value should survive due implicit liveness of | 3384 // Weak property key and value should survive due implicit liveness of |
3385 // non-heap objects. | 3385 // non-heap objects. |
3386 EXPECT(weak.key() != Object::null()); | 3386 EXPECT(weak.key() != Object::null()); |
3387 EXPECT(weak.value() != Object::null()); | 3387 EXPECT(weak.value() != Object::null()); |
3388 { | 3388 { |
3389 // Weak property and value in old. Key is a Smi. | 3389 // Weak property and value in old. Key is a Smi. |
3390 HANDLESCOPE(isolate); | 3390 HANDLESCOPE(thread); |
3391 Integer& key = Integer::Handle(); | 3391 Integer& key = Integer::Handle(); |
3392 key ^= Integer::New(32); | 3392 key ^= Integer::New(32); |
3393 String& value = String::Handle(); | 3393 String& value = String::Handle(); |
3394 value ^= OneByteString::New("value", Heap::kOld); | 3394 value ^= OneByteString::New("value", Heap::kOld); |
3395 weak ^= WeakProperty::New(Heap::kOld); | 3395 weak ^= WeakProperty::New(Heap::kOld); |
3396 weak.set_key(key); | 3396 weak.set_key(key); |
3397 weak.set_value(value); | 3397 weak.set_value(value); |
3398 key ^= OneByteString::null(); | 3398 key ^= OneByteString::null(); |
3399 value ^= OneByteString::null(); | 3399 value ^= OneByteString::null(); |
3400 } | 3400 } |
3401 isolate->heap()->CollectAllGarbage(); | 3401 isolate->heap()->CollectAllGarbage(); |
3402 // Weak property key and value should survive due implicit liveness of | 3402 // Weak property key and value should survive due implicit liveness of |
3403 // non-heap objects. | 3403 // non-heap objects. |
3404 EXPECT(weak.key() != Object::null()); | 3404 EXPECT(weak.key() != Object::null()); |
3405 EXPECT(weak.value() != Object::null()); | 3405 EXPECT(weak.value() != Object::null()); |
3406 { | 3406 { |
3407 // Weak property and value in new. Key in VM isolate. | 3407 // Weak property and value in new. Key in VM isolate. |
3408 HANDLESCOPE(isolate); | 3408 HANDLESCOPE(thread); |
3409 String& value = String::Handle(); | 3409 String& value = String::Handle(); |
3410 value ^= OneByteString::New("value", Heap::kNew); | 3410 value ^= OneByteString::New("value", Heap::kNew); |
3411 weak ^= WeakProperty::New(Heap::kNew); | 3411 weak ^= WeakProperty::New(Heap::kNew); |
3412 weak.set_key(Symbols::Dot()); | 3412 weak.set_key(Symbols::Dot()); |
3413 weak.set_value(value); | 3413 weak.set_value(value); |
3414 String& key = String::Handle(); | 3414 String& key = String::Handle(); |
3415 key ^= OneByteString::null(); | 3415 key ^= OneByteString::null(); |
3416 value ^= OneByteString::null(); | 3416 value ^= OneByteString::null(); |
3417 } | 3417 } |
3418 isolate->heap()->CollectAllGarbage(); | 3418 isolate->heap()->CollectAllGarbage(); |
3419 // Weak property key and value should survive due to cross-generation | 3419 // Weak property key and value should survive due to cross-generation |
3420 // pointers. | 3420 // pointers. |
3421 EXPECT(weak.key() != Object::null()); | 3421 EXPECT(weak.key() != Object::null()); |
3422 EXPECT(weak.value() != Object::null()); | 3422 EXPECT(weak.value() != Object::null()); |
3423 { | 3423 { |
3424 // Weak property and value in old. Key in VM isolate. | 3424 // Weak property and value in old. Key in VM isolate. |
3425 HANDLESCOPE(isolate); | 3425 HANDLESCOPE(thread); |
3426 String& value = String::Handle(); | 3426 String& value = String::Handle(); |
3427 value ^= OneByteString::New("value", Heap::kOld); | 3427 value ^= OneByteString::New("value", Heap::kOld); |
3428 weak ^= WeakProperty::New(Heap::kOld); | 3428 weak ^= WeakProperty::New(Heap::kOld); |
3429 weak.set_key(Symbols::Dot()); | 3429 weak.set_key(Symbols::Dot()); |
3430 weak.set_value(value); | 3430 weak.set_value(value); |
3431 String& key = String::Handle(); | 3431 String& key = String::Handle(); |
3432 key ^= OneByteString::null(); | 3432 key ^= OneByteString::null(); |
3433 value ^= OneByteString::null(); | 3433 value ^= OneByteString::null(); |
3434 } | 3434 } |
3435 isolate->heap()->CollectAllGarbage(); | 3435 isolate->heap()->CollectAllGarbage(); |
3436 // Weak property key and value should survive due to cross-generation | 3436 // Weak property key and value should survive due to cross-generation |
3437 // pointers. | 3437 // pointers. |
3438 EXPECT(weak.key() != Object::null()); | 3438 EXPECT(weak.key() != Object::null()); |
3439 EXPECT(weak.value() != Object::null()); | 3439 EXPECT(weak.value() != Object::null()); |
3440 } | 3440 } |
3441 | 3441 |
3442 | 3442 |
3443 TEST_CASE(WeakProperty_PreserveRecurse) { | 3443 TEST_CASE(WeakProperty_PreserveRecurse) { |
3444 // This used to end in an infinite recursion. Caused by scavenging the weak | 3444 // This used to end in an infinite recursion. Caused by scavenging the weak |
3445 // property before scavenging the key. | 3445 // property before scavenging the key. |
3446 Isolate* isolate = Isolate::Current(); | 3446 Isolate* isolate = Isolate::Current(); |
3447 WeakProperty& weak = WeakProperty::Handle(); | 3447 WeakProperty& weak = WeakProperty::Handle(); |
3448 Array& arr = Array::Handle(Array::New(1)); | 3448 Array& arr = Array::Handle(Array::New(1)); |
3449 { | 3449 { |
3450 HANDLESCOPE(isolate); | 3450 HANDLESCOPE(thread); |
3451 String& key = String::Handle(); | 3451 String& key = String::Handle(); |
3452 key ^= OneByteString::New("key"); | 3452 key ^= OneByteString::New("key"); |
3453 arr.SetAt(0, key); | 3453 arr.SetAt(0, key); |
3454 String& value = String::Handle(); | 3454 String& value = String::Handle(); |
3455 value ^= OneByteString::New("value"); | 3455 value ^= OneByteString::New("value"); |
3456 weak ^= WeakProperty::New(); | 3456 weak ^= WeakProperty::New(); |
3457 weak.set_key(key); | 3457 weak.set_key(key); |
3458 weak.set_value(value); | 3458 weak.set_value(value); |
3459 } | 3459 } |
3460 isolate->heap()->CollectAllGarbage(); | 3460 isolate->heap()->CollectAllGarbage(); |
3461 EXPECT(weak.key() != Object::null()); | 3461 EXPECT(weak.key() != Object::null()); |
3462 EXPECT(weak.value() != Object::null()); | 3462 EXPECT(weak.value() != Object::null()); |
3463 } | 3463 } |
3464 | 3464 |
3465 | 3465 |
3466 TEST_CASE(WeakProperty_PreserveOne_NewSpace) { | 3466 TEST_CASE(WeakProperty_PreserveOne_NewSpace) { |
3467 Isolate* isolate = Isolate::Current(); | 3467 Isolate* isolate = Isolate::Current(); |
3468 WeakProperty& weak = WeakProperty::Handle(); | 3468 WeakProperty& weak = WeakProperty::Handle(); |
3469 String& key = String::Handle(); | 3469 String& key = String::Handle(); |
3470 key ^= OneByteString::New("key"); | 3470 key ^= OneByteString::New("key"); |
3471 { | 3471 { |
3472 HANDLESCOPE(isolate); | 3472 HANDLESCOPE(thread); |
3473 String& value = String::Handle(); | 3473 String& value = String::Handle(); |
3474 value ^= OneByteString::New("value"); | 3474 value ^= OneByteString::New("value"); |
3475 weak ^= WeakProperty::New(); | 3475 weak ^= WeakProperty::New(); |
3476 weak.set_key(key); | 3476 weak.set_key(key); |
3477 weak.set_value(value); | 3477 weak.set_value(value); |
3478 } | 3478 } |
3479 isolate->heap()->CollectAllGarbage(); | 3479 isolate->heap()->CollectAllGarbage(); |
3480 EXPECT(weak.key() != Object::null()); | 3480 EXPECT(weak.key() != Object::null()); |
3481 EXPECT(weak.value() != Object::null()); | 3481 EXPECT(weak.value() != Object::null()); |
3482 } | 3482 } |
3483 | 3483 |
3484 | 3484 |
3485 TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { | 3485 TEST_CASE(WeakProperty_PreserveTwo_NewSpace) { |
3486 Isolate* isolate = Isolate::Current(); | 3486 Isolate* isolate = Isolate::Current(); |
3487 WeakProperty& weak1 = WeakProperty::Handle(); | 3487 WeakProperty& weak1 = WeakProperty::Handle(); |
3488 String& key1 = String::Handle(); | 3488 String& key1 = String::Handle(); |
3489 key1 ^= OneByteString::New("key1"); | 3489 key1 ^= OneByteString::New("key1"); |
3490 WeakProperty& weak2 = WeakProperty::Handle(); | 3490 WeakProperty& weak2 = WeakProperty::Handle(); |
3491 String& key2 = String::Handle(); | 3491 String& key2 = String::Handle(); |
3492 key2 ^= OneByteString::New("key2"); | 3492 key2 ^= OneByteString::New("key2"); |
3493 { | 3493 { |
3494 HANDLESCOPE(isolate); | 3494 HANDLESCOPE(thread); |
3495 String& value1 = String::Handle(); | 3495 String& value1 = String::Handle(); |
3496 value1 ^= OneByteString::New("value1"); | 3496 value1 ^= OneByteString::New("value1"); |
3497 weak1 ^= WeakProperty::New(); | 3497 weak1 ^= WeakProperty::New(); |
3498 weak1.set_key(key1); | 3498 weak1.set_key(key1); |
3499 weak1.set_value(value1); | 3499 weak1.set_value(value1); |
3500 String& value2 = String::Handle(); | 3500 String& value2 = String::Handle(); |
3501 value2 ^= OneByteString::New("value2"); | 3501 value2 ^= OneByteString::New("value2"); |
3502 weak2 ^= WeakProperty::New(); | 3502 weak2 ^= WeakProperty::New(); |
3503 weak2.set_key(key2); | 3503 weak2.set_key(key2); |
3504 weak2.set_value(value2); | 3504 weak2.set_value(value2); |
3505 } | 3505 } |
3506 isolate->heap()->CollectAllGarbage(); | 3506 isolate->heap()->CollectAllGarbage(); |
3507 EXPECT(weak1.key() != Object::null()); | 3507 EXPECT(weak1.key() != Object::null()); |
3508 EXPECT(weak1.value() != Object::null()); | 3508 EXPECT(weak1.value() != Object::null()); |
3509 EXPECT(weak2.key() != Object::null()); | 3509 EXPECT(weak2.key() != Object::null()); |
3510 EXPECT(weak2.value() != Object::null()); | 3510 EXPECT(weak2.value() != Object::null()); |
3511 } | 3511 } |
3512 | 3512 |
3513 | 3513 |
3514 TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { | 3514 TEST_CASE(WeakProperty_PreserveTwoShared_NewSpace) { |
3515 Isolate* isolate = Isolate::Current(); | 3515 Isolate* isolate = Isolate::Current(); |
3516 WeakProperty& weak1 = WeakProperty::Handle(); | 3516 WeakProperty& weak1 = WeakProperty::Handle(); |
3517 WeakProperty& weak2 = WeakProperty::Handle(); | 3517 WeakProperty& weak2 = WeakProperty::Handle(); |
3518 String& key = String::Handle(); | 3518 String& key = String::Handle(); |
3519 key ^= OneByteString::New("key"); | 3519 key ^= OneByteString::New("key"); |
3520 { | 3520 { |
3521 HANDLESCOPE(isolate); | 3521 HANDLESCOPE(thread); |
3522 String& value1 = String::Handle(); | 3522 String& value1 = String::Handle(); |
3523 value1 ^= OneByteString::New("value1"); | 3523 value1 ^= OneByteString::New("value1"); |
3524 weak1 ^= WeakProperty::New(); | 3524 weak1 ^= WeakProperty::New(); |
3525 weak1.set_key(key); | 3525 weak1.set_key(key); |
3526 weak1.set_value(value1); | 3526 weak1.set_value(value1); |
3527 String& value2 = String::Handle(); | 3527 String& value2 = String::Handle(); |
3528 value2 ^= OneByteString::New("value2"); | 3528 value2 ^= OneByteString::New("value2"); |
3529 weak2 ^= WeakProperty::New(); | 3529 weak2 ^= WeakProperty::New(); |
3530 weak2.set_key(key); | 3530 weak2.set_key(key); |
3531 weak2.set_value(value2); | 3531 weak2.set_value(value2); |
3532 } | 3532 } |
3533 isolate->heap()->CollectAllGarbage(); | 3533 isolate->heap()->CollectAllGarbage(); |
3534 EXPECT(weak1.key() != Object::null()); | 3534 EXPECT(weak1.key() != Object::null()); |
3535 EXPECT(weak1.value() != Object::null()); | 3535 EXPECT(weak1.value() != Object::null()); |
3536 EXPECT(weak2.key() != Object::null()); | 3536 EXPECT(weak2.key() != Object::null()); |
3537 EXPECT(weak2.value() != Object::null()); | 3537 EXPECT(weak2.value() != Object::null()); |
3538 } | 3538 } |
3539 | 3539 |
3540 | 3540 |
3541 TEST_CASE(WeakProperty_PreserveOne_OldSpace) { | 3541 TEST_CASE(WeakProperty_PreserveOne_OldSpace) { |
3542 Isolate* isolate = Isolate::Current(); | 3542 Isolate* isolate = Isolate::Current(); |
3543 WeakProperty& weak = WeakProperty::Handle(); | 3543 WeakProperty& weak = WeakProperty::Handle(); |
3544 String& key = String::Handle(); | 3544 String& key = String::Handle(); |
3545 key ^= OneByteString::New("key", Heap::kOld); | 3545 key ^= OneByteString::New("key", Heap::kOld); |
3546 { | 3546 { |
3547 HANDLESCOPE(isolate); | 3547 HANDLESCOPE(thread); |
3548 String& value = String::Handle(); | 3548 String& value = String::Handle(); |
3549 value ^= OneByteString::New("value", Heap::kOld); | 3549 value ^= OneByteString::New("value", Heap::kOld); |
3550 weak ^= WeakProperty::New(Heap::kOld); | 3550 weak ^= WeakProperty::New(Heap::kOld); |
3551 weak.set_key(key); | 3551 weak.set_key(key); |
3552 weak.set_value(value); | 3552 weak.set_value(value); |
3553 } | 3553 } |
3554 isolate->heap()->CollectAllGarbage(); | 3554 isolate->heap()->CollectAllGarbage(); |
3555 EXPECT(weak.key() != Object::null()); | 3555 EXPECT(weak.key() != Object::null()); |
3556 EXPECT(weak.value() != Object::null()); | 3556 EXPECT(weak.value() != Object::null()); |
3557 } | 3557 } |
3558 | 3558 |
3559 | 3559 |
3560 TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { | 3560 TEST_CASE(WeakProperty_PreserveTwo_OldSpace) { |
3561 Isolate* isolate = Isolate::Current(); | 3561 Isolate* isolate = Isolate::Current(); |
3562 WeakProperty& weak1 = WeakProperty::Handle(); | 3562 WeakProperty& weak1 = WeakProperty::Handle(); |
3563 String& key1 = String::Handle(); | 3563 String& key1 = String::Handle(); |
3564 key1 ^= OneByteString::New("key1", Heap::kOld); | 3564 key1 ^= OneByteString::New("key1", Heap::kOld); |
3565 WeakProperty& weak2 = WeakProperty::Handle(); | 3565 WeakProperty& weak2 = WeakProperty::Handle(); |
3566 String& key2 = String::Handle(); | 3566 String& key2 = String::Handle(); |
3567 key2 ^= OneByteString::New("key2", Heap::kOld); | 3567 key2 ^= OneByteString::New("key2", Heap::kOld); |
3568 { | 3568 { |
3569 HANDLESCOPE(isolate); | 3569 HANDLESCOPE(thread); |
3570 String& value1 = String::Handle(); | 3570 String& value1 = String::Handle(); |
3571 value1 ^= OneByteString::New("value1", Heap::kOld); | 3571 value1 ^= OneByteString::New("value1", Heap::kOld); |
3572 weak1 ^= WeakProperty::New(Heap::kOld); | 3572 weak1 ^= WeakProperty::New(Heap::kOld); |
3573 weak1.set_key(key1); | 3573 weak1.set_key(key1); |
3574 weak1.set_value(value1); | 3574 weak1.set_value(value1); |
3575 String& value2 = String::Handle(); | 3575 String& value2 = String::Handle(); |
3576 value2 ^= OneByteString::New("value2", Heap::kOld); | 3576 value2 ^= OneByteString::New("value2", Heap::kOld); |
3577 weak2 ^= WeakProperty::New(Heap::kOld); | 3577 weak2 ^= WeakProperty::New(Heap::kOld); |
3578 weak2.set_key(key2); | 3578 weak2.set_key(key2); |
3579 weak2.set_value(value2); | 3579 weak2.set_value(value2); |
3580 } | 3580 } |
3581 isolate->heap()->CollectAllGarbage(); | 3581 isolate->heap()->CollectAllGarbage(); |
3582 EXPECT(weak1.key() != Object::null()); | 3582 EXPECT(weak1.key() != Object::null()); |
3583 EXPECT(weak1.value() != Object::null()); | 3583 EXPECT(weak1.value() != Object::null()); |
3584 EXPECT(weak2.key() != Object::null()); | 3584 EXPECT(weak2.key() != Object::null()); |
3585 EXPECT(weak2.value() != Object::null()); | 3585 EXPECT(weak2.value() != Object::null()); |
3586 } | 3586 } |
3587 | 3587 |
3588 | 3588 |
3589 TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { | 3589 TEST_CASE(WeakProperty_PreserveTwoShared_OldSpace) { |
3590 Isolate* isolate = Isolate::Current(); | 3590 Isolate* isolate = Isolate::Current(); |
3591 WeakProperty& weak1 = WeakProperty::Handle(); | 3591 WeakProperty& weak1 = WeakProperty::Handle(); |
3592 WeakProperty& weak2 = WeakProperty::Handle(); | 3592 WeakProperty& weak2 = WeakProperty::Handle(); |
3593 String& key = String::Handle(); | 3593 String& key = String::Handle(); |
3594 key ^= OneByteString::New("key", Heap::kOld); | 3594 key ^= OneByteString::New("key", Heap::kOld); |
3595 { | 3595 { |
3596 HANDLESCOPE(isolate); | 3596 HANDLESCOPE(thread); |
3597 String& value1 = String::Handle(); | 3597 String& value1 = String::Handle(); |
3598 value1 ^= OneByteString::New("value1", Heap::kOld); | 3598 value1 ^= OneByteString::New("value1", Heap::kOld); |
3599 weak1 ^= WeakProperty::New(Heap::kOld); | 3599 weak1 ^= WeakProperty::New(Heap::kOld); |
3600 weak1.set_key(key); | 3600 weak1.set_key(key); |
3601 weak1.set_value(value1); | 3601 weak1.set_value(value1); |
3602 String& value2 = String::Handle(); | 3602 String& value2 = String::Handle(); |
3603 value2 ^= OneByteString::New("value2", Heap::kOld); | 3603 value2 ^= OneByteString::New("value2", Heap::kOld); |
3604 weak2 ^= WeakProperty::New(Heap::kOld); | 3604 weak2 ^= WeakProperty::New(Heap::kOld); |
3605 weak2.set_key(key); | 3605 weak2.set_key(key); |
3606 weak2.set_value(value2); | 3606 weak2.set_value(value2); |
3607 } | 3607 } |
3608 isolate->heap()->CollectAllGarbage(); | 3608 isolate->heap()->CollectAllGarbage(); |
3609 EXPECT(weak1.key() != Object::null()); | 3609 EXPECT(weak1.key() != Object::null()); |
3610 EXPECT(weak1.value() != Object::null()); | 3610 EXPECT(weak1.value() != Object::null()); |
3611 EXPECT(weak2.key() != Object::null()); | 3611 EXPECT(weak2.key() != Object::null()); |
3612 EXPECT(weak2.value() != Object::null()); | 3612 EXPECT(weak2.value() != Object::null()); |
3613 } | 3613 } |
3614 | 3614 |
3615 | 3615 |
3616 TEST_CASE(WeakProperty_ClearOne_NewSpace) { | 3616 TEST_CASE(WeakProperty_ClearOne_NewSpace) { |
3617 Isolate* isolate = Isolate::Current(); | 3617 Isolate* isolate = Isolate::Current(); |
3618 WeakProperty& weak = WeakProperty::Handle(); | 3618 WeakProperty& weak = WeakProperty::Handle(); |
3619 { | 3619 { |
3620 HANDLESCOPE(isolate); | 3620 HANDLESCOPE(thread); |
3621 String& key = String::Handle(); | 3621 String& key = String::Handle(); |
3622 key ^= OneByteString::New("key"); | 3622 key ^= OneByteString::New("key"); |
3623 String& value = String::Handle(); | 3623 String& value = String::Handle(); |
3624 value ^= OneByteString::New("value"); | 3624 value ^= OneByteString::New("value"); |
3625 weak ^= WeakProperty::New(); | 3625 weak ^= WeakProperty::New(); |
3626 weak.set_key(key); | 3626 weak.set_key(key); |
3627 weak.set_value(value); | 3627 weak.set_value(value); |
3628 key ^= OneByteString::null(); | 3628 key ^= OneByteString::null(); |
3629 value ^= OneByteString::null(); | 3629 value ^= OneByteString::null(); |
3630 } | 3630 } |
3631 isolate->heap()->CollectAllGarbage(); | 3631 isolate->heap()->CollectAllGarbage(); |
3632 EXPECT(weak.key() == Object::null()); | 3632 EXPECT(weak.key() == Object::null()); |
3633 EXPECT(weak.value() == Object::null()); | 3633 EXPECT(weak.value() == Object::null()); |
3634 } | 3634 } |
3635 | 3635 |
3636 | 3636 |
3637 TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { | 3637 TEST_CASE(WeakProperty_ClearTwoShared_NewSpace) { |
3638 Isolate* isolate = Isolate::Current(); | 3638 Isolate* isolate = Isolate::Current(); |
3639 WeakProperty& weak1 = WeakProperty::Handle(); | 3639 WeakProperty& weak1 = WeakProperty::Handle(); |
3640 WeakProperty& weak2 = WeakProperty::Handle(); | 3640 WeakProperty& weak2 = WeakProperty::Handle(); |
3641 { | 3641 { |
3642 HANDLESCOPE(isolate); | 3642 HANDLESCOPE(thread); |
3643 String& key = String::Handle(); | 3643 String& key = String::Handle(); |
3644 key ^= OneByteString::New("key"); | 3644 key ^= OneByteString::New("key"); |
3645 String& value1 = String::Handle(); | 3645 String& value1 = String::Handle(); |
3646 value1 ^= OneByteString::New("value1"); | 3646 value1 ^= OneByteString::New("value1"); |
3647 weak1 ^= WeakProperty::New(); | 3647 weak1 ^= WeakProperty::New(); |
3648 weak1.set_key(key); | 3648 weak1.set_key(key); |
3649 weak1.set_value(value1); | 3649 weak1.set_value(value1); |
3650 String& value2 = String::Handle(); | 3650 String& value2 = String::Handle(); |
3651 value2 ^= OneByteString::New("value2"); | 3651 value2 ^= OneByteString::New("value2"); |
3652 weak2 ^= WeakProperty::New(); | 3652 weak2 ^= WeakProperty::New(); |
3653 weak2.set_key(key); | 3653 weak2.set_key(key); |
3654 weak2.set_value(value2); | 3654 weak2.set_value(value2); |
3655 } | 3655 } |
3656 isolate->heap()->CollectAllGarbage(); | 3656 isolate->heap()->CollectAllGarbage(); |
3657 EXPECT(weak1.key() == Object::null()); | 3657 EXPECT(weak1.key() == Object::null()); |
3658 EXPECT(weak1.value() == Object::null()); | 3658 EXPECT(weak1.value() == Object::null()); |
3659 EXPECT(weak2.key() == Object::null()); | 3659 EXPECT(weak2.key() == Object::null()); |
3660 EXPECT(weak2.value() == Object::null()); | 3660 EXPECT(weak2.value() == Object::null()); |
3661 } | 3661 } |
3662 | 3662 |
3663 | 3663 |
3664 TEST_CASE(WeakProperty_ClearOne_OldSpace) { | 3664 TEST_CASE(WeakProperty_ClearOne_OldSpace) { |
3665 Isolate* isolate = Isolate::Current(); | 3665 Isolate* isolate = Isolate::Current(); |
3666 WeakProperty& weak = WeakProperty::Handle(); | 3666 WeakProperty& weak = WeakProperty::Handle(); |
3667 { | 3667 { |
3668 HANDLESCOPE(isolate); | 3668 HANDLESCOPE(thread); |
3669 String& key = String::Handle(); | 3669 String& key = String::Handle(); |
3670 key ^= OneByteString::New("key", Heap::kOld); | 3670 key ^= OneByteString::New("key", Heap::kOld); |
3671 String& value = String::Handle(); | 3671 String& value = String::Handle(); |
3672 value ^= OneByteString::New("value", Heap::kOld); | 3672 value ^= OneByteString::New("value", Heap::kOld); |
3673 weak ^= WeakProperty::New(Heap::kOld); | 3673 weak ^= WeakProperty::New(Heap::kOld); |
3674 weak.set_key(key); | 3674 weak.set_key(key); |
3675 weak.set_value(value); | 3675 weak.set_value(value); |
3676 key ^= OneByteString::null(); | 3676 key ^= OneByteString::null(); |
3677 value ^= OneByteString::null(); | 3677 value ^= OneByteString::null(); |
3678 } | 3678 } |
3679 isolate->heap()->CollectAllGarbage(); | 3679 isolate->heap()->CollectAllGarbage(); |
3680 EXPECT(weak.key() == Object::null()); | 3680 EXPECT(weak.key() == Object::null()); |
3681 EXPECT(weak.value() == Object::null()); | 3681 EXPECT(weak.value() == Object::null()); |
3682 } | 3682 } |
3683 | 3683 |
3684 | 3684 |
3685 TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { | 3685 TEST_CASE(WeakProperty_ClearTwoShared_OldSpace) { |
3686 Isolate* isolate = Isolate::Current(); | 3686 Isolate* isolate = Isolate::Current(); |
3687 WeakProperty& weak1 = WeakProperty::Handle(); | 3687 WeakProperty& weak1 = WeakProperty::Handle(); |
3688 WeakProperty& weak2 = WeakProperty::Handle(); | 3688 WeakProperty& weak2 = WeakProperty::Handle(); |
3689 { | 3689 { |
3690 HANDLESCOPE(isolate); | 3690 HANDLESCOPE(thread); |
3691 String& key = String::Handle(); | 3691 String& key = String::Handle(); |
3692 key ^= OneByteString::New("key", Heap::kOld); | 3692 key ^= OneByteString::New("key", Heap::kOld); |
3693 String& value1 = String::Handle(); | 3693 String& value1 = String::Handle(); |
3694 value1 ^= OneByteString::New("value1"); | 3694 value1 ^= OneByteString::New("value1"); |
3695 weak1 ^= WeakProperty::New(Heap::kOld); | 3695 weak1 ^= WeakProperty::New(Heap::kOld); |
3696 weak1.set_key(key); | 3696 weak1.set_key(key); |
3697 weak1.set_value(value1); | 3697 weak1.set_value(value1); |
3698 String& value2 = String::Handle(); | 3698 String& value2 = String::Handle(); |
3699 value2 ^= OneByteString::New("value2", Heap::kOld); | 3699 value2 ^= OneByteString::New("value2", Heap::kOld); |
3700 weak2 ^= WeakProperty::New(Heap::kOld); | 3700 weak2 ^= WeakProperty::New(Heap::kOld); |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4703 EXPECT(iterator.MoveNext()); | 4703 EXPECT(iterator.MoveNext()); |
4704 object = iterator.CurrentKey(); | 4704 object = iterator.CurrentKey(); |
4705 EXPECT_STREQ("z", object.ToCString()); | 4705 EXPECT_STREQ("z", object.ToCString()); |
4706 object = iterator.CurrentValue(); | 4706 object = iterator.CurrentValue(); |
4707 EXPECT_STREQ("5", object.ToCString()); | 4707 EXPECT_STREQ("5", object.ToCString()); |
4708 | 4708 |
4709 EXPECT(!iterator.MoveNext()); | 4709 EXPECT(!iterator.MoveNext()); |
4710 } | 4710 } |
4711 | 4711 |
4712 } // namespace dart | 4712 } // namespace dart |
OLD | NEW |