Commit b4354d6d authored by alph@chromium.org's avatar alph@chromium.org

DevTools: Drop kSinTable dependency off the heap profiler ArrayBuffer backing_store test

LOG=N
R=dslomov@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/170253008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19458 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5224c3d0
...@@ -2406,31 +2406,47 @@ static int GetRetainersCount(const v8::HeapSnapshot* snapshot, ...@@ -2406,31 +2406,47 @@ static int GetRetainersCount(const v8::HeapSnapshot* snapshot,
TEST(ArrayBufferSharedBackingStore) { TEST(ArrayBufferSharedBackingStore) {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::Isolate* isolate = env->GetIsolate();
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); v8::HandleScope handle_scope(isolate);
CompileRun("sin1 = Math.sin(1);"); v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
LocalContext env2;
CompileRun("sin2 = Math.sin(2);"); v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024);
CHECK_EQ(1024, static_cast<int>(ab->ByteLength()));
CHECK(!ab->IsExternal());
v8::ArrayBuffer::Contents ab_contents = ab->Externalize();
CHECK(ab->IsExternal());
CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
void* data = ab_contents.Data();
ASSERT(data != NULL);
v8::Local<v8::ArrayBuffer> ab2 =
v8::ArrayBuffer::New(isolate, data, ab_contents.ByteLength());
CHECK(ab2->IsExternal());
env->Global()->Set(v8_str("ab1"), ab);
env->Global()->Set(v8_str("ab2"), ab2);
v8::Handle<v8::Value> result = CompileRun("ab2.byteLength");
CHECK_EQ(1024, result->Int32Value());
const v8::HeapSnapshot* snapshot = const v8::HeapSnapshot* snapshot =
heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
CHECK(ValidateSnapshot(snapshot)); CHECK(ValidateSnapshot(snapshot));
// The 0th-child is (GC Roots), 1st is the user root. const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* global = const v8::HeapGraphNode* ab1_node =
snapshot->GetRoot()->GetChild(1)->GetToNode(); GetProperty(global, v8::HeapGraphEdge::kProperty, "ab1");
const v8::HeapGraphNode* builtins = CHECK_NE(NULL, ab1_node);
GetProperty(global, v8::HeapGraphEdge::kInternal, "builtins"); const v8::HeapGraphNode* ab1_data =
CHECK_NE(NULL, builtins); GetProperty(ab1_node, v8::HeapGraphEdge::kInternal, "backing_store");
const v8::HeapGraphNode* sin_table = CHECK_NE(NULL, ab1_data);
GetProperty(builtins, v8::HeapGraphEdge::kProperty, "kSinTable"); const v8::HeapGraphNode* ab2_node =
CHECK_NE(NULL, sin_table); GetProperty(global, v8::HeapGraphEdge::kProperty, "ab2");
const v8::HeapGraphNode* buffer = CHECK_NE(NULL, ab2_node);
GetProperty(sin_table, v8::HeapGraphEdge::kInternal, "buffer"); const v8::HeapGraphNode* ab2_data =
CHECK_NE(NULL, buffer); GetProperty(ab2_node, v8::HeapGraphEdge::kInternal, "backing_store");
const v8::HeapGraphNode* backing_store = CHECK_NE(NULL, ab2_data);
GetProperty(buffer, v8::HeapGraphEdge::kInternal, "backing_store"); CHECK_EQ(ab1_data, ab2_data);
CHECK_NE(NULL, backing_store); CHECK_EQ(2, GetRetainersCount(snapshot, ab1_data));
int retainers = GetRetainersCount(snapshot, backing_store); free(data);
CHECK_EQ(2, retainers);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment