Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests for heap profiler | 3 // Tests for heap profiler |
| 4 | 4 |
| 5 #include <ctype.h> | 5 #include <ctype.h> |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "cctest.h" | 9 #include "cctest.h" |
| 10 #include "hashmap.h" | 10 #include "hashmap.h" |
| (...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); | 1442 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); |
| 1443 CHECK_NE(NULL, obj1); | 1443 CHECK_NE(NULL, obj1); |
| 1444 const v8::HeapGraphNode* getterFunction = | 1444 const v8::HeapGraphNode* getterFunction = |
| 1445 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter"); | 1445 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter"); |
| 1446 CHECK_NE(NULL, getterFunction); | 1446 CHECK_NE(NULL, getterFunction); |
| 1447 const v8::HeapGraphNode* setterFunction = | 1447 const v8::HeapGraphNode* setterFunction = |
| 1448 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter"); | 1448 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter"); |
| 1449 CHECK_NE(NULL, setterFunction); | 1449 CHECK_NE(NULL, setterFunction); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 TEST(HiddenPropertiesFastCase) { | |
| 1453 v8::HandleScope scope; | |
| 1454 LocalContext env; | |
| 1455 | |
| 1456 CompileRun( | |
| 1457 "function C(x) { this.a = this; this.b = x; }\n" | |
| 1458 "c = new C(2012);\n"); | |
| 1459 const v8::HeapSnapshot* snapshot = | |
| 1460 v8::HeapProfiler::TakeSnapshot(v8_str("HiddenPropertiesFastCase1")); | |
| 1461 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | |
| 1462 const v8::HeapGraphNode* c = | |
| 1463 GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); | |
| 1464 CHECK_NE(NULL, c); | |
| 1465 const v8::HeapGraphNode* hidden_props = | |
| 1466 GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties"); | |
| 1467 CHECK_EQ(NULL, hidden_props); | |
| 1468 | |
| 1469 v8::Handle<v8::Value> cHandle = env->Global()->Get(v8::String::New("c")); | |
| 1470 CHECK(!cHandle.IsEmpty() && cHandle->IsObject()); | |
| 1471 cHandle->ToObject()->GetIdentityHash(); | |
| 1472 | |
| 1473 snapshot = v8::HeapProfiler::TakeSnapshot(v8_str("HiddenPropertiesFastCase2")) ; | |
|
mnaganov (inactive)
2012/07/02 12:16:19
nit: 80 chars
yurys
2012/07/02 12:43:27
Done.
| |
| 1474 global = GetGlobalObject(snapshot); | |
| 1475 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); | |
| 1476 CHECK_NE(NULL, c); | |
| 1477 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties "); | |
|
mnaganov (inactive)
2012/07/02 12:16:19
nit: 80 chars
yurys
2012/07/02 12:43:27
Done.
| |
| 1478 CHECK_NE(NULL, hidden_props); | |
| 1479 } | |
| 1452 | 1480 |
| 1453 bool HasWeakEdge(const v8::HeapGraphNode* node) { | 1481 bool HasWeakEdge(const v8::HeapGraphNode* node) { |
| 1454 for (int i = 0; i < node->GetChildrenCount(); ++i) { | 1482 for (int i = 0; i < node->GetChildrenCount(); ++i) { |
| 1455 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); | 1483 const v8::HeapGraphEdge* handle_edge = node->GetChild(i); |
| 1456 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; | 1484 if (handle_edge->GetType() == v8::HeapGraphEdge::kWeak) return true; |
| 1457 } | 1485 } |
| 1458 return false; | 1486 return false; |
| 1459 } | 1487 } |
| 1460 | 1488 |
| 1461 | 1489 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1619 const v8::HeapGraphNode* global_object = | 1647 const v8::HeapGraphNode* global_object = |
| 1620 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); | 1648 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); |
| 1621 CHECK_NE(NULL, global_object); | 1649 CHECK_NE(NULL, global_object); |
| 1622 const v8::HeapGraphNode* properties = | 1650 const v8::HeapGraphNode* properties = |
| 1623 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); | 1651 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); |
| 1624 CHECK_EQ(NULL, properties); | 1652 CHECK_EQ(NULL, properties); |
| 1625 const v8::HeapGraphNode* elements = | 1653 const v8::HeapGraphNode* elements = |
| 1626 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); | 1654 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); |
| 1627 CHECK_EQ(NULL, elements); | 1655 CHECK_EQ(NULL, elements); |
| 1628 } | 1656 } |
| OLD | NEW |