| 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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 delete data.GetParameter(); | 1848 delete data.GetParameter(); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 | 1851 |
| 1852 TEST(WeakGlobalHandle) { | 1852 TEST(WeakGlobalHandle) { |
| 1853 LocalContext env; | 1853 LocalContext env; |
| 1854 v8::HandleScope scope(env->GetIsolate()); | 1854 v8::HandleScope scope(env->GetIsolate()); |
| 1855 | 1855 |
| 1856 CHECK(!HasWeakGlobalHandle()); | 1856 CHECK(!HasWeakGlobalHandle()); |
| 1857 | 1857 |
| 1858 v8::Persistent<v8::Object>* handle = | 1858 v8::Persistent<v8::Object> handle(env->GetIsolate(), |
| 1859 new v8::Persistent<v8::Object>(env->GetIsolate(), | 1859 v8::Object::New(env->GetIsolate())); |
| 1860 v8::Object::New(env->GetIsolate())); | 1860 handle.SetWeak(&handle, PersistentHandleCallback); |
| 1861 handle->SetWeak(handle, PersistentHandleCallback); | |
| 1862 | 1861 |
| 1863 CHECK(HasWeakGlobalHandle()); | 1862 CHECK(HasWeakGlobalHandle()); |
| 1864 } | 1863 } |
| 1865 | 1864 |
| 1866 | 1865 |
| 1867 TEST(SfiAndJsFunctionWeakRefs) { | 1866 TEST(SfiAndJsFunctionWeakRefs) { |
| 1868 LocalContext env; | 1867 LocalContext env; |
| 1869 v8::HandleScope scope(env->GetIsolate()); | 1868 v8::HandleScope scope(env->GetIsolate()); |
| 1870 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1869 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 1871 | 1870 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 const v8::HeapGraphNode* arr1_obj = | 2375 const v8::HeapGraphNode* arr1_obj = |
| 2377 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); | 2376 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); |
| 2378 CHECK_NE(NULL, arr1_obj); | 2377 CHECK_NE(NULL, arr1_obj); |
| 2379 const v8::HeapGraphNode* arr1_buffer = | 2378 const v8::HeapGraphNode* arr1_buffer = |
| 2380 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); | 2379 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); |
| 2381 CHECK_NE(NULL, arr1_buffer); | 2380 CHECK_NE(NULL, arr1_buffer); |
| 2382 const v8::HeapGraphNode* first_view = | 2381 const v8::HeapGraphNode* first_view = |
| 2383 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); | 2382 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); |
| 2384 CHECK_NE(NULL, first_view); | 2383 CHECK_NE(NULL, first_view); |
| 2385 } | 2384 } |
| 2385 |
| 2386 |
| 2387 TEST(BoxObject) { |
| 2388 v8::Isolate* isolate = CcTest::isolate(); |
| 2389 v8::HandleScope scope(isolate); |
| 2390 LocalContext env; |
| 2391 v8::Handle<v8::Object> global_proxy = env->Global(); |
| 2392 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
| 2393 |
| 2394 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 2395 i::Handle<i::String> string = |
| 2396 factory->NewStringFromAscii(i::CStrVector("string")); |
| 2397 i::Handle<i::Object> box = factory->NewBox(string); |
| 2398 global->Set(0, v8::ToApiHandle<v8::Object>(box)); |
| 2399 |
| 2400 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); |
| 2401 const v8::HeapSnapshot* snapshot = |
| 2402 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
| 2403 CHECK(ValidateSnapshot(snapshot)); |
| 2404 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); |
| 2405 const v8::HeapGraphNode* box_node = |
| 2406 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); |
| 2407 CHECK_NE(NULL, box_node); |
| 2408 v8::String::Utf8Value box_node_name(box_node->GetName()); |
| 2409 CHECK_EQ("system / Box", *box_node_name); |
| 2410 const v8::HeapGraphNode* box_value = |
| 2411 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); |
| 2412 CHECK_NE(NULL, box_value); |
| 2413 } |
| OLD | NEW |