Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 17616002: Handle AccessorPair struct in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); 1500 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5);
1501 CHECK_EQ(0, StringCmp( 1501 CHECK_EQ(0, StringCmp(
1502 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); 1502 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5)));
1503 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); 1503 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>();
1504 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); 1504 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6);
1505 CHECK_EQ(0, StringCmp( 1505 CHECK_EQ(0, StringCmp(
1506 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); 1506 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6)));
1507 } 1507 }
1508 1508
1509 1509
1510 TEST(FastCaseGetter) { 1510 TEST(FastCaseAccessors) {
1511 LocalContext env; 1511 LocalContext env;
1512 v8::HandleScope scope(env->GetIsolate()); 1512 v8::HandleScope scope(env->GetIsolate());
1513 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1513 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1514 1514
1515 CompileRun("var obj1 = {};\n" 1515 CompileRun("var obj1 = {};\n"
1516 "obj1.__defineGetter__('propWithGetter', function Y() {\n" 1516 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1517 " return 42;\n" 1517 " return 42;\n"
1518 "});\n" 1518 "});\n"
1519 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n" 1519 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1520 " return this.value_ = value;\n" 1520 " return this.value_ = value;\n"
1521 "});\n"); 1521 "});\n");
1522 const v8::HeapSnapshot* snapshot = 1522 const v8::HeapSnapshot* snapshot =
1523 heap_profiler->TakeHeapSnapshot(v8_str("fastCaseGetter")); 1523 heap_profiler->TakeHeapSnapshot(v8_str("fastCaseAccessors"));
1524 1524
1525 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1525 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1526 CHECK_NE(NULL, global); 1526 CHECK_NE(NULL, global);
1527 const v8::HeapGraphNode* obj1 = 1527 const v8::HeapGraphNode* obj1 =
1528 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); 1528 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1");
1529 CHECK_NE(NULL, obj1); 1529 CHECK_NE(NULL, obj1);
1530 const v8::HeapGraphNode* getterFunction = 1530 const v8::HeapGraphNode* func;
1531 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter"); 1531 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithGetter");
1532 CHECK_NE(NULL, getterFunction); 1532 CHECK_NE(NULL, func);
1533 const v8::HeapGraphNode* setterFunction = 1533 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter");
1534 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter"); 1534 CHECK_EQ(NULL, func);
1535 CHECK_NE(NULL, setterFunction); 1535 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter");
1536 CHECK_NE(NULL, func);
1537 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter");
1538 CHECK_EQ(NULL, func);
1536 } 1539 }
1537 1540
1541
1542 TEST(SlowCaseAccessors) {
1543 LocalContext env;
1544 v8::HandleScope scope(env->GetIsolate());
1545 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1546
1547 CompileRun("var obj1 = {};\n"
1548 "for (var i = 0; i < 100; ++i) obj1['z' + i] = {};"
1549 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1550 " return 42;\n"
1551 "});\n"
1552 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1553 " return this.value_ = value;\n"
1554 "});\n");
1555 const v8::HeapSnapshot* snapshot =
1556 heap_profiler->TakeHeapSnapshot(v8_str("slowCaseAccessors"));
1557
1558 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1559 CHECK_NE(NULL, global);
1560 const v8::HeapGraphNode* obj1 =
1561 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1");
1562 CHECK_NE(NULL, obj1);
1563 const v8::HeapGraphNode* func;
1564 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithGetter");
1565 CHECK_NE(NULL, func);
1566 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter");
1567 CHECK_EQ(NULL, func);
1568 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter");
1569 CHECK_NE(NULL, func);
1570 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter");
1571 CHECK_EQ(NULL, func);
1572 }
1573
1574
1538 TEST(HiddenPropertiesFastCase) { 1575 TEST(HiddenPropertiesFastCase) {
1539 LocalContext env; 1576 LocalContext env;
1540 v8::HandleScope scope(env->GetIsolate()); 1577 v8::HandleScope scope(env->GetIsolate());
1541 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1578 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1542 1579
1543 CompileRun( 1580 CompileRun(
1544 "function C(x) { this.a = this; this.b = x; }\n" 1581 "function C(x) { this.a = this; this.b = x; }\n"
1545 "c = new C(2012);\n"); 1582 "c = new C(2012);\n");
1546 const v8::HeapSnapshot* snapshot = 1583 const v8::HeapSnapshot* snapshot =
1547 heap_profiler->TakeHeapSnapshot(v8_str("HiddenPropertiesFastCase1")); 1584 heap_profiler->TakeHeapSnapshot(v8_str("HiddenPropertiesFastCase1"));
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 // Check all the objects have got their names. 1817 // Check all the objects have got their names.
1781 // ... well check just every 8th because otherwise it's too slow in debug. 1818 // ... well check just every 8th because otherwise it's too slow in debug.
1782 for (int i = 0; i < num_objects - 1; i += 8) { 1819 for (int i = 0; i < num_objects - 1; i += 8) {
1783 i::EmbeddedVector<char, 100> var_name; 1820 i::EmbeddedVector<char, 100> var_name;
1784 i::OS::SNPrintF(var_name, "f_%d", i); 1821 i::OS::SNPrintF(var_name, "f_%d", i);
1785 const v8::HeapGraphNode* f_object = GetProperty( 1822 const v8::HeapGraphNode* f_object = GetProperty(
1786 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1823 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1787 CHECK_NE(NULL, f_object); 1824 CHECK_NE(NULL, f_object);
1788 } 1825 }
1789 } 1826 }
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698