Fixed exception reporting bug where certain exceptions were incorrectly reported as uncaught.

Improved the memory allocation strategy used during compilation to make running out of memory when compiling huge scripts less likely.

Optimized String.replace by avoiding the construction of certain sub strings.

Fixed bug in code generation for large switch statements on ARM.

Fixed bug that caused V8 to change the global object template passed in by the user.

Changed the API for creating object groups used during garbage collection.  Entire object groups are now passed to V8 instead of individual members of the groups.


git-svn-id: http://v8.googlecode.com/svn/trunk@968 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/global-handles.cc b/src/global-handles.cc
index 29ad86e..a92f0df 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -352,29 +352,26 @@
 
 #endif
 
-List<ObjectGroup*> GlobalHandles::object_groups_(4);
+List<ObjectGroup*>* GlobalHandles::ObjectGroups() {
+  // Lazily initialize the list to avoid startup time static constructors.
+  static List<ObjectGroup*> groups(4);
+  return &groups;
+}
 
-void GlobalHandles::AddToGroup(void* id, Object** handle) {
-  for (int i = 0; i < object_groups_.length(); i++) {
-    ObjectGroup* entry = object_groups_[i];
-    if (entry->id_ == id) {
-      entry->objects_.Add(handle);
-      return;
-    }
-  }
-
-  // not found
-  ObjectGroup* new_entry = new ObjectGroup(id);
-  new_entry->objects_.Add(handle);
-  object_groups_.Add(new_entry);
+void GlobalHandles::AddGroup(Object*** handles, size_t length) {
+  ObjectGroup* new_entry = new ObjectGroup(length);
+  for (size_t i = 0; i < length; ++i)
+    new_entry->objects_.Add(handles[i]);
+  ObjectGroups()->Add(new_entry);
 }
 
 
 void GlobalHandles::RemoveObjectGroups() {
-  for (int i = 0; i< object_groups_.length(); i++) {
-    delete object_groups_[i];
+  List<ObjectGroup*>* object_groups = ObjectGroups();
+  for (int i = 0; i< object_groups->length(); i++) {
+    delete object_groups->at(i);
   }
-  object_groups_.Clear();
+  object_groups->Clear();
 }