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

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

Issue 15964004: remove most V8_ALLOW_ACCESS_TO_* defines from test classes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comment addressed Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests for heap profiler 28 // Tests for heap profiler
29 29
30 #include <ctype.h> 30 #include <ctype.h>
31 31
32 // TODO(dcarney): remove
33 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
34
35 #include "v8.h" 32 #include "v8.h"
36 33
37 #include "cctest.h" 34 #include "cctest.h"
38 #include "hashmap.h" 35 #include "hashmap.h"
39 #include "heap-profiler.h" 36 #include "heap-profiler.h"
40 #include "snapshot.h" 37 #include "snapshot.h"
41 #include "debug.h" 38 #include "debug.h"
42 #include "utils-inl.h" 39 #include "utils-inl.h"
43 #include "../include/v8-profiler.h" 40 #include "../include/v8-profiler.h"
44 41
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 TEST(HeapSnapshotRetainedObjectInfo) { 1127 TEST(HeapSnapshotRetainedObjectInfo) {
1131 LocalContext env; 1128 LocalContext env;
1132 v8::Isolate* isolate = env->GetIsolate(); 1129 v8::Isolate* isolate = env->GetIsolate();
1133 v8::HandleScope scope(isolate); 1130 v8::HandleScope scope(isolate);
1134 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); 1131 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
1135 1132
1136 heap_profiler->SetWrapperClassInfoProvider( 1133 heap_profiler->SetWrapperClassInfoProvider(
1137 1, TestRetainedObjectInfo::WrapperInfoCallback); 1134 1, TestRetainedObjectInfo::WrapperInfoCallback);
1138 heap_profiler->SetWrapperClassInfoProvider( 1135 heap_profiler->SetWrapperClassInfoProvider(
1139 2, TestRetainedObjectInfo::WrapperInfoCallback); 1136 2, TestRetainedObjectInfo::WrapperInfoCallback);
1140 v8::Persistent<v8::String> p_AAA = 1137 v8::Persistent<v8::String> p_AAA(isolate, v8_str("AAA"));
1141 v8::Persistent<v8::String>::New(isolate, v8_str("AAA"));
1142 p_AAA.SetWrapperClassId(isolate, 1); 1138 p_AAA.SetWrapperClassId(isolate, 1);
1143 v8::Persistent<v8::String> p_BBB = 1139 v8::Persistent<v8::String> p_BBB(isolate, v8_str("BBB"));
1144 v8::Persistent<v8::String>::New(isolate, v8_str("BBB"));
1145 p_BBB.SetWrapperClassId(isolate, 1); 1140 p_BBB.SetWrapperClassId(isolate, 1);
1146 v8::Persistent<v8::String> p_CCC = 1141 v8::Persistent<v8::String> p_CCC(isolate, v8_str("CCC"));
1147 v8::Persistent<v8::String>::New(isolate, v8_str("CCC"));
1148 p_CCC.SetWrapperClassId(isolate, 2); 1142 p_CCC.SetWrapperClassId(isolate, 2);
1149 CHECK_EQ(0, TestRetainedObjectInfo::instances.length()); 1143 CHECK_EQ(0, TestRetainedObjectInfo::instances.length());
1150 const v8::HeapSnapshot* snapshot = 1144 const v8::HeapSnapshot* snapshot =
1151 heap_profiler->TakeHeapSnapshot(v8_str("retained")); 1145 heap_profiler->TakeHeapSnapshot(v8_str("retained"));
1152 1146
1153 CHECK_EQ(3, TestRetainedObjectInfo::instances.length()); 1147 CHECK_EQ(3, TestRetainedObjectInfo::instances.length());
1154 for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) { 1148 for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) {
1155 CHECK(TestRetainedObjectInfo::instances[i]->disposed()); 1149 CHECK(TestRetainedObjectInfo::instances[i]->disposed());
1156 delete TestRetainedObjectInfo::instances[i]; 1150 delete TestRetainedObjectInfo::instances[i];
1157 } 1151 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1183
1190 1184
1191 class GraphWithImplicitRefs { 1185 class GraphWithImplicitRefs {
1192 public: 1186 public:
1193 static const int kObjectsCount = 4; 1187 static const int kObjectsCount = 4;
1194 explicit GraphWithImplicitRefs(LocalContext* env) { 1188 explicit GraphWithImplicitRefs(LocalContext* env) {
1195 CHECK_EQ(NULL, instance_); 1189 CHECK_EQ(NULL, instance_);
1196 instance_ = this; 1190 instance_ = this;
1197 isolate_ = (*env)->GetIsolate(); 1191 isolate_ = (*env)->GetIsolate();
1198 for (int i = 0; i < kObjectsCount; i++) { 1192 for (int i = 0; i < kObjectsCount; i++) {
1199 objects_[i] = 1193 objects_[i].Reset(isolate_, v8::Object::New());
1200 v8::Persistent<v8::Object>::New(isolate_, v8::Object::New());
1201 } 1194 }
1202 (*env)->Global()->Set(v8_str("root_object"), 1195 (*env)->Global()->Set(v8_str("root_object"),
1203 v8::Local<v8::Value>::New(isolate_, objects_[0])); 1196 v8::Local<v8::Value>::New(isolate_, objects_[0]));
1204 } 1197 }
1205 ~GraphWithImplicitRefs() { 1198 ~GraphWithImplicitRefs() {
1206 instance_ = NULL; 1199 instance_ = NULL;
1207 } 1200 }
1208 1201
1209 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { 1202 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) {
1210 instance_->AddImplicitReferences(); 1203 instance_->AddImplicitReferences();
1211 } 1204 }
1212 1205
1213 private: 1206 private:
1214 void AddImplicitReferences() { 1207 void AddImplicitReferences() {
1215 // 0 -> 1 1208 // 0 -> 1
1216 isolate_->SetObjectGroupId(v8::Persistent<v8::Object>::Cast(objects_[0]), 1209 isolate_->SetObjectGroupId(objects_[0],
1217 v8::UniqueId(1)); 1210 v8::UniqueId(1));
1218 isolate_->SetReferenceFromGroup( 1211 isolate_->SetReferenceFromGroup(
1219 v8::UniqueId(1), v8::Persistent<v8::Object>::Cast(objects_[1])); 1212 v8::UniqueId(1), objects_[1]);
1220 // Adding two more references: 1 -> 2, 1 -> 3 1213 // Adding two more references: 1 -> 2, 1 -> 3
1221 isolate_->SetReference(v8::Persistent<v8::Object>::Cast(objects_[1]), 1214 isolate_->SetReference(objects_[1].As<v8::Object>(),
1222 v8::Persistent<v8::Object>::Cast(objects_[2])); 1215 objects_[2]);
1223 isolate_->SetReference(v8::Persistent<v8::Object>::Cast(objects_[1]), 1216 isolate_->SetReference(objects_[1].As<v8::Object>(),
1224 v8::Persistent<v8::Object>::Cast(objects_[3])); 1217 objects_[3]);
1225 } 1218 }
1226 1219
1227 v8::Persistent<v8::Value> objects_[kObjectsCount]; 1220 v8::Persistent<v8::Value> objects_[kObjectsCount];
1228 static GraphWithImplicitRefs* instance_; 1221 static GraphWithImplicitRefs* instance_;
1229 v8::Isolate* isolate_; 1222 v8::Isolate* isolate_;
1230 }; 1223 };
1231 1224
1232 GraphWithImplicitRefs* GraphWithImplicitRefs::instance_ = NULL; 1225 GraphWithImplicitRefs* GraphWithImplicitRefs::instance_ = NULL;
1233 1226
1234 1227
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 handle->Dispose(isolate); 1597 handle->Dispose(isolate);
1605 } 1598 }
1606 1599
1607 1600
1608 TEST(WeakGlobalHandle) { 1601 TEST(WeakGlobalHandle) {
1609 LocalContext env; 1602 LocalContext env;
1610 v8::HandleScope scope(env->GetIsolate()); 1603 v8::HandleScope scope(env->GetIsolate());
1611 1604
1612 CHECK(!HasWeakGlobalHandle()); 1605 CHECK(!HasWeakGlobalHandle());
1613 1606
1614 v8::Persistent<v8::Object> handle = 1607 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New());
1615 v8::Persistent<v8::Object>::New(env->GetIsolate(), v8::Object::New());
1616 handle.MakeWeak<v8::Value, void>(env->GetIsolate(), 1608 handle.MakeWeak<v8::Value, void>(env->GetIsolate(),
1617 NULL, 1609 NULL,
1618 PersistentHandleCallback); 1610 PersistentHandleCallback);
1619 1611
1620 CHECK(HasWeakGlobalHandle()); 1612 CHECK(HasWeakGlobalHandle());
1621 } 1613 }
1622 1614
1623 1615
1624 TEST(WeakNativeContextRefs) { 1616 TEST(WeakNativeContextRefs) {
1625 LocalContext env; 1617 LocalContext env;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 // Check all the objects have got their names. 1782 // Check all the objects have got their names.
1791 // ... well check just every 8th because otherwise it's too slow in debug. 1783 // ... well check just every 8th because otherwise it's too slow in debug.
1792 for (int i = 0; i < num_objects - 1; i += 8) { 1784 for (int i = 0; i < num_objects - 1; i += 8) {
1793 i::EmbeddedVector<char, 100> var_name; 1785 i::EmbeddedVector<char, 100> var_name;
1794 i::OS::SNPrintF(var_name, "f_%d", i); 1786 i::OS::SNPrintF(var_name, "f_%d", i);
1795 const v8::HeapGraphNode* f_object = GetProperty( 1787 const v8::HeapGraphNode* f_object = GetProperty(
1796 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1788 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1797 CHECK_NE(NULL, f_object); 1789 CHECK_NE(NULL, f_object);
1798 } 1790 }
1799 } 1791 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698