Don't use alloca.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 19 Jul 2012 07:32:58 +0000 (07:32 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 19 Jul 2012 07:32:58 +0000 (07:32 +0000)
It leads to compability hell, and the amount of memory we need is bounded,
anyway. Added a few more assertions on the way.

Review URL: https://chromiumcodereview.appspot.com/10808029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12137 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/objects-inl.h

index 9e866e3..e48787b 100644 (file)
@@ -3503,11 +3503,11 @@ void Map::set_instance_descriptors(DescriptorArray* value,
 
 void Map::InitializeDescriptors(DescriptorArray* descriptors) {
   int len = descriptors->number_of_descriptors();
+  ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors);
   SLOW_ASSERT(descriptors->IsSortedNoDuplicates());
 
 #ifdef DEBUG
-  bool* used_indices =
-      reinterpret_cast<bool*>(alloca(sizeof(*used_indices) * len));
+  bool used_indices[DescriptorArray::kMaxNumberOfDescriptors];
   for (int i = 0; i < len; ++i) used_indices[i] = false;
 
   // Ensure that all enumeration indexes between 1 and length occur uniquely in
@@ -3515,6 +3515,7 @@ void Map::InitializeDescriptors(DescriptorArray* descriptors) {
   for (int i = 0; i < len; ++i) {
     int enum_index = descriptors->GetDetails(i).index() -
                      PropertyDetails::kInitialIndex;
+    ASSERT(0 <= enum_index && enum_index < len);
     ASSERT(!used_indices[enum_index]);
     used_indices[enum_index] = true;
   }