OLD | NEW |
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 Loading... |
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 { |
| 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 }; |
| 94 |
| 95 |
83 class CcTest { | 96 class CcTest { |
84 public: | 97 public: |
85 typedef void (TestFunction)(); | 98 typedef void (TestFunction)(); |
86 CcTest(TestFunction* callback, const char* file, const char* name, | 99 CcTest(TestFunction* callback, const char* file, const char* name, |
87 const char* dependency, bool enabled, bool initialize); | 100 const char* dependency, bool enabled, bool initialize); |
88 void Run(); | 101 void Run(); |
89 static CcTest* last() { return last_; } | 102 static CcTest* last() { return last_; } |
90 CcTest* prev() { return prev_; } | 103 CcTest* prev() { return prev_; } |
91 const char* file() { return file_; } | 104 const char* file() { return file_; } |
92 const char* name() { return name_; } | 105 const char* name() { return name_; } |
93 const char* dependency() { return dependency_; } | 106 const char* dependency() { return dependency_; } |
94 bool enabled() { return enabled_; } | 107 bool enabled() { return enabled_; } |
95 | 108 |
96 static v8::Isolate* isolate() { | 109 static v8::Isolate* isolate() { |
97 CHECK(isolate_ != NULL); | 110 CHECK(isolate_ != NULL); |
98 isolate_used_ = true; | 111 isolate_used_ = true; |
99 return isolate_; | 112 return isolate_; |
100 } | 113 } |
101 | 114 |
102 static i::Isolate* i_isolate() { | 115 static i::Isolate* i_isolate() { |
103 return reinterpret_cast<i::Isolate*>(isolate()); | 116 return reinterpret_cast<i::Isolate*>(isolate()); |
104 } | 117 } |
105 | 118 |
106 static i::Heap* heap() { | 119 static i::Heap* heap() { |
107 return i_isolate()->heap(); | 120 return i_isolate()->heap(); |
108 } | 121 } |
109 | 122 |
| 123 static TestHeap* test_heap() { |
| 124 return reinterpret_cast<TestHeap*>(i_isolate()->heap()); |
| 125 } |
| 126 |
110 static v8::Local<v8::Object> global() { | 127 static v8::Local<v8::Object> global() { |
111 return isolate()->GetCurrentContext()->Global(); | 128 return isolate()->GetCurrentContext()->Global(); |
112 } | 129 } |
113 | 130 |
114 // TODO(dcarney): Remove. | 131 // TODO(dcarney): Remove. |
115 // This must be called first in a test. | 132 // This must be called first in a test. |
116 static void InitializeVM() { | 133 static void InitializeVM() { |
117 CHECK(!isolate_used_); | 134 CHECK(!isolate_used_); |
118 CHECK(!initialize_called_); | 135 CHECK(!initialize_called_); |
119 initialize_called_ = true; | 136 initialize_called_ = true; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 444 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |
428 heap_profiler_->StopHeapObjectsTracking(); | 445 heap_profiler_->StopHeapObjectsTracking(); |
429 } | 446 } |
430 | 447 |
431 private: | 448 private: |
432 i::HeapProfiler* heap_profiler_; | 449 i::HeapProfiler* heap_profiler_; |
433 }; | 450 }; |
434 | 451 |
435 | 452 |
436 #endif // ifndef CCTEST_H_ | 453 #endif // ifndef CCTEST_H_ |
OLD | NEW |