Fixed issue where regexps were parsed without having set up a zone

scope, leading to zone exhaustion.  Added assertion that a zone scope
exists on zone allocation.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@898 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 739cf680
......@@ -207,12 +207,15 @@ Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags);
bool in_cache = !cached.is_null();
LOG(RegExpCompileEvent(re, in_cache));
Handle<Object> result;
if (in_cache) {
re->set_data(*cached);
result = re;
} else {
FlattenString(pattern);
ZoneScope zone_scope(DELETE_ON_EXIT);
RegExpParseResult parse_result;
FlatStringReader reader(pattern);
if (!ParseRegExp(&reader, flags.is_multiline(), &parse_result)) {
......@@ -258,7 +261,6 @@ Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
}
}
LOG(RegExpCompileEvent(re, in_cache));
return result;
}
......
......@@ -118,7 +118,8 @@ namespace v8 { namespace internal {
SC(enum_cache_hits, V8.EnumCacheHits) \
SC(enum_cache_misses, V8.EnumCacheMisses) \
SC(reloc_info_count, V8.RelocInfoCount) \
SC(reloc_info_size, V8.RelocInfoSize)
SC(reloc_info_size, V8.RelocInfoSize) \
SC(zone_segment_bytes, V8.ZoneSegmentBytes)
// This file contains all the v8 counters that are in use.
......
......@@ -29,12 +29,14 @@
#define V8_ZONE_INL_H_
#include "zone.h"
#include "v8-counters.h"
namespace v8 { namespace internal {
inline void* Zone::New(int size) {
ASSERT(AssertNoZoneAllocation::allow_allocation());
ASSERT(ZoneScope::nesting() > 0);
// Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignment);
......@@ -53,6 +55,12 @@ bool Zone::excess_allocation() {
}
void Zone::adjust_segment_bytes_allocated(int delta) {
segment_bytes_allocated_ += delta;
Counters::zone_segment_bytes.Set(segment_bytes_allocated_);
}
} } // namespace v8::internal
#endif // V8_ZONE_INL_H_
......@@ -65,7 +65,7 @@ class Segment {
// of the segment chain. Returns the new segment.
static Segment* New(int size) {
Segment* result = reinterpret_cast<Segment*>(Malloced::New(size));
Zone::segment_bytes_allocated_ += size;
Zone::adjust_segment_bytes_allocated(size);
if (result != NULL) {
result->next_ = head_;
result->size_ = size;
......@@ -76,7 +76,7 @@ class Segment {
// Deletes the given segment. Does not touch the segment chain.
static void Delete(Segment* segment, int size) {
Zone::segment_bytes_allocated_ -= size;
Zone::adjust_segment_bytes_allocated(-size);
Malloced::Delete(segment);
}
......
......@@ -65,8 +65,9 @@ class Zone {
// the limit allows.
static inline bool excess_allocation();
static inline void adjust_segment_bytes_allocated(int delta);
private:
friend class Segment;
// All pointers returned from New() have this alignment.
static const int kAlignment = kPointerSize;
......@@ -183,6 +184,8 @@ class ZoneScope BASE_EMBEDDED {
mode_ = DELETE_ON_EXIT;
}
static int nesting() { return nesting_; }
private:
ZoneScopeMode mode_;
static int nesting_;
......
......@@ -38,6 +38,7 @@ TEST(List) {
List<Node*>* list = new List<Node*>(0);
CHECK_EQ(0, list->length());
ZoneScope zone_scope(DELETE_ON_EXIT);
Node* node = new EmptyStatement();
list->Add(node);
CHECK_EQ(1, list->length());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment