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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp

Issue 2343643003: binding: Makes assertion of adjustAmountOfExternalAllocatedMemory more exact. (Closed)
Patch Set: Factor it out to checkIfAAOEAMIsConsistent. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
index 8635a20f5aad9f767c654b187c1745ffcd525747..a4b34b9e605113129cbd9380fdf6dd78dcbb027f 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
@@ -359,14 +359,20 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
} // namespace
-static void adjustAmountOfExternalAllocatedMemory(int64_t size) {
+static void adjustAmountOfExternalAllocatedMemory(int64_t diff) {
#if ENABLE(ASSERT)
- static int64_t totalSize = 0;
- totalSize += size;
- DCHECK_GE(totalSize, 0);
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(int64_t, processTotal, new int64_t(0));
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex);
+ {
+ MutexLocker locker(mutex);
+
+ processTotal += diff;
+ DCHECK_GE(processTotal, 0) << "total amount = " << processTotal
+ << ", diff = " << diff;
+ }
#endif
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size);
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff);
}
void V8Initializer::initializeMainThread() {
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/typed_arrays/ArrayBufferContents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698