| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 regexp_stack_->Reset(); | 44 regexp_stack_->Reset(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 RegExpStack::RegExpStack() | 48 RegExpStack::RegExpStack() |
| 49 : isolate_(NULL) { | 49 : isolate_(NULL) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 RegExpStack::~RegExpStack() { | 53 RegExpStack::~RegExpStack() { |
| 54 thread_local_.Free(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 | 57 |
| 57 char* RegExpStack::ArchiveStack(char* to) { | 58 char* RegExpStack::ArchiveStack(char* to) { |
| 58 size_t size = sizeof(thread_local_); | 59 size_t size = sizeof(thread_local_); |
| 59 memcpy(reinterpret_cast<void*>(to), | 60 memcpy(reinterpret_cast<void*>(to), |
| 60 &thread_local_, | 61 &thread_local_, |
| 61 size); | 62 size); |
| 62 thread_local_ = ThreadLocal(); | 63 thread_local_ = ThreadLocal(); |
| 63 return to + size; | 64 return to + size; |
| 64 } | 65 } |
| 65 | 66 |
| 66 | 67 |
| 67 char* RegExpStack::RestoreStack(char* from) { | 68 char* RegExpStack::RestoreStack(char* from) { |
| 68 size_t size = sizeof(thread_local_); | 69 size_t size = sizeof(thread_local_); |
| 69 memcpy(&thread_local_, reinterpret_cast<void*>(from), size); | 70 memcpy(&thread_local_, reinterpret_cast<void*>(from), size); |
| 70 return from + size; | 71 return from + size; |
| 71 } | 72 } |
| 72 | 73 |
| 73 | 74 |
| 74 void RegExpStack::Reset() { | 75 void RegExpStack::Reset() { |
| 75 if (thread_local_.memory_size_ >= kMinimumStackSize) { | 76 if (thread_local_.memory_size_ > kMinimumStackSize) { |
| 76 DeleteArray(thread_local_.memory_); | 77 DeleteArray(thread_local_.memory_); |
| 77 thread_local_ = ThreadLocal(); | 78 thread_local_ = ThreadLocal(); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 | 82 |
| 82 void RegExpStack::ThreadLocal::Free() { | 83 void RegExpStack::ThreadLocal::Free() { |
| 83 if (memory_size_ > 0) { | 84 if (memory_size_ > 0) { |
| 84 DeleteArray(memory_); | 85 DeleteArray(memory_); |
| 85 Clear(); | 86 Clear(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 102 } | 103 } |
| 103 thread_local_.memory_ = new_memory; | 104 thread_local_.memory_ = new_memory; |
| 104 thread_local_.memory_size_ = size; | 105 thread_local_.memory_size_ = size; |
| 105 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize; | 106 thread_local_.limit_ = new_memory + kStackLimitSlack * kPointerSize; |
| 106 } | 107 } |
| 107 return thread_local_.memory_ + thread_local_.memory_size_; | 108 return thread_local_.memory_ + thread_local_.memory_size_; |
| 108 } | 109 } |
| 109 | 110 |
| 110 | 111 |
| 111 }} // namespace v8::internal | 112 }} // namespace v8::internal |
| OLD | NEW |