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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #endif | 45 #endif |
46 #endif | 46 #endif |
47 | 47 |
48 enum InitializationState {kUnset, kUnintialized, kInitialized}; | 48 enum InitializationState {kUnset, kUnintialized, kInitialized}; |
49 static InitializationState initialization_state_ = kUnset; | 49 static InitializationState initialization_state_ = kUnset; |
50 static bool disable_automatic_dispose_ = false; | 50 static bool disable_automatic_dispose_ = false; |
51 | 51 |
52 CcTest* CcTest::last_ = NULL; | 52 CcTest* CcTest::last_ = NULL; |
53 bool CcTest::initialize_called_ = false; | 53 bool CcTest::initialize_called_ = false; |
54 v8::base::Atomic32 CcTest::isolate_used_ = 0; | 54 v8::base::Atomic32 CcTest::isolate_used_ = 0; |
| 55 v8::ArrayBuffer::Allocator* CcTest::allocator_ = NULL; |
55 v8::Isolate* CcTest::isolate_ = NULL; | 56 v8::Isolate* CcTest::isolate_ = NULL; |
56 | 57 |
57 | 58 |
58 CcTest::CcTest(TestFunction* callback, const char* file, const char* name, | 59 CcTest::CcTest(TestFunction* callback, const char* file, const char* name, |
59 const char* dependency, bool enabled, bool initialize) | 60 const char* dependency, bool enabled, bool initialize) |
60 : callback_(callback), name_(name), dependency_(dependency), | 61 : callback_(callback), name_(name), dependency_(dependency), |
61 enabled_(enabled), initialize_(initialize), prev_(last_) { | 62 enabled_(enabled), initialize_(initialize), prev_(last_) { |
62 // Find the base name of this test (const_cast required on Windows). | 63 // Find the base name of this test (const_cast required on Windows). |
63 char *basename = strrchr(const_cast<char *>(file), '/'); | 64 char *basename = strrchr(const_cast<char *>(file), '/'); |
64 if (!basename) { | 65 if (!basename) { |
(...skipping 16 matching lines...) Expand all Loading... |
81 | 82 |
82 void CcTest::Run() { | 83 void CcTest::Run() { |
83 if (!initialize_) { | 84 if (!initialize_) { |
84 CHECK(initialization_state_ != kInitialized); | 85 CHECK(initialization_state_ != kInitialized); |
85 initialization_state_ = kUnintialized; | 86 initialization_state_ = kUnintialized; |
86 CHECK(CcTest::isolate_ == NULL); | 87 CHECK(CcTest::isolate_ == NULL); |
87 } else { | 88 } else { |
88 CHECK(initialization_state_ != kUnintialized); | 89 CHECK(initialization_state_ != kUnintialized); |
89 initialization_state_ = kInitialized; | 90 initialization_state_ = kInitialized; |
90 if (isolate_ == NULL) { | 91 if (isolate_ == NULL) { |
91 isolate_ = v8::Isolate::New(); | 92 v8::Isolate::CreateParams create_params; |
| 93 create_params.array_buffer_allocator = allocator_; |
| 94 isolate_ = v8::Isolate::New(create_params); |
92 } | 95 } |
93 isolate_->Enter(); | 96 isolate_->Enter(); |
94 } | 97 } |
95 callback_(); | 98 callback_(); |
96 if (initialize_) { | 99 if (initialize_) { |
97 isolate_->Exit(); | 100 isolate_->Exit(); |
98 } | 101 } |
99 } | 102 } |
100 | 103 |
101 | 104 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 v8::V8::InitializeICU(); | 171 v8::V8::InitializeICU(); |
169 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); | 172 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); |
170 v8::V8::InitializePlatform(platform); | 173 v8::V8::InitializePlatform(platform); |
171 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); | 174 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
172 v8::V8::Initialize(); | 175 v8::V8::Initialize(); |
173 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 176 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
174 v8::StartupDataHandler startup_data(argv[0], NULL, NULL); | 177 v8::StartupDataHandler startup_data(argv[0], NULL, NULL); |
175 #endif | 178 #endif |
176 | 179 |
177 CcTestArrayBufferAllocator array_buffer_allocator; | 180 CcTestArrayBufferAllocator array_buffer_allocator; |
178 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 181 CcTest::set_array_buffer_allocator(&array_buffer_allocator); |
179 | 182 |
180 i::PrintExtension print_extension; | 183 i::PrintExtension print_extension; |
181 v8::RegisterExtension(&print_extension); | 184 v8::RegisterExtension(&print_extension); |
182 i::ProfilerExtension profiler_extension; | 185 i::ProfilerExtension profiler_extension; |
183 v8::RegisterExtension(&profiler_extension); | 186 v8::RegisterExtension(&profiler_extension); |
184 i::TraceExtension trace_extension; | 187 i::TraceExtension trace_extension; |
185 v8::RegisterExtension(&trace_extension); | 188 v8::RegisterExtension(&trace_extension); |
186 | 189 |
187 int tests_run = 0; | 190 int tests_run = 0; |
188 bool print_run_count = true; | 191 bool print_run_count = true; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 CcTest::TearDown(); | 237 CcTest::TearDown(); |
235 // TODO(svenpanne) See comment above. | 238 // TODO(svenpanne) See comment above. |
236 // if (!disable_automatic_dispose_) v8::V8::Dispose(); | 239 // if (!disable_automatic_dispose_) v8::V8::Dispose(); |
237 v8::V8::ShutdownPlatform(); | 240 v8::V8::ShutdownPlatform(); |
238 delete platform; | 241 delete platform; |
239 return 0; | 242 return 0; |
240 } | 243 } |
241 | 244 |
242 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL; | 245 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL; |
243 int RegisterThreadedTest::count_ = 0; | 246 int RegisterThreadedTest::count_ = 0; |
OLD | NEW |