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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 &name_resolver); | 1530 &name_resolver); |
1531 CHECK(ValidateSnapshot(snapshot)); | 1531 CHECK(ValidateSnapshot(snapshot)); |
1532 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 1532 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
1533 CHECK_NE(NULL, global); | 1533 CHECK_NE(NULL, global); |
1534 CHECK_EQ("Object / Global object name" , | 1534 CHECK_EQ("Object / Global object name" , |
1535 const_cast<i::HeapEntry*>( | 1535 const_cast<i::HeapEntry*>( |
1536 reinterpret_cast<const i::HeapEntry*>(global))->name()); | 1536 reinterpret_cast<const i::HeapEntry*>(global))->name()); |
1537 } | 1537 } |
1538 | 1538 |
1539 | 1539 |
| 1540 TEST(GlobalObjectFields) { |
| 1541 LocalContext env; |
| 1542 v8::HandleScope scope(env->GetIsolate()); |
| 1543 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 1544 CompileRun("obj = {};"); |
| 1545 const v8::HeapSnapshot* snapshot = |
| 1546 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
| 1547 CHECK(ValidateSnapshot(snapshot)); |
| 1548 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 1549 const v8::HeapGraphNode* builtins = |
| 1550 GetProperty(global, v8::HeapGraphEdge::kInternal, "builtins"); |
| 1551 CHECK_NE(NULL, builtins); |
| 1552 const v8::HeapGraphNode* native_context = |
| 1553 GetProperty(global, v8::HeapGraphEdge::kInternal, "native_context"); |
| 1554 CHECK_NE(NULL, native_context); |
| 1555 const v8::HeapGraphNode* global_context = |
| 1556 GetProperty(global, v8::HeapGraphEdge::kInternal, "global_context"); |
| 1557 CHECK_NE(NULL, global_context); |
| 1558 const v8::HeapGraphNode* global_receiver = |
| 1559 GetProperty(global, v8::HeapGraphEdge::kInternal, "global_receiver"); |
| 1560 CHECK_NE(NULL, global_receiver); |
| 1561 } |
| 1562 |
| 1563 |
1540 TEST(NoHandleLeaks) { | 1564 TEST(NoHandleLeaks) { |
1541 LocalContext env; | 1565 LocalContext env; |
1542 v8::HandleScope scope(env->GetIsolate()); | 1566 v8::HandleScope scope(env->GetIsolate()); |
1543 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1567 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1544 | 1568 |
1545 CompileRun("document = { URL:\"abcdefgh\" };"); | 1569 CompileRun("document = { URL:\"abcdefgh\" };"); |
1546 | 1570 |
1547 v8::Handle<v8::String> name(v8_str("leakz")); | 1571 v8::Handle<v8::String> name(v8_str("leakz")); |
1548 i::Isolate* isolate = CcTest::i_isolate(); | 1572 i::Isolate* isolate = CcTest::i_isolate(); |
1549 int count_before = i::HandleScope::NumberOfHandles(isolate); | 1573 int count_before = i::HandleScope::NumberOfHandles(isolate); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 const v8::HeapGraphNode* arr1_obj = | 2376 const v8::HeapGraphNode* arr1_obj = |
2353 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); | 2377 GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1"); |
2354 CHECK_NE(NULL, arr1_obj); | 2378 CHECK_NE(NULL, arr1_obj); |
2355 const v8::HeapGraphNode* arr1_buffer = | 2379 const v8::HeapGraphNode* arr1_buffer = |
2356 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); | 2380 GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer"); |
2357 CHECK_NE(NULL, arr1_buffer); | 2381 CHECK_NE(NULL, arr1_buffer); |
2358 const v8::HeapGraphNode* first_view = | 2382 const v8::HeapGraphNode* first_view = |
2359 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); | 2383 GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view"); |
2360 CHECK_NE(NULL, first_view); | 2384 CHECK_NE(NULL, first_view); |
2361 } | 2385 } |
OLD | NEW |