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

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

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: DEPRECATE_SOON(GetInternalField) Created 3 years, 9 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
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 CHECK_EQ(parent_string, parent); 415 CHECK_EQ(parent_string, parent);
416 heap_profiler->DeleteAllHeapSnapshots(); 416 heap_profiler->DeleteAllHeapSnapshots();
417 } 417 }
418 418
419 419
420 TEST(HeapSnapshotConsString) { 420 TEST(HeapSnapshotConsString) {
421 v8::Isolate* isolate = CcTest::isolate(); 421 v8::Isolate* isolate = CcTest::isolate();
422 v8::HandleScope scope(isolate); 422 v8::HandleScope scope(isolate);
423 v8::Local<v8::ObjectTemplate> global_template = 423 v8::Local<v8::ObjectTemplate> global_template =
424 v8::ObjectTemplate::New(isolate); 424 v8::ObjectTemplate::New(isolate);
425 global_template->SetInternalFieldCount(1); 425 global_template->SetEmbedderFieldCount(1);
426 LocalContext env(NULL, global_template); 426 LocalContext env(NULL, global_template);
427 v8::Local<v8::Object> global_proxy = env->Global(); 427 v8::Local<v8::Object> global_proxy = env->Global();
428 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 428 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
429 CHECK_EQ(1, global->InternalFieldCount()); 429 CHECK_EQ(1, global->EmbedderFieldCount());
430 430
431 i::Factory* factory = CcTest::i_isolate()->factory(); 431 i::Factory* factory = CcTest::i_isolate()->factory();
432 i::Handle<i::String> first = factory->NewStringFromStaticChars("0123456789"); 432 i::Handle<i::String> first = factory->NewStringFromStaticChars("0123456789");
433 i::Handle<i::String> second = factory->NewStringFromStaticChars("0123456789"); 433 i::Handle<i::String> second = factory->NewStringFromStaticChars("0123456789");
434 i::Handle<i::String> cons_string = 434 i::Handle<i::String> cons_string =
435 factory->NewConsString(first, second).ToHandleChecked(); 435 factory->NewConsString(first, second).ToHandleChecked();
436 436
437 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); 437 global->SetEmbedderField(0, v8::ToApiHandle<v8::String>(cons_string));
438 438
439 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 439 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
440 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 440 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
441 CHECK(ValidateSnapshot(snapshot)); 441 CHECK(ValidateSnapshot(snapshot));
442 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); 442 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
443 443
444 const v8::HeapGraphNode* string_node = 444 const v8::HeapGraphNode* string_node =
445 GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"); 445 GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0");
446 CHECK(string_node); 446 CHECK(string_node);
447 CHECK_EQ(v8::HeapGraphNode::kConsString, string_node->GetType()); 447 CHECK_EQ(v8::HeapGraphNode::kConsString, string_node->GetType());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 const v8::HeapGraphNode* weak_cell = 646 const v8::HeapGraphNode* weak_cell =
647 GetProperty(map, v8::HeapGraphEdge::kInternal, "weak_cell_cache"); 647 GetProperty(map, v8::HeapGraphEdge::kInternal, "weak_cell_cache");
648 CHECK(GetProperty(weak_cell, v8::HeapGraphEdge::kWeak, "value")); 648 CHECK(GetProperty(weak_cell, v8::HeapGraphEdge::kWeak, "value"));
649 } 649 }
650 650
651 TEST(HeapSnapshotInternalReferences) { 651 TEST(HeapSnapshotInternalReferences) {
652 v8::Isolate* isolate = CcTest::isolate(); 652 v8::Isolate* isolate = CcTest::isolate();
653 v8::HandleScope scope(isolate); 653 v8::HandleScope scope(isolate);
654 v8::Local<v8::ObjectTemplate> global_template = 654 v8::Local<v8::ObjectTemplate> global_template =
655 v8::ObjectTemplate::New(isolate); 655 v8::ObjectTemplate::New(isolate);
656 global_template->SetInternalFieldCount(2); 656 global_template->SetEmbedderFieldCount(2);
657 LocalContext env(NULL, global_template); 657 LocalContext env(NULL, global_template);
658 v8::Local<v8::Object> global_proxy = env->Global(); 658 v8::Local<v8::Object> global_proxy = env->Global();
659 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); 659 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
660 CHECK_EQ(2, global->InternalFieldCount()); 660 CHECK_EQ(2, global->EmbedderFieldCount());
661 v8::Local<v8::Object> obj = v8::Object::New(isolate); 661 v8::Local<v8::Object> obj = v8::Object::New(isolate);
662 global->SetInternalField(0, v8_num(17)); 662 global->SetEmbedderField(0, v8_num(17));
663 global->SetInternalField(1, obj); 663 global->SetEmbedderField(1, obj);
664 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 664 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
665 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 665 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
666 CHECK(ValidateSnapshot(snapshot)); 666 CHECK(ValidateSnapshot(snapshot));
667 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); 667 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot);
668 // The first reference will not present, because it's a Smi. 668 // The first reference will not present, because it's a Smi.
669 CHECK(!GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0")); 669 CHECK(!GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0"));
670 // The second reference is to an object. 670 // The second reference is to an object.
671 CHECK(GetProperty(global_node, v8::HeapGraphEdge::kInternal, "1")); 671 CHECK(GetProperty(global_node, v8::HeapGraphEdge::kInternal, "1"));
672 } 672 }
673 673
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 " a[i] = i;\n" 2957 " a[i] = i;\n"
2958 " for (var i = 0; i < 3; ++i)\n" 2958 " for (var i = 0; i < 3; ++i)\n"
2959 " a.shift();\n" 2959 " a.shift();\n"
2960 "}\n"); 2960 "}\n");
2961 2961
2962 CcTest::CollectGarbage(v8::internal::NEW_SPACE); 2962 CcTest::CollectGarbage(v8::internal::NEW_SPACE);
2963 // Should not crash. 2963 // Should not crash.
2964 2964
2965 heap_profiler->StopSamplingHeapProfiler(); 2965 heap_profiler->StopSamplingHeapProfiler();
2966 } 2966 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698