Version 1.8.5

svn merge -c 42797 https://dart.googlecode.com/svn/branches/bleeding_edge 1.8
svn merge -c 42824 https://dart.googlecode.com/svn/branches/bleeding_edge 1.8

R=iposva@google.com

Review URL: https://codereview.chromium.org//849893002

git-svn-id: http://dart.googlecode.com/svn/branches/1.8@42828 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h
index ab854bf..e7daafb 100644
--- a/runtime/vm/code_descriptors.h
+++ b/runtime/vm/code_descriptors.h
@@ -135,7 +135,7 @@
     list_[try_index].pc_offset = pc_offset;
     ASSERT(handler_types.IsZoneHandle());
     list_[try_index].handler_types = &handler_types;
-    list_[try_index].needs_stacktrace = needs_stacktrace;
+    list_[try_index].needs_stacktrace |= needs_stacktrace;
   }
 
 
@@ -145,7 +145,10 @@
     if (try_index == CatchClauseNode::kInvalidTryIndex) {
       return;
     }
-    ASSERT((0 <= try_index) && (try_index < Length()));
+    ASSERT(try_index >= 0);
+    while (Length() <= try_index) {
+      AddPlaceHolder();
+    }
     list_[try_index].needs_stacktrace = true;
   }
 
diff --git a/runtime/vm/globals.h b/runtime/vm/globals.h
index 267b4a3..597756d 100644
--- a/runtime/vm/globals.h
+++ b/runtime/vm/globals.h
@@ -72,10 +72,12 @@
 
 
 // When using GCC we can use GCC attributes to ensure that certain
-// contants are 16 byte aligned.
+// contants are 8 or 16 byte aligned.
 #if defined(TARGET_OS_WINDOWS)
+#define ALIGN8 __declspec(align(8))
 #define ALIGN16 __declspec(align(16))
 #else
+#define ALIGN8 __attribute__((aligned(8)))
 #define ALIGN16 __attribute__((aligned(16)))
 #endif
 
diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc
index dc8dcf2..b16c030 100644
--- a/runtime/vm/zone.cc
+++ b/runtime/vm/zone.cc
@@ -63,6 +63,7 @@
 Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) {
   ASSERT(size >= 0);
   Segment* result = reinterpret_cast<Segment*>(new uint8_t[size]);
+  ASSERT(Utils::IsAligned(result->start(), Zone::kAlignment));
   if (result != NULL) {
 #ifdef DEBUG
     // Zap the entire allocated segment (including the header).
diff --git a/runtime/vm/zone.h b/runtime/vm/zone.h
index fea44c9..ce2810b 100644
--- a/runtime/vm/zone.h
+++ b/runtime/vm/zone.h
@@ -67,6 +67,7 @@
       large_segments_(NULL),
       handles_(),
       previous_(NULL) {
+    ASSERT(Utils::IsAligned(position_, kAlignment));
 #ifdef DEBUG
     // Zap the entire initial buffer.
     memset(initial_buffer_.pointer(), kZapUninitializedByte,
@@ -84,7 +85,7 @@
   }
 
   // All pointers returned from AllocateUnsafe() and New() have this alignment.
-  static const intptr_t kAlignment = kWordSize;
+  static const intptr_t kAlignment = kDoubleSize;
 
   // Default initial chunk size.
   static const intptr_t kInitialChunkSize = 1 * KB;
@@ -121,7 +122,8 @@
   // This would act as the initial stack allocated chunk so that we don't
   // end up calling malloc/free on zone scopes that allocate less than
   // kChunkSize
-  uint8_t buffer_[kInitialChunkSize];
+  COMPILE_ASSERT(kAlignment <= 8);
+  ALIGN8 uint8_t buffer_[kInitialChunkSize];
   MemoryRegion initial_buffer_;
 
   // The free region in the current (head) segment or the initial buffer is
diff --git a/tests/language/regress_21795_test.dart b/tests/language/regress_21795_test.dart
new file mode 100644
index 0000000..91506c7
--- /dev/null
+++ b/tests/language/regress_21795_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for issue 21795.
+
+foo(t) {
+  try {
+    if (t == 123) throw 42;
+  } finally { }
+}
+
+bar() {
+  try {
+    return 42;
+  } finally { }
+}
+
+
+class A {
+  test(t) {
+    try {
+      foo(t);
+    } finally {
+      if (t == 0) {
+        try {
+        } catch (err, st) {
+        }
+      }
+    }
+  }
+}
+
+
+main() {
+  var a = new A();
+  for (var i=0; i<10000; ++i) a.test(0);
+  try {
+    a.test(123);
+  } catch (e, s) {
+    if (s.toString().indexOf("foo") == -1) {
+      print(s);
+      throw "Expected foo in stacktrace!";
+    }
+  }
+}
diff --git a/tools/VERSION b/tools/VERSION
index b02fbca..ad37b7d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
 CHANNEL stable
 MAJOR 1
 MINOR 8
-PATCH 4
+PATCH 5
 PRERELEASE 0
 PRERELEASE_PATCH 0