OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 data.GetParameter()->Reset(); | 2023 data.GetParameter()->Reset(); |
2024 } | 2024 } |
2025 | 2025 |
2026 | 2026 |
2027 TEST(WeakGlobalHandle) { | 2027 TEST(WeakGlobalHandle) { |
2028 LocalContext env; | 2028 LocalContext env; |
2029 v8::HandleScope scope(env->GetIsolate()); | 2029 v8::HandleScope scope(env->GetIsolate()); |
2030 | 2030 |
2031 CHECK(!HasWeakGlobalHandle()); | 2031 CHECK(!HasWeakGlobalHandle()); |
2032 | 2032 |
2033 v8::Persistent<v8::Object> handle(env->GetIsolate(), | 2033 v8::Persistent<v8::Object> handle; |
2034 v8::Object::New(env->GetIsolate())); | 2034 |
| 2035 handle.Reset(env->GetIsolate(), v8::Object::New(env->GetIsolate())); |
2035 handle.SetWeak(&handle, PersistentHandleCallback, | 2036 handle.SetWeak(&handle, PersistentHandleCallback, |
2036 v8::WeakCallbackType::kParameter); | 2037 v8::WeakCallbackType::kParameter); |
2037 | 2038 |
2038 CHECK(HasWeakGlobalHandle()); | 2039 CHECK(HasWeakGlobalHandle()); |
| 2040 CcTest::CollectAllGarbage(); |
| 2041 EmptyMessageQueues(env->GetIsolate()); |
2039 } | 2042 } |
2040 | 2043 |
2041 | 2044 |
2042 TEST(SfiAndJsFunctionWeakRefs) { | 2045 TEST(SfiAndJsFunctionWeakRefs) { |
2043 LocalContext env; | 2046 LocalContext env; |
2044 v8::HandleScope scope(env->GetIsolate()); | 2047 v8::HandleScope scope(env->GetIsolate()); |
2045 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 2048 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
2046 | 2049 |
2047 CompileRun( | 2050 CompileRun( |
2048 "fun = (function (x) { return function () { return x + 1; } })(1);"); | 2051 "fun = (function (x) { return function () { return x + 1; } })(1);"); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 " a[i] = i;\n" | 2960 " a[i] = i;\n" |
2958 " for (var i = 0; i < 3; ++i)\n" | 2961 " for (var i = 0; i < 3; ++i)\n" |
2959 " a.shift();\n" | 2962 " a.shift();\n" |
2960 "}\n"); | 2963 "}\n"); |
2961 | 2964 |
2962 CcTest::CollectGarbage(v8::internal::NEW_SPACE); | 2965 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
2963 // Should not crash. | 2966 // Should not crash. |
2964 | 2967 |
2965 heap_profiler->StopSamplingHeapProfiler(); | 2968 heap_profiler->StopSamplingHeapProfiler(); |
2966 } | 2969 } |
OLD | NEW |