Author: [EMAIL PROTECTED]
Date: Tue Dec  2 06:00:24 2008
New Revision: 898

Modified:
    branches/bleeding_edge/src/jsregexp.cc
    branches/bleeding_edge/src/v8-counters.h
    branches/bleeding_edge/src/zone-inl.h
    branches/bleeding_edge/src/zone.cc
    branches/bleeding_edge/src/zone.h
    branches/bleeding_edge/test/cctest/test-ast.cc

Log:
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.


Modified: branches/bleeding_edge/src/jsregexp.cc
==============================================================================
--- branches/bleeding_edge/src/jsregexp.cc      (original)
+++ branches/bleeding_edge/src/jsregexp.cc      Tue Dec  2 06:00:24 2008
@@ -207,12 +207,15 @@
    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 @@
      }
    }

-  LOG(RegExpCompileEvent(re, in_cache));
    return result;
  }


Modified: branches/bleeding_edge/src/v8-counters.h
==============================================================================
--- branches/bleeding_edge/src/v8-counters.h    (original)
+++ branches/bleeding_edge/src/v8-counters.h    Tue Dec  2 06:00:24 2008
@@ -118,7 +118,8 @@
    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.

Modified: branches/bleeding_edge/src/zone-inl.h
==============================================================================
--- branches/bleeding_edge/src/zone-inl.h       (original)
+++ branches/bleeding_edge/src/zone-inl.h       Tue Dec  2 06:00:24 2008
@@ -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);

@@ -50,6 +52,12 @@

  bool Zone::excess_allocation() {
    return segment_bytes_allocated_ > zone_excess_limit_;
+}
+
+
+void Zone::adjust_segment_bytes_allocated(int delta) {
+  segment_bytes_allocated_ += delta;
+  Counters::zone_segment_bytes.Set(segment_bytes_allocated_);
  }



Modified: branches/bleeding_edge/src/zone.cc
==============================================================================
--- branches/bleeding_edge/src/zone.cc  (original)
+++ branches/bleeding_edge/src/zone.cc  Tue Dec  2 06:00:24 2008
@@ -65,7 +65,7 @@
    // 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 @@

    // 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);
    }


Modified: branches/bleeding_edge/src/zone.h
==============================================================================
--- branches/bleeding_edge/src/zone.h   (original)
+++ branches/bleeding_edge/src/zone.h   Tue Dec  2 06:00:24 2008
@@ -65,8 +65,9 @@
    // 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;
@@ -182,6 +183,8 @@
    void DeleteOnExit() {
      mode_ = DELETE_ON_EXIT;
    }
+
+  static int nesting() { return nesting_; }

   private:
    ZoneScopeMode mode_;

Modified: branches/bleeding_edge/test/cctest/test-ast.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-ast.cc      (original)
+++ branches/bleeding_edge/test/cctest/test-ast.cc      Tue Dec  2 06:00:24 2008
@@ -38,6 +38,7 @@
    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());

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to