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

Side by Side Diff: test/cctest/cctest.h

Issue 247263003: Hide heap methods where possible. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; 74 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
75 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ 75 #define DEFINE_EXTENSION_FLAG(Name, Ident) \
76 static const CcTestExtensionFlags Name(1 << Name##_ID); 76 static const CcTestExtensionFlags Name(1 << Name##_ID);
77 static const CcTestExtensionFlags NO_EXTENSIONS(0); 77 static const CcTestExtensionFlags NO_EXTENSIONS(0);
78 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); 78 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1);
79 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) 79 EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
80 #undef DEFINE_EXTENSION_FLAG 80 #undef DEFINE_EXTENSION_FLAG
81 81
82 82
83 // Use this to expose protected methods in i::Heap.
84 class TestHeap : public i::Heap {
Michael Starzinger 2014/04/29 13:15:09 At first this helper class worried me, but the mor
Yang 2014/04/29 13:55:13 :) Apparently this is covered by the C++ spec, so
85 public:
86 using i::Heap::AllocateHeapNumber;
87 using i::Heap::AllocateMap;
88 using i::Heap::AllocateJSObject;
89 using i::Heap::AllocateJSObjectFromMap;
90 using i::Heap::AllocateByteArray;
91 using i::Heap::AllocateArgumentsObject;
92 using i::Heap::CopyCode;
93 using i::Heap::InternalizeString;
94 };
95
96
83 class CcTest { 97 class CcTest {
84 public: 98 public:
85 typedef void (TestFunction)(); 99 typedef void (TestFunction)();
86 CcTest(TestFunction* callback, const char* file, const char* name, 100 CcTest(TestFunction* callback, const char* file, const char* name,
87 const char* dependency, bool enabled, bool initialize); 101 const char* dependency, bool enabled, bool initialize);
88 void Run(); 102 void Run();
89 static CcTest* last() { return last_; } 103 static CcTest* last() { return last_; }
90 CcTest* prev() { return prev_; } 104 CcTest* prev() { return prev_; }
91 const char* file() { return file_; } 105 const char* file() { return file_; }
92 const char* name() { return name_; } 106 const char* name() { return name_; }
93 const char* dependency() { return dependency_; } 107 const char* dependency() { return dependency_; }
94 bool enabled() { return enabled_; } 108 bool enabled() { return enabled_; }
95 109
96 static v8::Isolate* isolate() { 110 static v8::Isolate* isolate() {
97 CHECK(isolate_ != NULL); 111 CHECK(isolate_ != NULL);
98 isolate_used_ = true; 112 isolate_used_ = true;
99 return isolate_; 113 return isolate_;
100 } 114 }
101 115
102 static i::Isolate* i_isolate() { 116 static i::Isolate* i_isolate() {
103 return reinterpret_cast<i::Isolate*>(isolate()); 117 return reinterpret_cast<i::Isolate*>(isolate());
104 } 118 }
105 119
106 static i::Heap* heap() { 120 static i::Heap* heap() {
107 return i_isolate()->heap(); 121 return i_isolate()->heap();
108 } 122 }
109 123
124 static TestHeap* test_heap() {
125 return reinterpret_cast<TestHeap*>(i_isolate()->heap());
126 }
127
110 static v8::Local<v8::Object> global() { 128 static v8::Local<v8::Object> global() {
111 return isolate()->GetCurrentContext()->Global(); 129 return isolate()->GetCurrentContext()->Global();
112 } 130 }
113 131
114 // TODO(dcarney): Remove. 132 // TODO(dcarney): Remove.
115 // This must be called first in a test. 133 // This must be called first in a test.
116 static void InitializeVM() { 134 static void InitializeVM() {
117 CHECK(!isolate_used_); 135 CHECK(!isolate_used_);
118 CHECK(!initialize_called_); 136 CHECK(!initialize_called_);
119 initialize_called_ = true; 137 initialize_called_ = true;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); 445 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects());
428 heap_profiler_->StopHeapObjectsTracking(); 446 heap_profiler_->StopHeapObjectsTracking();
429 } 447 }
430 448
431 private: 449 private:
432 i::HeapProfiler* heap_profiler_; 450 i::HeapProfiler* heap_profiler_;
433 }; 451 };
434 452
435 453
436 #endif // ifndef CCTEST_H_ 454 #endif // ifndef CCTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698