| 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 17 matching lines...) Expand all Loading... |
| 28 #include "include/v8.h" | 28 #include "include/v8.h" |
| 29 #include "test/cctest/cctest.h" | 29 #include "test/cctest/cctest.h" |
| 30 | 30 |
| 31 #include "include/libplatform/libplatform.h" | 31 #include "include/libplatform/libplatform.h" |
| 32 #include "src/debug.h" | 32 #include "src/debug.h" |
| 33 #include "test/cctest/print-extension.h" | 33 #include "test/cctest/print-extension.h" |
| 34 #include "test/cctest/profiler-extension.h" | 34 #include "test/cctest/profiler-extension.h" |
| 35 #include "test/cctest/trace-extension.h" | 35 #include "test/cctest/trace-extension.h" |
| 36 | 36 |
| 37 #if V8_OS_WIN | 37 #if V8_OS_WIN |
| 38 #include <malloc.h> |
| 38 #include <windows.h> // NOLINT | 39 #include <windows.h> // NOLINT |
| 39 #if V8_CC_MSVC | 40 #if V8_CC_MSVC |
| 40 #include <crtdbg.h> | 41 #include <crtdbg.h> |
| 41 #endif | 42 #endif |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 enum InitializationState {kUnset, kUnintialized, kInitialized}; | 45 enum InitializationState {kUnset, kUnintialized, kInitialized}; |
| 45 static InitializationState initialization_state_ = kUnset; | 46 static InitializationState initialization_state_ = kUnset; |
| 46 static bool disable_automatic_dispose_ = false; | 47 static bool disable_automatic_dispose_ = false; |
| 47 | 48 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (current->dependency() != NULL) { | 123 if (current->dependency() != NULL) { |
| 123 printf("%s/%s<%s\n", | 124 printf("%s/%s<%s\n", |
| 124 current->file(), current->name(), current->dependency()); | 125 current->file(), current->name(), current->dependency()); |
| 125 } else { | 126 } else { |
| 126 printf("%s/%s<\n", current->file(), current->name()); | 127 printf("%s/%s<\n", current->file(), current->name()); |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 | 130 |
| 130 | 131 |
| 131 class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 132 class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 132 virtual void* Allocate(size_t length) { return malloc(length); } | 133 public: |
| 133 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } | 134 virtual void* Allocate(size_t length) { |
| 134 virtual void Free(void* data, size_t length) { free(data); } | 135 void* data = AllocateUninitialized(length); |
| 135 // TODO(dslomov): Remove when v8:2823 is fixed. | 136 return data == NULL ? data : memset(data, 0, length); |
| 136 virtual void Free(void* data) { UNREACHABLE(); } | 137 } |
| 138 virtual void* AllocateUninitialized(size_t length) { |
| 139 return Allocate(length, 8); |
| 140 } |
| 141 virtual void* Allocate(size_t length, size_t alignment) { |
| 142 #if V8_OS_ANDROID |
| 143 return memalign(alignment, length); |
| 144 #elif V8_OS_WIN |
| 145 return _aligned_malloc(length, alignment); |
| 146 #else |
| 147 void* ptr = NULL; |
| 148 posix_memalign(&ptr, alignment, length); |
| 149 return ptr; |
| 150 #endif |
| 151 } |
| 152 virtual void Free(void* data, size_t) { Free(data); } |
| 153 virtual void Free(void* data) { |
| 154 #if V8_OS_WIN |
| 155 _aligned_free(data); |
| 156 #else |
| 157 free(data); |
| 158 #endif |
| 159 } |
| 137 }; | 160 }; |
| 138 | 161 |
| 139 | 162 |
| 140 static void SuggestTestHarness(int tests) { | 163 static void SuggestTestHarness(int tests) { |
| 141 if (tests == 0) return; | 164 if (tests == 0) return; |
| 142 printf("Running multiple tests in sequence is deprecated and may cause " | 165 printf("Running multiple tests in sequence is deprecated and may cause " |
| 143 "bogus failure. Consider using tools/run-tests.py instead.\n"); | 166 "bogus failure. Consider using tools/run-tests.py instead.\n"); |
| 144 } | 167 } |
| 145 | 168 |
| 146 | 169 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 CcTest::TearDown(); | 250 CcTest::TearDown(); |
| 228 // TODO(svenpanne) See comment above. | 251 // TODO(svenpanne) See comment above. |
| 229 // if (!disable_automatic_dispose_) v8::V8::Dispose(); | 252 // if (!disable_automatic_dispose_) v8::V8::Dispose(); |
| 230 v8::V8::ShutdownPlatform(); | 253 v8::V8::ShutdownPlatform(); |
| 231 delete platform; | 254 delete platform; |
| 232 return 0; | 255 return 0; |
| 233 } | 256 } |
| 234 | 257 |
| 235 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL; | 258 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL; |
| 236 int RegisterThreadedTest::count_ = 0; | 259 int RegisterThreadedTest::count_ = 0; |
| OLD | NEW |