| 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 3497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3508 template<bool is_weak> | 3508 template<bool is_weak> |
| 3509 static void TestPersistentValueMap() { | 3509 static void TestPersistentValueMap() { |
| 3510 LocalContext env; | 3510 LocalContext env; |
| 3511 v8::Isolate* isolate = env->GetIsolate(); | 3511 v8::Isolate* isolate = env->GetIsolate(); |
| 3512 typedef v8::PersistentValueMap<int, v8::Object, | 3512 typedef v8::PersistentValueMap<int, v8::Object, |
| 3513 StdPersistentValueMapTraits<int, v8::Object, is_weak> > Map; | 3513 StdPersistentValueMapTraits<int, v8::Object, is_weak> > Map; |
| 3514 Map map(isolate); | 3514 Map map(isolate); |
| 3515 v8::internal::GlobalHandles* global_handles = | 3515 v8::internal::GlobalHandles* global_handles = |
| 3516 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3516 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3517 int initial_handle_count = global_handles->global_handles_count(); | 3517 int initial_handle_count = global_handles->global_handles_count(); |
| 3518 CHECK_EQ(0, map.Size()); | 3518 CHECK_EQ(0, static_cast<int>(map.Size())); |
| 3519 { | 3519 { |
| 3520 HandleScope scope(isolate); | 3520 HandleScope scope(isolate); |
| 3521 Local<v8::Object> obj = map.Get(7); | 3521 Local<v8::Object> obj = map.Get(7); |
| 3522 CHECK(obj.IsEmpty()); | 3522 CHECK(obj.IsEmpty()); |
| 3523 Local<v8::Object> expected = v8::Object::New(isolate); | 3523 Local<v8::Object> expected = v8::Object::New(isolate); |
| 3524 map.Set(7, expected); | 3524 map.Set(7, expected); |
| 3525 CHECK_EQ(1, map.Size()); | 3525 CHECK_EQ(1, static_cast<int>(map.Size())); |
| 3526 obj = map.Get(7); | 3526 obj = map.Get(7); |
| 3527 CHECK_EQ(expected, obj); | 3527 CHECK_EQ(expected, obj); |
| 3528 v8::UniquePersistent<v8::Object> removed = map.Remove(7); | 3528 v8::UniquePersistent<v8::Object> removed = map.Remove(7); |
| 3529 CHECK_EQ(0, map.Size()); | 3529 CHECK_EQ(0, static_cast<int>(map.Size())); |
| 3530 CHECK(expected == removed); | 3530 CHECK(expected == removed); |
| 3531 removed = map.Remove(7); | 3531 removed = map.Remove(7); |
| 3532 CHECK(removed.IsEmpty()); | 3532 CHECK(removed.IsEmpty()); |
| 3533 map.Set(8, expected); | 3533 map.Set(8, expected); |
| 3534 CHECK_EQ(1, map.Size()); | 3534 CHECK_EQ(1, static_cast<int>(map.Size())); |
| 3535 map.Set(8, expected); | 3535 map.Set(8, expected); |
| 3536 CHECK_EQ(1, map.Size()); | 3536 CHECK_EQ(1, static_cast<int>(map.Size())); |
| 3537 } | 3537 } |
| 3538 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); | 3538 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
| 3539 if (is_weak) { | 3539 if (is_weak) { |
| 3540 reinterpret_cast<v8::internal::Isolate*>(isolate)->heap()-> | 3540 reinterpret_cast<v8::internal::Isolate*>(isolate)->heap()-> |
| 3541 CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3541 CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 3542 } else { | 3542 } else { |
| 3543 map.Clear(); | 3543 map.Clear(); |
| 3544 } | 3544 } |
| 3545 CHECK_EQ(0, map.Size()); | 3545 CHECK_EQ(0, static_cast<int>(map.Size())); |
| 3546 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); | 3546 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); |
| 3547 } | 3547 } |
| 3548 | 3548 |
| 3549 | 3549 |
| 3550 TEST(PersistentValueMap) { | 3550 TEST(PersistentValueMap) { |
| 3551 TestPersistentValueMap<false>(); | 3551 TestPersistentValueMap<false>(); |
| 3552 TestPersistentValueMap<true>(); | 3552 TestPersistentValueMap<true>(); |
| 3553 } | 3553 } |
| 3554 | 3554 |
| 3555 | 3555 |
| (...skipping 18750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22306 CompileRun("x1 = x2 = 0;"); | 22306 CompileRun("x1 = x2 = 0;"); |
| 22307 r = v8::Promise::New(isolate); | 22307 r = v8::Promise::New(isolate); |
| 22308 r->Catch(f1)->Chain(f2); | 22308 r->Catch(f1)->Chain(f2); |
| 22309 r->Reject(v8::Integer::New(isolate, 3)); | 22309 r->Reject(v8::Integer::New(isolate, 3)); |
| 22310 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); | 22310 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); |
| 22311 CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value()); | 22311 CHECK_EQ(0, global->Get(v8_str("x2"))->Int32Value()); |
| 22312 V8::RunMicrotasks(isolate); | 22312 V8::RunMicrotasks(isolate); |
| 22313 CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value()); | 22313 CHECK_EQ(3, global->Get(v8_str("x1"))->Int32Value()); |
| 22314 CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value()); | 22314 CHECK_EQ(4, global->Get(v8_str("x2"))->Int32Value()); |
| 22315 } | 22315 } |
| OLD | NEW |