Do not read document and URL properties on global objects while taking heap snapshot
authoryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 12 Dec 2012 09:49:46 +0000 (09:49 +0000)
committeryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 12 Dec 2012 09:49:46 +0000 (09:49 +0000)
This unsafe mechanism was replaced with a user provided callback in r13137 and now we should remove old code.
Review URL: https://codereview.chromium.org/11519029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13203 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/profile-generator.cc
test/cctest/test-heap-profiler.cc

index 6e49c7b..6601e51 100644 (file)
@@ -2708,10 +2708,6 @@ void V8HeapExplorer::TagGlobalObjects() {
   Isolate* isolate = Isolate::Current();
   GlobalObjectsEnumerator enumerator;
   isolate->global_handles()->IterateAllRoots(&enumerator);
-  Handle<String> document_string =
-      isolate->factory()->NewStringFromAscii(CStrVector("document"));
-  Handle<String> url_string =
-      isolate->factory()->NewStringFromAscii(CStrVector("URL"));
   const char** urls = NewArray<const char*>(enumerator.count());
   for (int i = 0, l = enumerator.count(); i < l; ++i) {
     if (global_object_name_resolver_) {
@@ -2720,25 +2716,7 @@ void V8HeapExplorer::TagGlobalObjects() {
       urls[i] = global_object_name_resolver_->GetName(
           Utils::ToLocal(Handle<JSObject>::cast(global_obj)));
     } else {
-      // TODO(yurys): This branch is going to be removed once Chromium migrates
-      // to the new name resolver.
       urls[i] = NULL;
-      HandleScope scope;
-      Handle<JSGlobalObject> global_obj = enumerator.at(i);
-      Object* obj_document;
-      if (global_obj->GetProperty(*document_string)->ToObject(&obj_document) &&
-          obj_document->IsJSObject()) {
-        // FixMe: Workaround: SharedWorker's current Isolate has NULL context.
-        // As result GetProperty(*url_string) will crash.
-        if (!Isolate::Current()->context() && obj_document->IsJSGlobalProxy())
-          continue;
-        JSObject* document = JSObject::cast(obj_document);
-        Object* obj_url;
-        if (document->GetProperty(*url_string)->ToObject(&obj_url) &&
-            obj_url->IsString()) {
-          urls[i] = collection_->names()->GetName(String::cast(obj_url));
-        }
-      }
     }
   }
 
index 4a65344..8da841e 100644 (file)
@@ -1254,56 +1254,6 @@ TEST(GlobalObjectName) {
 }
 
 
-TEST(DocumentURL) {
-  v8::HandleScope scope;
-  LocalContext env;
-
-  CompileRun("document = { URL:\"abcdefgh\" };");
-
-  const v8::HeapSnapshot* snapshot =
-      v8::HeapProfiler::TakeSnapshot(v8_str("document"));
-  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
-  CHECK_NE(NULL, global);
-  CHECK_EQ("Object / abcdefgh",
-           const_cast<i::HeapEntry*>(
-               reinterpret_cast<const i::HeapEntry*>(global))->name());
-}
-
-
-TEST(DocumentWithException) {
-  v8::HandleScope scope;
-  LocalContext env;
-
-  CompileRun(
-      "this.__defineGetter__(\"document\", function() { throw new Error(); })");
-  const v8::HeapSnapshot* snapshot =
-      v8::HeapProfiler::TakeSnapshot(v8_str("document"));
-  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
-  CHECK_NE(NULL, global);
-  CHECK_EQ("Object",
-           const_cast<i::HeapEntry*>(
-               reinterpret_cast<const i::HeapEntry*>(global))->name());
-}
-
-
-TEST(DocumentURLWithException) {
-  v8::HandleScope scope;
-  LocalContext env;
-
-  CompileRun(
-      "function URLWithException() {}\n"
-      "URLWithException.prototype = { get URL() { throw new Error(); } };\n"
-      "document = { URL: new URLWithException() };");
-  const v8::HeapSnapshot* snapshot =
-      v8::HeapProfiler::TakeSnapshot(v8_str("document"));
-  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
-  CHECK_NE(NULL, global);
-  CHECK_EQ("Object",
-           const_cast<i::HeapEntry*>(
-               reinterpret_cast<const i::HeapEntry*>(global))->name());
-}
-
-
 TEST(NoHandleLeaks) {
   v8::HandleScope scope;
   LocalContext env;