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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #undef DEFINE_EXTENSION_ID | 71 #undef DEFINE_EXTENSION_ID |
72 | 72 |
73 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; | 73 typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags; |
74 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ | 74 #define DEFINE_EXTENSION_FLAG(Name, Ident) \ |
75 static const CcTestExtensionFlags Name(1 << Name##_ID); | 75 static const CcTestExtensionFlags Name(1 << Name##_ID); |
76 static const CcTestExtensionFlags NO_EXTENSIONS(0); | 76 static const CcTestExtensionFlags NO_EXTENSIONS(0); |
77 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); | 77 static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1); |
78 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) | 78 EXTENSION_LIST(DEFINE_EXTENSION_FLAG) |
79 #undef DEFINE_EXTENSION_FLAG | 79 #undef DEFINE_EXTENSION_FLAG |
80 | 80 |
81 // Temporary macros for accessing current isolate and its subobjects. | |
82 // They provide better readability, especially when used a lot in the code. | |
83 #define HEAP (v8::internal::Isolate::Current()->heap()) | |
84 | 81 |
85 class CcTest { | 82 class CcTest { |
86 public: | 83 public: |
87 typedef void (TestFunction)(); | 84 typedef void (TestFunction)(); |
88 CcTest(TestFunction* callback, const char* file, const char* name, | 85 CcTest(TestFunction* callback, const char* file, const char* name, |
89 const char* dependency, bool enabled, bool initialize); | 86 const char* dependency, bool enabled, bool initialize); |
90 void Run(); | 87 void Run(); |
91 static CcTest* last() { return last_; } | 88 static CcTest* last() { return last_; } |
92 CcTest* prev() { return prev_; } | 89 CcTest* prev() { return prev_; } |
93 const char* file() { return file_; } | 90 const char* file() { return file_; } |
94 const char* name() { return name_; } | 91 const char* name() { return name_; } |
95 const char* dependency() { return dependency_; } | 92 const char* dependency() { return dependency_; } |
96 bool enabled() { return enabled_; } | 93 bool enabled() { return enabled_; } |
97 static v8::Isolate* default_isolate() { return isolate(); } | 94 static v8::Isolate* default_isolate() { return isolate(); } |
98 | 95 |
99 static v8::Handle<v8::Context> env() { | 96 static v8::Handle<v8::Context> env() { |
100 return v8::Local<v8::Context>::New(isolate(), context_); | 97 return v8::Local<v8::Context>::New(isolate(), context_); |
101 } | 98 } |
102 | 99 |
103 static v8::Isolate* isolate() { | 100 static v8::Isolate* isolate() { |
104 return default_isolate_; | 101 return default_isolate_; |
105 } | 102 } |
106 | 103 |
107 static i::Isolate* i_isolate() { | 104 static i::Isolate* i_isolate() { |
108 return reinterpret_cast<i::Isolate*>(isolate()); | 105 return reinterpret_cast<i::Isolate*>(isolate()); |
109 } | 106 } |
110 | 107 |
| 108 static i::Heap* heap() { |
| 109 return i_isolate()->heap(); |
| 110 } |
| 111 |
111 // Helper function to initialize the VM. | 112 // Helper function to initialize the VM. |
112 static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); | 113 static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); |
113 | 114 |
114 private: | 115 private: |
115 friend int main(int argc, char** argv); | 116 friend int main(int argc, char** argv); |
116 TestFunction* callback_; | 117 TestFunction* callback_; |
117 const char* file_; | 118 const char* file_; |
118 const char* name_; | 119 const char* name_; |
119 const char* dependency_; | 120 const char* dependency_; |
120 bool enabled_; | 121 bool enabled_; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 312 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
312 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 313 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
313 space->Free(space->top(), old_linear_size); | 314 space->Free(space->top(), old_linear_size); |
314 space->SetTop(space->limit(), space->limit()); | 315 space->SetTop(space->limit(), space->limit()); |
315 space->ResetFreeList(); | 316 space->ResetFreeList(); |
316 space->ClearStats(); | 317 space->ClearStats(); |
317 } | 318 } |
318 | 319 |
319 | 320 |
320 #endif // ifndef CCTEST_H_ | 321 #endif // ifndef CCTEST_H_ |
OLD | NEW |