| Index: test/cctest/test-heap-profiler.cc
|
| diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
|
| index 59b0b5bcb5636463f060c19ce14c06e5f400cc1e..b86a3361605b5ee79abadb8dff0796a36faef8c1 100644
|
| --- a/test/cctest/test-heap-profiler.cc
|
| +++ b/test/cctest/test-heap-profiler.cc
|
| @@ -20,11 +20,6 @@ using i::JSObjectsClusterTree;
|
| using i::RetainerHeapProfile;
|
|
|
|
|
| -static void CompileAndRunScript(const char *src) {
|
| - v8::Script::Compile(v8::String::New(src))->Run();
|
| -}
|
| -
|
| -
|
| namespace {
|
|
|
| class ConstructorHeapProfileTestHelper : public i::ConstructorHeapProfile {
|
| @@ -58,7 +53,7 @@ TEST(ConstructorProfile) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function F() {} // A constructor\n"
|
| "var f1 = new F();\n"
|
| "var f2 = new F();\n");
|
| @@ -359,7 +354,7 @@ TEST(RetainerProfile) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A() {}\n"
|
| "function B(x) { this.x = x; }\n"
|
| "function C(x) { this.x1 = x; this.x2 = x; }\n"
|
| @@ -473,7 +468,7 @@ TEST(HeapSnapshot) {
|
| LocalContext env1;
|
| env1->SetSecurityToken(token1);
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A1() {}\n"
|
| "function B1(x) { this.x = x; }\n"
|
| "function C1(x) { this.x1 = x; this.x2 = x; }\n"
|
| @@ -485,7 +480,7 @@ TEST(HeapSnapshot) {
|
| LocalContext env2;
|
| env2->SetSecurityToken(token2);
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A2() {}\n"
|
| "function B2(x) { return function() { return typeof x; }; }\n"
|
| "function C2(x) { this.x1 = x; this.x2 = x; this[1] = x; }\n"
|
| @@ -583,7 +578,7 @@ TEST(HeapSnapshotObjectSizes) {
|
|
|
| // -a-> X1 --a
|
| // x -b-> X2 <-|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function X(a, b) { this.a = a; this.b = b; }\n"
|
| "x = new X(new X(), new X());\n"
|
| "x.a.a = x.b;");
|
| @@ -624,7 +619,7 @@ TEST(HeapSnapshotEntryChildren) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A() { }\n"
|
| "a = new A;");
|
| const v8::HeapSnapshot* snapshot =
|
| @@ -648,7 +643,7 @@ TEST(HeapSnapshotCodeObjects) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function lazy(x) { return x - 1; }\n"
|
| "function compiled(x) { return x + 1; }\n"
|
| "var anonymous = (function() { return function() { return 0; } })();\n"
|
| @@ -709,6 +704,44 @@ TEST(HeapSnapshotCodeObjects) {
|
| }
|
|
|
|
|
| +TEST(HeapSnapshotHeapNumbers) {
|
| + v8::HandleScope scope;
|
| + LocalContext env;
|
| + CompileRun(
|
| + "a = 1; // a is Smi\n"
|
| + "b = 2.5; // b is HeapNumber");
|
| + const v8::HeapSnapshot* snapshot =
|
| + v8::HeapProfiler::TakeSnapshot(v8::String::New("numbers"));
|
| + const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
|
| + CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a"));
|
| + const v8::HeapGraphNode* b =
|
| + GetProperty(global, v8::HeapGraphEdge::kProperty, "b");
|
| + CHECK_NE(NULL, b);
|
| + CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
|
| +}
|
| +
|
| +
|
| +TEST(HeapSnapshotInternalReferences) {
|
| + v8::HandleScope scope;
|
| + v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
|
| + global_template->SetInternalFieldCount(2);
|
| + LocalContext env(NULL, global_template);
|
| + v8::Handle<v8::Object> global_proxy = env->Global();
|
| + v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
|
| + CHECK_EQ(2, global->InternalFieldCount());
|
| + v8::Local<v8::Object> obj = v8::Object::New();
|
| + global->SetInternalField(0, v8_num(17));
|
| + global->SetInternalField(1, obj);
|
| + const v8::HeapSnapshot* snapshot =
|
| + v8::HeapProfiler::TakeSnapshot(v8::String::New("internals"));
|
| + const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
|
| + // The first reference will not present, because it's a Smi.
|
| + CHECK_EQ(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"));
|
| + // The second reference is to an object.
|
| + CHECK_NE(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "1"));
|
| +}
|
| +
|
| +
|
| // Trying to introduce a check helper for uint64_t causes many
|
| // overloading ambiguities, so it seems easier just to cast
|
| // them to a signed type.
|
| @@ -721,7 +754,7 @@ TEST(HeapEntryIdsAndGC) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A() {}\n"
|
| "function B(x) { this.x = x; }\n"
|
| "var a = new A();\n"
|
| @@ -777,7 +810,7 @@ TEST(HeapSnapshotsDiff) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A() {}\n"
|
| "function B(x) { this.x = x; }\n"
|
| "function A2(a) { for (var i = 0; i < a; ++i) this[i] = i; }\n"
|
| @@ -786,7 +819,7 @@ TEST(HeapSnapshotsDiff) {
|
| const v8::HeapSnapshot* snapshot1 =
|
| v8::HeapProfiler::TakeSnapshot(v8::String::New("s1"));
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "delete a;\n"
|
| "b.x = null;\n"
|
| "var a = new A2(20);\n"
|
| @@ -921,7 +954,7 @@ TEST(AggregatedHeapSnapshot) {
|
| v8::HandleScope scope;
|
| LocalContext env;
|
|
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A() {}\n"
|
| "function B(x) { this.x = x; }\n"
|
| "var a = new A();\n"
|
| @@ -1042,7 +1075,7 @@ TEST(HeapSnapshotJSONSerialization) {
|
|
|
| #define STRING_LITERAL_FOR_TEST \
|
| "\"String \\n\\r\\u0008\\u0081\\u0101\\u0801\\u8001\""
|
| - CompileAndRunScript(
|
| + CompileRun(
|
| "function A(s) { this.s = s; }\n"
|
| "function B(x) { this.x = x; }\n"
|
| "var a = new A(" STRING_LITERAL_FOR_TEST ");\n"
|
|
|