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

Side by Side Diff: src/regexp-stack.cc

Issue 251014: * Fix memory leaks caused by thread local data being lost.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/regexp-stack.h ('k') | src/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 63
64 void RegExpStack::Reset() { 64 void RegExpStack::Reset() {
65 if (thread_local_.memory_size_ > kMinimumStackSize) { 65 if (thread_local_.memory_size_ > kMinimumStackSize) {
66 DeleteArray(thread_local_.memory_); 66 DeleteArray(thread_local_.memory_);
67 thread_local_ = ThreadLocal(); 67 thread_local_ = ThreadLocal();
68 } 68 }
69 } 69 }
70 70
71 71
72 void RegExpStack::ThreadLocal::Free() {
73 if (thread_local_.memory_size_ > 0) {
74 DeleteArray(thread_local_.memory_);
75 thread_local_ = ThreadLocal();
76 }
77 }
78
79
72 Address RegExpStack::EnsureCapacity(size_t size) { 80 Address RegExpStack::EnsureCapacity(size_t size) {
73 if (size > kMaximumStackSize) return NULL; 81 if (size > kMaximumStackSize) return NULL;
74 if (size < kMinimumStackSize) size = kMinimumStackSize; 82 if (size < kMinimumStackSize) size = kMinimumStackSize;
75 if (thread_local_.memory_size_ < size) { 83 if (thread_local_.memory_size_ < size) {
76 Address new_memory = NewArray<byte>(size); 84 Address new_memory = NewArray<byte>(size);
77 if (thread_local_.memory_size_ > 0) { 85 if (thread_local_.memory_size_ > 0) {
78 // Copy original memory into top of new memory. 86 // Copy original memory into top of new memory.
79 memcpy(reinterpret_cast<void*>( 87 memcpy(reinterpret_cast<void*>(
80 new_memory + size - thread_local_.memory_size_), 88 new_memory + size - thread_local_.memory_size_),
81 reinterpret_cast<void*>(thread_local_.memory_), 89 reinterpret_cast<void*>(thread_local_.memory_),
82 thread_local_.memory_size_); 90 thread_local_.memory_size_);
83 DeleteArray(thread_local_.memory_); 91 DeleteArray(thread_local_.memory_);
84 } 92 }
85 thread_local_.memory_ = new_memory; 93 thread_local_.memory_ = new_memory;
86 thread_local_.memory_size_ = size; 94 thread_local_.memory_size_ = size;
87 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize; 95 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize;
88 } 96 }
89 return thread_local_.memory_ + thread_local_.memory_size_; 97 return thread_local_.memory_ + thread_local_.memory_size_;
90 } 98 }
91 99
92 100
93 RegExpStack::ThreadLocal RegExpStack::thread_local_; 101 RegExpStack::ThreadLocal RegExpStack::thread_local_;
94 102
95 }} // namespace v8::internal 103 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-stack.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698