summaryrefslogtreecommitdiff
path: root/deps/v8/src/regexp-stack.h
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-06-29 17:26:51 +0200
committerRyan Dahl <ry@tinyclouds.org>2011-06-29 17:26:51 +0200
commit33af2720f26c2b25bc7f75ce7eb454ff99db6d35 (patch)
tree9a38f0c96420edf503eebd6325dd8d2d8249f653 /deps/v8/src/regexp-stack.h
parent6afdca885adeeeed9eef8cbb01c3d97af0bc084d (diff)
downloadnode-new-33af2720f26c2b25bc7f75ce7eb454ff99db6d35.tar.gz
Upgrade V8 to 3.4.8
Diffstat (limited to 'deps/v8/src/regexp-stack.h')
-rw-r--r--deps/v8/src/regexp-stack.h66
1 files changed, 45 insertions, 21 deletions
diff --git a/deps/v8/src/regexp-stack.h b/deps/v8/src/regexp-stack.h
index b4fa2e9204..59432067e4 100644
--- a/deps/v8/src/regexp-stack.h
+++ b/deps/v8/src/regexp-stack.h
@@ -31,11 +31,30 @@
namespace v8 {
namespace internal {
+class RegExpStack;
+
// Maintains a per-v8thread stack area that can be used by irregexp
// implementation for its backtracking stack.
// Since there is only one stack area, the Irregexp implementation is not
// re-entrant. I.e., no regular expressions may be executed in the same thread
// during a preempted Irregexp execution.
+class RegExpStackScope {
+ public:
+ // Create and delete an instance to control the life-time of a growing stack.
+
+ // Initializes the stack memory area if necessary.
+ explicit RegExpStackScope(Isolate* isolate);
+ ~RegExpStackScope(); // Releases the stack if it has grown.
+
+ RegExpStack* stack() const { return regexp_stack_; }
+
+ private:
+ RegExpStack* regexp_stack_;
+
+ DISALLOW_COPY_AND_ASSIGN(RegExpStackScope);
+};
+
+
class RegExpStack {
public:
// Number of allocated locations on the stack below the limit.
@@ -43,39 +62,37 @@ class RegExpStack {
// check.
static const int kStackLimitSlack = 32;
- // Create and delete an instance to control the life-time of a growing stack.
- RegExpStack(); // Initializes the stack memory area if necessary.
- ~RegExpStack(); // Releases the stack if it has grown.
-
// Gives the top of the memory used as stack.
- static Address stack_base() {
+ Address stack_base() {
ASSERT(thread_local_.memory_size_ != 0);
return thread_local_.memory_ + thread_local_.memory_size_;
}
// The total size of the memory allocated for the stack.
- static size_t stack_capacity() { return thread_local_.memory_size_; }
+ size_t stack_capacity() { return thread_local_.memory_size_; }
// If the stack pointer gets below the limit, we should react and
// either grow the stack or report an out-of-stack exception.
// There is only a limited number of locations below the stack limit,
// so users of the stack should check the stack limit during any
// sequence of pushes longer that this.
- static Address* limit_address() { return &(thread_local_.limit_); }
+ Address* limit_address() { return &(thread_local_.limit_); }
// Ensures that there is a memory area with at least the specified size.
// If passing zero, the default/minimum size buffer is allocated.
- static Address EnsureCapacity(size_t size);
+ Address EnsureCapacity(size_t size);
// Thread local archiving.
static int ArchiveSpacePerThread() {
- return static_cast<int>(sizeof(thread_local_));
+ return static_cast<int>(sizeof(ThreadLocal));
}
- static char* ArchiveStack(char* to);
- static char* RestoreStack(char* from);
- static void FreeThreadResources() { thread_local_.Free(); }
-
+ char* ArchiveStack(char* to);
+ char* RestoreStack(char* from);
+ void FreeThreadResources() { thread_local_.Free(); }
private:
+ RegExpStack();
+ ~RegExpStack();
+
// Artificial limit used when no memory has been allocated.
static const uintptr_t kMemoryTop = static_cast<uintptr_t>(-1);
@@ -87,35 +104,42 @@ class RegExpStack {
// Structure holding the allocated memory, size and limit.
struct ThreadLocal {
- ThreadLocal()
- : memory_(NULL),
- memory_size_(0),
- limit_(reinterpret_cast<Address>(kMemoryTop)) {}
+ ThreadLocal() { Clear(); }
// If memory_size_ > 0 then memory_ must be non-NULL.
Address memory_;
size_t memory_size_;
Address limit_;
+ void Clear() {
+ memory_ = NULL;
+ memory_size_ = 0;
+ limit_ = reinterpret_cast<Address>(kMemoryTop);
+ }
void Free();
};
// Address of allocated memory.
- static Address memory_address() {
+ Address memory_address() {
return reinterpret_cast<Address>(&thread_local_.memory_);
}
// Address of size of allocated memory.
- static Address memory_size_address() {
+ Address memory_size_address() {
return reinterpret_cast<Address>(&thread_local_.memory_size_);
}
// Resets the buffer if it has grown beyond the default/minimum size.
// After this, the buffer is either the default size, or it is empty, so
// you have to call EnsureCapacity before using it again.
- static void Reset();
+ void Reset();
- static ThreadLocal thread_local_;
+ ThreadLocal thread_local_;
+ Isolate* isolate_;
friend class ExternalReference;
+ friend class Isolate;
+ friend class RegExpStackScope;
+
+ DISALLOW_COPY_AND_ASSIGN(RegExpStack);
};
}} // namespace v8::internal