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

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

Issue 306473004: Reland 21502 - "Move OS::MemCopy and OS::MemMove out of platform to utils" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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-macro-assembler-irregexp.cc ('k') | src/scanner.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 #include "regexp-stack.h" 6 #include "regexp-stack.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 28
29 RegExpStack::~RegExpStack() { 29 RegExpStack::~RegExpStack() {
30 thread_local_.Free(); 30 thread_local_.Free();
31 } 31 }
32 32
33 33
34 char* RegExpStack::ArchiveStack(char* to) { 34 char* RegExpStack::ArchiveStack(char* to) {
35 size_t size = sizeof(thread_local_); 35 size_t size = sizeof(thread_local_);
36 OS::MemCopy(reinterpret_cast<void*>(to), &thread_local_, size); 36 MemCopy(reinterpret_cast<void*>(to), &thread_local_, size);
37 thread_local_ = ThreadLocal(); 37 thread_local_ = ThreadLocal();
38 return to + size; 38 return to + size;
39 } 39 }
40 40
41 41
42 char* RegExpStack::RestoreStack(char* from) { 42 char* RegExpStack::RestoreStack(char* from) {
43 size_t size = sizeof(thread_local_); 43 size_t size = sizeof(thread_local_);
44 OS::MemCopy(&thread_local_, reinterpret_cast<void*>(from), size); 44 MemCopy(&thread_local_, reinterpret_cast<void*>(from), size);
45 return from + size; 45 return from + size;
46 } 46 }
47 47
48 48
49 void RegExpStack::Reset() { 49 void RegExpStack::Reset() {
50 if (thread_local_.memory_size_ > kMinimumStackSize) { 50 if (thread_local_.memory_size_ > kMinimumStackSize) {
51 DeleteArray(thread_local_.memory_); 51 DeleteArray(thread_local_.memory_);
52 thread_local_ = ThreadLocal(); 52 thread_local_ = ThreadLocal();
53 } 53 }
54 } 54 }
55 55
56 56
57 void RegExpStack::ThreadLocal::Free() { 57 void RegExpStack::ThreadLocal::Free() {
58 if (memory_size_ > 0) { 58 if (memory_size_ > 0) {
59 DeleteArray(memory_); 59 DeleteArray(memory_);
60 Clear(); 60 Clear();
61 } 61 }
62 } 62 }
63 63
64 64
65 Address RegExpStack::EnsureCapacity(size_t size) { 65 Address RegExpStack::EnsureCapacity(size_t size) {
66 if (size > kMaximumStackSize) return NULL; 66 if (size > kMaximumStackSize) return NULL;
67 if (size < kMinimumStackSize) size = kMinimumStackSize; 67 if (size < kMinimumStackSize) size = kMinimumStackSize;
68 if (thread_local_.memory_size_ < size) { 68 if (thread_local_.memory_size_ < size) {
69 Address new_memory = NewArray<byte>(static_cast<int>(size)); 69 Address new_memory = NewArray<byte>(static_cast<int>(size));
70 if (thread_local_.memory_size_ > 0) { 70 if (thread_local_.memory_size_ > 0) {
71 // Copy original memory into top of new memory. 71 // Copy original memory into top of new memory.
72 OS::MemCopy( 72 MemCopy(reinterpret_cast<void*>(new_memory + size -
73 reinterpret_cast<void*>( 73 thread_local_.memory_size_),
74 new_memory + size - thread_local_.memory_size_), 74 reinterpret_cast<void*>(thread_local_.memory_),
75 reinterpret_cast<void*>(thread_local_.memory_), 75 thread_local_.memory_size_);
76 thread_local_.memory_size_);
77 DeleteArray(thread_local_.memory_); 76 DeleteArray(thread_local_.memory_);
78 } 77 }
79 thread_local_.memory_ = new_memory; 78 thread_local_.memory_ = new_memory;
80 thread_local_.memory_size_ = size; 79 thread_local_.memory_size_ = size;
81 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize; 80 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize;
82 } 81 }
83 return thread_local_.memory_ + thread_local_.memory_size_; 82 return thread_local_.memory_ + thread_local_.memory_size_;
84 } 83 }
85 84
86 85
87 }} // namespace v8::internal 86 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-irregexp.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698