| Index: test/cctest/test-heap-profiler.cc
|
| diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
|
| index 7a27495695a68ce8f66e9fcf45d07bc804646f6e..8943c5db7d1b14d3db793bbf82c6a26b86dcf4ac 100644
|
| --- a/test/cctest/test-heap-profiler.cc
|
| +++ b/test/cctest/test-heap-profiler.cc
|
| @@ -1041,6 +1041,49 @@ TEST(HeapSnapshotObjectsStats) {
|
| }
|
|
|
|
|
| +TEST(HeapObjectIds) {
|
| + LocalContext env;
|
| + v8::Isolate* isolate = env->GetIsolate();
|
| + v8::HandleScope scope(isolate);
|
| + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
| +
|
| + const int kLength = 10;
|
| + v8::Handle<v8::Object> objects[kLength];
|
| + v8::SnapshotObjectId ids[kLength];
|
| +
|
| + heap_profiler->StartTrackingHeapObjects(false);
|
| +
|
| + for (int i = 0; i < kLength; i++) {
|
| + objects[i] = v8::Object::New(isolate);
|
| + }
|
| + GetHeapStatsUpdate(heap_profiler);
|
| +
|
| + for (int i = 0; i < kLength; i++) {
|
| + v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
|
| + CHECK_NE(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
|
| + ids[i] = id;
|
| + }
|
| +
|
| + heap_profiler->StopTrackingHeapObjects();
|
| + CcTest::heap()->CollectAllAvailableGarbage();
|
| +
|
| + for (int i = 0; i < kLength; i++) {
|
| + v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
|
| + CHECK_EQ(static_cast<int>(ids[i]), static_cast<int>(id));
|
| + v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
|
| + CHECK_EQ(objects[i], obj);
|
| + }
|
| +
|
| + heap_profiler->ClearObjectIds();
|
| + for (int i = 0; i < kLength; i++) {
|
| + v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
|
| + CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
|
| + v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
|
| + CHECK(obj.IsEmpty());
|
| + }
|
| +}
|
| +
|
| +
|
| static void CheckChildrenIds(const v8::HeapSnapshot* snapshot,
|
| const v8::HeapGraphNode* node,
|
| int level, int max_level) {
|
| @@ -1519,7 +1562,7 @@ TEST(NodesIteration) {
|
| }
|
|
|
|
|
| -TEST(GetHeapValue) {
|
| +TEST(GetHeapValueForNode) {
|
| LocalContext env;
|
| v8::HandleScope scope(env->GetIsolate());
|
| v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
| @@ -1529,25 +1572,26 @@ TEST(GetHeapValue) {
|
| heap_profiler->TakeHeapSnapshot(v8_str("value"));
|
| CHECK(ValidateSnapshot(snapshot));
|
| const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
|
| - CHECK(global->GetHeapValue()->IsObject());
|
| + CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject());
|
| v8::Local<v8::Object> js_global =
|
| env->Global()->GetPrototype().As<v8::Object>();
|
| - CHECK(js_global == global->GetHeapValue());
|
| + CHECK(js_global == heap_profiler->FindObjectById(global->GetId()));
|
| const v8::HeapGraphNode* obj = GetProperty(
|
| global, v8::HeapGraphEdge::kProperty, "a");
|
| - CHECK(obj->GetHeapValue()->IsObject());
|
| + CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject());
|
| v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>();
|
| - CHECK(js_obj == obj->GetHeapValue());
|
| + CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId()));
|
| const v8::HeapGraphNode* s_prop =
|
| GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop");
|
| v8::Local<v8::String> js_s_prop =
|
| js_obj->Get(v8_str("s_prop")).As<v8::String>();
|
| - CHECK(js_s_prop == s_prop->GetHeapValue());
|
| + CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId()));
|
| const v8::HeapGraphNode* n_prop =
|
| GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop");
|
| v8::Local<v8::Number> js_n_prop =
|
| js_obj->Get(v8_str("n_prop")).As<v8::Number>();
|
| - CHECK(js_n_prop->NumberValue() == n_prop->GetHeapValue()->NumberValue());
|
| + CHECK(js_n_prop->NumberValue() ==
|
| + heap_profiler->FindObjectById(n_prop->GetId())->NumberValue());
|
| }
|
|
|
|
|
| @@ -1572,18 +1616,18 @@ TEST(GetHeapValueForDeletedObject) {
|
| // Perform the check inside a nested local scope to avoid creating a
|
| // reference to the object we are deleting.
|
| v8::HandleScope scope(env->GetIsolate());
|
| - CHECK(prop->GetHeapValue()->IsObject());
|
| + CHECK(heap_profiler->FindObjectById(prop->GetId())->IsObject());
|
| }
|
| CompileRun("delete a.p;");
|
| - CHECK(prop->GetHeapValue()->IsUndefined());
|
| + CHECK(heap_profiler->FindObjectById(prop->GetId()).IsEmpty());
|
| }
|
|
|
|
|
| static int StringCmp(const char* ref, i::String* act) {
|
| i::SmartArrayPointer<char> s_act = act->ToCString();
|
| - int result = strcmp(ref, *s_act);
|
| + int result = strcmp(ref, s_act.get());
|
| if (result != 0)
|
| - fprintf(stderr, "Expected: \"%s\", Actual: \"%s\"\n", ref, *s_act);
|
| + fprintf(stderr, "Expected: \"%s\", Actual: \"%s\"\n", ref, s_act.get());
|
| return result;
|
| }
|
|
|
| @@ -1989,9 +2033,10 @@ TEST(AllocationSitesAreVisible) {
|
| CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
|
| CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
|
|
|
| - CHECK(transition_info->GetHeapValue()->IsArray());
|
| - v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(
|
| - transition_info->GetHeapValue());
|
| + v8::Handle<v8::Value> array_val =
|
| + heap_profiler->FindObjectById(transition_info->GetId());
|
| + CHECK(array_val->IsArray());
|
| + v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(array_val);
|
| // Verify the array is "a" in the code above.
|
| CHECK_EQ(3, array->Length());
|
| CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
|
| @@ -2044,6 +2089,7 @@ HeapProfilerExtension::GetNativeFunctionTemplate(v8::Isolate* isolate,
|
| v8::Handle<v8::String> name) {
|
| if (name->Equals(v8::String::NewFromUtf8(isolate, "findUntrackedObjects"))) {
|
| return v8::FunctionTemplate::New(
|
| + isolate,
|
| HeapProfilerExtension::FindUntrackedObjects);
|
| } else {
|
| CHECK(false);
|
|
|