| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 static Address* limit_address() { return &(thread_local_.limit_); } | 64 static Address* limit_address() { return &(thread_local_.limit_); } |
| 65 | 65 |
| 66 // Ensures that there is a memory area with at least the specified size. | 66 // Ensures that there is a memory area with at least the specified size. |
| 67 // If passing zero, the default/minimum size buffer is allocated. | 67 // If passing zero, the default/minimum size buffer is allocated. |
| 68 static Address EnsureCapacity(size_t size); | 68 static Address EnsureCapacity(size_t size); |
| 69 | 69 |
| 70 // Thread local archiving. | 70 // Thread local archiving. |
| 71 static size_t ArchiveSpacePerThread() { return sizeof(thread_local_); } | 71 static size_t ArchiveSpacePerThread() { return sizeof(thread_local_); } |
| 72 static char* ArchiveStack(char* to); | 72 static char* ArchiveStack(char* to); |
| 73 static char* RestoreStack(char* from); | 73 static char* RestoreStack(char* from); |
| 74 static void FreeThreadResources() { thread_local_.Free(); } |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 // Artificial limit used when no memory has been allocated. | 77 // Artificial limit used when no memory has been allocated. |
| 77 static const uintptr_t kMemoryTop = static_cast<uintptr_t>(-1); | 78 static const uintptr_t kMemoryTop = static_cast<uintptr_t>(-1); |
| 78 | 79 |
| 79 // Minimal size of allocated stack area. | 80 // Minimal size of allocated stack area. |
| 80 static const size_t kMinimumStackSize = 1 * KB; | 81 static const size_t kMinimumStackSize = 1 * KB; |
| 81 | 82 |
| 82 // Maximal size of allocated stack area. | 83 // Maximal size of allocated stack area. |
| 83 static const size_t kMaximumStackSize = 64 * MB; | 84 static const size_t kMaximumStackSize = 64 * MB; |
| 84 | 85 |
| 85 // Structure holding the allocated memory, size and limit. | 86 // Structure holding the allocated memory, size and limit. |
| 86 struct ThreadLocal { | 87 struct ThreadLocal { |
| 87 ThreadLocal() | 88 ThreadLocal() |
| 88 : memory_(NULL), | 89 : memory_(NULL), |
| 89 memory_size_(0), | 90 memory_size_(0), |
| 90 limit_(reinterpret_cast<Address>(kMemoryTop)) {} | 91 limit_(reinterpret_cast<Address>(kMemoryTop)) {} |
| 91 // If memory_size_ > 0 then memory_ must be non-NULL. | 92 // If memory_size_ > 0 then memory_ must be non-NULL. |
| 92 Address memory_; | 93 Address memory_; |
| 93 size_t memory_size_; | 94 size_t memory_size_; |
| 94 Address limit_; | 95 Address limit_; |
| 96 void Free(); |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 // Resets the buffer if it has grown beyond the default/minimum size. | 99 // Resets the buffer if it has grown beyond the default/minimum size. |
| 98 // After this, the buffer is either the default size, or it is empty, so | 100 // After this, the buffer is either the default size, or it is empty, so |
| 99 // you have to call EnsureCapacity before using it again. | 101 // you have to call EnsureCapacity before using it again. |
| 100 static void Reset(); | 102 static void Reset(); |
| 101 | 103 |
| 102 static ThreadLocal thread_local_; | 104 static ThreadLocal thread_local_; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 }} // namespace v8::internal | 107 }} // namespace v8::internal |
| 106 | 108 |
| 107 #endif // V8_REGEXP_STACK_H_ | 109 #endif // V8_REGEXP_STACK_H_ |
| OLD | NEW |