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 3364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3375 String& key = String::Handle(); | 3375 String& key = String::Handle(); |
3376 key ^= OneByteString::New("key", Heap::kOld); | 3376 key ^= OneByteString::New("key", Heap::kOld); |
3377 String& value = String::Handle(); | 3377 String& value = String::Handle(); |
3378 value ^= OneByteString::New("value", Heap::kNew); | 3378 value ^= OneByteString::New("value", Heap::kNew); |
3379 weak ^= WeakProperty::New(Heap::kNew); | 3379 weak ^= WeakProperty::New(Heap::kNew); |
3380 weak.set_key(key); | 3380 weak.set_key(key); |
3381 weak.set_value(value); | 3381 weak.set_value(value); |
3382 key ^= OneByteString::null(); | 3382 key ^= OneByteString::null(); |
3383 value ^= OneByteString::null(); | 3383 value ^= OneByteString::null(); |
3384 } | 3384 } |
3385 isolate->heap()->CollectAllGarbage(); | 3385 isolate->heap()->CollectGarbage(Heap::kNew); |
| 3386 isolate->heap()->CollectGarbage(Heap::kOld); |
3386 // Weak property key and value should survive due to cross-generation | 3387 // Weak property key and value should survive due to cross-generation |
3387 // pointers. | 3388 // pointers. |
3388 EXPECT(weak.key() != Object::null()); | 3389 EXPECT(weak.key() != Object::null()); |
3389 EXPECT(weak.value() != Object::null()); | 3390 EXPECT(weak.value() != Object::null()); |
3390 { | 3391 { |
3391 // Weak property and value in old. Key in new. | 3392 // Weak property and value in old. Key in new. |
3392 HANDLESCOPE(thread); | 3393 HANDLESCOPE(thread); |
3393 String& key = String::Handle(); | 3394 String& key = String::Handle(); |
3394 key ^= OneByteString::New("key", Heap::kNew); | 3395 key ^= OneByteString::New("key", Heap::kNew); |
3395 String& value = String::Handle(); | 3396 String& value = String::Handle(); |
3396 value ^= OneByteString::New("value", Heap::kOld); | 3397 value ^= OneByteString::New("value", Heap::kOld); |
3397 weak ^= WeakProperty::New(Heap::kOld); | 3398 weak ^= WeakProperty::New(Heap::kOld); |
3398 weak.set_key(key); | 3399 weak.set_key(key); |
3399 weak.set_value(value); | 3400 weak.set_value(value); |
3400 key ^= OneByteString::null(); | 3401 key ^= OneByteString::null(); |
3401 value ^= OneByteString::null(); | 3402 value ^= OneByteString::null(); |
3402 } | 3403 } |
3403 isolate->heap()->CollectAllGarbage(); | 3404 isolate->heap()->CollectGarbage(Heap::kNew); |
| 3405 isolate->heap()->CollectGarbage(Heap::kOld); |
3404 // Weak property key and value should survive due to cross-generation | 3406 // Weak property key and value should survive due to cross-generation |
3405 // pointers. | 3407 // pointers. |
3406 EXPECT(weak.key() != Object::null()); | 3408 EXPECT(weak.key() != Object::null()); |
3407 EXPECT(weak.value() != Object::null()); | 3409 EXPECT(weak.value() != Object::null()); |
3408 { | 3410 { |
3409 // Weak property and value in new. Key is a Smi. | 3411 // Weak property and value in new. Key is a Smi. |
3410 HANDLESCOPE(thread); | 3412 HANDLESCOPE(thread); |
3411 Integer& key = Integer::Handle(); | 3413 Integer& key = Integer::Handle(); |
3412 key ^= Integer::New(31); | 3414 key ^= Integer::New(31); |
3413 String& value = String::Handle(); | 3415 String& value = String::Handle(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 HANDLESCOPE(thread); | 3448 HANDLESCOPE(thread); |
3447 String& value = String::Handle(); | 3449 String& value = String::Handle(); |
3448 value ^= OneByteString::New("value", Heap::kNew); | 3450 value ^= OneByteString::New("value", Heap::kNew); |
3449 weak ^= WeakProperty::New(Heap::kNew); | 3451 weak ^= WeakProperty::New(Heap::kNew); |
3450 weak.set_key(Symbols::Dot()); | 3452 weak.set_key(Symbols::Dot()); |
3451 weak.set_value(value); | 3453 weak.set_value(value); |
3452 String& key = String::Handle(); | 3454 String& key = String::Handle(); |
3453 key ^= OneByteString::null(); | 3455 key ^= OneByteString::null(); |
3454 value ^= OneByteString::null(); | 3456 value ^= OneByteString::null(); |
3455 } | 3457 } |
3456 isolate->heap()->CollectAllGarbage(); | 3458 isolate->heap()->CollectGarbage(Heap::kNew); |
| 3459 isolate->heap()->CollectGarbage(Heap::kOld); |
3457 // Weak property key and value should survive due to cross-generation | 3460 // Weak property key and value should survive due to cross-generation |
3458 // pointers. | 3461 // pointers. |
3459 EXPECT(weak.key() != Object::null()); | 3462 EXPECT(weak.key() != Object::null()); |
3460 EXPECT(weak.value() != Object::null()); | 3463 EXPECT(weak.value() != Object::null()); |
3461 { | 3464 { |
3462 // Weak property and value in old. Key in VM isolate. | 3465 // Weak property and value in old. Key in VM isolate. |
3463 HANDLESCOPE(thread); | 3466 HANDLESCOPE(thread); |
3464 String& value = String::Handle(); | 3467 String& value = String::Handle(); |
3465 value ^= OneByteString::New("value", Heap::kOld); | 3468 value ^= OneByteString::New("value", Heap::kOld); |
3466 weak ^= WeakProperty::New(Heap::kOld); | 3469 weak ^= WeakProperty::New(Heap::kOld); |
3467 weak.set_key(Symbols::Dot()); | 3470 weak.set_key(Symbols::Dot()); |
3468 weak.set_value(value); | 3471 weak.set_value(value); |
3469 String& key = String::Handle(); | 3472 String& key = String::Handle(); |
3470 key ^= OneByteString::null(); | 3473 key ^= OneByteString::null(); |
3471 value ^= OneByteString::null(); | 3474 value ^= OneByteString::null(); |
3472 } | 3475 } |
3473 isolate->heap()->CollectAllGarbage(); | 3476 isolate->heap()->CollectGarbage(Heap::kNew); |
| 3477 isolate->heap()->CollectGarbage(Heap::kOld); |
3474 // Weak property key and value should survive due to cross-generation | 3478 // Weak property key and value should survive due to cross-generation |
3475 // pointers. | 3479 // pointers. |
3476 EXPECT(weak.key() != Object::null()); | 3480 EXPECT(weak.key() != Object::null()); |
3477 EXPECT(weak.value() != Object::null()); | 3481 EXPECT(weak.value() != Object::null()); |
3478 } | 3482 } |
3479 | 3483 |
3480 | 3484 |
3481 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveRecurse) { | 3485 ISOLATE_UNIT_TEST_CASE(WeakProperty_PreserveRecurse) { |
3482 // This used to end in an infinite recursion. Caused by scavenging the weak | 3486 // This used to end in an infinite recursion. Caused by scavenging the weak |
3483 // property before scavenging the key. | 3487 // property before scavenging the key. |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4740 // utf32->utf16 conversion. | 4744 // utf32->utf16 conversion. |
4741 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff, | 4745 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff, |
4742 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff}; | 4746 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff}; |
4743 | 4747 |
4744 const String& str = | 4748 const String& str = |
4745 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); | 4749 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); |
4746 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); | 4750 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); |
4747 } | 4751 } |
4748 | 4752 |
4749 } // namespace dart | 4753 } // namespace dart |
OLD | NEW |