Version 0.5.11.1

svn merge -r 23195:23196  https://dart.googlecode.com/svn/branches/bleeding_edge trunk

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

git-svn-id: http://dart.googlecode.com/svn/trunk@23200 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/compiler/implementation/lib/web.dart b/lib/compiler/implementation/lib/web.dart
new file mode 100644
index 0000000..a75db7b
--- /dev/null
+++ b/lib/compiler/implementation/lib/web.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2012, 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.
+
+#library("web");
+
+String htmlEscape(String text) {
+  throw "Unimplemented: web::htmlEscape(String).";
+}
diff --git a/lib/compiler/implementation/lib/web.dartp b/lib/compiler/implementation/lib/web.dartp
new file mode 100644
index 0000000..c3ba2ad
--- /dev/null
+++ b/lib/compiler/implementation/lib/web.dartp
@@ -0,0 +1,13 @@
+// Copyright (c) 2012, 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.
+
+// Patch file for dart:web
+
+/*patch*/ String htmlEscape(String text) {
+  return text.replaceAll("&", "&")
+             .replaceAll("<", "&lt;")
+             .replaceAll(">", "&gt;")
+             .replaceAll('"', "&quot;")
+             .replaceAll("'", "&apos;");  // Different from original.
+}
diff --git a/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate b/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate
new file mode 100644
index 0000000..8fe27e5
--- /dev/null
+++ b/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate
@@ -0,0 +1,7 @@
+// Copyright (c) 2012, 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.
+
+class _Elements {
+
+$!FACTORY_METHODS}
diff --git a/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate b/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate
new file mode 100644
index 0000000..1b4a00d
--- /dev/null
+++ b/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate
@@ -0,0 +1,106 @@
+// Copyright (c) 2012, 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.
+
+class _EventsImpl implements Events {
+  // TODO(podivilov): add type.
+  final _ptr;
+
+  final Map<String, EventListenerList> _listenerMap;
+
+  _EventsImpl(this._ptr) : _listenerMap = <EventListenerList>{};
+
+  EventListenerList operator [](String type) {
+    return _listenerMap.putIfAbsent(type,
+      () => new _EventListenerListImpl(_ptr, type));
+  }
+}
+
+class _EventListenerWrapper {
+  final EventListener raw;
+  final Function wrapped;
+  final bool useCapture;
+  _EventListenerWrapper(this.raw, this.wrapped, this.useCapture);
+}
+
+class _EventListenerListImpl implements EventListenerList {
+  // TODO(podivilov): add type.
+  final _ptr;
+  final String _type;
+  List<_EventListenerWrapper> _wrappers;
+
+  _EventListenerListImpl(this._ptr, this._type) :
+    // TODO(jacobr): switch to <_EventListenerWrapper>[] when the VM allow it.
+    _wrappers = new List<_EventListenerWrapper>();
+
+  EventListenerList add(EventListener listener, [bool useCapture = false]) {
+    _add(listener, useCapture);
+    return this;
+  }
+
+  EventListenerList remove(EventListener listener, [bool useCapture = false]) {
+    _remove(listener, useCapture);
+    return this;
+  }
+
+  bool dispatch(Event evt) {
+    // TODO(jacobr): what is the correct behavior here. We could alternately
+    // force the event to have the expected type.
+    assert(evt.type == _type);
+    return _ptr.$dom_dispatchEvent(evt);
+  }
+
+  void _add(EventListener listener, bool useCapture) {
+    _ptr.$dom_addEventListener(_type,
+                          _findOrAddWrapper(listener, useCapture),
+                          useCapture);
+  }
+
+  void _remove(EventListener listener, bool useCapture) {
+    Function wrapper = _removeWrapper(listener, useCapture);
+    if (wrapper !== null) {
+      _ptr.$dom_removeEventListener(_type, wrapper, useCapture);
+    }
+  }
+
+  Function _removeWrapper(EventListener listener, bool useCapture) {
+    if (_wrappers === null) {
+      return null;
+    }
+    for (int i = 0; i < _wrappers.length; i++) {
+      _EventListenerWrapper wrapper = _wrappers[i];
+      if (wrapper.raw === listener && wrapper.useCapture == useCapture) {
+        // Order doesn't matter so we swap with the last element instead of
+        // performing a more expensive remove from the middle of the list.
+        if (i + 1 != _wrappers.length) {
+          _wrappers[i] = _wrappers.removeLast();
+        } else {
+          _wrappers.removeLast();
+        }
+        return wrapper.wrapped;
+      }
+    }
+    return null;
+  }
+
+  Function _findOrAddWrapper(EventListener listener, bool useCapture) {
+    if (_wrappers === null) {
+      _wrappers = <_EventListenerWrapper>[];
+    } else {
+      for (_EventListenerWrapper wrapper in _wrappers) {
+        if (wrapper.raw === listener && wrapper.useCapture == useCapture) {
+          return wrapper.wrapped;
+        }
+      }
+    }
+    final wrapped = (e) { listener(e); };
+    _wrappers.add(new _EventListenerWrapper(listener, wrapped, useCapture));
+    return wrapped;
+  }
+}
+
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+/*
+$!MEMBERS
+*/
+}
diff --git a/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate b/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate
new file mode 100644
index 0000000..8fe27e5
--- /dev/null
+++ b/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate
@@ -0,0 +1,7 @@
+// Copyright (c) 2012, 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.
+
+class _Elements {
+
+$!FACTORY_METHODS}
diff --git a/lib/dom/templates/html/frog/impl_EventTarget.darttemplate b/lib/dom/templates/html/frog/impl_EventTarget.darttemplate
new file mode 100644
index 0000000..893f3d2
--- /dev/null
+++ b/lib/dom/templates/html/frog/impl_EventTarget.darttemplate
@@ -0,0 +1,61 @@
+// Copyright (c) 2012, 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.
+
+class _EventsImpl implements Events {
+  /* Raw event target. */
+  // TODO(jacobr): it would be nice if we could specify this as
+  // _EventTargetImpl or EventTarget
+  final Dynamic _ptr;
+
+  _EventsImpl(this._ptr);
+
+  _EventListenerListImpl operator [](String type) {
+    return new _EventListenerListImpl(_ptr, type);
+  }
+}
+
+class _EventListenerListImpl implements EventListenerList {
+  
+  // TODO(jacobr): make this _EventTargetImpl
+  final Dynamic _ptr;
+  final String _type;
+
+  _EventListenerListImpl(this._ptr, this._type);
+
+  // TODO(jacobr): implement equals.
+
+  _EventListenerListImpl add(EventListener listener,
+      [bool useCapture = false]) {
+    _add(listener, useCapture);
+    return this;
+  }
+
+  _EventListenerListImpl remove(EventListener listener,
+      [bool useCapture = false]) {
+    _remove(listener, useCapture);
+    return this;
+  }
+
+  bool dispatch(Event evt) {
+    // TODO(jacobr): what is the correct behavior here. We could alternately
+    // force the event to have the expected type.
+    assert(evt.type == _type);
+    return _ptr.$dom_dispatchEvent(evt);
+  }
+
+  void _add(EventListener listener, bool useCapture) {
+    _ptr.$dom_addEventListener(_type, listener, useCapture);
+  }
+
+  void _remove(EventListener listener, bool useCapture) {
+    _ptr.$dom_removeEventListener(_type, listener, useCapture);
+  }
+}
+
+
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+
+  Events get on() => new _EventsImpl(this);
+$!MEMBERS
+}
diff --git a/pkg/analyzer_experimental/example/resolver_driver.dart b/pkg/analyzer_experimental/example/resolver_driver.dart
index 883816e..c3a9ef7 100644
--- a/pkg/analyzer_experimental/example/resolver_driver.dart
+++ b/pkg/analyzer_experimental/example/resolver_driver.dart
@@ -28,7 +28,7 @@
 
   AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
   context.sourceFactory = new SourceFactory.con2([new DartUriResolver(sdk), new FileUriResolver()]);
-  Source source = new FileBasedSource.con1(context.sourceFactory.contentCache, new JavaFile(args[1]));
+  Source source = new FileBasedSource.con1(context.sourceFactory, new JavaFile(args[1]));
   //
   ChangeSet changeSet = new ChangeSet();
   changeSet.added(source);
diff --git a/pkg/analyzer_experimental/lib/src/error.dart b/pkg/analyzer_experimental/lib/src/error.dart
index d3df0e1..5485a0f 100644
--- a/pkg/analyzer_experimental/lib/src/error.dart
+++ b/pkg/analyzer_experimental/lib/src/error.dart
@@ -98,8 +98,8 @@
 
   String get result => _buffer.toString();
 
-  void accept(CharBuffer contents, _) =>
-    _buffer.write(contents.subSequence(0, contents.length()));
+  void accept1(CharBuffer contents, _) =>
+    _buffer.write(contents.subSequence(0, contents.length));
 
   void accept2(String contents, _) => _buffer.write(contents);
 }
diff --git a/pkg/analyzer_experimental/lib/src/generated/error.dart b/pkg/analyzer_experimental/lib/src/generated/error.dart
index 152ea76..1f684c9 100644
--- a/pkg/analyzer_experimental/lib/src/generated/error.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/error.dart
@@ -1395,7 +1395,7 @@
   /**
    * An error listener that ignores errors that are reported to it.
    */
-  static AnalysisErrorListener _NULL_LISTENER = new AnalysisErrorListener_4();
+  AnalysisErrorListener _NULL_LISTENER = new AnalysisErrorListener_4();
   /**
    * This method is invoked when an error has been found by the analysis engine.
    * @param error the error that was just found (not {@code null})
diff --git a/pkg/analyzer_experimental/lib/src/generated/java_core.dart b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
index d415448..3bf99ccc 100644
--- a/pkg/analyzer_experimental/lib/src/generated/java_core.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
@@ -319,7 +319,7 @@
   }
 
   void setAll(int index, Iterable<E> iterable) {
-    elements.setAll(index, iterable);
+    elements.setAll(iterable);
   }
 
   void sort([int compare(E a, E b)]) {
@@ -462,13 +462,11 @@
 class JavaStringBuilder {
   StringBuffer sb = new StringBuffer();
   String toString() => sb.toString();
-  JavaStringBuilder append(x) {
+  void append(x) {
     sb.write(x);
-    return this;
   }
-  JavaStringBuilder appendChar(int c) {
+  void appendChar(int c) {
     sb.writeCharCode(c);
-    return this;
   }
   int get length => sb.length;
   void set length(int newLength) {
diff --git a/pkg/analyzer_experimental/lib/src/generated/resolver.dart b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
index 714a079..fc7b84d 100644
--- a/pkg/analyzer_experimental/lib/src/generated/resolver.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
@@ -1994,7 +1994,7 @@
         } else if (identifier.inGetterContext()) {
           _resolver.reportError(StaticWarningCode.UNDEFINED_GETTER, identifier, [identifier.name, targetType.name]);
         } else {
-          print("two ${identifier.name}");
+          System.out.println("two ${identifier.name}");
           _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, identifier, [identifier.name]);
         }
       }
diff --git a/pkg/analyzer_experimental/lib/src/generated/source_io.dart b/pkg/analyzer_experimental/lib/src/generated/source_io.dart
index 912469a..f016564 100644
--- a/pkg/analyzer_experimental/lib/src/generated/source_io.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/source_io.dart
@@ -195,7 +195,7 @@
     } on IOException catch (e) {
       AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
     }
-    return new JavaFile.relative(pkgDir, relPath.replaceAll('/', JavaFile.separatorChar));
+    return new JavaFile.relative(pkgDir, relPath.replaceAll(0x2F, JavaFile.separatorChar));
   }
 }
 /**
diff --git a/pkg/analyzer_experimental/test/generated/test_support.dart b/pkg/analyzer_experimental/test/generated/test_support.dart
index 06881f9..c666db1 100644
--- a/pkg/analyzer_experimental/test/generated/test_support.dart
+++ b/pkg/analyzer_experimental/test/generated/test_support.dart
@@ -669,9 +669,6 @@
   Source resolveRelative(Uri uri) {
     throw new UnsupportedOperationException();
   }
-  UriKind get uriKind {
-    throw new UnsupportedOperationException();
-  }
 }
 
 /**
diff --git a/pkg/scheduled_test/lib/scheduled_process.dart b/pkg/scheduled_test/lib/scheduled_process.dart
index 4508f54..75891a9 100644
--- a/pkg/scheduled_test/lib/scheduled_process.dart
+++ b/pkg/scheduled_test/lib/scheduled_process.dart
@@ -151,7 +151,8 @@
                              arguments,
                              workingDirectory: workingDirectory,
                              environment: environment).then((process) {
-          process.stdin.encoding = Encoding.UTF_8;
+          // TODO(nweiz): enable this when issue 9020 is fixed.
+          // process.stdin.encoding = Encoding.UTF_8;
           return process;
         });
       });
diff --git a/runtime/bin/dbg_message.cc b/runtime/bin/dbg_message.cc
index caec295..5713657 100644
--- a/runtime/bin/dbg_message.cc
+++ b/runtime/bin/dbg_message.cc
@@ -1053,7 +1053,7 @@
 
 
 DbgMsgQueue* DbgMsgQueueList::list_ = NULL;
-dart::Mutex* DbgMsgQueueList::msg_queue_list_lock_ = new dart::Mutex();
+dart::Mutex DbgMsgQueueList::msg_queue_list_lock_;
 
 
 void DbgMsgQueueList::Initialize() {
@@ -1085,7 +1085,7 @@
                                         const char* start,
                                         const char* end,
                                         int debug_fd) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
   DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
   if (queue != NULL) {
     queue->AddMessage(cmd_idx, start, end, debug_fd);
@@ -1096,7 +1096,7 @@
 
 
 bool DbgMsgQueueList::InterruptIsolate(Dart_IsolateId isolate_id) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
   DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueueLocked(isolate_id);
   if (queue != NULL) {
     queue->InterruptIsolate();
@@ -1107,7 +1107,7 @@
 
 
 DbgMsgQueue* DbgMsgQueueList::AddIsolateMsgQueue(Dart_IsolateId isolate_id) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
 
   DbgMsgQueue* queue = new DbgMsgQueue(isolate_id, list_);
   ASSERT(queue != NULL);
@@ -1117,7 +1117,7 @@
 
 
 DbgMsgQueue* DbgMsgQueueList::GetIsolateMsgQueue(Dart_IsolateId isolate_id) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
   ASSERT(Dart_GetIsolate(isolate_id) == Dart_CurrentIsolate());
   return GetIsolateMsgQueueLocked(isolate_id);
 }
@@ -1138,7 +1138,7 @@
 
 
 void DbgMsgQueueList::RemoveIsolateMsgQueue(Dart_IsolateId isolate_id) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
   if (list_ == NULL) {
     return;  // No items in the list.
   }
@@ -1165,7 +1165,7 @@
 
 
 void DbgMsgQueueList::ListIsolateIds(dart::TextBuffer* msg) {
-  MutexLocker ml(msg_queue_list_lock_);
+  MutexLocker ml(&msg_queue_list_lock_);
   if (list_ == NULL) {
     return;  // No items in the list.
   }
diff --git a/runtime/bin/dbg_message.h b/runtime/bin/dbg_message.h
index ca05255..85be1a5 100644
--- a/runtime/bin/dbg_message.h
+++ b/runtime/bin/dbg_message.h
@@ -255,7 +255,7 @@
   static DbgMsgQueue* GetIsolateMsgQueueLocked(Dart_IsolateId isolate_id);
 
   static DbgMsgQueue* list_;
-  static dart::Mutex* msg_queue_list_lock_;
+  static dart::Mutex msg_queue_list_lock_;
 
   DISALLOW_ALLOCATION();
   DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMsgQueueList);
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index c852c42..63e214c 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -66,6 +66,8 @@
 dart/byte_array_optimized_test: Skip
 
 # Bug in optimized code generation.
+cc/ExternalStringDeoptimize: Skip
+dart/inline_stack_frame_test: Skip
 dart/isolate_mirror_local_test: Skip
 
 [ $arch == mips ]
@@ -80,11 +82,6 @@
 dart/byte_array_optimized_test: Skip
 dart/inline_stack_frame_test: Skip
 
-# Bug in optimized code generation.
-cc/ExternalStringDeoptimize: Skip
-dart/inline_stack_frame_test: Skip
-dart/isolate_mirror_local_test: Skip
-
 # TODO(ajohnsen): Fix this as part of library changes.
 [ $compiler == none ]
 cc/CustomIsolates: Skip # Bug 6890
diff --git a/runtime/vm/assembler_mips.cc b/runtime/vm/assembler_mips.cc
index 200e777..3f496db 100644
--- a/runtime/vm/assembler_mips.cc
+++ b/runtime/vm/assembler_mips.cc
@@ -204,14 +204,10 @@
 }
 
 
-void Assembler::CompareObject(Register rd1, Register rd2,
-                              Register rn, const Object& object) {
+void Assembler::CompareObject(Register rd, Register rn, const Object& object) {
   ASSERT(rn != TMP1);
-  ASSERT(rd1 != TMP1);
-  ASSERT(rd1 != rd2);
   LoadObject(TMP1, object);
-  slt(rd1, rn, TMP1);
-  slt(rd2, TMP1, rn);
+  subu(rd, rn, TMP1);
 }
 
 
diff --git a/runtime/vm/assembler_mips.h b/runtime/vm/assembler_mips.h
index c48f1bd..d496837 100644
--- a/runtime/vm/assembler_mips.h
+++ b/runtime/vm/assembler_mips.h
@@ -230,11 +230,10 @@
   }
 
   // CPU instructions in alphabetical order.
-  void addd(DRegister dd, DRegister ds, DRegister dt) {
-    // DRegisters start at the even FRegisters.
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void addd(FRegister fd, FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, fd, COP1_ADD);
   }
 
@@ -379,58 +378,58 @@
   }
 
   // FPU compare, always false.
-  void cfd(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void cfd(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_F);
   }
 
   // FPU compare, true if unordered, i.e. one is NaN.
-  void cund(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void cund(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_UN);
   }
 
   // FPU compare, true if equal.
-  void ceqd(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void ceqd(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_EQ);
   }
 
   // FPU compare, true if unordered or equal.
-  void cueqd(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void cueqd(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_UEQ);
   }
 
   // FPU compare, true if less than.
-  void coltd(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void coltd(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_OLT);
   }
 
   // FPU compare, true if unordered or less than.
-  void cultd(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void cultd(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_ULT);
   }
 
   // FPU compare, true if less or equal.
-  void coled(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void coled(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_OLE);
   }
 
   // FPU compare, true if unordered or less or equal.
-  void culed(DRegister ds, DRegister dt) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void culed(FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, F0, COP1_C_ULE);
   }
 
@@ -443,20 +442,21 @@
   }
 
   // Converts a 32-bit signed int in fs to a double in fd.
-  void cvtdw(DRegister dd, FRegister fs) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
+  void cvtdw(FRegister fd, FRegister fs) {
+    ASSERT(EvenFPURegister(fd));
     EmitFpuRType(COP1, FMT_W, F0, fs, fd, COP1_CVT_D);
   }
 
   // Converts a 64-bit signed int in fs to a double in fd.
-  void cvtdl(DRegister dd, DRegister ds) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister fd = static_cast<FRegister>(dd * 2);
+  void cvtdl(FRegister fd, FRegister fs) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(fd));
     EmitFpuRType(COP1, FMT_L, F0, fs, fd, COP1_CVT_D);
   }
 
-  void cvtwd(FRegister fd, DRegister ds) {
-    FRegister fs = static_cast<FRegister>(ds * 2);
+  void cvtwd(FRegister fd, FRegister fs) {
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(fd));
     EmitFpuRType(COP1, FMT_D, F0, fs, fd, COP1_CVT_W);
   }
 
@@ -464,10 +464,10 @@
     EmitRType(SPECIAL, rs, rt, R0, 0, DIV);
   }
 
-  void divd(DRegister dd, DRegister ds, DRegister dt) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void divd(FRegister fd, FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, fd, COP1_DIV);
   }
 
@@ -496,8 +496,8 @@
     EmitLoadStore(LBU, rt, addr);
   }
 
-  void ldc1(DRegister dt, const Address& addr) {
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void ldc1(FRegister ft, const Address& addr) {
+    ASSERT(EvenFPURegister(ft));
     EmitFpuLoadStore(LDC1, ft, addr);
   }
 
@@ -542,9 +542,9 @@
     or_(rd, rs, ZR);
   }
 
-  void movd(DRegister dd, DRegister ds) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
+  void movd(FRegister fd, FRegister fs) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
     EmitFpuRType(COP1, FMT_D, F0, fs, fd, COP1_MOV);
   }
 
@@ -567,10 +567,10 @@
          fs << kFsShift);
   }
 
-  void muld(DRegister dd, DRegister ds, DRegister dt) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void muld(FRegister fd, FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, fd, COP1_MUL);
   }
 
@@ -604,8 +604,8 @@
     EmitLoadStore(SB, rt, addr);
   }
 
-  void sdc1(DRegister dt, const Address& addr) {
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void sdc1(FRegister ft, const Address& addr) {
+    ASSERT(EvenFPURegister(ft));
     EmitFpuLoadStore(SDC1, ft, addr);
   }
 
@@ -625,25 +625,13 @@
     EmitRType(SPECIAL, rs, rt, rd, 0, SLT);
   }
 
-  void slti(Register rt, Register rs, const Immediate& imm) {
-    ASSERT(Utils::IsInt(kImmBits, imm.value()));
-    int16_t imm_value = static_cast<int16_t>(imm.value());
-    EmitIType(SLTI, rs, rt, imm_value);
-  }
-
-  void sltiu(Register rt, Register rs, const Immediate& imm) {
-    ASSERT(Utils::IsUint(kImmBits, imm.value()));
-    uint16_t imm_value = static_cast<uint16_t>(imm.value());
-    EmitIType(SLTIU, rs, rt, imm_value);
-  }
-
   void sltu(Register rd, Register rs, Register rt) {
     EmitRType(SPECIAL, rs, rt, rd, 0, SLTU);
   }
 
-  void sqrtd(DRegister dd, DRegister ds) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
+  void sqrtd(FRegister fd, FRegister fs) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
     EmitFpuRType(COP1, FMT_D, F0, fs, fd, COP1_SQRT);
   }
 
@@ -663,10 +651,10 @@
     EmitRType(SPECIAL, rs, rt, rd, 0, SRLV);
   }
 
-  void subd(DRegister dd, DRegister ds, DRegister dt) {
-    FRegister fd = static_cast<FRegister>(dd * 2);
-    FRegister fs = static_cast<FRegister>(ds * 2);
-    FRegister ft = static_cast<FRegister>(dt * 2);
+  void subd(FRegister fd, FRegister fs, FRegister ft) {
+    ASSERT(EvenFPURegister(fd));
+    ASSERT(EvenFPURegister(fs));
+    ASSERT(EvenFPURegister(ft));
     EmitFpuRType(COP1, FMT_D, ft, fs, fd, COP1_SUB);
   }
 
@@ -772,23 +760,23 @@
     }
   }
 
-  void LoadImmediate(DRegister rd, double value) {
-    FRegister frd = static_cast<FRegister>(rd * 2);
+  void LoadImmediate(FRegister rd, double value) {
+    ASSERT(EvenFPURegister(rd));
     const int64_t ival = bit_cast<uint64_t, double>(value);
     const int32_t low = Utils::Low32Bits(ival);
     const int32_t high = Utils::High32Bits(ival);
     if (low != 0) {
       LoadImmediate(TMP1, low);
-      mtc1(TMP1, frd);
+      mtc1(TMP1, rd);
     } else {
-      mtc1(ZR, frd);
+      mtc1(ZR, rd);
     }
 
     if (high != 0) {
       LoadImmediate(TMP1, high);
-      mtc1(TMP1, static_cast<FRegister>(frd + 1));
+      mtc1(TMP1, static_cast<FRegister>(rd + 1));
     } else {
-      mtc1(ZR, static_cast<FRegister>(frd + 1));
+      mtc1(ZR, static_cast<FRegister>(rd + 1));
     }
   }
 
@@ -865,13 +853,8 @@
   }
 
   void BranchSignedGreaterEqual(Register rd, int32_t value, Label* l) {
-    if (Utils::IsInt(kImmBits, value)) {
-      slti(CMPRES, rd, Immediate(value));
-      beq(CMPRES, ZR, l);
-    } else {
-      LoadImmediate(CMPRES, value);
-      BranchSignedGreaterEqual(rd, CMPRES, l);
-    }
+    LoadImmediate(CMPRES, value);
+    BranchSignedGreaterEqual(rd, CMPRES, l);
   }
 
   void BranchUnsignedGreaterEqual(Register rd, Register rs, Label* l) {
@@ -880,13 +863,8 @@
   }
 
   void BranchUnsignedGreaterEqual(Register rd, int32_t value, Label* l) {
-    if (Utils::IsUint(kImmBits, value)) {
-      sltiu(CMPRES, rd, Immediate(value));
-      beq(CMPRES, ZR, l);
-    } else {
-      LoadImmediate(CMPRES, value);
-      BranchUnsignedGreaterEqual(rd, CMPRES, l);
-    }
+    LoadImmediate(CMPRES, value);
+    BranchUnsignedGreaterEqual(rd, CMPRES, l);
   }
 
   void BranchSignedLess(Register rd, Register rs, Label* l) {
@@ -894,13 +872,8 @@
   }
 
   void BranchSignedLess(Register rd, int32_t value, Label* l) {
-    if (Utils::IsInt(kImmBits, value)) {
-      slti(CMPRES, rd, Immediate(value));
-      bne(CMPRES, ZR, l);
-    } else {
-      LoadImmediate(CMPRES, value);
-      BranchSignedGreater(CMPRES, rd, l);
-    }
+    LoadImmediate(CMPRES, value);
+    BranchSignedGreater(CMPRES, rd, l);
   }
 
   void BranchUnsignedLess(Register rd, Register rs, Label* l) {
@@ -908,13 +881,8 @@
   }
 
   void BranchUnsignedLess(Register rd, int32_t value, Label* l) {
-    if (Utils::IsUint(kImmBits, value)) {
-      sltiu(CMPRES, rd, Immediate(value));
-      bne(CMPRES, ZR, l);
-    } else {
-      LoadImmediate(CMPRES, value);
-      BranchUnsignedGreater(CMPRES, rd, l);
-    }
+    LoadImmediate(CMPRES, value);
+    BranchUnsignedGreater(CMPRES, rd, l);
   }
 
   void BranchSignedLessEqual(Register rd, Register rs, Label* l) {
@@ -969,11 +937,9 @@
   void LoadObject(Register rd, const Object& object);
   void PushObject(const Object& object);
 
-  // Compares rn with the object. Returns results in rd1 and rd2.
-  // rd1 is 1 if rn < object. rd2 is 1 if object < rn. Since both cannot be
-  // 1, rd1 == rd2 (== 0) iff rn == object.
-  void CompareObject(Register rd1, Register rd2,
-                     Register rn, const Object& object);
+  // Sets register rd to zero if the object is equal to register rn,
+  // sets it to non-zero otherwise.
+  void CompareObject(Register rd, Register rn, const Object& object);
 
   void LoadClassId(Register result, Register object);
   void LoadClassById(Register result, Register class_id);
@@ -1027,6 +993,10 @@
 
   GrowableArray<CodeComment*> comments_;
 
+  bool EvenFPURegister(FRegister reg) {
+    return (static_cast<int>(reg) & 1) == 0;
+  }
+
   void Emit(int32_t value) {
     // Emitting an instruction clears the delay slot state.
     in_delay_slot_ = false;
diff --git a/runtime/vm/assembler_mips_test.cc b/runtime/vm/assembler_mips_test.cc
index 445ab8e..1dc7d33 100644
--- a/runtime/vm/assembler_mips_test.cc
+++ b/runtime/vm/assembler_mips_test.cc
@@ -1186,9 +1186,9 @@
 
 
 ASSEMBLER_TEST_GENERATE(Addd, assembler) {
-  __ LoadImmediate(D0, 1.0);
-  __ LoadImmediate(D1, 2.0);
-  __ addd(D2, D0, D1);
+  __ LoadImmediate(F0, 1.0);
+  __ LoadImmediate(F2, 2.0);
+  __ addd(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1204,8 +1204,8 @@
 
 
 ASSEMBLER_TEST_GENERATE(Movd, assembler) {
-  __ LoadImmediate(D0, 1.0);
-  __ movd(D1, D0);
+  __ LoadImmediate(F0, 1.0);
+  __ movd(F2, F0);
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1224,9 +1224,9 @@
   __ AddImmediate(SP, -8 * kWordSize);
   __ LoadImmediate(T1, ~(8 - 1));
   __ and_(T0, SP, T1);  // Need 8 byte alignment.
-  __ LoadImmediate(D0, 1.0);
-  __ sdc1(D0, Address(T0));
-  __ ldc1(D1, Address(T0));
+  __ LoadImmediate(F0, 1.0);
+  __ sdc1(F0, Address(T0));
+  __ ldc1(F2, Address(T0));
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1242,12 +1242,12 @@
 
 
 ASSEMBLER_TEST_GENERATE(Addd_NaN, assembler) {
-  __ LoadImmediate(D0, 1.0);
+  __ LoadImmediate(F0, 1.0);
   // Double non-signaling NaN is 0x7FF8000000000000.
   __ LoadImmediate(T0, 0x7FF80000);
   __ mtc1(ZR, F2);  // Load upper bits of NaN.
   __ mtc1(T0, F3);  // Load lower bits of NaN.
-  __ addd(D2, D0, D1);
+  __ addd(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1263,11 +1263,11 @@
 
 
 ASSEMBLER_TEST_GENERATE(Addd_Inf, assembler) {
-  __ LoadImmediate(D0, 1.0);
+  __ LoadImmediate(F0, 1.0f);
   __ LoadImmediate(T0, 0x7FF00000);  // +inf
   __ mtc1(ZR, F2);
   __ mtc1(T0, F3);
-  __ addd(D2, D0, D1);
+  __ addd(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1283,9 +1283,9 @@
 
 
 ASSEMBLER_TEST_GENERATE(Subd, assembler) {
-  __ LoadImmediate(D0, 2.5);
-  __ LoadImmediate(D1, 1.5);
-  __ subd(D2, D0, D1);
+  __ LoadImmediate(F0, 2.5);
+  __ LoadImmediate(F2, 1.5);
+  __ subd(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1301,9 +1301,9 @@
 
 
 ASSEMBLER_TEST_GENERATE(Muld, assembler) {
-  __ LoadImmediate(D0, 6.0);
-  __ LoadImmediate(D1, 7.0);
-  __ muld(D2, D0, D1);
+  __ LoadImmediate(F0, 6.0);
+  __ LoadImmediate(F2, 7.0);
+  __ muld(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1319,9 +1319,9 @@
 
 
 ASSEMBLER_TEST_GENERATE(Divd, assembler) {
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 7.0);
-  __ divd(D2, D0, D1);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 7.0);
+  __ divd(F4, F0, F2);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1337,8 +1337,8 @@
 
 
 ASSEMBLER_TEST_GENERATE(Sqrtd, assembler) {
-  __ LoadImmediate(D0, 36.0);
-  __ sqrtd(D2, D0);
+  __ LoadImmediate(F0, 36.0);
+  __ sqrtd(F4, F0);
   __ mfc1(V0, F4);
   __ mfc1(V1, F5);
   __ Ret();
@@ -1356,12 +1356,12 @@
 ASSEMBLER_TEST_GENERATE(Cop1CUN, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
+  __ LoadImmediate(F0, 42.0);
   __ LoadImmediate(T0, 0x7FF80000);
   __ mtc1(ZR, F2);
   __ mtc1(T0, F3);
   __ LoadImmediate(V0, 42);
-  __ cund(D0, D1);
+  __ cund(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1378,10 +1378,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1CUN_not_taken, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 42.0);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 42.0);
   __ LoadImmediate(V0, 42);
-  __ cund(D0, D1);
+  __ cund(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1398,10 +1398,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1CEq, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.5);
-  __ LoadImmediate(D1, 42.5);
+  __ LoadImmediate(F0, 42.5);
+  __ LoadImmediate(F2, 42.5);
   __ LoadImmediate(V0, 42);
-  __ ceqd(D0, D1);
+  __ ceqd(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1418,10 +1418,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1CEq_not_taken, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 42.5);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 42.5);
   __ LoadImmediate(V0, 42);
-  __ ceqd(D0, D1);
+  __ ceqd(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1438,10 +1438,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1CEq_false, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 42.5);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 42.5);
   __ LoadImmediate(V0, 42);
-  __ ceqd(D0, D1);
+  __ ceqd(F0, F2);
   __ bc1f(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1458,10 +1458,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1CEq_false_not_taken, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.5);
-  __ LoadImmediate(D1, 42.5);
+  __ LoadImmediate(F0, 42.5);
+  __ LoadImmediate(F2, 42.5);
   __ LoadImmediate(V0, 42);
-  __ ceqd(D0, D1);
+  __ ceqd(F0, F2);
   __ bc1f(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1478,10 +1478,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1COLT, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 42.5);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 42.5);
   __ LoadImmediate(V0, 42);
-  __ coltd(D0, D1);
+  __ coltd(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1498,10 +1498,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1COLT_not_taken, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.5);
-  __ LoadImmediate(D1, 42.0);
+  __ LoadImmediate(F0, 42.5);
+  __ LoadImmediate(F2, 42.0);
   __ LoadImmediate(V0, 42);
-  __ coltd(D0, D1);
+  __ coltd(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1518,10 +1518,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1COLE, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.0);
-  __ LoadImmediate(D1, 42.0);
+  __ LoadImmediate(F0, 42.0);
+  __ LoadImmediate(F2, 42.0);
   __ LoadImmediate(V0, 42);
-  __ coled(D0, D1);
+  __ coled(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1538,10 +1538,10 @@
 ASSEMBLER_TEST_GENERATE(Cop1COLE_not_taken, assembler) {
   Label is_true;
 
-  __ LoadImmediate(D0, 42.5);
-  __ LoadImmediate(D1, 42.0);
+  __ LoadImmediate(F0, 42.5);
+  __ LoadImmediate(F2, 42.0);
   __ LoadImmediate(V0, 42);
-  __ coled(D0, D1);
+  __ coled(F0, F2);
   __ bc1t(&is_true);
   __ mov(V0, ZR);
   __ Bind(&is_true);
@@ -1558,7 +1558,7 @@
 ASSEMBLER_TEST_GENERATE(Cop1CvtDW, assembler) {
   __ LoadImmediate(T0, 42);
   __ mtc1(T0, F0);
-  __ cvtdw(D1, F0);
+  __ cvtdw(F2, F0);
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1576,7 +1576,7 @@
 ASSEMBLER_TEST_GENERATE(Cop1CvtDW_neg, assembler) {
   __ LoadImmediate(T0, -42);
   __ mtc1(T0, F0);
-  __ cvtdw(D1, F0);
+  __ cvtdw(F2, F0);
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1595,7 +1595,7 @@
   __ LoadImmediate(T0, 0x1);
   __ mtc1(ZR, F0);
   __ mtc1(T0, F1);  // D0 <- 0x100000000 = 4294967296
-  __ cvtdl(D1, D0);
+  __ cvtdl(F2, F0);
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1614,7 +1614,7 @@
   __ LoadImmediate(T0, 0xffffffff);
   __ mtc1(T0, F0);
   __ mtc1(T0, F1);  // D0 <- 0xffffffffffffffff = -1
-  __ cvtdl(D1, D0);
+  __ cvtdl(F2, F0);
   __ mfc1(V0, F2);
   __ mfc1(V1, F3);
   __ Ret();
@@ -1630,8 +1630,8 @@
 
 
 ASSEMBLER_TEST_GENERATE(Cop1CvtWD, assembler) {
-  __ LoadImmediate(D0, 42.0);
-  __ cvtwd(F2, D0);
+  __ LoadImmediate(F0, 42.0);
+  __ cvtwd(F2, F0);
   __ mfc1(V0, F2);
   __ Ret();
 }
@@ -1645,8 +1645,8 @@
 
 
 ASSEMBLER_TEST_GENERATE(Cop1CvtWD_neg, assembler) {
-  __ LoadImmediate(D0, -42.0);
-  __ cvtwd(F2, D0);
+  __ LoadImmediate(F0, -42.0);
+  __ cvtwd(F2, F0);
   __ mfc1(V0, F2);
   __ Ret();
 }
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index 86ca5af..ffc41a1 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -38,8 +38,16 @@
     "Trace IC miss in optimized code");
 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code.");
 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls");
+#if defined(TARGET_ARCH_IA32) ||                                               \
+    defined(TARGET_ARCH_X64) ||                                                \
+    defined(TARGET_ARCH_ARM)
 DEFINE_FLAG(int, optimization_counter_threshold, 3000,
     "Function's usage-counter value before it is optimized, -1 means never");
+#else
+// TODO(regis): Enable optimization on MIPS.
+DEFINE_FLAG(int, optimization_counter_threshold, -1,
+    "Function's usage-counter value before it is optimized, -1 means never");
+#endif
 DECLARE_FLAG(bool, enable_type_checks);
 DECLARE_FLAG(bool, trace_type_checks);
 DECLARE_FLAG(bool, report_usage_count);
@@ -1540,7 +1548,7 @@
   ASSERT(!deopt_info.IsNull());
 
   CopyFrame(optimized_code, *caller_frame);
-  if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
+  if (FLAG_trace_deoptimization) {
     Function& function = Function::Handle(optimized_code.function());
     OS::PrintErr(
         "Deoptimizing (reason %"Pd" '%s') at pc %#"Px" '%s' (count %d)\n",
@@ -1706,7 +1714,7 @@
 
   // Since this is the only step where GC can occur during deoptimization,
   // use it to report the source line where deoptimization occured.
-  if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
+  if (FLAG_trace_deoptimization) {
     DartFrameIterator iterator;
     StackFrame* top_frame = iterator.NextFrame();
     ASSERT(top_frame != NULL);
diff --git a/runtime/vm/constants_mips.h b/runtime/vm/constants_mips.h
index 64a92c3..32f608b 100644
--- a/runtime/vm/constants_mips.h
+++ b/runtime/vm/constants_mips.h
@@ -129,38 +129,12 @@
   kNoFRegister = -1,
 };
 
-// The double precision floating point registers are concatenated pairs of the
-// single precision registers, e.g. D0 is F1:F0, D1 is F3:F2, etc.. We only
-// tell the architecture generic code about the double precision registers, then
-// convert to the single precision registers when needed in the mips-specific
-// code.
-enum DRegister {
-  D0  =  0,
-  D1  =  1,
-  D2  =  2,
-  D3  =  3,
-  D4  =  4,
-  D5  =  5,
-  D6  =  6,
-  D7  =  7,
-  D8  =  8,
-  D9  =  9,
-  D10 = 10,
-  D11 = 11,
-  D12 = 12,
-  D13 = 13,
-  D14 = 14,
-  D15 = 15,
-  D16 = 16,
-  kNumberOfDRegisters = 16,
-  kNoDRegister = -1,
-};
 
 // Architecture independent aliases.
-typedef DRegister FpuRegister;
-const FpuRegister FpuTMP = D0;
-const int kNumberOfFpuRegisters = kNumberOfDRegisters;
-const FpuRegister kNoFpuRegister = kNoDRegister;
+typedef FRegister FpuRegister;
+const FpuRegister FpuTMP = F0;
+const int kNumberOfFpuRegisters = kNumberOfFRegisters;
+const FpuRegister kNoFpuRegister = kNoFRegister;
 
 
 // Register aliases.
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc
index 8b37613..9c9dd24 100644
--- a/runtime/vm/deopt_instructions.cc
+++ b/runtime/vm/deopt_instructions.cc
@@ -73,8 +73,7 @@
 // Deoptimization instruction moving value from optimized frame at
 // 'from_index' to specified slots in the unoptimized frame.
 // 'from_index' represents the slot index of the frame (0 being first argument)
-// and accounts for saved return address, frame pointer, pool pointer and pc
-// marker.
+// and accounts for saved return address, frame pointer and pc marker.
 class DeoptStackSlotInstr : public DeoptInstr {
  public:
   explicit DeoptStackSlotInstr(intptr_t from_index)
@@ -516,7 +515,7 @@
     // Increment the deoptimization counter. This effectively increments each
     // function occurring in the optimized frame.
     function.set_deoptimization_counter(function.deoptimization_counter() + 1);
-    if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) {
+    if (FLAG_trace_deoptimization) {
       OS::PrintErr("Deoptimizing %s (count %d)\n",
           function.ToFullyQualifiedCString(),
           function.deoptimization_counter());
@@ -864,7 +863,7 @@
 intptr_t DeoptInfoBuilder::CalculateStackIndex(const Location& from_loc) const {
   return from_loc.stack_index() < 0 ?
             from_loc.stack_index() + num_args_ :
-            from_loc.stack_index() + num_args_ + kDartFrameFixedSize;
+            from_loc.stack_index() + num_args_ - kFirstLocalSlotFromFp + 1;
 }
 
 
diff --git a/runtime/vm/disassembler_mips.cc b/runtime/vm/disassembler_mips.cc
index f6d7051..8c672b3 100644
--- a/runtime/vm/disassembler_mips.cc
+++ b/runtime/vm/disassembler_mips.cc
@@ -685,14 +685,6 @@
       Format(instr, "sb 'rt, 'imms('rs)");
       break;
     }
-    case SLTI: {
-      Format(instr, "slti 'rt, 'rs, 'imms");
-      break;
-    }
-    case SLTIU: {
-      Format(instr, "sltu 'rt, 'rs, 'immu");
-      break;
-    }
     case SH: {
       Format(instr, "sh 'rt, 'imms('rs)");
       break;
diff --git a/runtime/vm/flow_graph_compiler.h b/runtime/vm/flow_graph_compiler.h
index 6dbcaa4..a5672d4 100644
--- a/runtime/vm/flow_graph_compiler.h
+++ b/runtime/vm/flow_graph_compiler.h
@@ -442,6 +442,10 @@
 
   bool may_reoptimize() const { return may_reoptimize_; }
 
+  static Condition FlipCondition(Condition condition);
+
+  static bool EvaluateCondition(Condition condition, intptr_t l, intptr_t r);
+
   // Array/list element address computations.
   static intptr_t DataOffsetFor(intptr_t cid);
   static intptr_t ElementSizeFor(intptr_t cid);
diff --git a/runtime/vm/flow_graph_compiler_arm.cc b/runtime/vm/flow_graph_compiler_arm.cc
index 6bd4049..686c7e0 100644
--- a/runtime/vm/flow_graph_compiler_arm.cc
+++ b/runtime/vm/flow_graph_compiler_arm.cc
@@ -1290,65 +1290,7 @@
     intptr_t deopt_id,
     intptr_t token_pos,
     LocationSummary* locs) {
-  MegamorphicCacheTable* table = Isolate::Current()->megamorphic_cache_table();
-  const String& name = String::Handle(ic_data.target_name());
-  const MegamorphicCache& cache =
-      MegamorphicCache::ZoneHandle(table->Lookup(name, arguments_descriptor));
-  Label not_smi, load_cache;
-  __ LoadFromOffset(kLoadWord, R0, SP, (argument_count - 1) * kWordSize);
-  __ tst(R0, ShifterOperand(kSmiTagMask));
-  __ b(&not_smi, NE);
-  __ mov(R0, ShifterOperand(Smi::RawValue(kSmiCid)));
-  __ b(&load_cache);
-
-  __ Bind(&not_smi);
-  __ LoadClassId(R0, R0);
-  __ SmiTag(R0);
-
-  // R0: class ID of the receiver (smi).
-  __ Bind(&load_cache);
-  __ LoadObject(R1, cache);
-  __ ldr(R2, FieldAddress(R1, MegamorphicCache::buckets_offset()));
-  __ ldr(R1, FieldAddress(R1, MegamorphicCache::mask_offset()));
-  // R2: cache buckets array.
-  // R1: mask.
-  __ mov(R3, ShifterOperand(R0));
-
-  Label loop, update, call_target_function;
-  __ b(&loop);
-
-  __ Bind(&update);
-  __ add(R3, R3, ShifterOperand(Smi::RawValue(1)));
-  __ Bind(&loop);
-  __ and_(R3, R3, ShifterOperand(R1));
-  const intptr_t base = Array::data_offset();
-  // R3 is smi tagged, but table entries are two words, so LSL 2.
-  __ add(IP, R2, ShifterOperand(R3, LSL, 2));
-  __ ldr(R4, FieldAddress(IP, base));
-
-  ASSERT(kIllegalCid == 0);
-  __ tst(R4, ShifterOperand(R4));
-  __ b(&call_target_function, EQ);
-  __ cmp(R4, ShifterOperand(R0));
-  __ b(&update, NE);
-
-  __ Bind(&call_target_function);
-  // Call the target found in the cache.  For a class id match, this is a
-  // proper target for the given name and arguments descriptor.  If the
-  // illegal class id was found, the target is a cache miss handler that can
-  // be invoked as a normal Dart function.
-  __ add(IP, R2, ShifterOperand(R3, LSL, 2));
-  __ ldr(R0, FieldAddress(IP, base + kWordSize));
-  __ ldr(R0, FieldAddress(R0, Function::code_offset()));
-  __ ldr(R0, FieldAddress(R0, Code::instructions_offset()));
-  __ LoadObject(R5, ic_data);
-  __ LoadObject(R4, arguments_descriptor);
-  __ AddImmediate(R0, Instructions::HeaderSize() - kHeapObjectTag);
-  __ blx(R0);
-  AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
-  RecordSafepoint(locs);
-  AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
-  __ Drop(argument_count);
+  UNIMPLEMENTED();
 }
 
 
@@ -1514,6 +1456,20 @@
 }
 
 
+Condition FlowGraphCompiler::FlipCondition(Condition condition) {
+  UNIMPLEMENTED();
+  return condition;
+}
+
+
+bool FlowGraphCompiler::EvaluateCondition(Condition condition,
+                                          intptr_t left,
+                                          intptr_t right) {
+  UNIMPLEMENTED();
+  return false;
+}
+
+
 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid,
                                                           intptr_t index_scale,
                                                           Register array,
diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc
index 71bb3fa..593b42d 100644
--- a/runtime/vm/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/flow_graph_compiler_ia32.cc
@@ -1653,6 +1653,48 @@
 }
 
 
+Condition FlowGraphCompiler::FlipCondition(Condition condition) {
+  switch (condition) {
+    case EQUAL:         return EQUAL;
+    case NOT_EQUAL:     return NOT_EQUAL;
+    case LESS:          return GREATER;
+    case LESS_EQUAL:    return GREATER_EQUAL;
+    case GREATER:       return LESS;
+    case GREATER_EQUAL: return LESS_EQUAL;
+    case BELOW:         return ABOVE;
+    case BELOW_EQUAL:   return ABOVE_EQUAL;
+    case ABOVE:         return BELOW;
+    case ABOVE_EQUAL:   return BELOW_EQUAL;
+    default:
+      UNIMPLEMENTED();
+      return EQUAL;
+  }
+}
+
+
+bool FlowGraphCompiler::EvaluateCondition(Condition condition,
+                                          intptr_t left,
+                                          intptr_t right) {
+  const uintptr_t unsigned_left = static_cast<uintptr_t>(left);
+  const uintptr_t unsigned_right = static_cast<uintptr_t>(right);
+  switch (condition) {
+    case EQUAL:         return left == right;
+    case NOT_EQUAL:     return left != right;
+    case LESS:          return left < right;
+    case LESS_EQUAL:    return left <= right;
+    case GREATER:       return left > right;
+    case GREATER_EQUAL: return left >= right;
+    case BELOW:         return unsigned_left < unsigned_right;
+    case BELOW_EQUAL:   return unsigned_left <= unsigned_right;
+    case ABOVE:         return unsigned_left > unsigned_right;
+    case ABOVE_EQUAL:   return unsigned_left >= unsigned_right;
+    default:
+      UNIMPLEMENTED();
+      return false;
+  }
+}
+
+
 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid,
                                                           intptr_t index_scale,
                                                           Register array,
diff --git a/runtime/vm/flow_graph_compiler_mips.cc b/runtime/vm/flow_graph_compiler_mips.cc
index 652ff03..efcd64c 100644
--- a/runtime/vm/flow_graph_compiler_mips.cc
+++ b/runtime/vm/flow_graph_compiler_mips.cc
@@ -45,96 +45,8 @@
 
 RawDeoptInfo* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
                                                  DeoptInfoBuilder* builder) {
-  if (deopt_env_ == NULL) return DeoptInfo::null();
-
-  intptr_t stack_height = compiler->StackSize();
-  AllocateIncomingParametersRecursive(deopt_env_, &stack_height);
-
-  intptr_t slot_ix = 0;
-  Environment* current = deopt_env_;
-
-  // Emit all kMaterializeObject instructions describing objects to be
-  // materialized on the deoptimization as a prefix to the deoptimization info.
-  EmitMaterializations(deopt_env_, builder);
-
-  // The real frame starts here.
-  builder->MarkFrameStart();
-
-  // Current PP, FP, and PC.
-  builder->AddPp(current->function(), slot_ix++);
-  builder->AddCallerFp(slot_ix++);
-  builder->AddReturnAddress(current->function(), deopt_id(), slot_ix++);
-
-  // Callee's PC marker is not used anymore. Pass Function::null() to set to 0.
-  builder->AddPcMarker(Function::Handle(), slot_ix++);
-
-  // Emit all values that are needed for materialization as a part of the
-  // expression stack for the bottom-most frame. This guarantees that GC
-  // will be able to find them during materialization.
-  slot_ix = builder->EmitMaterializationArguments(slot_ix);
-
-  // For the innermost environment, set outgoing arguments and the locals.
-  for (intptr_t i = current->Length() - 1;
-       i >= current->fixed_parameter_count();
-       i--) {
-    builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++);
-  }
-
-  Environment* previous = current;
-  current = current->outer();
-  while (current != NULL) {
-    // PP, FP, and PC.
-    builder->AddPp(current->function(), slot_ix++);
-    builder->AddCallerFp(slot_ix++);
-
-    // For any outer environment the deopt id is that of the call instruction
-    // which is recorded in the outer environment.
-    builder->AddReturnAddress(current->function(),
-                              Isolate::ToDeoptAfter(current->deopt_id()),
-                              slot_ix++);
-
-    // PC marker.
-    builder->AddPcMarker(previous->function(), slot_ix++);
-
-    // The values of outgoing arguments can be changed from the inlined call so
-    // we must read them from the previous environment.
-    for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) {
-      builder->AddCopy(previous->ValueAt(i),
-                       previous->LocationAt(i),
-                       slot_ix++);
-    }
-
-    // Set the locals, note that outgoing arguments are not in the environment.
-    for (intptr_t i = current->Length() - 1;
-         i >= current->fixed_parameter_count();
-         i--) {
-      builder->AddCopy(current->ValueAt(i),
-                       current->LocationAt(i),
-                       slot_ix++);
-    }
-
-    // Iterate on the outer environment.
-    previous = current;
-    current = current->outer();
-  }
-  // The previous pointer is now the outermost environment.
-  ASSERT(previous != NULL);
-
-  // For the outermost environment, set caller PC, caller PP, and caller FP.
-  builder->AddCallerPp(slot_ix++);
-  builder->AddCallerFp(slot_ix++);
-  builder->AddCallerPc(slot_ix++);
-
-  // PC marker.
-  builder->AddPcMarker(previous->function(), slot_ix++);
-
-  // For the outermost environment, set the incoming arguments.
-  for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) {
-    builder->AddCopy(previous->ValueAt(i), previous->LocationAt(i), slot_ix++);
-  }
-
-  const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo());
-  return deopt_info.raw();
+  UNIMPLEMENTED();  // TODO(regis): Copy ARM version.
+  return NULL;
 }
 
 
@@ -166,7 +78,8 @@
                                            Label* is_false) {
   __ TraceSimMsg("BoolToJump");
   Label fall_through;
-  __ beq(bool_register, NULLREG, &fall_through);
+  __ BranchEqual(bool_register, reinterpret_cast<intptr_t>(Object::null()),
+                 &fall_through);
   __ BranchEqual(bool_register, Bool::True(), is_true);
   __ b(is_false);
   __ Bind(&fall_through);
@@ -188,14 +101,19 @@
   const SubtypeTestCache& type_test_cache =
       SubtypeTestCache::ZoneHandle(SubtypeTestCache::New());
   __ LoadObject(A2, type_test_cache);
+  intptr_t null = reinterpret_cast<intptr_t>(Object::null());
+  uint16_t null_lo = Utils::Low16Bits(null);
+  uint16_t null_hi = Utils::High16Bits(null);
   if (test_kind == kTestTypeOneArg) {
     ASSERT(type_arguments_reg == kNoRegister);
+    __ lui(A1, Immediate(null_hi));
     __ BranchLink(&StubCode::Subtype1TestCacheLabel());
-    __ delay_slot()->mov(A1, NULLREG);
+    __ delay_slot()->ori(A1, A1, Immediate(null_lo));
   } else if (test_kind == kTestTypeTwoArgs) {
     ASSERT(type_arguments_reg == kNoRegister);
+    __ lui(A1, Immediate(null_hi));
     __ BranchLink(&StubCode::Subtype2TestCacheLabel());
-    __ delay_slot()->mov(A1, NULLREG);
+    __ delay_slot()->ori(A1, A1, Immediate(null_lo));
   } else if (test_kind == kTestTypeThreeArgs) {
     ASSERT(type_arguments_reg == A1);
     __ BranchLink(&StubCode::Subtype3TestCacheLabel());
@@ -329,7 +247,8 @@
     // Check if instance is a closure.
     __ LoadClassById(T1, kClassIdReg);
     __ lw(T1, FieldAddress(T1, Class::signature_function_offset()));
-    __ bne(T1, NULLREG, is_instance_lbl);
+    __ BranchNotEqual(T1, reinterpret_cast<int32_t>(Object::null()),
+                      is_instance_lbl);
   }
   // Custom checking for numbers (Smi, Mint, Bigint and Double).
   // Note that instance is not Smi (checked above).
@@ -396,7 +315,8 @@
     __ lw(A1, Address(SP, 0));  // Get instantiator type arguments.
     // A1: instantiator type arguments.
     // Check if type argument is dynamic.
-    __ beq(A1, NULLREG, is_instance_lbl);
+    __ BranchEqual(A1, reinterpret_cast<intptr_t>(Object::null()),
+                   is_instance_lbl);
     // Can handle only type arguments that are instances of TypeArguments.
     // (runtime checks canonicalize type arguments).
     Label fall_through;
@@ -407,7 +327,8 @@
     // R2: concrete type of type.
     // Check if type argument is dynamic.
     __ BranchEqual(T2, Type::ZoneHandle(Type::DynamicType()), is_instance_lbl);
-    __ beq(T2, NULLREG, is_instance_lbl);
+    __ BranchEqual(T2, reinterpret_cast<intptr_t>(Object::null()),
+                   is_instance_lbl);
     const Type& object_type = Type::ZoneHandle(Type::ObjectType());
     __ BranchEqual(T2, object_type, is_instance_lbl);
 
@@ -566,7 +487,7 @@
 
   // A null object is always assignable and is returned as result.
   Label is_assignable, runtime_call;
-  __ beq(A0, NULLREG, &is_assignable);
+  __ BranchEqual(A0, reinterpret_cast<int32_t>(Object::null()), &is_assignable);
   __ delay_slot()->sw(A1, Address(SP, 0 * kWordSize));
 
   if (!FLAG_eliminate_type_checks) {
@@ -805,7 +726,8 @@
     delete[] opt_param_position;
     // Check that T0 now points to the null terminator in the array descriptor.
     __ lw(T3, Address(T0));
-    __ beq(T3, NULLREG, &all_arguments_processed);
+    __ BranchEqual(T3, reinterpret_cast<int32_t>(Object::null()),
+                   &all_arguments_processed);
   } else {
     ASSERT(num_opt_pos_params > 0);
     __ lw(T2,
@@ -882,6 +804,8 @@
   // implicitly final, since garbage collecting the unmodified value is not
   // an issue anymore.
 
+  __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
+
   // S4 : arguments descriptor array.
   __ lw(T2, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
   __ sll(T2, T2, 1);  // T2 is a Smi.
@@ -894,7 +818,7 @@
   __ addiu(T2, T2, Immediate(-kWordSize));
   __ addu(T3, T1, T2);
   __ bgtz(T2, &null_args_loop);
-  __ delay_slot()->sw(NULLREG, Address(T3));
+  __ delay_slot()->sw(T0, Address(T3));
   __ Bind(&null_args_loop_exit);
 }
 
@@ -917,8 +841,12 @@
   __ lw(T0, Address(SP, 1 * kWordSize));  // Receiver.
   __ lw(T1, Address(SP, 0 * kWordSize));  // Value.
   __ StoreIntoObject(T0, FieldAddress(T0, offset), T1);
+  intptr_t null = reinterpret_cast<intptr_t>(Object::null());
+  uint16_t null_lo = Utils::Low16Bits(null);
+  uint16_t null_hi = Utils::High16Bits(null);
+  __ lui(V0, Immediate(null_hi));
   __ Ret();
-  __ delay_slot()->mov(V0, NULLREG);
+  __ delay_slot()->ori(V0, V0, Immediate(null_lo));
 }
 
 
@@ -1111,9 +1039,10 @@
     __ TraceSimMsg("Initialize spill slots");
     __ Comment("Initialize spill slots");
     const intptr_t slot_base = parsed_function().first_stack_local_index();
+    __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
     for (intptr_t i = 0; i < num_locals; ++i) {
       // Subtract index i (locals lie at lower addresses than FP).
-      __ sw(NULLREG, Address(FP, (slot_base - i) * kWordSize));
+      __ sw(T0, Address(FP, (slot_base - i) * kWordSize));
     }
   }
 
@@ -1136,7 +1065,7 @@
   AddCurrentDescriptor(PcDescriptors::kPatchCode,
                        Isolate::kNoDeoptId,
                        0);  // No token position.
-  __ BranchPatchable(&StubCode::FixCallersTargetLabel());
+  __ Branch(&StubCode::FixCallersTargetLabel());
   AddCurrentDescriptor(PcDescriptors::kLazyDeoptJump,
                        Isolate::kNoDeoptId,
                        0);  // No token position.
@@ -1300,7 +1229,7 @@
     __ addiu(SP, SP, Immediate(2 * kWordSize));  // Discard constant.
     return;
   }
-  __ CompareObject(CMPRES, TMP1, reg, obj);
+  __ CompareObject(CMPRES, reg, obj);
 }
 
 
@@ -1323,8 +1252,7 @@
     __ lw(left, Address(SP, 1 * kWordSize));
     __ addiu(SP, SP, Immediate(2 * kWordSize));
   } else {
-    __ slt(CMPRES, left, right);
-    __ slt(TMP1, right, left);
+    __ subu(CMPRES, left, right);
   }
 }
 
@@ -1414,6 +1342,20 @@
 }
 
 
+Condition FlowGraphCompiler::FlipCondition(Condition condition) {
+  UNIMPLEMENTED();
+  return condition;
+}
+
+
+bool FlowGraphCompiler::EvaluateCondition(Condition condition,
+                                          intptr_t left,
+                                          intptr_t right) {
+  UNIMPLEMENTED();
+  return false;
+}
+
+
 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid,
                                                           intptr_t index_scale,
                                                           Register array,
@@ -1540,7 +1482,7 @@
            source.IsQuadStackSlot());
     bool double_width = destination.IsDoubleStackSlot() ||
                         source.IsDoubleStackSlot();
-    DRegister reg = source.IsFpuRegister() ? source.fpu_reg()
+    FRegister reg = source.IsFpuRegister() ? source.fpu_reg()
                                            : destination.fpu_reg();
     const Address& slot_address = source.IsFpuRegister()
         ? destination.ToStackSlotAddress()
diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc
index be0f589..8c9e874 100644
--- a/runtime/vm/flow_graph_compiler_x64.cc
+++ b/runtime/vm/flow_graph_compiler_x64.cc
@@ -1650,6 +1650,48 @@
 }
 
 
+Condition FlowGraphCompiler::FlipCondition(Condition condition) {
+  switch (condition) {
+    case EQUAL:         return EQUAL;
+    case NOT_EQUAL:     return NOT_EQUAL;
+    case LESS:          return GREATER;
+    case LESS_EQUAL:    return GREATER_EQUAL;
+    case GREATER:       return LESS;
+    case GREATER_EQUAL: return LESS_EQUAL;
+    case BELOW:         return ABOVE;
+    case BELOW_EQUAL:   return ABOVE_EQUAL;
+    case ABOVE:         return BELOW;
+    case ABOVE_EQUAL:   return BELOW_EQUAL;
+    default:
+      UNIMPLEMENTED();
+      return EQUAL;
+  }
+}
+
+
+bool FlowGraphCompiler::EvaluateCondition(Condition condition,
+                                          intptr_t left,
+                                          intptr_t right) {
+  const uintptr_t unsigned_left = static_cast<uintptr_t>(left);
+  const uintptr_t unsigned_right = static_cast<uintptr_t>(right);
+  switch (condition) {
+    case EQUAL:         return left == right;
+    case NOT_EQUAL:     return left != right;
+    case LESS:          return left < right;
+    case LESS_EQUAL:    return left <= right;
+    case GREATER:       return left > right;
+    case GREATER_EQUAL: return left >= right;
+    case BELOW:         return unsigned_left < unsigned_right;
+    case BELOW_EQUAL:   return unsigned_left <= unsigned_right;
+    case ABOVE:         return unsigned_left > unsigned_right;
+    case ABOVE_EQUAL:   return unsigned_left >= unsigned_right;
+    default:
+      UNIMPLEMENTED();
+      return false;
+  }
+}
+
+
 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid,
                                                           intptr_t index_scale,
                                                           Register array,
diff --git a/runtime/vm/instructions_mips.h b/runtime/vm/instructions_mips.h
index 5567ae6..ed16b16 100644
--- a/runtime/vm/instructions_mips.h
+++ b/runtime/vm/instructions_mips.h
@@ -25,10 +25,6 @@
   uword TargetAddress() const;
   void SetTargetAddress(uword target_address) const;
 
-  // This constant length is only valid for inserted call patterns used for
-  // lazy deoptimization. Regular call pattern may vary in length.
-  static const int kFixedLengthInBytes = 3 * Instr::kInstrSize;
-
  private:
   uword Back(int n) const;
   int DecodeLoadObject(int end, Register* reg, Object* obj);
diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc
index 71b94d3..d07ab4d 100644
--- a/runtime/vm/intermediate_language_arm.cc
+++ b/runtime/vm/intermediate_language_arm.cc
@@ -527,7 +527,6 @@
         __ LoadObject(result, Bool::False(), NegateCondition(cond));
       }
     } else {
-      __ PushList((1 << R0) | (1 << R1));
       const int kNumberOfArguments = 2;
       const Array& kNoArgumentNames = Array::Handle();
       compiler->GenerateStaticCall(deopt_id,
@@ -615,25 +614,6 @@
 }
 
 
-static Condition FlipCondition(Condition condition) {
-  switch (condition) {
-    case EQ: return EQ;
-    case NE: return NE;
-    case LT: return GT;
-    case LE: return GE;
-    case GT: return LT;
-    case GE: return LE;
-    case CC: return HI;
-    case LS: return CS;
-    case HI: return CC;
-    case CS: return LS;
-    default:
-      UNIMPLEMENTED();
-      return EQ;
-  }
-}
-
-
 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
                                 const LocationSummary& locs,
                                 Token::Kind kind,
@@ -646,7 +626,7 @@
 
   if (left.IsConstant()) {
     __ CompareObject(right.reg(), left.constant());
-    true_condition = FlipCondition(true_condition);
+    true_condition = FlowGraphCompiler::FlipCondition(true_condition);
   } else if (right.IsConstant()) {
     __ CompareObject(left.reg(), right.constant());
   } else {
@@ -2550,8 +2530,7 @@
   }
 
   // Load receiver into R0.
-  __ LoadFromOffset(kLoadWord, R0, SP,
-                    (instance_call()->ArgumentCount() - 1) * kWordSize);
+  __ ldr(R0, Address(SP, (instance_call()->ArgumentCount() - 1) * kWordSize));
 
   LoadValueCid(compiler, R2, R0,
                (ic_data().GetReceiverClassIdAt(0) == kSmiCid) ? NULL : deopt);
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index eab4a67..23b6241 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -629,25 +629,6 @@
 }
 
 
-static Condition FlipCondition(Condition condition) {
-  switch (condition) {
-    case EQUAL:         return EQUAL;
-    case NOT_EQUAL:     return NOT_EQUAL;
-    case LESS:          return GREATER;
-    case LESS_EQUAL:    return GREATER_EQUAL;
-    case GREATER:       return LESS;
-    case GREATER_EQUAL: return LESS_EQUAL;
-    case BELOW:         return ABOVE;
-    case BELOW_EQUAL:   return ABOVE_EQUAL;
-    case ABOVE:         return BELOW;
-    case ABOVE_EQUAL:   return BELOW_EQUAL;
-    default:
-      UNIMPLEMENTED();
-      return EQUAL;
-  }
-}
-
-
 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
                                 const LocationSummary& locs,
                                 Token::Kind kind,
@@ -660,7 +641,7 @@
 
   if (left.IsConstant()) {
     __ CompareObject(right.reg(), left.constant());
-    true_condition = FlipCondition(true_condition);
+    true_condition = FlowGraphCompiler::FlipCondition(true_condition);
   } else if (right.IsConstant()) {
     __ CompareObject(left.reg(), right.constant());
   } else if (right.IsStackSlot()) {
@@ -768,11 +749,11 @@
   __ cmpl(left_tmp, right_tmp);
   if (branch != NULL) {
     __ j(hi_cond, compiler->GetJumpLabel(branch->true_successor()));
-    __ j(FlipCondition(hi_cond),
+    __ j(FlowGraphCompiler::FlipCondition(hi_cond),
          compiler->GetJumpLabel(branch->false_successor()));
   } else {
     __ j(hi_cond, &is_true);
-    __ j(FlipCondition(hi_cond), &is_false);
+    __ j(FlowGraphCompiler::FlipCondition(hi_cond), &is_false);
   }
 
   // If upper is equal, compare lower half.
diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
index 704a030..5107f34 100644
--- a/runtime/vm/intermediate_language_mips.cc
+++ b/runtime/vm/intermediate_language_mips.cc
@@ -92,9 +92,9 @@
     const intptr_t fp_sp_dist =
         (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize;
     ASSERT(fp_sp_dist <= 0);
-    __ subu(TMP1, SP, FP);
+    __ subu(T2, SP, FP);
 
-    __ BranchEqual(TMP1, fp_sp_dist, &stack_ok);
+    __ BranchEqual(T2, fp_sp_dist, &stack_ok);
     __ break_(0);
 
     __ Bind(&stack_ok);
@@ -328,10 +328,7 @@
     const intptr_t kNumTemps = 1;
     LocationSummary* locs =
         new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
-    locs->set_in(0, Location::RegisterLocation(A1));
-    locs->set_in(1, Location::RegisterLocation(A0));
-    locs->set_temp(0, Location::RegisterLocation(T0));
-    locs->set_out(Location::RegisterLocation(V0));
+    UNIMPLEMENTED();  // TODO(regis): Verify register allocation.
     return locs;
   }
   const intptr_t kNumTemps = 1;
@@ -366,8 +363,9 @@
   const int kNumArgumentsChecked = 2;
 
   Label check_identity;
-  __ beq(A1, NULLREG, &check_identity);
-  __ beq(A0, NULLREG, &check_identity);
+  __ LoadImmediate(TMP1, reinterpret_cast<intptr_t>(Object::null()));
+  __ beq(A1, TMP1, &check_identity);
+  __ beq(A0, TMP1, &check_identity);
 
   ICData& equality_ic_data = ICData::ZoneHandle();
   if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
@@ -498,29 +496,6 @@
 }
 
 
-// Branches on condition c assuming comparison results in CMPRES and TMP1.
-static void EmitBranchAfterCompare(
-    FlowGraphCompiler* compiler, Condition c, Label* is_true) {
-    switch (c) {
-      case EQ: __ beq(CMPRES, TMP1, is_true); break;
-      case NE: __ bne(CMPRES, TMP1, is_true); break;
-      case GT: __ bne(TMP1, ZR, is_true); break;
-      case GE: __ beq(CMPRES, ZR, is_true); break;
-      case LT: __ bne(CMPRES, ZR, is_true); break;
-      case LE: __ beq(TMP1, ZR, is_true); break;
-      default:
-        UNREACHABLE();
-        break;
-    }
-}
-
-
-static Condition FlipCondition(Condition condition) {
-  UNIMPLEMENTED();
-  return condition;
-}
-
-
 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
                                 const LocationSummary& locs,
                                 Token::Kind kind,
@@ -533,13 +508,12 @@
   Condition true_condition = TokenKindToSmiCondition(kind);
 
   if (left.IsConstant()) {
-    __ CompareObject(CMPRES, TMP1, right.reg(), left.constant());
-    true_condition = FlipCondition(true_condition);
+    __ CompareObject(CMPRES, right.reg(), left.constant());
+    true_condition = FlowGraphCompiler::FlipCondition(true_condition);
   } else if (right.IsConstant()) {
-    __ CompareObject(CMPRES, TMP1, left.reg(), right.constant());
+    __ CompareObject(CMPRES, left.reg(), right.constant());
   } else {
-    __ slt(CMPRES, left.reg(), right.reg());
-    __ slt(TMP1, right.reg(), left.reg());
+    __ subu(CMPRES, left.reg(), right.reg());
   }
 
   if (branch != NULL) {
@@ -547,7 +521,17 @@
   } else {
     Register result = locs.out().reg();
     Label done, is_true;
-    EmitBranchAfterCompare(compiler, true_condition, &is_true);
+    switch (true_condition) {
+      case EQ: __ beq(CMPRES, ZR, &is_true); break;
+      case NE: __ bne(CMPRES, ZR, &is_true); break;
+      case GT: __ bgtz(CMPRES, &is_true); break;
+      case GE: __ bgez(CMPRES, &is_true); break;
+      case LT: __ bltz(CMPRES, &is_true); break;
+      case LE: __ blez(CMPRES, &is_true); break;
+      default:
+        UNREACHABLE();
+        break;
+    }
     __ LoadObject(result, Bool::False());
     __ b(&done);
     __ Bind(&is_true);
@@ -665,7 +649,7 @@
     EmitAssertBoolean(V0, token_pos(), deopt_id(), locs(), compiler);
   }
   Condition branch_condition = (kind() == Token::kNE) ? NE : EQ;
-  __ CompareObject(CMPRES, TMP1, V0, Bool::True());
+  __ CompareObject(CMPRES, V0, Bool::True());
   branch->EmitBranchOnCondition(compiler, branch_condition);
 }
 
@@ -801,7 +785,7 @@
     return;
   }
   EmitNativeCode(compiler);
-  __ CompareObject(CMPRES, TMP1, V0, Bool::True());
+  __ CompareObject(CMPRES, V0, Bool::True());
   branch->EmitBranchOnCondition(compiler, EQ);
 }
 
@@ -875,25 +859,13 @@
 
 
 LocationSummary* LoadClassIdInstr::MakeLocationSummary() const {
-  const intptr_t kNumInputs = 1;
-  return LocationSummary::Make(kNumInputs,
-                               Location::RequiresRegister(),
-                               LocationSummary::kNoCall);
+  UNIMPLEMENTED();
+  return NULL;
 }
 
 
 void LoadClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
-  Register object = locs()->in(0).reg();
-  Register result = locs()->out().reg();
-  Label load, done;
-  __ andi(CMPRES, object, Immediate(kSmiTagMask));
-  __ bne(CMPRES, ZR, &load);
-  __ LoadImmediate(result, Smi::RawValue(kSmiCid));
-  __ b(&done);
-  __ Bind(&load);
-  __ LoadClassId(result, object);
-  __ SmiTag(result);
-  __ Bind(&done);
+  UNIMPLEMENTED();
 }
 
 
@@ -1022,9 +994,9 @@
       default:
         UNREACHABLE();
     }
-    __ addu(index.reg(), array, index.reg());
-    element_address = Address(index.reg(),
+    __ AddImmediate(index.reg(),
         FlowGraphCompiler::DataOffsetFor(class_id()) - kHeapObjectTag);
+    element_address = Address(array, index.reg());
   }
 
   if ((representation() == kUnboxedDouble) ||
@@ -1034,6 +1006,9 @@
   }
 
   Register result = locs()->out().reg();
+  if ((index_scale() == 1) && index.IsRegister()) {
+    __ SmiUntag(index.reg());
+  }
   switch (class_id()) {
     case kTypedDataInt8ArrayCid:
       ASSERT(index_scale() == 1);
@@ -1086,33 +1061,8 @@
 
 Representation StoreIndexedInstr::RequiredInputRepresentation(
     intptr_t idx) const {
-  // Array can be a Dart object or a pointer to external data.
-  if (idx == 0)  return kNoRepresentation;  // Flexible input representation.
-  if (idx == 1) return kTagged;  // Index is a smi.
-  ASSERT(idx == 2);
-  switch (class_id_) {
-    case kArrayCid:
-    case kOneByteStringCid:
-    case kTypedDataInt8ArrayCid:
-    case kTypedDataUint8ArrayCid:
-    case kExternalTypedDataUint8ArrayCid:
-    case kTypedDataUint8ClampedArrayCid:
-    case kExternalTypedDataUint8ClampedArrayCid:
-    case kTypedDataInt16ArrayCid:
-    case kTypedDataUint16ArrayCid:
-      return kTagged;
-    case kTypedDataInt32ArrayCid:
-    case kTypedDataUint32ArrayCid:
-      return value()->IsSmiValue() ? kTagged : kUnboxedMint;
-    case kTypedDataFloat32ArrayCid:
-    case kTypedDataFloat64ArrayCid:
-      return kUnboxedDouble;
-    case kTypedDataFloat32x4ArrayCid:
-      return kUnboxedFloat32x4;
-    default:
-      UNIMPLEMENTED();
-      return kTagged;
-  }
+  UNIMPLEMENTED();
+  return kTagged;
 }
 
 
@@ -1138,22 +1088,14 @@
     case kTypedDataUint8ArrayCid:
     case kTypedDataUint8ClampedArrayCid:
     case kOneByteStringCid:
-      locs->set_in(2, Location::RegisterOrSmiConstant(value()));
-      break;
     case kTypedDataInt16ArrayCid:
     case kTypedDataUint16ArrayCid:
     case kTypedDataInt32ArrayCid:
     case kTypedDataUint32ArrayCid:
-      locs->set_in(2, Location::WritableRegister());
-      break;
     case kTypedDataFloat32ArrayCid:
-      // TODO(regis): Verify.
-      // Need temp register for float-to-double conversion.
-      locs->AddTemp(Location::RequiresFpuRegister());
-      // Fall through.
-    case kTypedDataFloat64ArrayCid:  // TODO(srdjan): Support Float64 constants.
+    case kTypedDataFloat64ArrayCid:
     case kTypedDataFloat32x4ArrayCid:
-      locs->set_in(2, Location::RequiresFpuRegister());
+      UNIMPLEMENTED();
       break;
     default:
       UNREACHABLE();
@@ -1201,9 +1143,10 @@
       default:
         UNREACHABLE();
     }
-    __ addu(index.reg(), array, index.reg());
-    element_address = Address(index.reg(),
+    __ AddImmediate(index.reg(),
         FlowGraphCompiler::DataOffsetFor(class_id()) - kHeapObjectTag);
+    __ addu(TMP1, array, index.reg());
+    element_address = Address(TMP1);
   }
 
   switch (class_id()) {
@@ -1222,64 +1165,13 @@
     case kTypedDataInt8ArrayCid:
     case kTypedDataUint8ArrayCid:
     case kExternalTypedDataUint8ArrayCid:
-    case kOneByteStringCid: {
-      if (locs()->in(2).IsConstant()) {
-        const Smi& constant = Smi::Cast(locs()->in(2).constant());
-        __ LoadImmediate(TMP, static_cast<int8_t>(constant.Value()));
-        __ sb(TMP, element_address);
-      } else {
-        Register value = locs()->in(2).reg();
-        __ SmiUntag(value);
-        __ sb(value, element_address);
-      }
-      break;
-    }
     case kTypedDataUint8ClampedArrayCid:
-    case kExternalTypedDataUint8ClampedArrayCid: {
-      if (locs()->in(2).IsConstant()) {
-        const Smi& constant = Smi::Cast(locs()->in(2).constant());
-        intptr_t value = constant.Value();
-        // Clamp to 0x0 or 0xFF respectively.
-        if (value > 0xFF) {
-          value = 0xFF;
-        } else if (value < 0) {
-          value = 0;
-        }
-        __ LoadImmediate(TMP, static_cast<int8_t>(value));
-        __ sb(TMP, element_address);
-      } else {
-        Register value = locs()->in(2).reg();
-        Label store_value, bigger, smaller;
-        __ SmiUntag(value);
-        __ BranchUnsignedLess(value, 0xFF + 1, &store_value);
-        __ LoadImmediate(TMP, 0xFF);
-        __ slti(CMPRES, value, Immediate(1));
-        __ movn(TMP, ZR, CMPRES);
-        __ mov(value, TMP);
-        __ Bind(&store_value);
-        __ sb(value, element_address);
-      }
-      break;
-    }
+    case kExternalTypedDataUint8ClampedArrayCid:
+    case kOneByteStringCid:
     case kTypedDataInt16ArrayCid:
-    case kTypedDataUint16ArrayCid: {
-      Register value = locs()->in(2).reg();
-      __ SmiUntag(value);
-      __ sh(value, element_address);
-      break;
-    }
+    case kTypedDataUint16ArrayCid:
     case kTypedDataInt32ArrayCid:
-    case kTypedDataUint32ArrayCid: {
-      if (value()->IsSmiValue()) {
-        ASSERT(RequiredInputRepresentation(2) == kTagged);
-        Register value = locs()->in(2).reg();
-        __ SmiUntag(value);
-        __ sw(value, element_address);
-      } else {
-        UNIMPLEMENTED();
-      }
-      break;
-    }
+    case kTypedDataUint32ArrayCid:
     case kTypedDataFloat32ArrayCid:
     case kTypedDataFloat64ArrayCid:
     case kTypedDataFloat32x4ArrayCid:
@@ -1407,7 +1299,8 @@
 
       if (field().is_nullable() && (field_cid != kNullCid)) {
         __ beq(CMPRES, ZR, &ok);
-        __ subu(CMPRES, value_reg, NULLREG);
+        __ LoadImmediate(TMP1, reinterpret_cast<intptr_t>(Object::null()));
+        __ subu(CMPRES, value_reg, TMP1);
       }
 
       if (ok_is_fall_through) {
@@ -1614,7 +1507,9 @@
     Label type_arguments_instantiated;
     const intptr_t len = type_arguments().Length();
     if (type_arguments().IsRawInstantiatedRaw(len)) {
-      __ beq(instantiator_reg, NULLREG, &type_arguments_instantiated);
+      __ BranchEqual(instantiator_reg,
+                     reinterpret_cast<intptr_t>(Object::null()),
+                     &type_arguments_instantiated);
     }
     // Instantiate non-null type arguments.
     // A runtime call to instantiate the type arguments is required.
@@ -1669,7 +1564,9 @@
   // the type arguments.
   Label type_arguments_instantiated;
   ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length()));
-  __ beq(instantiator_reg, NULLREG, &type_arguments_instantiated);
+  __ BranchEqual(instantiator_reg,
+                 reinterpret_cast<intptr_t>(Object::null()),
+                 &type_arguments_instantiated);
   // Instantiate non-null type arguments.
   // In the non-factory case, we rely on the allocation stub to
   // instantiate the type arguments.
@@ -1709,7 +1606,8 @@
   // the type arguments and do not pass the instantiator.
   ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length()));
   Label instantiator_not_null;
-  __ bne(instantiator_reg, NULLREG, &instantiator_not_null);
+  __ BranchNotEqual(instantiator_reg,
+      reinterpret_cast<intptr_t>(Object::null()), &instantiator_not_null);
   // Null was used in VisitExtractConstructorTypeArguments as the
   // instantiated type arguments, no proper instantiator needed.
   __ LoadImmediate(instantiator_reg,
@@ -1783,10 +1681,10 @@
         Address(FP, stacktrace_var().index() * kWordSize));
 
   Label next;
-  __ mov(TMP, RA);  // Save return adress.
+  __ mov(T0, RA);  // Save return adress.
   // Restore the pool pointer.
   __ bal(&next);  // Branch and link to next instruction to get PC in RA.
-  __ delay_slot()->mov(CMPRES, RA);  // Save PC of the following mov.
+  __ delay_slot()->mov(T1, RA);  // Save PC of the following mov.
 
   // Calculate offset of pool pointer from the PC.
   const intptr_t object_pool_pc_dist =
@@ -1794,8 +1692,8 @@
      compiler->assembler()->CodeSize();
 
   __ Bind(&next);
-  __ mov(RA, TMP);  // Restore return address.
-  __ lw(PP, Address(CMPRES, -object_pool_pc_dist));
+  __ mov(RA, T0);  // Restore return address.
+  __ lw(PP, Address(T1, -object_pool_pc_dist));
 }
 
 
@@ -1858,7 +1756,7 @@
     UNIMPLEMENTED();
     return NULL;
   } else {
-    const intptr_t kNumTemps = op_kind() == Token::kADD ? 1 : 0;
+    const intptr_t kNumTemps = 0;
     LocationSummary* summary =
         new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
     summary->set_in(0, Location::RequiresRegister());
@@ -2510,7 +2408,8 @@
   if (null_check()) {
     Label* deopt = compiler->AddDeoptStub(deopt_id(),
                                           kDeoptCheckClass);
-    __ beq(locs()->in(0).reg(), NULLREG, deopt);
+    __ BranchEqual(locs()->in(0).reg(),
+                  reinterpret_cast<intptr_t>(Object::null()), deopt);
     return;
   }
 
@@ -2763,13 +2662,33 @@
   if (compiler->CanFallThroughTo(false_successor())) {
     // If the next block is the false successor we will fall through to it.
     Label* label = compiler->GetJumpLabel(true_successor());
-    EmitBranchAfterCompare(compiler, true_condition, label);
+    switch (true_condition) {
+      case EQ: __ beq(CMPRES, ZR, label); break;
+      case NE: __ bne(CMPRES, ZR, label); break;
+      case GT: __ bgtz(CMPRES, label); break;
+      case GE: __ bgez(CMPRES, label); break;
+      case LT: __ bltz(CMPRES, label); break;
+      case LE: __ blez(CMPRES, label); break;
+      default:
+        UNREACHABLE();
+        break;
+    }
   } else {
     // If the next block is the true successor we negate comparison and fall
     // through to it.
     Condition false_condition = NegateCondition(true_condition);
     Label* label = compiler->GetJumpLabel(false_successor());
-    EmitBranchAfterCompare(compiler, false_condition, label);
+    switch (false_condition) {
+      case EQ: __ beq(CMPRES, ZR, label); break;
+      case NE: __ bne(CMPRES, ZR, label); break;
+      case GT: __ bgtz(CMPRES, label); break;
+      case GE: __ bgez(CMPRES, label); break;
+      case LT: __ bltz(CMPRES, label); break;
+      case LE: __ blez(CMPRES, label); break;
+      default:
+        UNREACHABLE();
+        break;
+    }
     // Fall through or jump to the true successor.
     if (!compiler->CanFallThroughTo(true_successor())) {
       __ b(compiler->GetJumpLabel(true_successor()));
@@ -2939,11 +2858,11 @@
   Register dest_reg = locs()->in(1).reg();
 
   if (value()->NeedsStoreBuffer()) {
-    __ StoreIntoObject(dest_reg,
-        FieldAddress(dest_reg, offset_in_bytes()), value_reg);
+    __ StoreIntoObject(dest_reg, FieldAddress(dest_reg, offset_in_bytes()),
+                       value_reg);
   } else {
-    __ StoreIntoObjectNoBarrier(dest_reg,
-        FieldAddress(dest_reg, offset_in_bytes()), value_reg);
+    __ StoreIntoObjectNoBarrier(
+        dest_reg, FieldAddress(dest_reg, offset_in_bytes()), value_reg);
   }
 }
 
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc
index 86e07dc..6cb751f 100644
--- a/runtime/vm/intermediate_language_x64.cc
+++ b/runtime/vm/intermediate_language_x64.cc
@@ -785,25 +785,6 @@
 }
 
 
-static Condition FlipCondition(Condition condition) {
-  switch (condition) {
-    case EQUAL:         return EQUAL;
-    case NOT_EQUAL:     return NOT_EQUAL;
-    case LESS:          return GREATER;
-    case LESS_EQUAL:    return GREATER_EQUAL;
-    case GREATER:       return LESS;
-    case GREATER_EQUAL: return LESS_EQUAL;
-    case BELOW:         return ABOVE;
-    case BELOW_EQUAL:   return ABOVE_EQUAL;
-    case ABOVE:         return BELOW;
-    case ABOVE_EQUAL:   return BELOW_EQUAL;
-    default:
-      UNIMPLEMENTED();
-      return EQUAL;
-  }
-}
-
-
 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
                                 const LocationSummary& locs,
                                 Token::Kind kind,
@@ -816,7 +797,7 @@
 
   if (left.IsConstant()) {
     __ CompareObject(right.reg(), left.constant());
-    true_condition = FlipCondition(true_condition);
+    true_condition = FlowGraphCompiler::FlipCondition(true_condition);
   } else if (right.IsConstant()) {
     __ CompareObject(left.reg(), right.constant());
   } else if (right.IsStackSlot()) {
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 7b34a1a..f455a0a 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2299,53 +2299,74 @@
 
 
 bool Class::IsTopLevel() const {
-  return Name() == Symbols::TopLevel().raw();
+  return String::Handle(Name()).Equals("::");
 }
 
 
 RawFunction* Class::LookupDynamicFunction(const String& name) const {
-  return LookupFunction(name, kInstance);
+  Function& function = Function::Handle(LookupFunction(name));
+  if (function.IsNull() || !function.IsDynamicFunction()) {
+    return Function::null();
+  }
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupDynamicFunctionAllowPrivate(
     const String& name) const {
-  return LookupFunctionAllowPrivate(name, kInstance);
+  Function& function = Function::Handle(LookupFunctionAllowPrivate(name));
+  if (function.IsNull() || !function.IsDynamicFunction()) {
+    return Function::null();
+  }
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupStaticFunction(const String& name) const {
-  return LookupFunction(name, kStatic);
+  Function& function = Function::Handle(LookupFunction(name));
+  if (function.IsNull() || !function.IsStaticFunction()) {
+    return Function::null();
+  }
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupStaticFunctionAllowPrivate(const String& name) const {
-  return LookupFunctionAllowPrivate(name, kStatic);
+  Function& function = Function::Handle(LookupFunctionAllowPrivate(name));
+  if (function.IsNull() || !function.IsStaticFunction()) {
+    return Function::null();
+  }
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupConstructor(const String& name) const {
-  return LookupFunction(name, kConstructor);
+  Function& function = Function::Handle(LookupFunction(name));
+  if (function.IsNull() || !function.IsConstructor()) {
+    return Function::null();
+  }
+  ASSERT(!function.is_static());
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupConstructorAllowPrivate(const String& name) const {
-  return LookupFunctionAllowPrivate(name, kConstructor);
+  Function& function = Function::Handle(LookupFunctionAllowPrivate(name));
+  if (function.IsNull() || !function.IsConstructor()) {
+    return Function::null();
+  }
+  ASSERT(!function.is_static());
+  return function.raw();
 }
 
 
 RawFunction* Class::LookupFactory(const String& name) const {
-  return LookupFunction(name, kFactory);
-}
-
-
-RawFunction* Class::LookupFunction(const String& name) const {
-  return LookupFunction(name, kAny);
-}
-
-
-RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const {
-  return LookupFunctionAllowPrivate(name, kAny);
+  Function& function = Function::Handle(LookupFunction(name));
+  if (function.IsNull() || !function.IsFactory()) {
+    return Function::null();
+  }
+  ASSERT(function.is_static());
+  return function.raw();
 }
 
 
@@ -2374,33 +2395,7 @@
 }
 
 
-RawFunction* Class::CheckFunctionType(const Function& func, intptr_t type) {
-  if (type == kInstance) {
-    if (func.IsDynamicFunction()) {
-      return func.raw();
-    }
-  } else if (type == kStatic) {
-    if (func.IsStaticFunction()) {
-      return func.raw();
-    }
-  } else if (type == kConstructor) {
-    if (func.IsConstructor()) {
-      ASSERT(!func.is_static());
-      return func.raw();
-    }
-  } else if (type == kFactory) {
-    if (func.IsFactory()) {
-      ASSERT(func.is_static());
-      return func.raw();
-    }
-  } else if (type == kAny) {
-    return func.raw();
-  }
-  return Function::null();
-}
-
-
-RawFunction* Class::LookupFunction(const String& name, intptr_t type) const {
+RawFunction* Class::LookupFunction(const String& name) const {
   Isolate* isolate = Isolate::Current();
   if (EnsureIsFinalized(isolate) != Error::null()) {
     return Function::null();
@@ -2410,7 +2405,7 @@
     // This can occur, e.g., for Null classes.
     return Function::null();
   }
-  Function& function = Function::Handle(isolate);
+  Function& function = Function::Handle(isolate, Function::null());
   const intptr_t len = funcs.Length();
   if (name.IsSymbol()) {
     // Quick Symbol compare.
@@ -2418,16 +2413,16 @@
     for (intptr_t i = 0; i < len; i++) {
       function ^= funcs.At(i);
       if (function.name() == name.raw()) {
-        return CheckFunctionType(function, type);
+        return function.raw();
       }
     }
   } else {
-    String& function_name = String::Handle(isolate);
+    String& function_name = String::Handle(isolate, String::null());
     for (intptr_t i = 0; i < len; i++) {
       function ^= funcs.At(i);
       function_name ^= function.name();
       if (function_name.Equals(name)) {
-        return CheckFunctionType(function, type);
+        return function.raw();
       }
     }
   }
@@ -2436,8 +2431,7 @@
 }
 
 
-RawFunction* Class::LookupFunctionAllowPrivate(const String& name,
-                                               intptr_t type) const {
+RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const {
   Isolate* isolate = Isolate::Current();
   if (EnsureIsFinalized(isolate) != Error::null()) {
     return Function::null();
@@ -2447,14 +2441,14 @@
     // This can occur, e.g., for Null classes.
     return Function::null();
   }
-  Function& function = Function::Handle(isolate);
-  String& function_name = String::Handle(isolate);
+  Function& function = Function::Handle(isolate, Function::null());
+  String& function_name = String::Handle(isolate, String::null());
   intptr_t len = funcs.Length();
   for (intptr_t i = 0; i < len; i++) {
     function ^= funcs.At(i);
     function_name ^= function.name();
     if (String::EqualsIgnoringPrivateKey(function_name, name)) {
-      return CheckFunctionType(function, type);
+        return function.raw();
     }
   }
   // No function found.
@@ -2523,21 +2517,44 @@
 
 
 RawField* Class::LookupInstanceField(const String& name) const {
-  return LookupField(name, kInstance);
+  Isolate* isolate = Isolate::Current();
+  if (EnsureIsFinalized(isolate) != Error::null()) {
+    return Field::null();
+  }
+  ASSERT(is_finalized());
+  const Field& field = Field::Handle(isolate, LookupField(name));
+  if (!field.IsNull()) {
+    if (field.is_static()) {
+      // Name matches but it is not of the correct kind, return NULL.
+      return Field::null();
+    }
+    return field.raw();
+  }
+  // No field found.
+  return Field::null();
 }
 
 
 RawField* Class::LookupStaticField(const String& name) const {
-  return LookupField(name, kStatic);
+  Isolate* isolate = Isolate::Current();
+  if (EnsureIsFinalized(isolate) != Error::null()) {
+    return Field::null();
+  }
+  ASSERT(is_finalized());
+  const Field& field = Field::Handle(isolate, LookupField(name));
+  if (!field.IsNull()) {
+    if (!field.is_static()) {
+      // Name matches but it is not of the correct kind, return NULL.
+      return Field::null();
+    }
+    return field.raw();
+  }
+  // No field found.
+  return Field::null();
 }
 
 
 RawField* Class::LookupField(const String& name) const {
-  return LookupField(name, kAny);
-}
-
-
-RawField* Class::LookupField(const String& name, intptr_t type) const {
   Isolate* isolate = Isolate::Current();
   if (EnsureIsFinalized(isolate) != Error::null()) {
     return Field::null();
@@ -2550,18 +2567,7 @@
     field ^= flds.At(i);
     field_name ^= field.name();
     if (String::EqualsIgnoringPrivateKey(field_name, name)) {
-      if (type == kInstance) {
-        if (!field.is_static()) {
-          return field.raw();
-        }
-      } else if (type == kStatic) {
-        if (field.is_static()) {
-          return field.raw();
-        }
-      } else if (type == kAny) {
-        return field.raw();
-      }
-      return Field::null();
+      return field.raw();
     }
   }
   // No field found.
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index b38d3ac..480ce5b 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -917,13 +917,6 @@
 
  private:
   enum {
-    kAny = 0,
-    kStatic,
-    kInstance,
-    kConstructor,
-    kFactory,
-  };
-  enum {
     kConstBit = 0,
     kImplementedBit = 1,
     kAbstractBit = 2,
@@ -960,12 +953,6 @@
   // Assigns empty array to all raw class array fields.
   void InitEmptyFields();
 
-  static RawFunction* CheckFunctionType(const Function& func, intptr_t type);
-  RawFunction* LookupFunction(const String& name, intptr_t type) const;
-  RawFunction* LookupFunctionAllowPrivate(const String& name,
-                                          intptr_t type) const;
-  RawField* LookupField(const String& name, intptr_t type) const;
-
   RawFunction* LookupAccessorFunction(const char* prefix,
                                       intptr_t prefix_length,
                                       const String& name) const;
diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc
index 17d8ae6..4e161c6 100644
--- a/runtime/vm/simulator_arm.cc
+++ b/runtime/vm/simulator_arm.cc
@@ -114,13 +114,11 @@
   bool GetFValue(char* desc, float* value);
   bool GetDValue(char* desc, double* value);
 
-  static intptr_t GetApproximateTokenIndex(const Code& code, uword pc);
-
-  static void PrintDartFrame(uword pc, uword fp, uword sp,
-                             const Function& function,
-                             intptr_t token_pos,
-                             bool is_optimized,
-                             bool is_inlined);
+  void PrintDartFrame(uword pc, uword fp, uword sp,
+                      const Function& function,
+                      intptr_t token_pos,
+                      bool is_optimized,
+                      bool is_inlined);
   void PrintBacktrace();
 
   // Set or delete a breakpoint. Returns true if successful.
@@ -264,23 +262,6 @@
 }
 
 
-intptr_t SimulatorDebugger::GetApproximateTokenIndex(const Code& code,
-                                                     uword pc) {
-  intptr_t token_pos = -1;
-  const PcDescriptors& descriptors =
-      PcDescriptors::Handle(code.pc_descriptors());
-  for (intptr_t i = 0; i < descriptors.Length(); i++) {
-    if (descriptors.PC(i) == pc) {
-      token_pos = descriptors.TokenPos(i);
-      break;
-    } else if ((token_pos <= 0) && (descriptors.PC(i) > pc)) {
-      token_pos = descriptors.TokenPos(i);
-    }
-  }
-  return token_pos;
-}
-
-
 void SimulatorDebugger::PrintDartFrame(uword pc, uword fp, uword sp,
                                        const Function& function,
                                        intptr_t token_pos,
@@ -332,8 +313,7 @@
           if (!it.Done()) {
             PrintDartFrame(unoptimized_pc, frame->fp(), frame->sp(),
                            inlined_function,
-                           GetApproximateTokenIndex(unoptimized_code,
-                                                    unoptimized_pc),
+                           unoptimized_code.GetTokenIndexOfPC(unoptimized_pc),
                            true, true);
           }
         }
@@ -341,7 +321,7 @@
       }
       PrintDartFrame(frame->pc(), frame->fp(), frame->sp(),
                      function,
-                     GetApproximateTokenIndex(code, frame->pc()),
+                     code.GetTokenIndexOfPC(frame->pc()),
                      code.is_optimized(), false);
     } else {
       OS::Print("pc=0x%"Px" fp=0x%"Px" sp=0x%"Px" %s frame\n",
diff --git a/runtime/vm/simulator_mips.cc b/runtime/vm/simulator_mips.cc
index 0da94b0..393e261 100644
--- a/runtime/vm/simulator_mips.cc
+++ b/runtime/vm/simulator_mips.cc
@@ -1762,20 +1762,6 @@
       }
       break;
     }
-    case SLTI: {
-      // Format(instr, "slti 'rt, 'rs, 'imms");
-      int32_t rs_val = get_register(instr->RsField());
-      int32_t imm_val = instr->SImmField();
-      set_register(instr->RtField(), rs_val < imm_val ? 1 : 0);
-      break;
-    }
-    case SLTIU: {
-      // Format(instr, "slti 'rt, 'rs, 'immu");
-      uint32_t rs_val = get_register(instr->RsField());
-      uint32_t imm_val = instr->UImmField();
-      set_register(instr->RtField(), rs_val < imm_val ? 1 : 0);
-      break;
-    }
     case SDC1: {
       // Format(instr, "sdc1 'ft, 'imms('rs)");
       int32_t base_val = get_register(instr->RsField());
diff --git a/runtime/vm/stub_code_arm.cc b/runtime/vm/stub_code_arm.cc
index 1491ec3..0b8a041 100644
--- a/runtime/vm/stub_code_arm.cc
+++ b/runtime/vm/stub_code_arm.cc
@@ -437,9 +437,13 @@
   // Push arguments descriptor array.
   __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null()));
   __ PushList((1 << R4) | (1 << R5) | (1 << R6) | (1 << IP));
+
+  // R2: Smi-tagged arguments array length.
+  PushArgumentsArray(assembler);
+
   __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry);
   // Remove arguments.
-  __ Drop(3);
+  __ Drop(4);
   __ Pop(R0);  // Get result into R0.
 
   // Restore IC data and arguments descriptor.
diff --git a/runtime/vm/stub_code_ia32.cc b/runtime/vm/stub_code_ia32.cc
index 1acfc81..0657984 100644
--- a/runtime/vm/stub_code_ia32.cc
+++ b/runtime/vm/stub_code_ia32.cc
@@ -448,7 +448,7 @@
   __ pushl(raw_null);  // Space for the result of the runtime call.
   __ pushl(EAX);  // Pass receiver.
   __ pushl(ECX);  // Pass IC data.
-  __ pushl(EDX);  // Pass arguments descriptor.
+  __ pushl(EDX);  // Pass rguments descriptor.
   __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry);
   // Discard arguments.
   __ popl(EAX);
diff --git a/runtime/vm/stub_code_mips.cc b/runtime/vm/stub_code_mips.cc
index 39d3357..5881403 100644
--- a/runtime/vm/stub_code_mips.cc
+++ b/runtime/vm/stub_code_mips.cc
@@ -111,22 +111,8 @@
 }
 
 
-// Print the stop message.
-DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, const char* message) {
-  OS::Print("Stop message: %s\n", message);
-}
-END_LEAF_RUNTIME_ENTRY
-
-
-// Input parameters:
-//   A0 : stop message (const char*).
-// Must preserve all registers.
 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) {
-  __ EnterCallRuntimeFrame(0);
-  // Call the runtime leaf function. A0 already contains the parameter.
-  __ CallRuntime(kPrintStopMessageRuntimeEntry);
-  __ LeaveCallRuntimeFrame();
-  __ Ret();
+  __ Unimplemented("PrintStopMessage stub");
 }
 
 
@@ -253,7 +239,6 @@
 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) {
   // Create a stub frame as we are pushing some objects on the stack before
   // calling into the runtime.
-  __ TraceSimMsg("FixCallersTarget");
   __ EnterStubFrame();
   // Setup space on stack for return value and preserve arguments descriptor.
   __ addiu(SP, SP, Immediate(-2 * kWordSize));
@@ -339,6 +324,17 @@
   PushArgumentsArray(assembler);
   __ TraceSimMsg("InstanceFunctionLookupStub return");
 
+  // Stack:
+  // TOS + 0: argument array.
+  // TOS + 1: arguments descriptor array.
+  // TOS + 2: IC data object.
+  // TOS + 3: Receiver.
+  // TOS + 4: place for result from the call.
+  // TOS + 5: saved FP of previous frame.
+  // TOS + 6: dart code return address
+  // TOS + 7: pc marker (0 for stub).
+  // TOS + 8: last argument of caller.
+  // ....
   __ CallRuntime(kInstanceFunctionLookupRuntimeEntry);
 
   __ lw(V0, Address(SP, 4 * kWordSize));  // Get result into V0.
@@ -355,8 +351,6 @@
 DECLARE_LEAF_RUNTIME_ENTRY(void, DeoptimizeFillFrame, uword last_fp);
 
 
-
-
 // Used by eager and lazy deoptimization. Preserve result in V0 if necessary.
 // This stub translates optimized frame into unoptimized frame. The optimized
 // frame can contain values in registers and on stack, the unoptimized
@@ -370,53 +364,42 @@
 // GC can occur only after frame is fully rewritten.
 // Stack after EnterFrame(...) below:
 //   +------------------+
-//   | Saved PP         | <- TOS
+//   | Saved FP         | <- TOS
 //   +------------------+
-//   | Saved FP         | <- FP of stub
+//   | return-address   |  (deoptimization point)
 //   +------------------+
-//   | Saved LR         |  (deoptimization point)
-//   +------------------+
-//   | PC marker        |
-//   +------------------+
-//   | ...              | <- SP of optimized frame
+//   | optimized frame  |
+//   |  ...             |
 //
 // Parts of the code cannot GC, part of the code can GC.
 static void GenerateDeoptimizationSequence(Assembler* assembler,
                                            bool preserve_result) {
-  __ TraceSimMsg("GenerateDeoptimizationSequence");
   const intptr_t kPushedRegistersSize =
       kNumberOfCpuRegisters * kWordSize +
-      4 * kWordSize +  // PP, FP, RA, PC marker.
+      2 * kWordSize +  // FP and RA.
       kNumberOfFRegisters * kWordSize;
 
-  // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there
-  // is no need to set the correct PC marker or load PP, since they get patched.
   __ addiu(SP, SP, Immediate(-kPushedRegistersSize * kWordSize));
-  __ sw(ZR, Address(SP, kPushedRegistersSize - 1 * kWordSize));
-  __ sw(RA, Address(SP, kPushedRegistersSize - 2 * kWordSize));
-  __ sw(FP, Address(SP, kPushedRegistersSize - 3 * kWordSize));
-  __ sw(PP, Address(SP, kPushedRegistersSize - 4 * kWordSize));
-  __ addiu(FP, SP, Immediate(kPushedRegistersSize - 3 * kWordSize));
+  __ sw(RA, Address(SP, kPushedRegistersSize - 1 * kWordSize));
+  __ sw(FP, Address(SP, kPushedRegistersSize - 2 * kWordSize));
+  __ addiu(FP, SP, Immediate(kPushedRegistersSize - 2 * kWordSize));
+
 
   // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry
   // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls.
-  const intptr_t saved_result_slot_from_fp =
-      kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - V0);
+  const intptr_t saved_v0_offset_from_fp = -(kNumberOfCpuRegisters - V0);
   // Result in V0 is preserved as part of pushing all registers below.
 
-  // TODO(regis): Should we align the stack before pushing the fpu registers?
-  // If we do, saved_result_slot_from_fp is not constant anymore.
-
   // Push registers in their enumeration order: lowest register number at
   // lowest address.
   for (int i = 0; i < kNumberOfCpuRegisters; i++) {
-    const int slot = 4 + kNumberOfCpuRegisters - i;
+    const int slot = 2 + kNumberOfCpuRegisters - i;
     Register reg = static_cast<Register>(i);
     __ sw(reg, Address(SP, kPushedRegistersSize - slot * kWordSize));
   }
   for (int i = 0; i < kNumberOfFRegisters; i++) {
     // These go below the CPU registers.
-    const int slot = 4 + kNumberOfCpuRegisters + kNumberOfFRegisters - i;
+    const int slot = 2 + kNumberOfCpuRegisters + kNumberOfFRegisters - i;
     FRegister reg = static_cast<FRegister>(i);
     __ swc1(reg, Address(SP, kPushedRegistersSize - slot * kWordSize));
   }
@@ -428,40 +411,38 @@
 
   if (preserve_result) {
     // Restore result into T1 temporarily.
-    __ lw(T1, Address(FP, saved_result_slot_from_fp * kWordSize));
+    __ lw(T1, Address(FP, saved_v0_offset_from_fp * kWordSize));
   }
 
-  __ addiu(SP, FP, Immediate(-kWordSize));
-  __ lw(RA, Address(SP, 2 * kWordSize));
-  __ lw(FP, Address(SP, 1 * kWordSize));
-  __ lw(PP, Address(SP, 0 * kWordSize));
+  __ mov(SP, FP);
+  __ lw(FP, Address(SP, 0 * kWordSize));
+  __ lw(RA, Address(SP, 1 * kWordSize));
+  __ addiu(SP, SP, Immediate(2 * kWordSize));
+
   __ subu(SP, FP, V0);
 
-  // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there
-  // is no need to set the correct PC marker or load PP, since they get patched.
-  __ addiu(SP, SP, Immediate(-4 * kWordSize));
-  __ sw(ZR, Address(SP, 3 * kWordSize));
-  __ sw(RA, Address(SP, 2 * kWordSize));
-  __ sw(FP, Address(SP, 1 * kWordSize));
-  __ sw(PP, Address(SP, 0 * kWordSize));
-  __ addiu(FP, SP, Immediate(kWordSize));
+  __ addiu(SP, SP, Immediate(-2 * kWordSize));
+  __ sw(RA, Address(SP, 1 * kWordSize));
+  __ sw(FP, Address(SP, 0 * kWordSize));
+  __ mov(FP, SP);
 
-  __ mov(A0, FP);  // Get last FP address.
+  __ mov(A0, SP);  // Get last FP address.
   if (preserve_result) {
-    __ Push(T1);  // Preserve result as first local.
+    __ Push(T1);  // Preserve result.
   }
   __ ReserveAlignedFrameSpace(0);
   __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry);  // Pass last FP in A0.
+  // Result (V0) is our FP.
   if (preserve_result) {
     // Restore result into T1.
-    __ lw(T1, Address(FP, kFirstLocalSlotFromFp * kWordSize));
+    __ lw(T1, Address(FP, -1 * kWordSize));
   }
   // Code above cannot cause GC.
-  __ addiu(SP, FP, Immediate(-kWordSize));
-  __ lw(RA, Address(SP, 2 * kWordSize));
-  __ lw(FP, Address(SP, 1 * kWordSize));
-  __ lw(PP, Address(SP, 0 * kWordSize));
-  __ addiu(SP, SP, Immediate(4 * kWordSize));
+  __ mov(SP, FP);
+  __ lw(FP, Address(SP, 0 * kWordSize));
+  __ lw(RA, Address(SP, 1 * kWordSize));
+  __ addiu(SP, SP, Immediate(2 * kWordSize));
+  __ mov(FP, V0);
 
   // Frame is fully rewritten at this point and it is safe to perform a GC.
   // Materialize any objects that were deferred by FillFrame because they
@@ -475,22 +456,20 @@
   // Result tells stub how many bytes to remove from the expression stack
   // of the bottom-most frame. They were used as materialization arguments.
   __ Pop(T1);
+  __ SmiUntag(T1);
   if (preserve_result) {
     __ Pop(V0);  // Restore result.
   }
   __ LeaveStubFrame();
-  // Remove materialization arguments.
-  __ SmiUntag(T1);
-  __ addu(SP, SP, T1);
-  __ Ret();
+
+  // Return.
+  __ jr(RA);
+  __ delay_slot()->addu(SP, SP, T1);  // Remove materialization arguments.
 }
 
 
 void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) {
-  // Correct return address to point just after the call that is being
-  // deoptimized.
-  __ AddImmediate(RA, -CallPattern::kFixedLengthInBytes);
-  GenerateDeoptimizationSequence(assembler, true);  // Preserve V0.
+  __ Unimplemented("DeoptimizeLazy stub");
 }
 
 
@@ -501,7 +480,6 @@
 
 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) {
   __ Unimplemented("MegamorphicMiss stub");
-  return;
 }
 
 
@@ -888,7 +866,6 @@
 // Output:
 //   V0: new allocated RawContext object.
 void StubCode::GenerateAllocateContextStub(Assembler* assembler) {
-  __ TraceSimMsg("AllocateContext");
   if (FLAG_inline_alloc) {
     const Class& context_class = Class::ZoneHandle(Object::context_class());
     Label slow_case;
@@ -1780,7 +1757,6 @@
 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) {
   // Create a stub frame as we are pushing some objects on the stack before
   // calling into the runtime.
-  __ TraceSimMsg("BreakpointDynamicStub");
   __ EnterStubFrame();
   __ addiu(SP, SP, Immediate(-2 * kWordSize));
   __ sw(S5, Address(SP, 1 * kWordSize));
@@ -2161,8 +2137,6 @@
   __ Bind(&reference_compare);
   __ subu(ret, left, right);
   __ Bind(&done);
-  // A branch or test after this comparison will check CMPRES == TMP1.
-  __ mov(TMP1, ZR);
   __ lw(T0, Address(SP, 0 * kWordSize));
   __ lw(T1, Address(SP, 1 * kWordSize));
   __ Ret();
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart
index abc2468..d1f8516 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -134,11 +134,11 @@
       return commandFuture;
     }).whenComplete(() => cache.deleteTempDir()).catchError((e) {
       if (e is PubspecNotFoundException && e.name == null) {
-        e = new ApplicationException('Could not find a file named '
-            '"pubspec.yaml" in the directory ${path.current}.');
+        e = 'Could not find a file named "pubspec.yaml" in the directory '
+          '${path.current}.';
       } else if (e is PubspecHasNoNameException && e.name == null) {
-        e = new ApplicationException('pubspec.yaml is missing the required '
-            '"name" field (e.g. "name: ${path.basename(path.current)}").');
+        e = 'pubspec.yaml is missing the required "name" field (e.g. "name: '
+          '${path.basename(path.current)}").';
       }
 
       handleError(e);
diff --git a/sdk/lib/_internal/pub/lib/src/command_lish.dart b/sdk/lib/_internal/pub/lib/src/command_lish.dart
index bb40f91..9fc723c 100644
--- a/sdk/lib/_internal/pub/lib/src/command_lish.dart
+++ b/sdk/lib/_internal/pub/lib/src/command_lish.dart
@@ -87,7 +87,7 @@
         // TODO(nweiz): the response may have XML-formatted information about
         // the error. Try to parse that out once we have an easily-accessible
         // XML parser.
-        throw new ApplicationException('Failed to upload the package.');
+        throw new Exception('Failed to upload the package.');
       } else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) {
         handleJsonError(error.response);
       } else {
diff --git a/sdk/lib/_internal/pub/lib/src/package.dart b/sdk/lib/_internal/pub/lib/src/package.dart
index 22d3bee..a2a1b12 100644
--- a/sdk/lib/_internal/pub/lib/src/package.dart
+++ b/sdk/lib/_internal/pub/lib/src/package.dart
@@ -11,7 +11,6 @@
 import 'io.dart';
 import 'pubspec.dart';
 import 'source_registry.dart';
-import 'utils.dart';
 import 'version.dart';
 
 final _README_REGEXP = new RegExp(r"^README($|\.)", caseSensitive: false);
@@ -191,30 +190,29 @@
   }
 }
 
-class PubspecNotFoundException extends ApplicationException {
+class PubspecNotFoundException implements Exception {
   final String name;
 
-  PubspecNotFoundException(String name)
-      : name = name,
-        super('Package "$name" doesn\'t have a pubspec.yaml file.');
+  PubspecNotFoundException(this.name);
+
+  String toString() => 'Package "$name" doesn\'t have a pubspec.yaml file.';
 }
 
-class PubspecHasNoNameException extends ApplicationException {
+class PubspecHasNoNameException implements Exception {
   final String name;
 
-  PubspecHasNoNameException(String name)
-      : name = name,
-        super('Package "$name"\'s pubspec.yaml file is missing the '
-              'required "name" field (e.g. "name: $name").');
+  PubspecHasNoNameException(this.name);
+
+  String toString() => 'Package "$name"\'s pubspec.yaml file is missing the '
+    'required "name" field (e.g. "name: $name").';
 }
 
-class PubspecNameMismatchException extends ApplicationException {
+class PubspecNameMismatchException implements Exception {
   final String expectedName;
   final String actualName;
 
-  PubspecNameMismatchException(String expectedName, String actualName)
-      : expectedName = expectedName,
-        actualName = actualName,
-        super('The name you specified for your dependency, "$expectedName", '
-              'doesn\'t match the name "$actualName" in its pubspec.');
+  PubspecNameMismatchException(this.expectedName, this.actualName);
+
+  String toString() => 'The name you specified for your dependency, '
+    '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
 }
diff --git a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
index e2b7b5b..7b6713b 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart
@@ -176,6 +176,29 @@
   SolveFailure(this.package, Iterable<Dependency> dependencies)
       : dependencies = dependencies != null ? dependencies : <Dependency>[];
 
+  /// Writes [dependencies] to [buffer] as a bullet list. If [describe] is
+  /// passed, it will be called for each dependency and the result will be
+  /// written next to the dependency.
+  void writeDependencies(StringBuffer buffer,
+      [String describe(PackageDep dep)]) {
+    var map = {};
+    for (var dep in dependencies) {
+      map[dep.depender] = dep.dep;
+    }
+
+    var names = map.keys.toList();
+    names.sort();
+
+    for (var name in names) {
+      buffer.writeln("- '$name' ");
+      if (describe != null) {
+        buffer.writeln(describe(map[name]));
+      } else {
+        buffer.writeln("depends on version ${map[name].constraint}");
+      }
+    }
+  }
+
   String toString() {
     if (dependencies.isEmpty) return _message;
 
@@ -190,8 +213,9 @@
     var names = map.keys.toList();
     names.sort();
 
-    buffer.writeAll(names.map(
-        (name) => "- '$name' ${_describeDependency(map[name])}"), '\n');
+    for (var name in names) {
+      buffer.writeln("- '$name' ${_describeDependency(map[name])}");
+    }
 
     return buffer.toString();
   }
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 76defb0..0311c9d 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -472,8 +472,8 @@
     // TODO(nweiz): Serialize using the YAML library once it supports
     // serialization.
 
-    // Use indentation for (non-empty) maps.
-    if (data is Map && !data.isEmpty) {
+    // Use indentation for maps.
+    if (data is Map) {
       if (isMapValue) {
         buffer.writeln();
         indent += '  ';
diff --git a/sdk/lib/_internal/pub/test/deploy/copies_dart_js_next_to_entrypoints_test.dart b/sdk/lib/_internal/pub/test/deploy/copies_dart_js_next_to_entrypoints_test.dart
index 7eecff3..d95b3d9 100644
--- a/sdk/lib/_internal/pub/test/deploy/copies_dart_js_next_to_entrypoints_test.dart
+++ b/sdk/lib/_internal/pub/test/deploy/copies_dart_js_next_to_entrypoints_test.dart
@@ -45,7 +45,8 @@
       ])
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     schedulePub(args: ["deploy"],
         output: '''
diff --git a/sdk/lib/_internal/pub/test/dev_dependency_test.dart b/sdk/lib/_internal/pub/test/dev_dependency_test.dart
index 88df801..1e37807 100644
--- a/sdk/lib/_internal/pub/test/dev_dependency_test.dart
+++ b/sdk/lib/_internal/pub/test/dev_dependency_test.dart
@@ -30,7 +30,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
@@ -64,7 +65,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
@@ -102,7 +104,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
diff --git a/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_missing_package_test.dart b/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_missing_package_test.dart
index 5d79470..675e52e 100644
--- a/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_missing_package_test.dart
+++ b/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_missing_package_test.dart
@@ -18,8 +18,8 @@
 
       d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
-      pubCommand(command, error: new RegExp(
-          r'Could not find package "foo" at http://localhost:\d+\.$'));
+      pubCommand(command, error:
+          new RegExp('Could not find package "foo" at http://localhost:'));
     });
   });
 }
diff --git a/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_url_resolve_test.dart b/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_url_resolve_test.dart
index f6f4628..49742d3 100644
--- a/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_url_resolve_test.dart
+++ b/sdk/lib/_internal/pub/test/hosted/fail_gracefully_on_url_resolve_test.dart
@@ -28,7 +28,8 @@
         })
       ]).create();
 
-      pubCommand(command, error: 'Could not resolve URL "http://pub.invalid".');
+      pubCommand(command, error:
+        new RegExp('Could not resolve URL "http://pub.invalid".'));
     });
   });
 }
diff --git a/sdk/lib/_internal/pub/test/hosted/offline_test.dart b/sdk/lib/_internal/pub/test/hosted/offline_test.dart
index 3019a6b..eaca7f2 100644
--- a/sdk/lib/_internal/pub/test/hosted/offline_test.dart
+++ b/sdk/lib/_internal/pub/test/hosted/offline_test.dart
@@ -50,7 +50,7 @@
       ]).create();
 
       pubCommand(command, args: ['--offline'],
-          error: 'Could not find package "foo" in cache.');
+          error: new RegExp('Could not find package "foo" in cache'));
     });
 
     integration('fails gracefully no cached versions match', () {
@@ -65,9 +65,8 @@
         dependencyMap("foo", ">2.0.0")
       ]).create();
 
-      pubCommand(command, args: ['--offline'], error:
-          "Package 'foo' has no versions that match >2.0.0 derived from:\n"
-          "- 'myapp' depends on version >2.0.0");
+      pubCommand(command, args: ['--offline'],
+          error: new RegExp("Package 'foo' has no versions that match >2.0.0"));
     });
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/broken_symlink_test.dart b/sdk/lib/_internal/pub/test/install/broken_symlink_test.dart
index 2d9e551..7b627b2 100644
--- a/sdk/lib/_internal/pub/test/install/broken_symlink_test.dart
+++ b/sdk/lib/_internal/pub/test/install/broken_symlink_test.dart
@@ -23,7 +23,8 @@
     // Create a broken "packages" symlink in "bin".
     scheduleSymlink("nonexistent", path.join(appPath, "packages"));
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(appPath, [
       d.dir("bin", [
@@ -46,7 +47,8 @@
     // Create a broken "packages" symlink in "bin".
     scheduleSymlink("nonexistent", path.join(appPath, "bin", "packages"));
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(appPath, [
       d.dir("bin", [
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_and_update_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_and_update_test.dart
index b606972..3af7fb7 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_and_update_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_and_update_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(cachePath, [
       d.dir('git', [
@@ -41,7 +42,8 @@
       d.libPubspec('foo', '1.0.0')
     ]).commit();
 
-    pubUpdate();
+    schedulePub(args: ['update'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     // When we download a new version of the git package, we should re-use the
     // git/cache directory but create a new git/ directory.
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_branch_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_branch_test.dart
index 3e5aef0..2df0198 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_branch_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_branch_test.dart
@@ -28,7 +28,8 @@
 
     d.appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_revision_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_revision_test.dart
index cd1587a..b763dd4 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_revision_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_revision_test.dart
@@ -28,7 +28,8 @@
 
     d.appDir([{"git": {"url": "../foo.git", "ref": commit}}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_test.dart
index 9c36368..c2a4f68 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(cachePath, [
       d.dir('git', [
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_transitive_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_transitive_test.dart
index d07b3e2..d68763c 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_transitive_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_transitive_test.dart
@@ -26,7 +26,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.dir(cachePath, [
       d.dir('git', [
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_twice_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_twice_test.dart
index 2aef954..87d9a94 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_twice_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_twice_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(cachePath, [
       d.dir('git', [
@@ -38,6 +39,7 @@
 
     // Verify that nothing breaks if we install a Git revision that's already
     // in the cache.
-    pubUpdate();
+    schedulePub(args: ['update'],
+        output: new RegExp(r"Dependencies updated!$"));
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/git/check_out_with_trailing_slash_test.dart b/sdk/lib/_internal/pub/test/install/git/check_out_with_trailing_slash_test.dart
index 5162b2f..e414483 100644
--- a/sdk/lib/_internal/pub/test/install/git/check_out_with_trailing_slash_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/check_out_with_trailing_slash_test.dart
@@ -24,7 +24,8 @@
 
       d.appDir([{"git": "../foo.git/"}]).create();
 
-      pubInstall();
+      schedulePub(args: ['install'],
+          output: new RegExp(r"Dependencies installed!$"));
 
       d.dir(cachePath, [
         d.dir('git', [
diff --git a/sdk/lib/_internal/pub/test/install/git/dependency_name_match_pubspec_test.dart b/sdk/lib/_internal/pub/test/install/git/dependency_name_match_pubspec_test.dart
index c6f89ee..c1e5572 100644
--- a/sdk/lib/_internal/pub/test/install/git/dependency_name_match_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/dependency_name_match_pubspec_test.dart
@@ -29,8 +29,12 @@
       })
     ]).create();
 
-    pubInstall(error:
-        'The name you specified for your dependency, "weirdname", doesn\'t '
-        'match the name "foo" in its pubspec.');
+    // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is
+    // fixed.
+    schedulePub(args: ['install'],
+        error: new RegExp(r'^The name you specified for your dependency, '
+            '"weirdname", doesn\'t match the name "foo" in its '
+            r'pubspec\.'),
+        exitCode: 1);
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/git/different_repo_name_test.dart b/sdk/lib/_internal/pub/test/install/git/different_repo_name_test.dart
index 0203f9b..3e5378c 100644
--- a/sdk/lib/_internal/pub/test/install/git/different_repo_name_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/different_repo_name_test.dart
@@ -29,7 +29,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('weirdname', [
diff --git a/sdk/lib/_internal/pub/test/install/git/lock_version_test.dart b/sdk/lib/_internal/pub/test/install/git/lock_version_test.dart
index 8eb7087..ed4994b 100644
--- a/sdk/lib/_internal/pub/test/install/git/lock_version_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/lock_version_test.dart
@@ -26,7 +26,8 @@
     d.appDir([{"git": "../foo.git"}]).create();
 
     // This install should lock the foo.git dependency to the current revision.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -43,7 +44,8 @@
     ]).commit();
 
     // This install shouldn't update the foo.git dependency due to the lockfile.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/install/git/require_pubspec_name_test.dart b/sdk/lib/_internal/pub/test/install/git/require_pubspec_name_test.dart
index eafd067..aad6a52 100644
--- a/sdk/lib/_internal/pub/test/install/git/require_pubspec_name_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/require_pubspec_name_test.dart
@@ -24,8 +24,9 @@
 
     // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is
     // fixed.
-    pubInstall(error:
-        'Package "foo"\'s pubspec.yaml file is '
-        'missing the required "name" field (e.g. "name: foo").');
+    schedulePub(args: ['install'],
+        error: new RegExp(r'^Package "foo"' "'" 's pubspec.yaml file is '
+            r'missing the required "name" field \(e\.g\. "name: foo"\)\.'),
+        exitCode: 1);
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/git/require_pubspec_test.dart b/sdk/lib/_internal/pub/test/install/git/require_pubspec_test.dart
index ba2b5c6..ad1a22d 100644
--- a/sdk/lib/_internal/pub/test/install/git/require_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/require_pubspec_test.dart
@@ -22,6 +22,9 @@
 
     // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is
     // fixed.
-    pubInstall(error: 'Package "foo" doesn\'t have a pubspec.yaml file.');
+    schedulePub(args: ['install'],
+        error: new RegExp('^Package "foo" doesn\'t have a '
+            'pubspec.yaml file.'),
+        exitCode: 1);
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/git/stay_locked_if_compatible_test.dart b/sdk/lib/_internal/pub/test/install/git/stay_locked_if_compatible_test.dart
index f59b93b..8bc5025 100644
--- a/sdk/lib/_internal/pub/test/install/git/stay_locked_if_compatible_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/stay_locked_if_compatible_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -37,7 +38,8 @@
 
     d.appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/install/git/unlock_if_incompatible_test.dart b/sdk/lib/_internal/pub/test/install/git/unlock_if_incompatible_test.dart
index 644650b..1b23fba 100644
--- a/sdk/lib/_internal/pub/test/install/git/unlock_if_incompatible_test.dart
+++ b/sdk/lib/_internal/pub/test/install/git/unlock_if_incompatible_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -37,7 +38,8 @@
 
     d.appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/install/hosted/cached_pubspec_test.dart b/sdk/lib/_internal/pub/test/install/hosted/cached_pubspec_test.dart
index 5949d4b..153431a 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/cached_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/cached_pubspec_test.dart
@@ -20,7 +20,8 @@
     d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
     // Run install once so it gets cached.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     // Clear the cache. We don't care about anything that was served during
     // the initial install.
@@ -30,7 +31,8 @@
     d.packagesDir({"foo": "1.2.3"}).validate();
 
     // Run the solver again now that it's cached.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     // The update should not have requested the pubspec since it's installed
     // locally already.
diff --git a/sdk/lib/_internal/pub/test/install/hosted/do_not_update_on_removed_constraints_test.dart b/sdk/lib/_internal/pub/test/install/hosted/do_not_update_on_removed_constraints_test.dart
index 9184b83..539d263 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/do_not_update_on_removed_constraints_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/do_not_update_on_removed_constraints_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("bar")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -32,7 +33,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
diff --git a/sdk/lib/_internal/pub/test/install/hosted/install_test.dart b/sdk/lib/_internal/pub/test/install/hosted/install_test.dart
index 375860a..5db5553 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/install_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/install_test.dart
@@ -16,7 +16,8 @@
 
     d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.cacheDir({"foo": "1.2.3"}).validate();
     d.packagesDir({"foo": "1.2.3"}).validate();
@@ -27,7 +28,9 @@
 
     d.appDir([dependencyMap("bad name!", "1.2.3")]).create();
 
-    pubInstall(error: new RegExp(
-        r'Could not find package "bad name!" at http://localhost:\d+\.$'));
+    schedulePub(args: ['install'],
+        error: new RegExp('Could not find package "bad name!" at '
+                          'http://localhost:'),
+        exitCode: 1);
   });
 }
diff --git a/sdk/lib/_internal/pub/test/install/hosted/install_transitive_test.dart b/sdk/lib/_internal/pub/test/install/hosted/install_transitive_test.dart
index e474897..7da990f5 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/install_transitive_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/install_transitive_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.cacheDir({"foo": "1.2.3", "bar": "2.0.4"}).validate();
     d.packagesDir({"foo": "1.2.3", "bar": "2.0.4"}).validate();
diff --git a/sdk/lib/_internal/pub/test/install/hosted/repair_cache_test.dart b/sdk/lib/_internal/pub/test/install/hosted/repair_cache_test.dart
index 94874ad..a343cc4 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/repair_cache_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/repair_cache_test.dart
@@ -30,7 +30,8 @@
 
     d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.cacheDir({"foo": "1.2.3"}).validate();
     d.packagesDir({"foo": "1.2.3"}).validate();
@@ -53,7 +54,8 @@
 
     d.appDir([dependencyMap("foo", "1.2.3")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.cacheDir({"foo": "1.2.3"}).validate();
     d.packagesDir({"foo": "1.2.3"}).validate();
diff --git a/sdk/lib/_internal/pub/test/install/hosted/resolve_constraints_test.dart b/sdk/lib/_internal/pub/test/install/hosted/resolve_constraints_test.dart
index 522f21a..0da297a 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/resolve_constraints_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/resolve_constraints_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("bar")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.cacheDir({
       "foo": "1.2.3",
diff --git a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_compatible_test.dart b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_compatible_test.dart
index dfe1b50..7c08ab5 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_compatible_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_compatible_test.dart
@@ -17,7 +17,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.0"}).validate();
 
@@ -25,7 +26,8 @@
 
     d.appDir([dependencyMap("foo", ">=1.0.0")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.0"}).validate();
   });
diff --git a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_new_is_satisfied_test.dart b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_new_is_satisfied_test.dart
index 1f57d92..fd2f244 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_new_is_satisfied_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_new_is_satisfied_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -38,7 +39,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("newdep")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
diff --git a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_test.dart b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_test.dart
index 4cbafe3..188012e 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/stay_locked_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/stay_locked_test.dart
@@ -22,7 +22,8 @@
     d.appDir([dependencyMap("foo")]).create();
 
     // This install should lock the foo dependency to version 1.0.0.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.0"}).validate();
 
@@ -33,7 +34,8 @@
     servePackages([packageMap("foo", "1.0.1")]);
 
     // This install shouldn't update the foo dependency due to the lockfile.
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.0"}).validate();
   });
diff --git a/sdk/lib/_internal/pub/test/install/hosted/unlock_if_incompatible_test.dart b/sdk/lib/_internal/pub/test/install/hosted/unlock_if_incompatible_test.dart
index 348a400..082a36c 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/unlock_if_incompatible_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/unlock_if_incompatible_test.dart
@@ -17,13 +17,17 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.0"}).validate();
+
     servePackages([packageMap("foo", "1.0.1")]);
+
     d.appDir([dependencyMap("foo", ">1.0.0")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({"foo": "1.0.1"}).validate();
   });
diff --git a/sdk/lib/_internal/pub/test/install/hosted/unlock_if_new_is_unsatisfied_test.dart b/sdk/lib/_internal/pub/test/install/hosted/unlock_if_new_is_unsatisfied_test.dart
index a80bc58..44ecb89 100644
--- a/sdk/lib/_internal/pub/test/install/hosted/unlock_if_new_is_unsatisfied_test.dart
+++ b/sdk/lib/_internal/pub/test/install/hosted/unlock_if_new_is_unsatisfied_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -41,7 +42,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("newdep")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "2.0.0",
diff --git a/sdk/lib/_internal/pub/test/install/path/absolute_path_test.dart b/sdk/lib/_internal/pub/test/install/path/absolute_path_test.dart
index 42b2636..9d12d16 100644
--- a/sdk/lib/_internal/pub/test/install/path/absolute_path_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/absolute_path_test.dart
@@ -26,7 +26,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
diff --git a/sdk/lib/_internal/pub/test/install/path/absolute_symlink_test.dart b/sdk/lib/_internal/pub/test/install/path/absolute_symlink_test.dart
index 83724c3..4e4b196 100644
--- a/sdk/lib/_internal/pub/test/install/path/absolute_symlink_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/absolute_symlink_test.dart
@@ -26,7 +26,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir("moved").create();
 
diff --git a/sdk/lib/_internal/pub/test/install/path/no_pubspec_test.dart b/sdk/lib/_internal/pub/test/install/path/no_pubspec_test.dart
index 61789ad..4553861 100644
--- a/sdk/lib/_internal/pub/test/install/path/no_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/no_pubspec_test.dart
@@ -26,6 +26,8 @@
       })
     ]).create();
 
-    pubInstall(error: 'Package "foo" doesn\'t have a pubspec.yaml file.');
+    schedulePub(args: ['install'],
+        error: new RegExp('Package "foo" doesn\'t have a pubspec.yaml file.'),
+        exitCode: 1);
   });
 }
\ No newline at end of file
diff --git a/sdk/lib/_internal/pub/test/install/path/nonexistent_dir_test.dart b/sdk/lib/_internal/pub/test/install/path/nonexistent_dir_test.dart
index 3564817..053c922 100644
--- a/sdk/lib/_internal/pub/test/install/path/nonexistent_dir_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/nonexistent_dir_test.dart
@@ -24,6 +24,15 @@
       })
     ]).create();
 
-    pubInstall(error: "Could not find package 'foo' at '$badPath'.");
+    // TODO(rnystrom): The "\" in a Windows path gets treated like a regex
+    // character, so hack escape. A better fix is to use a literal string
+    // instead of a RegExp to validate, but that requires us to move the
+    // stack traces out of the stderr when we invoke pub. See also: #4706.
+    var escapePath = badPath.replaceAll(r"\", r"\\");
+
+    schedulePub(args: ['install'],
+        error:
+            new RegExp("Could not find package 'foo' at '$escapePath'."),
+        exitCode: 1);
   });
 }
\ No newline at end of file
diff --git a/sdk/lib/_internal/pub/test/install/path/path_is_file_test.dart b/sdk/lib/_internal/pub/test/install/path/path_is_file_test.dart
index dbbc0df..7779467 100644
--- a/sdk/lib/_internal/pub/test/install/path/path_is_file_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/path_is_file_test.dart
@@ -10,7 +10,7 @@
 
 main() {
   initConfig();
-  integration('path dependency when path is a file', () {
+  integration('path dependency when path is a d.file', () {
     d.dir('foo', [
       d.libDir('foo'),
       d.libPubspec('foo', '0.0.1')
@@ -28,7 +28,15 @@
       })
     ]).create();
 
-    pubInstall(error: "Path dependency for package 'foo' must refer to a "
-                      "directory, not a file. Was '$dummyPath'.");
+    // TODO(rnystrom): The "\" in a Windows path gets treated like a regex
+    // character, so hack escape. A better fix is to use a literal string
+    // instead of a RegExp to validate, but that requires us to move the
+    // stack traces out of the stderr when we invoke pub. See also: #4706.
+    var escapePath = dummyPath.replaceAll(r"\", r"\\");
+
+    schedulePub(args: ['install'],
+        error: new RegExp("Path dependency for package 'foo' must refer to a "
+                          "directory, not a file. Was '$escapePath'."),
+        exitCode: 1);
   });
 }
\ No newline at end of file
diff --git a/sdk/lib/_internal/pub/test/install/path/relative_path_test.dart b/sdk/lib/_internal/pub/test/install/path/relative_path_test.dart
index 5abaf09..b9c9c31 100644
--- a/sdk/lib/_internal/pub/test/install/path/relative_path_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/relative_path_test.dart
@@ -25,7 +25,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
@@ -57,7 +58,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [
diff --git a/sdk/lib/_internal/pub/test/install/path/relative_symlink_test.dart b/sdk/lib/_internal/pub/test/install/path/relative_symlink_test.dart
index 97bd902..859f12c 100644
--- a/sdk/lib/_internal/pub/test/install/path/relative_symlink_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/relative_symlink_test.dart
@@ -34,7 +34,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir("moved").create();
 
diff --git a/sdk/lib/_internal/pub/test/install/path/shared_dependency_symlink_test.dart b/sdk/lib/_internal/pub/test/install/path/shared_dependency_symlink_test.dart
index bfb26dc..d3b75da 100644
--- a/sdk/lib/_internal/pub/test/install/path/shared_dependency_symlink_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/shared_dependency_symlink_test.dart
@@ -44,7 +44,8 @@
     d.dir("link").create();
     scheduleSymlink("shared", path.join("link", "shared"));
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [d.file("foo.dart", 'main() => "foo";')]),
diff --git a/sdk/lib/_internal/pub/test/install/path/shared_dependency_test.dart b/sdk/lib/_internal/pub/test/install/path/shared_dependency_test.dart
index ee8a7c3..65e7992 100644
--- a/sdk/lib/_internal/pub/test/install/path/shared_dependency_test.dart
+++ b/sdk/lib/_internal/pub/test/install/path/shared_dependency_test.dart
@@ -39,7 +39,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [d.file("foo.dart", 'main() => "foo";')]),
@@ -78,7 +79,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [d.file("foo.dart", 'main() => "foo";')]),
@@ -117,7 +119,8 @@
       })
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ["install"],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir("foo", [d.file("foo.dart", 'main() => "foo";')]),
diff --git a/sdk/lib/_internal/pub/test/install/relative_symlink_test.dart b/sdk/lib/_internal/pub/test/install/relative_symlink_test.dart
index deb2254..aeb0a2a 100644
--- a/sdk/lib/_internal/pub/test/install/relative_symlink_test.dart
+++ b/sdk/lib/_internal/pub/test/install/relative_symlink_test.dart
@@ -25,7 +25,8 @@
       d.libDir('foo')
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     scheduleRename(appPath, "moved");
 
@@ -45,7 +46,8 @@
       d.dir("bin")
     ]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     scheduleRename(appPath, "moved");
 
diff --git a/sdk/lib/_internal/pub/test/install/switch_source_test.dart b/sdk/lib/_internal/pub/test/install/switch_source_test.dart
index 428292e..db8864e 100644
--- a/sdk/lib/_internal/pub/test/install/switch_source_test.dart
+++ b/sdk/lib/_internal/pub/test/install/switch_source_test.dart
@@ -19,13 +19,17 @@
 
     d.appDir([{"path": "../foo"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.packagesDir({"foo": "0.0.1"}).validate();
+
     servePackages([packageMap("foo", "1.2.3")]);
+
     d.appDir([dependencyMap("foo", "any")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp("Dependencies installed!\$"));
 
     d.packagesDir({"foo": "1.2.3"}).validate();
   });
diff --git a/sdk/lib/_internal/pub/test/pub_install_and_update_test.dart b/sdk/lib/_internal/pub/test/pub_install_and_update_test.dart
index d645071..1cbd5a3 100644
--- a/sdk/lib/_internal/pub/test/pub_install_and_update_test.dart
+++ b/sdk/lib/_internal/pub/test/pub_install_and_update_test.dart
@@ -20,8 +20,7 @@
         d.dir(appPath, []).create();
 
         pubCommand(command,
-            error: new RegExp(r'^Could not find a file named "pubspec.yaml" '
-                r'in the directory .*\.$'));
+            error: new RegExp(r'^Could not find a file named "pubspec.yaml"'));
       });
 
       integration('a pubspec with a "name" key', () {
@@ -29,9 +28,9 @@
           d.pubspec({"dependencies": {"foo": null}})
         ]).create();
 
-        pubCommand(command, error:
-            'pubspec.yaml is missing the required "name" field '
-            '(e.g. "name: myapp").');
+        pubCommand(command, error: new RegExp(
+            r'^pubspec.yaml is missing the required "name" field '
+            r'\(e\.g\. "name: myapp"\)\.'));
       });
     });
 
@@ -113,7 +112,7 @@
       ]).create();
 
       pubCommand(command,
-          error: new RegExp("^Incompatible dependencies on 'baz':\n"));
+          error: new RegExp(r"^Incompatible dependencies on 'baz':"));
     });
   });
 }
diff --git a/sdk/lib/_internal/pub/test/test_pub.dart b/sdk/lib/_internal/pub/test/test_pub.dart
index c9ee7d2..50f6343 100644
--- a/sdk/lib/_internal/pub/test/test_pub.dart
+++ b/sdk/lib/_internal/pub/test/test_pub.dart
@@ -238,13 +238,15 @@
 /// Enum identifying a pub command that can be run with a well-defined success
 /// output.
 class RunCommand {
-  static final install = new RunCommand('install', 'installed');
-  static final update = new RunCommand('update', 'updated');
+  static final install = new RunCommand('install',
+      new RegExp("Dependencies installed!\$"));
+
+  static final update = new RunCommand('update',
+      new RegExp("Dependencies updated!\$"));
 
   final String name;
   final RegExp success;
-  RunCommand(this.name, String verb)
-      : success = new RegExp("Dependencies $verb!\$");
+  RunCommand(this.name, this.success);
 }
 
 /// Many tests validate behavior that is the same between pub install and
diff --git a/sdk/lib/_internal/pub/test/unknown_source_test.dart b/sdk/lib/_internal/pub/test/unknown_source_test.dart
index 511b795..6b0cde0 100644
--- a/sdk/lib/_internal/pub/test/unknown_source_test.dart
+++ b/sdk/lib/_internal/pub/test/unknown_source_test.dart
@@ -17,8 +17,8 @@
     integration('fails gracefully on a dependency from an unknown source', () {
       d.appDir([{"bad": "foo"}]).create();
 
-      pubCommand(command, error:
-          "Package 'myapp' depends on 'foo' from unknown source 'bad'.");
+      pubCommand(command, error: new RegExp(
+          "Package 'myapp' depends on 'foo' from unknown source 'bad'.\$"));
     });
 
     integration('fails gracefully on transitive dependency from an unknown '
@@ -30,8 +30,8 @@
 
       d.appDir([{"path": "../foo"}]).create();
 
-      pubCommand(command, error:
-          "Package 'foo' depends on 'bar' from unknown source 'bad'.");
+      pubCommand(command, error: new RegExp(
+          "Package 'foo' depends on 'bar' from unknown source 'bad'.\$"));
     });
 
     integration('ignores unknown source in lockfile', () {
diff --git a/sdk/lib/_internal/pub/test/update/git/do_not_update_if_unneeded_test.dart b/sdk/lib/_internal/pub/test/update/git/do_not_update_if_unneeded_test.dart
index d48899a..512b619 100644
--- a/sdk/lib/_internal/pub/test/update/git/do_not_update_if_unneeded_test.dart
+++ b/sdk/lib/_internal/pub/test/update/git/do_not_update_if_unneeded_test.dart
@@ -27,7 +27,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -48,7 +49,8 @@
       d.libPubspec('foo-dep', '1.0.0')
     ]).commit();
 
-    pubUpdate(args: ['foo']);
+    schedulePub(args: ['update', 'foo'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/update/git/update_locked_test.dart b/sdk/lib/_internal/pub/test/update/git/update_locked_test.dart
index c17f641..3ed68c5 100644
--- a/sdk/lib/_internal/pub/test/update/git/update_locked_test.dart
+++ b/sdk/lib/_internal/pub/test/update/git/update_locked_test.dart
@@ -26,7 +26,8 @@
 
     d.appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -47,7 +48,8 @@
       d.libPubspec('bar', '1.0.0')
     ]).commit();
 
-    pubUpdate();
+    schedulePub(args: ['update'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/update/git/update_one_locked_test.dart b/sdk/lib/_internal/pub/test/update/git/update_one_locked_test.dart
index 35370e7..976553e 100644
--- a/sdk/lib/_internal/pub/test/update/git/update_one_locked_test.dart
+++ b/sdk/lib/_internal/pub/test/update/git/update_one_locked_test.dart
@@ -26,7 +26,8 @@
 
     d.appDir([{"git": "../foo.git"}, {"git": "../bar.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -47,7 +48,8 @@
       d.libPubspec('bar', '1.0.0')
     ]).commit();
 
-    pubUpdate(args: ['foo']);
+    schedulePub(args: ['update', 'foo'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/update/git/update_to_incompatible_pubspec_test.dart b/sdk/lib/_internal/pub/test/update/git/update_to_incompatible_pubspec_test.dart
index 348d6db..09123f4 100644
--- a/sdk/lib/_internal/pub/test/update/git/update_to_incompatible_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/update/git/update_to_incompatible_pubspec_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -34,8 +35,10 @@
       d.libPubspec('zoo', '1.0.0')
     ]).commit();
 
-    pubUpdate(error: 'The name you specified for your dependency, '
-                     '"foo", doesn\'t match the name "zoo" in its pubspec.');
+    schedulePub(args: ['update'],
+        error: new RegExp(r'The name you specified for your dependency, '
+            r'"foo", doesn' "'" r't match the name "zoo" in its pubspec.'),
+        exitCode: 1);
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/update/git/update_to_nonexistent_pubspec_test.dart b/sdk/lib/_internal/pub/test/update/git/update_to_nonexistent_pubspec_test.dart
index f746ee6..9e2e995 100644
--- a/sdk/lib/_internal/pub/test/update/git/update_to_nonexistent_pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/update/git/update_to_nonexistent_pubspec_test.dart
@@ -22,7 +22,8 @@
 
     d.appDir([{"git": "../foo.git"}]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.dir(packagesPath, [
       d.dir('foo', [
@@ -33,7 +34,10 @@
     repo.runGit(['rm', 'pubspec.yaml']);
     repo.runGit(['commit', '-m', 'delete']);
 
-    pubUpdate(error: 'Package "foo" doesn\'t have a pubspec.yaml file.');
+    schedulePub(args: ['update'],
+        error: new RegExp(r'Package "foo" doesn' "'" r't have a '
+            r'pubspec.yaml file.'),
+        exitCode: 1);
 
     d.dir(packagesPath, [
       d.dir('foo', [
diff --git a/sdk/lib/_internal/pub/test/update/hosted/unlock_dependers_test.dart b/sdk/lib/_internal/pub/test/update/hosted/unlock_dependers_test.dart
index b007e00..f1b8e4d 100644
--- a/sdk/lib/_internal/pub/test/update/hosted/unlock_dependers_test.dart
+++ b/sdk/lib/_internal/pub/test/update/hosted/unlock_dependers_test.dart
@@ -20,7 +20,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("bar")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -32,7 +33,8 @@
       packageMap("bar", "2.0.0")
     ]);
 
-    pubUpdate(args: ['bar']);
+    schedulePub(args: ['update', 'bar'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.packagesDir({
       "foo": "2.0.0",
diff --git a/sdk/lib/_internal/pub/test/update/hosted/unlock_if_necessary_test.dart b/sdk/lib/_internal/pub/test/update/hosted/unlock_if_necessary_test.dart
index 3f24c78..3115942 100644
--- a/sdk/lib/_internal/pub/test/update/hosted/unlock_if_necessary_test.dart
+++ b/sdk/lib/_internal/pub/test/update/hosted/unlock_if_necessary_test.dart
@@ -20,7 +20,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubInstall();
+    schedulePub(args: ['install'],
+        output: new RegExp(r"Dependencies installed!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -32,7 +33,8 @@
       packageMap("foo-dep", "2.0.0")
     ]);
 
-    pubUpdate(args: ['foo']);
+    schedulePub(args: ['update', 'foo'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.packagesDir({
       "foo": "2.0.0",
diff --git a/sdk/lib/_internal/pub/test/update/hosted/update_removed_constraints_test.dart b/sdk/lib/_internal/pub/test/update/hosted/update_removed_constraints_test.dart
index 3ff3efc..dc20323 100644
--- a/sdk/lib/_internal/pub/test/update/hosted/update_removed_constraints_test.dart
+++ b/sdk/lib/_internal/pub/test/update/hosted/update_removed_constraints_test.dart
@@ -21,7 +21,8 @@
 
     d.appDir([dependencyMap("foo"), dependencyMap("bar")]).create();
 
-    pubUpdate();
+    schedulePub(args: ['update'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
@@ -31,7 +32,8 @@
 
     d.appDir([dependencyMap("foo")]).create();
 
-    pubUpdate();
+    schedulePub(args: ['update'],
+        output: new RegExp(r"Dependencies updated!$"));
 
     d.packagesDir({
       "foo": "1.0.0",
diff --git a/sdk/lib/_internal/pub/test/utils_test.dart b/sdk/lib/_internal/pub/test/utils_test.dart
index a137d2d..c1c29a8 100644
--- a/sdk/lib/_internal/pub/test/utils_test.dart
+++ b/sdk/lib/_internal/pub/test/utils_test.dart
@@ -80,12 +80,5 @@
 null: null
 true: bool"""));
     });
-
-    test('handles empty maps', () {
-      expect(yamlToString({}), equals("{}"));
-      expect(yamlToString({'a': {}, 'b': {}}), equals("""
-a: {}
-b: {}"""));
-    });
   });
 }
diff --git a/tests/language/field1_negative_test.dart b/tests/language/field1_negative_test.dart
index a860b3d..e10f754 100644
--- a/tests/language/field1_negative_test.dart
+++ b/tests/language/field1_negative_test.dart
@@ -4,6 +4,7 @@
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have setter/getter functions and fields
 // in the class.
+// VMOptions=--compile_all
 
 class C {
   var a;
@@ -26,7 +27,6 @@
 
 class Field1NegativeTest {
   static testMain() {
-    var c = new C();
   }
 }
 
diff --git a/tests/language/field2_negative_test.dart b/tests/language/field2_negative_test.dart
index 26cb3c8..f37d307 100644
--- a/tests/language/field2_negative_test.dart
+++ b/tests/language/field2_negative_test.dart
@@ -4,6 +4,7 @@
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have setter/getter functions and fields
 // in the class.
+// VMOptions=--compile_all
 
 class C {
   get a {
@@ -26,7 +27,6 @@
 
 class Field2NegativeTest {
   static testMain() {
-    var c = new C();
   }
 }
 
diff --git a/tests/language/field4_negative_test.dart b/tests/language/field4_negative_test.dart
index 2f00c26..426fc0f 100644
--- a/tests/language/field4_negative_test.dart
+++ b/tests/language/field4_negative_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have a field overriding a function name.
+// VMOptions=--compile_all
 
 class A {
   int a() {
@@ -13,7 +14,6 @@
 
 class Field4NegativeTest {
   static testMain() {
-    var a = new A();
   }
 }
 
diff --git a/tests/language/field5_negative_test.dart b/tests/language/field5_negative_test.dart
index 3ba641b..9e6da06 100644
--- a/tests/language/field5_negative_test.dart
+++ b/tests/language/field5_negative_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have a function overriding a field name.
+// VMOptions=--compile_all
 
 class A {
   var a;
@@ -13,7 +14,6 @@
 
 class Field5NegativeTest {
   static testMain() {
-    var a = new A();
   }
 }
 
diff --git a/tests/language/field6_negative_test.dart b/tests/language/field6_negative_test.dart
index c9a9931..d841bbd 100644
--- a/tests/language/field6_negative_test.dart
+++ b/tests/language/field6_negative_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have a getter overriding a function name.
+// VMOptions=--compile_all
 
 class A {
   int a() {
@@ -15,7 +16,6 @@
 
 class Field6NegativeTest {
   static testMain() {
-    var a = new A();
   }
 }
 
diff --git a/tests/language/field6a_negative_test.dart b/tests/language/field6a_negative_test.dart
index d2e540a..8d8ac44 100644
--- a/tests/language/field6a_negative_test.dart
+++ b/tests/language/field6a_negative_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 // Dart test to catch error reporting bugs in class fields declarations.
 // Should be an error because we have a function overriding a getter.
+// VMOptions=--compile_all
 
 class A {
   int get a {
@@ -15,7 +16,6 @@
 
 class Field6aNegativeTest {
   static testMain() {
-    var a = new A();
   }
 }
 
diff --git a/tests/language/interface_static_method_negative_test.dart b/tests/language/interface_static_method_negative_test.dart
index 5e8a83c..ef1925e 100644
--- a/tests/language/interface_static_method_negative_test.dart
+++ b/tests/language/interface_static_method_negative_test.dart
@@ -1,6 +1,7 @@
 // Copyright (c) 2012, 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.
+// VMOptions=--compile_all
 
 abstract class A {
   static void foo();
@@ -9,7 +10,6 @@
 class InterfaceStaticMethodNegativeTest {
 
   static testMain() {
-    var a = new A();
   }
 }
 
diff --git a/tests/language/language.status b/tests/language/language.status
index 720297f..b61389a 100644
--- a/tests/language/language.status
+++ b/tests/language/language.status
@@ -312,6 +312,14 @@
 final_variable_assignment_test/03: Fail
 final_variable_assignment_test/04: Fail
 gc_test: Skip # Issue 1487
+field5_negative_test: Fail # Issue 10839
+field4_negative_test: Fail # Issue 10839
+field6_negative_test: Fail # Issue 10839
+non_const_super_negative_test: Fail # Issue 10839
+field2_negative_test: Fail # Issue 10839
+interface_static_method_negative_test: Fail # Issue 10839
+field1_negative_test: Fail # Issue 10839
+field6a_negative_test: Fail # Issue 10839
 
 
 [ $runtime == dartium ]
@@ -430,6 +438,8 @@
 const_var_test: Pass, Fail # Map literals take 2 type arguments.
 map_literal3_test: Fail # Map literals take 2 type arguments.
 class_cycle_negative_test: Fail, OK # Bad test: assumes eager loading.
+field1_negative_test: Fail, OK # Bad test: assumes eager loading.
+field6_negative_test: Fail, OK # Bad test: assumes eager loading.
 interface_cycle_negative_test: Fail, OK # Bad test: assumes eager loading.
 # Common problems with dart2js.  In illegal family, invalid
 # declarations are simply not parsed.  In pseudo kw dart2js
@@ -446,7 +456,13 @@
 duplicate_implements_test/02: Fail
 duplicate_implements_test/03: Fail
 duplicate_implements_test/04: Fail
+field2_negative_test: Fail
+field4_negative_test: Fail
+field5_negative_test: Fail
+field6a_negative_test: Fail
 interface_factory_constructor_negative_test: Fail
+interface_static_method_negative_test: Fail
+non_const_super_negative_test: Fail
 method_override2_test/00: Fail
 method_override2_test/02: Fail
 method_override2_test/03: Fail
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index 0f8ea61..541b3c9 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -227,6 +227,8 @@
 
 class_cycle_negative_test: Fail, OK # Bad test: assumes eager loading.
 external_test/16: Fail, OK # Bad test: assumes eager loading.
+field1_negative_test: Fail, OK # Bad test: assumes eager loading.
+field6_negative_test: Fail, OK # Bad test: assumes eager loading.
 interface_cycle_negative_test: Fail, OK # Bad test: assumes eager loading.
 syntax_test/47: Fail, OK # Bad test: assumes eager loading.
 
@@ -251,15 +253,21 @@
 duplicate_implements_test/02: Fail # Negative language test.
 duplicate_implements_test/03: Fail # Negative language test.
 duplicate_implements_test/04: Fail # Negative language test.
+field2_negative_test: Fail # Negative language test.
 field3_negative_test: Fail # Negative language test.
+field4_negative_test: Fail # Negative language test.
+field5_negative_test: Fail # Negative language test.
+field6a_negative_test: Fail # Negative language test.
 final_for_in_variable_test/01: Fail # Negative language test
 instantiate_type_variable_negative_test: Pass  # For the wrong reason.
 interface_factory3_negative_test: Fail # Negative language test.
 interface_factory_constructor_negative_test: Fail # Negative language test.
+interface_static_method_negative_test: Fail # Negative language test.
 list_literal1_negative_test: Fail # Negative language test.
 list_literal2_negative_test: Fail # Negative language test.
 map_literal1_negative_test: Fail # Negative language test.
 map_literal2_negative_test: Fail # Negative language test.
+non_const_super_negative_test: Fail # Negative language test.
 number_identifier_negative_test: Fail # Negative language test.
 operator1_negative_test: Fail # Negative language test.
 prefix23_negative_test: Fail # Negative language test.
diff --git a/tests/language/non_const_super_negative_test.dart b/tests/language/non_const_super_negative_test.dart
index 32742e2..17f3d5a 100644
--- a/tests/language/non_const_super_negative_test.dart
+++ b/tests/language/non_const_super_negative_test.dart
@@ -2,6 +2,7 @@
 // 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.
 // Check fails because const class extends from non const class.
+// VMOptions=--compile_all
 
 class Base {
   Base() {}
@@ -14,7 +15,6 @@
 
 class NonConstSuperNegativeTest {
   static testMain() {
-    var a = new Sub();
   }
 }
 
diff --git a/tests/standalone/standalone.status b/tests/standalone/standalone.status
index 7247230..10e39ba 100644
--- a/tests/standalone/standalone.status
+++ b/tests/standalone/standalone.status
@@ -4,6 +4,9 @@
 
 package/invalid_uri_test: Fail, OK # Fails intentionally
 
+[ $runtime == vm && $system == macos ]
+debugger/basic_debugger_test: Pass, Crash # Issue 10488.
+
 [ $runtime == vm && $system == windows ]
 debugger/*: Skip # Issue: 10791
 
diff --git a/tools/VERSION b/tools/VERSION
index 453bc99..2be690f 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -1,4 +1,4 @@
 MAJOR 0
-MINOR 1
-BUILD 2
-PATCH 0
+MINOR 5
+BUILD 11
+PATCH 1
diff --git a/utils/pub/pub.Makefile b/utils/pub/pub.Makefile
new file mode 100644
index 0000000..c1d628d
--- /dev/null
+++ b/utils/pub/pub.Makefile
@@ -0,0 +1,6 @@
+# This file is generated by gyp; do not edit.
+
+export builddir_name ?= dart/utils/pub/out
+.PHONY: all
+all:
+	$(MAKE) -C ../.. pub
diff --git a/utils/pub/pub.target.mk b/utils/pub/pub.target.mk
new file mode 100644
index 0000000..6ddab0c
--- /dev/null
+++ b/utils/pub/pub.target.mk
@@ -0,0 +1,38 @@
+# This file is generated by gyp; do not edit.
+
+TOOLSET := target
+TARGET := pub
+### Rules for action "generate_pub_snapshot":
+quiet_cmd_dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot = ACTION dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot $@
+cmd_dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot = LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd utils/pub; mkdir -p $(obj)/gen; "$(builddir)/dart" "--package-root=$(builddir)/packages/" "--generate-script-snapshot=$(obj)/gen/pub.dart.snapshot" ../../sdk/lib/_internal/pub/bin/pub.dart
+
+$(obj)/gen/pub.dart.snapshot: obj := $(abs_obj)
+$(obj)/gen/pub.dart.snapshot: builddir := $(abs_builddir)
+$(obj)/gen/pub.dart.snapshot: TOOLSET := $(TOOLSET)
+$(obj)/gen/pub.dart.snapshot: $(builddir)/dart sdk/lib/_internal/pub/bin/pub.dart sdk/lib/_internal/pub/lib/src/http.dart sdk/lib/_internal/pub/lib/src/utils.dart sdk/lib/_internal/pub/lib/src/git_source.dart sdk/lib/_internal/pub/lib/src/command_install.dart sdk/lib/_internal/pub/lib/src/exit_codes.dart sdk/lib/_internal/pub/lib/src/command.dart sdk/lib/_internal/pub/lib/src/source_registry.dart sdk/lib/_internal/pub/lib/src/pubspec.dart sdk/lib/_internal/pub/lib/src/command_help.dart sdk/lib/_internal/pub/lib/src/oauth2.dart sdk/lib/_internal/pub/lib/src/command_uploader.dart sdk/lib/_internal/pub/lib/src/error_group.dart sdk/lib/_internal/pub/lib/src/directory_tree.dart sdk/lib/_internal/pub/lib/src/sdk.dart sdk/lib/_internal/pub/lib/src/hosted_source.dart sdk/lib/_internal/pub/lib/src/version.dart sdk/lib/_internal/pub/lib/src/git.dart sdk/lib/_internal/pub/lib/src/io.dart sdk/lib/_internal/pub/lib/src/system_cache.dart sdk/lib/_internal/pub/lib/src/safe_http_server.dart sdk/lib/_internal/pub/lib/src/command_update.dart sdk/lib/_internal/pub/lib/src/command_version.dart sdk/lib/_internal/pub/lib/src/validator.dart sdk/lib/_internal/pub/lib/src/command_cache.dart sdk/lib/_internal/pub/lib/src/source.dart sdk/lib/_internal/pub/lib/src/command_lish.dart sdk/lib/_internal/pub/lib/src/package.dart sdk/lib/_internal/pub/lib/src/log.dart sdk/lib/_internal/pub/lib/src/entrypoint.dart sdk/lib/_internal/pub/lib/src/lock_file.dart sdk/lib/_internal/pub/lib/src/path_source.dart sdk/lib/_internal/pub/lib/src/validator/name.dart sdk/lib/_internal/pub/lib/src/validator/size.dart sdk/lib/_internal/pub/lib/src/validator/pubspec_field.dart sdk/lib/_internal/pub/lib/src/validator/compiled_dartdoc.dart sdk/lib/_internal/pub/lib/src/validator/directory.dart sdk/lib/_internal/pub/lib/src/validator/utf8_readme.dart sdk/lib/_internal/pub/lib/src/validator/dependency.dart sdk/lib/_internal/pub/lib/src/validator/license.dart sdk/lib/_internal/pub/lib/src/validator/lib.dart sdk/lib/_internal/pub/lib/src/solver/version_solver.dart sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart sdk/lib/_internal/pub/test/command_line_config.dart sdk/lib/_internal/pub/test/version_test.dart sdk/lib/_internal/pub/test/io_test.dart sdk/lib/_internal/pub/test/pub_cache_test.dart sdk/lib/_internal/pub/test/test_pub.dart sdk/lib/_internal/pub/test/lock_file_test.dart sdk/lib/_internal/pub/test/real_version_test.dart sdk/lib/_internal/pub/test/directory_tree_test.dart sdk/lib/_internal/pub/test/dev_dependency_test.dart sdk/lib/_internal/pub/test/pubspec_test.dart sdk/lib/_internal/pub/test/pub_test.dart sdk/lib/_internal/pub/test/version_solver_test.dart sdk/lib/_internal/pub/test/descriptor.dart sdk/lib/_internal/pub/test/error_group_test.dart sdk/lib/_internal/pub/test/pub_uploader_test.dart sdk/lib/_internal/pub/test/lish/cloud_storage_upload_doesnt_redirect_test.dart sdk/lib/_internal/pub/test/lish/cloud_storage_upload_provides_an_error_test.dart sdk/lib/_internal/pub/test/lish/upload_form_provides_an_error_test.dart sdk/lib/_internal/pub/test/lish/utils.dart sdk/lib/_internal/pub/test/lish/package_creation_provides_a_malformed_error_test.dart sdk/lib/_internal/pub/test/lish/package_validation_has_a_warning_and_is_canceled_test.dart sdk/lib/_internal/pub/test/lish/force_cannot_be_combined_with_dry_run_test.dart sdk/lib/_internal/pub/test/lish/upload_form_fields_is_not_a_map_test.dart sdk/lib/_internal/pub/test/lish/package_creation_provides_invalid_json_test.dart sdk/lib/_internal/pub/test/lish/package_creation_provides_a_malformed_success_test.dart sdk/lib/_internal/pub/test/lish/package_creation_provides_an_error_test.dart sdk/lib/_internal/pub/test/lish/upload_form_is_missing_url_test.dart sdk/lib/_internal/pub/test/lish/force_does_not_publish_if_there_are_errors_test.dart sdk/lib/_internal/pub/test/lish/upload_form_is_missing_fields_test.dart sdk/lib/_internal/pub/test/lish/package_validation_has_an_error_test.dart sdk/lib/_internal/pub/test/lish/preview_package_validation_has_a_warning_test.dart sdk/lib/_internal/pub/test/lish/package_validation_has_a_warning_and_continues_test.dart sdk/lib/_internal/pub/test/lish/force_publishes_if_tests_are_no_warnings_or_errors_test.dart sdk/lib/_internal/pub/test/lish/preview_package_validation_has_no_warnings_test.dart sdk/lib/_internal/pub/test/lish/archives_and_uploads_a_package_test.dart sdk/lib/_internal/pub/test/lish/upload_form_url_is_not_a_string_test.dart sdk/lib/_internal/pub/test/lish/force_publishes_if_there_are_warnings_test.dart sdk/lib/_internal/pub/test/lish/upload_form_fields_has_a_non_string_value_test.dart sdk/lib/_internal/pub/test/lish/upload_form_provides_invalid_json_test.dart sdk/lib/_internal/pub/test/update/pub_update_test.dart sdk/lib/_internal/pub/test/update/git/do_not_update_if_unneeded_test.dart sdk/lib/_internal/pub/test/update/git/update_to_incompatible_pubspec_test.dart sdk/lib/_internal/pub/test/update/git/update_to_nonexistent_pubspec_test.dart sdk/lib/_internal/pub/test/update/git/update_locked_test.dart sdk/lib/_internal/pub/test/update/git/update_one_locked_test.dart sdk/lib/_internal/pub/test/update/hosted/fail_gracefully_on_missing_package_test.dart sdk/lib/_internal/pub/test/update/hosted/unlock_dependers_test.dart sdk/lib/_internal/pub/test/update/hosted/unlock_if_necessary_test.dart sdk/lib/_internal/pub/test/update/hosted/fail_gracefully_on_url_resolve_test.dart sdk/lib/_internal/pub/test/update/hosted/remove_removed_transitive_dependency_test.dart sdk/lib/_internal/pub/test/update/hosted/update_removed_constraints_test.dart sdk/lib/_internal/pub/test/update/hosted/remove_removed_dependency_test.dart sdk/lib/_internal/pub/test/validator/license_test.dart sdk/lib/_internal/pub/test/validator/utils.dart sdk/lib/_internal/pub/test/validator/pubspec_field_test.dart sdk/lib/_internal/pub/test/validator/dependency_test.dart sdk/lib/_internal/pub/test/validator/directory_test.dart sdk/lib/_internal/pub/test/validator/name_test.dart sdk/lib/_internal/pub/test/validator/lib_test.dart sdk/lib/_internal/pub/test/validator/size_test.dart sdk/lib/_internal/pub/test/validator/utf8_readme_test.dart sdk/lib/_internal/pub/test/validator/compiled_dartdoc_test.dart sdk/lib/_internal/pub/test/oauth2/utils.dart sdk/lib/_internal/pub/test/oauth2/with_server_rejected_credentials_authenticates_again_test.dart sdk/lib/_internal/pub/test/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart sdk/lib/_internal/pub/test/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart sdk/lib/_internal/pub/test/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart sdk/lib/_internal/pub/test/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart sdk/lib/_internal/pub/test/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart sdk/lib/_internal/pub/test/oauth2/with_a_malformed_credentials_authenticates_again_test.dart sdk/lib/_internal/pub/test/descriptor/tar.dart sdk/lib/_internal/pub/test/descriptor/git.dart sdk/lib/_internal/pub/test/install/pub_install_test.dart sdk/lib/_internal/pub/test/install/relative_symlink_test.dart sdk/lib/_internal/pub/test/install/broken_symlink_test.dart sdk/lib/_internal/pub/test/install/switch_source_test.dart sdk/lib/_internal/pub/test/install/git/check_out_transitive_test.dart sdk/lib/_internal/pub/test/install/git/unlock_if_incompatible_test.dart sdk/lib/_internal/pub/test/install/git/require_pubspec_test.dart sdk/lib/_internal/pub/test/install/git/check_out_with_trailing_slash_test.dart sdk/lib/_internal/pub/test/install/git/dependency_name_match_pubspec_test.dart sdk/lib/_internal/pub/test/install/git/check_out_branch_test.dart sdk/lib/_internal/pub/test/install/git/stay_locked_if_compatible_test.dart sdk/lib/_internal/pub/test/install/git/check_out_and_update_test.dart sdk/lib/_internal/pub/test/install/git/check_out_twice_test.dart sdk/lib/_internal/pub/test/install/git/check_out_test.dart sdk/lib/_internal/pub/test/install/git/lock_version_test.dart sdk/lib/_internal/pub/test/install/git/require_pubspec_name_test.dart sdk/lib/_internal/pub/test/install/git/check_out_revision_test.dart sdk/lib/_internal/pub/test/install/git/different_repo_name_test.dart sdk/lib/_internal/pub/test/install/hosted/unlock_if_incompatible_test.dart sdk/lib/_internal/pub/test/install/hosted/fail_gracefully_on_missing_package_test.dart sdk/lib/_internal/pub/test/install/hosted/do_not_update_on_removed_constraints_test.dart sdk/lib/_internal/pub/test/install/hosted/stay_locked_test.dart sdk/lib/_internal/pub/test/install/hosted/install_test.dart sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_compatible_test.dart sdk/lib/_internal/pub/test/install/hosted/install_transitive_test.dart sdk/lib/_internal/pub/test/install/hosted/fail_gracefully_on_url_resolve_test.dart sdk/lib/_internal/pub/test/install/hosted/remove_removed_transitive_dependency_test.dart sdk/lib/_internal/pub/test/install/hosted/unlock_if_new_is_unsatisfied_test.dart sdk/lib/_internal/pub/test/install/hosted/stay_locked_if_new_is_satisfied_test.dart sdk/lib/_internal/pub/test/install/hosted/remove_removed_dependency_test.dart sdk/lib/_internal/pub/test/install/hosted/cached_pubspec_test.dart sdk/lib/_internal/pub/test/install/hosted/resolve_constraints_test.dart sdk/lib/_internal/pub/test/install/hosted/repair_cache_test.dart sdk/lib/_internal/pub/test/install/path/nonexistent_dir_test.dart sdk/lib/_internal/pub/test/install/path/absolute_path_test.dart sdk/lib/_internal/pub/test/install/path/relative_symlink_test.dart sdk/lib/_internal/pub/test/install/path/shared_dependency_test.dart sdk/lib/_internal/pub/test/install/path/shared_dependency_symlink_test.dart sdk/lib/_internal/pub/test/install/path/absolute_symlink_test.dart sdk/lib/_internal/pub/test/install/path/no_pubspec_test.dart sdk/lib/_internal/pub/test/install/path/relative_path_test.dart sdk/lib/_internal/pub/test/install/path/path_is_file_test.dart sdk/lib/_internal/libraries.dart sdk/lib/_internal/compiler/compiler.dart sdk/lib/_internal/compiler/implementation/dart_types.dart sdk/lib/_internal/compiler/implementation/string_validator.dart sdk/lib/_internal/compiler/implementation/world.dart sdk/lib/_internal/compiler/implementation/typechecker.dart sdk/lib/_internal/compiler/implementation/filenames.dart sdk/lib/_internal/compiler/implementation/dart2js.dart sdk/lib/_internal/compiler/implementation/patch_parser.dart sdk/lib/_internal/compiler/implementation/constants.dart sdk/lib/_internal/compiler/implementation/script.dart sdk/lib/_internal/compiler/implementation/library_loader.dart sdk/lib/_internal/compiler/implementation/enqueue.dart sdk/lib/_internal/compiler/implementation/compiler.dart sdk/lib/_internal/compiler/implementation/diagnostic_listener.dart sdk/lib/_internal/compiler/implementation/warnings.dart sdk/lib/_internal/compiler/implementation/source_file_provider.dart sdk/lib/_internal/compiler/implementation/tree_validator.dart sdk/lib/_internal/compiler/implementation/apiimpl.dart sdk/lib/_internal/compiler/implementation/native_handler.dart sdk/lib/_internal/compiler/implementation/constant_system_dart.dart sdk/lib/_internal/compiler/implementation/dart2jslib.dart sdk/lib/_internal/compiler/implementation/compile_time_constants.dart sdk/lib/_internal/compiler/implementation/closure.dart sdk/lib/_internal/compiler/implementation/code_buffer.dart sdk/lib/_internal/compiler/implementation/source_file.dart sdk/lib/_internal/compiler/implementation/deferred_load.dart sdk/lib/_internal/compiler/implementation/resolved_visitor.dart sdk/lib/_internal/compiler/implementation/colors.dart sdk/lib/_internal/compiler/implementation/source_map_builder.dart sdk/lib/_internal/compiler/implementation/constant_system.dart sdk/lib/_internal/compiler/implementation/util/characters.dart sdk/lib/_internal/compiler/implementation/util/util.dart sdk/lib/_internal/compiler/implementation/util/uri_extras.dart sdk/lib/_internal/compiler/implementation/util/link_implementation.dart sdk/lib/_internal/compiler/implementation/util/link.dart sdk/lib/_internal/compiler/implementation/util/util_implementation.dart sdk/lib/_internal/compiler/implementation/tools/mini_parser.dart sdk/lib/_internal/compiler/implementation/dart_backend/utils.dart sdk/lib/_internal/compiler/implementation/dart_backend/dart_backend.dart sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart sdk/lib/_internal/compiler/implementation/js_backend/namer.dart sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart sdk/lib/_internal/compiler/implementation/js_backend/constant_system_javascript.dart sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart sdk/lib/_internal/compiler/implementation/js_backend/backend.dart sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart sdk/lib/_internal/compiler/implementation/lib/string_helper.dart sdk/lib/_internal/compiler/implementation/lib/collection_patch.dart sdk/lib/_internal/compiler/implementation/lib/js_rti.dart sdk/lib/_internal/compiler/implementation/lib/core_patch.dart sdk/lib/_internal/compiler/implementation/lib/js_array.dart sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart sdk/lib/_internal/compiler/implementation/lib/isolate_patch.dart sdk/lib/_internal/compiler/implementation/lib/async_patch.dart sdk/lib/_internal/compiler/implementation/lib/collection_dev_patch.dart sdk/lib/_internal/compiler/implementation/lib/js_helper.dart sdk/lib/_internal/compiler/implementation/lib/scalarlist_patch.dart sdk/lib/_internal/compiler/implementation/lib/native_helper.dart sdk/lib/_internal/compiler/implementation/lib/io_patch.dart sdk/lib/_internal/compiler/implementation/lib/js_number.dart sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart sdk/lib/_internal/compiler/implementation/lib/constant_map.dart sdk/lib/_internal/compiler/implementation/lib/typed_data_patch.dart sdk/lib/_internal/compiler/implementation/lib/math_patch.dart sdk/lib/_internal/compiler/implementation/lib/js_string.dart sdk/lib/_internal/compiler/implementation/lib/json_patch.dart sdk/lib/_internal/compiler/implementation/lib/foreign_helper.dart sdk/lib/_internal/compiler/implementation/lib/interceptors.dart sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart sdk/lib/_internal/compiler/implementation/mirrors/util.dart sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart sdk/lib/_internal/compiler/implementation/resolution/scope.dart sdk/lib/_internal/compiler/implementation/resolution/resolution.dart sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart sdk/lib/_internal/compiler/implementation/resolution/members.dart sdk/lib/_internal/compiler/implementation/ssa/ssa.dart sdk/lib/_internal/compiler/implementation/ssa/bailout.dart sdk/lib/_internal/compiler/implementation/ssa/codegen.dart sdk/lib/_internal/compiler/implementation/ssa/types.dart sdk/lib/_internal/compiler/implementation/ssa/validate.dart sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart sdk/lib/_internal/compiler/implementation/ssa/optimize.dart sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart sdk/lib/_internal/compiler/implementation/ssa/codegen_helpers.dart sdk/lib/_internal/compiler/implementation/ssa/nodes.dart sdk/lib/_internal/compiler/implementation/ssa/value_set.dart sdk/lib/_internal/compiler/implementation/ssa/builder.dart sdk/lib/_internal/compiler/implementation/ssa/tracer.dart sdk/lib/_internal/compiler/implementation/ssa/variable_allocator.dart sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart sdk/lib/_internal/compiler/implementation/js/precedence.dart sdk/lib/_internal/compiler/implementation/js/nodes.dart sdk/lib/_internal/compiler/implementation/js/builder.dart sdk/lib/_internal/compiler/implementation/js/printer.dart sdk/lib/_internal/compiler/implementation/js/js.dart sdk/lib/_internal/compiler/implementation/types/types.dart sdk/lib/_internal/compiler/implementation/types/type_mask.dart sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart sdk/lib/_internal/compiler/implementation/elements/elements.dart sdk/lib/_internal/compiler/implementation/elements/modelx.dart sdk/lib/_internal/compiler/implementation/universe/selector_map.dart sdk/lib/_internal/compiler/implementation/universe/universe.dart sdk/lib/_internal/compiler/implementation/universe/function_set.dart sdk/lib/_internal/compiler/implementation/universe/full_function_set.dart sdk/lib/_internal/compiler/implementation/scanner/byte_array_scanner.dart sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart sdk/lib/_internal/compiler/implementation/scanner/scanner_implementation.dart sdk/lib/_internal/compiler/implementation/scanner/listener.dart sdk/lib/_internal/compiler/implementation/scanner/class_element_parser.dart sdk/lib/_internal/compiler/implementation/scanner/parser_task.dart sdk/lib/_internal/compiler/implementation/scanner/scanner.dart sdk/lib/_internal/compiler/implementation/scanner/keyword.dart sdk/lib/_internal/compiler/implementation/scanner/scanner_task.dart sdk/lib/_internal/compiler/implementation/scanner/partial_parser.dart sdk/lib/_internal/compiler/implementation/scanner/token.dart sdk/lib/_internal/compiler/implementation/scanner/parser.dart sdk/lib/_internal/compiler/implementation/scanner/array_based_scanner.dart sdk/lib/_internal/compiler/implementation/scanner/string_scanner.dart sdk/lib/_internal/compiler/implementation/tree/visitors.dart sdk/lib/_internal/compiler/implementation/tree/prettyprint.dart sdk/lib/_internal/compiler/implementation/tree/unparser.dart sdk/lib/_internal/compiler/implementation/tree/tree.dart sdk/lib/_internal/compiler/implementation/tree/nodes.dart sdk/lib/_internal/compiler/implementation/tree/dartstring.dart sdk/lib/_internal/compiler/samples/leap/leap_leg.dart sdk/lib/_internal/compiler/samples/leap/request_cache.dart sdk/lib/_internal/compiler/samples/leap/leap_script.dart sdk/lib/_internal/compiler/samples/leap/leap_server.dart sdk/lib/_internal/compiler/samples/leap/leap.dart pkg/intl/lib/number_symbols.dart pkg/intl/lib/intl.dart pkg/intl/lib/number_format.dart pkg/intl/lib/date_format.dart pkg/intl/lib/number_symbols_data.dart pkg/intl/lib/date_symbol_data_http_request.dart pkg/intl/lib/intl_browser.dart pkg/intl/lib/bidi_utils.dart pkg/intl/lib/date_symbol_data_local.dart pkg/intl/lib/date_time_patterns.dart pkg/intl/lib/message_lookup_by_library.dart pkg/intl/lib/date_symbol_data_file.dart pkg/intl/lib/extract_messages.dart pkg/intl/lib/generate_localized.dart pkg/intl/lib/bidi_formatter.dart pkg/intl/lib/date_symbols.dart pkg/intl/lib/intl_standalone.dart pkg/intl/lib/src/date_format_helpers.dart pkg/intl/lib/src/http_request_data_reader.dart pkg/intl/lib/src/file_data_reader.dart pkg/intl/lib/src/date_format_internal.dart pkg/intl/lib/src/intl_message.dart pkg/intl/lib/src/intl_helpers.dart pkg/intl/lib/src/date_format_field.dart pkg/intl/lib/src/lazy_locale_data.dart pkg/intl/lib/src/data/dates/localeList.dart pkg/intl/test/date_time_format_local_odd_test.dart pkg/intl/test/data_directory.dart pkg/intl/test/date_time_format_local_even_test.dart pkg/intl/test/intl_message_basic_example_test.dart pkg/intl/test/number_test_data.dart pkg/intl/test/bidi_utils_test.dart pkg/intl/test/date_time_format_test_data.dart pkg/intl/test/number_closure_test.dart pkg/intl/test/date_time_format_file_even_test.dart pkg/intl/test/number_format_test.dart pkg/intl/test/intl_test.dart pkg/intl/test/find_default_locale_standalone_test.dart pkg/intl/test/date_time_format_test_core.dart pkg/intl/test/date_time_format_http_request_test.dart pkg/intl/test/date_time_format_uninitialized_test.dart pkg/intl/test/date_time_format_test_stub.dart pkg/intl/test/find_default_locale_browser_test.dart pkg/intl/test/bidi_format_test.dart pkg/intl/test/date_time_format_file_odd_test.dart pkg/intl/test/message_extraction/generate_from_json.dart pkg/intl/test/message_extraction/sample_with_messages.dart pkg/intl/test/message_extraction/make_hardcoded_translation.dart pkg/intl/test/message_extraction/part_of_sample_with_messages.dart pkg/intl/test/message_extraction/extract_to_json.dart pkg/intl/test/message_extraction/message_extraction_test.dart pkg/intl/tool/generate_locale_data_files.dart pkg/intl/example/basic/basic_example_runner.dart pkg/intl/example/basic/basic_example.dart pkg/intl/example/basic/messages_de.dart pkg/intl/example/basic/messages_all.dart pkg/intl/example/basic/messages_th_th.dart pkg/serialization/lib/serialization.dart pkg/serialization/lib/src/format.dart pkg/serialization/lib/src/serialization_rule.dart pkg/serialization/lib/src/serialization_helpers.dart pkg/serialization/lib/src/mirrors_helpers.dart pkg/serialization/lib/src/basic_rule.dart pkg/serialization/lib/src/reader_writer.dart pkg/serialization/test/serialization_test.dart pkg/serialization/test/test_models.dart pkg/serialization/test/polyfill_identity_map_test.dart pkg/serialization/test/no_library_test.dart pkg/analyzer_experimental/bin/analyzer.dart pkg/analyzer_experimental/lib/options.dart pkg/analyzer_experimental/lib/analyzer.dart pkg/analyzer_experimental/lib/src/generated/constant.dart pkg/analyzer_experimental/lib/src/generated/utilities_dart.dart pkg/analyzer_experimental/lib/src/generated/instrumentation.dart pkg/analyzer_experimental/lib/src/generated/source_io.dart pkg/analyzer_experimental/lib/src/generated/ast.dart pkg/analyzer_experimental/lib/src/generated/sdk.dart pkg/analyzer_experimental/lib/src/generated/element.dart pkg/analyzer_experimental/lib/src/generated/engine.dart pkg/analyzer_experimental/lib/src/generated/scanner.dart pkg/analyzer_experimental/lib/src/generated/java_core.dart pkg/analyzer_experimental/lib/src/generated/java_engine.dart pkg/analyzer_experimental/lib/src/generated/java_io.dart pkg/analyzer_experimental/lib/src/generated/parser.dart pkg/analyzer_experimental/lib/src/generated/java_junit.dart pkg/analyzer_experimental/lib/src/generated/sdk_io.dart pkg/analyzer_experimental/lib/src/generated/html.dart pkg/analyzer_experimental/lib/src/generated/java_engine_io.dart pkg/analyzer_experimental/lib/src/generated/error.dart pkg/analyzer_experimental/lib/src/generated/source.dart pkg/analyzer_experimental/lib/src/generated/resolver.dart pkg/analyzer_experimental/test/options_test.dart pkg/analyzer_experimental/test/generated/resolver_test.dart pkg/analyzer_experimental/test/generated/scanner_test.dart pkg/analyzer_experimental/test/generated/element_test.dart pkg/analyzer_experimental/test/generated/ast_test.dart pkg/analyzer_experimental/test/generated/test_support.dart pkg/analyzer_experimental/test/generated/parser_test.dart pkg/analyzer_experimental/example/scanner_driver.dart pkg/analyzer_experimental/example/resolver_driver.dart pkg/analyzer_experimental/example/parser_driver.dart pkg/webdriver/lib/webdriver.dart pkg/webdriver/lib/src/base64decoder.dart pkg/webdriver/test/webdriver_test.dart pkg/fixnum/lib/fixnum.dart pkg/fixnum/lib/src/int64.dart pkg/fixnum/lib/src/intx.dart pkg/fixnum/lib/src/int32.dart pkg/fixnum/test/int_32_test.dart pkg/fixnum/test/int_64_vm_test.dart pkg/fixnum/test/int_64_test.dart pkg/pathos/lib/path.dart pkg/pathos/test/pathos_test.dart pkg/pathos/test/pathos_windows_test.dart pkg/pathos/test/pathos_posix_test.dart pkg/meta/lib/meta.dart pkg/oauth2/lib/oauth2.dart pkg/oauth2/lib/src/utils.dart pkg/oauth2/lib/src/expiration_exception.dart pkg/oauth2/lib/src/credentials.dart pkg/oauth2/lib/src/authorization_exception.dart pkg/oauth2/lib/src/authorization_code_grant.dart pkg/oauth2/lib/src/handle_access_token_response.dart pkg/oauth2/lib/src/client.dart pkg/oauth2/test/utils.dart pkg/oauth2/test/handle_access_token_response_test.dart pkg/oauth2/test/authorization_code_grant_test.dart pkg/oauth2/test/client_test.dart pkg/oauth2/test/utils_test.dart pkg/oauth2/test/credentials_test.dart pkg/http/lib/http.dart pkg/http/lib/testing.dart pkg/http/lib/src/io_client.dart pkg/http/lib/src/utils.dart pkg/http/lib/src/base_request.dart pkg/http/lib/src/streamed_response.dart pkg/http/lib/src/byte_stream.dart pkg/http/lib/src/base_client.dart pkg/http/lib/src/streamed_request.dart pkg/http/lib/src/base_response.dart pkg/http/lib/src/mock_client.dart pkg/http/lib/src/response.dart pkg/http/lib/src/request.dart pkg/http/lib/src/client.dart pkg/http/lib/src/multipart_file.dart pkg/http/lib/src/multipart_request.dart pkg/http/test/mock_client_test.dart pkg/http/test/utils.dart pkg/http/test/streamed_request_test.dart pkg/http/test/multipart_test.dart pkg/http/test/client_test.dart pkg/http/test/http_test.dart pkg/http/test/request_test.dart pkg/http/test/response_test.dart pkg/http/test/safe_http_server.dart pkg/expect/lib/expect.dart pkg/logging/lib/logging.dart pkg/logging/test/logging_test.dart pkg/stack_trace/lib/stack_trace.dart pkg/stack_trace/lib/src/utils.dart pkg/stack_trace/lib/src/trace.dart pkg/stack_trace/lib/src/frame.dart pkg/stack_trace/test/frame_test.dart pkg/stack_trace/test/trace_test.dart pkg/yaml/lib/yaml.dart pkg/yaml/lib/src/composer.dart pkg/yaml/lib/src/utils.dart pkg/yaml/lib/src/yaml_exception.dart pkg/yaml/lib/src/deep_equals.dart pkg/yaml/lib/src/visitor.dart pkg/yaml/lib/src/yaml_map.dart pkg/yaml/lib/src/parser.dart pkg/yaml/lib/src/model.dart pkg/yaml/lib/src/constructor.dart pkg/yaml/test/yaml_test.dart pkg/scheduled_test/lib/scheduled_test.dart pkg/scheduled_test/lib/scheduled_process.dart pkg/scheduled_test/lib/scheduled_server.dart pkg/scheduled_test/lib/descriptor.dart pkg/scheduled_test/lib/src/utils.dart pkg/scheduled_test/lib/src/schedule_error.dart pkg/scheduled_test/lib/src/task.dart pkg/scheduled_test/lib/src/substitute_future.dart pkg/scheduled_test/lib/src/scheduled_future_matchers.dart pkg/scheduled_test/lib/src/value_future.dart pkg/scheduled_test/lib/src/mock_clock.dart pkg/scheduled_test/lib/src/future_group.dart pkg/scheduled_test/lib/src/schedule.dart pkg/scheduled_test/lib/src/scheduled_server/handler.dart pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart pkg/scheduled_test/lib/src/descriptor/async_descriptor.dart pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart pkg/scheduled_test/lib/src/descriptor/descriptor.dart pkg/scheduled_test/lib/src/descriptor/file_descriptor.dart pkg/scheduled_test/lib/src/descriptor/pattern_descriptor.dart pkg/scheduled_test/test/utils.dart pkg/scheduled_test/test/substitute_future_test.dart pkg/scheduled_test/test/scheduled_server_test.dart pkg/scheduled_test/test/scheduled_future_matchers_test.dart pkg/scheduled_test/test/metatest.dart pkg/scheduled_test/test/value_future_test.dart pkg/scheduled_test/test/scheduled_process_test.dart pkg/scheduled_test/test/descriptor/utils.dart pkg/scheduled_test/test/descriptor/file_test.dart pkg/scheduled_test/test/descriptor/nothing_test.dart pkg/scheduled_test/test/descriptor/pattern_test.dart pkg/scheduled_test/test/descriptor/directory_test.dart pkg/scheduled_test/test/descriptor/async_test.dart pkg/scheduled_test/test/scheduled_test/current_schedule_state_test.dart pkg/scheduled_test/test/scheduled_test/current_schedule_current_task_test.dart pkg/scheduled_test/test/scheduled_test/nested_task_test.dart pkg/scheduled_test/test/scheduled_test/on_exception_test.dart pkg/scheduled_test/test/scheduled_test/task_return_value_test.dart pkg/scheduled_test/test/scheduled_test/abort_test.dart pkg/scheduled_test/test/scheduled_test/timeout_test.dart pkg/scheduled_test/test/scheduled_test/out_of_band_task_test.dart pkg/scheduled_test/test/scheduled_test/wrap_async_test.dart pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart pkg/scheduled_test/test/scheduled_test/wrap_future_test.dart pkg/scheduled_test/test/scheduled_test/signal_error_test.dart pkg/scheduled_test/test/scheduled_test/set_up_test.dart pkg/scheduled_test/test/scheduled_test/on_complete_test.dart pkg/scheduled_test/test/scheduled_test/simple_test.dart pkg/scheduled_test/test/scheduled_test/current_schedule_errors_test.dart pkg/unittest/lib/unittest.dart pkg/unittest/lib/html_individual_config.dart pkg/unittest/lib/vm_config.dart pkg/unittest/lib/html_enhanced_config.dart pkg/unittest/lib/matcher.dart pkg/unittest/lib/interactive_html_config.dart pkg/unittest/lib/mock.dart pkg/unittest/lib/html_config.dart pkg/unittest/lib/compact_vm_config.dart pkg/unittest/lib/src/expect.dart pkg/unittest/lib/src/basematcher.dart pkg/unittest/lib/src/string_matchers.dart pkg/unittest/lib/src/core_matchers.dart pkg/unittest/lib/src/interfaces.dart pkg/unittest/lib/src/description.dart pkg/unittest/lib/src/future_matchers.dart pkg/unittest/lib/src/numeric_matchers.dart pkg/unittest/lib/src/iterable_matchers.dart pkg/unittest/lib/src/map_matchers.dart pkg/unittest/lib/src/config.dart pkg/unittest/lib/src/test_case.dart pkg/unittest/lib/src/operator_matchers.dart pkg/unittest/test/mock_regexp_negative_test.dart pkg/unittest/test/matchers_test.dart pkg/unittest/test/unittest_test.dart pkg/unittest/test/test_utils.dart pkg/unittest/test/instance_test.dart pkg/unittest/test/mock_test.dart pkg/unittest/test/mock_stepwise_negative_test.dart pkg/args/lib/args.dart pkg/args/lib/src/parser.dart pkg/args/lib/src/usage.dart pkg/args/test/args_test.dart pkg/args/test/usage_test.dart pkg/args/test/command_test.dart pkg/args/test/parse_test.dart pkg/args/example/test_runner.dart pkg/source_maps/lib/span.dart pkg/source_maps/lib/source_maps.dart pkg/source_maps/lib/parser.dart pkg/source_maps/lib/builder.dart pkg/source_maps/lib/printer.dart pkg/source_maps/lib/src/utils.dart pkg/source_maps/lib/src/vlq.dart pkg/source_maps/test/vlq_test.dart pkg/source_maps/test/run.dart pkg/source_maps/test/builder_test.dart pkg/source_maps/test/utils_test.dart pkg/source_maps/test/common.dart pkg/source_maps/test/parser_test.dart pkg/source_maps/test/printer_test.dart pkg/source_maps/test/span_test.dart pkg/source_maps/test/end2end_test.dart FORCE_DO_CMD
+	$(call do_cmd,dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot)
+
+all_deps += $(obj)/gen/pub.dart.snapshot
+action_dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot_outputs := $(obj)/gen/pub.dart.snapshot
+
+
+### Rules for final target.
+# Build our special outputs first.
+$(obj).target/utils/pub/pub.stamp: | $(action_dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot_outputs)
+
+# Preserve order dependency of special output on deps.
+$(action_dart_utils_pub_pub_gyp_pub_target_generate_pub_snapshot_outputs): | $(builddir)/dart $(obj).target/pkg/pkg_packages.stamp
+
+$(obj).target/utils/pub/pub.stamp: TOOLSET := $(TOOLSET)
+$(obj).target/utils/pub/pub.stamp: $(builddir)/dart $(obj).target/pkg/pkg_packages.stamp FORCE_DO_CMD
+	$(call do_cmd,touch)
+
+all_deps += $(obj).target/utils/pub/pub.stamp
+# Add target alias
+.PHONY: pub
+pub: $(obj).target/utils/pub/pub.stamp
+
+# Add target alias to "all" target.
+.PHONY: all
+all: pub
+
diff --git a/utils/pub/solver/greedy_solver.dart b/utils/pub/solver/greedy_solver.dart
new file mode 100644
index 0000000..e664ea2
--- /dev/null
+++ b/utils/pub/solver/greedy_solver.dart
@@ -0,0 +1,556 @@
+// Copyright (c) 2012, 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.
+
+/// Attempts to resolve a set of version constraints for a package dependency
+/// graph and select an appropriate set of best specific versions for all
+/// dependent packages. It works iteratively and tries to reach a stable
+/// solution where the constraints of all dependencies are met. If it fails to
+/// reach a solution after a certain number of iterations, it assumes the
+/// dependency graph is unstable and reports and error.
+///
+/// There are two fundamental operations in the process of iterating over the
+/// graph:
+///
+/// 1.  Changing the selected concrete version of some package. (This includes
+///     adding and removing a package too, which is considering changing the
+///     version to or from "none".) In other words, a node has changed.
+/// 2.  Changing the version constraint that one package places on another. In
+///     other words, and edge has changed.
+///
+/// Both of these events have a corresponding (potentional) async operation and
+/// roughly cycle back and forth between each other. When we change the version
+/// of package changes, we asynchronously load the pubspec for the new version.
+/// When that's done, we compare the dependencies of the new version versus the
+/// old one. For everything that differs, we change those constraints between
+/// this package and that dependency.
+///
+/// When a constraint on a package changes, we re-calculate the overall
+/// constraint on that package. I.e. with a shared dependency, we intersect all
+/// of the constraints that its depending packages place on it. If that overall
+/// constraint changes (say from "<3.0.0" to "<2.5.0"), then the currently
+/// picked version for that package may fall outside of the new constraint. If
+/// that happens, we find the new best version that meets the updated constraint
+/// and then the change the package to use that version. That cycles back up to
+/// the beginning again.
+library version_solver1;
+
+import 'dart:async';
+import 'dart:collection' show Queue;
+import 'dart:math' as math;
+
+import '../lock_file.dart';
+import '../log.dart' as log;
+import '../package.dart';
+import '../source.dart';
+import '../source_registry.dart';
+import '../version.dart';
+import 'version_solver.dart';
+
+class GreedyVersionSolver extends VersionSolver {
+  final _packages = <String, DependencyNode>{};
+  final _work = new Queue<WorkItem>();
+  int _numIterations = 0;
+
+  GreedyVersionSolver(SourceRegistry sources, Package root, LockFile lockFile,
+                      List<String> useLatest)
+      : super(sources, root, lockFile, useLatest);
+
+  /// The non-backtracking solver always only tries one solution.
+  int get attemptedSolutions => 1;
+
+  void forceLatestVersion(String package) {
+    // TODO(nweiz): How do we want to detect and handle unknown dependencies
+    // here?
+    getDependency(package).useLatestVersion = true;
+  }
+
+  Future<List<PackageId>> runSolver() {
+    // Kick off the work by adding the root package at its concrete version to
+    // the dependency graph.
+    enqueue(new AddConstraint('(entrypoint)', new PackageRef.root(root)));
+
+    Future processNextWorkItem(_) {
+      while (true) {
+        // Stop if we are done.
+        if (_work.isEmpty) return new Future.value(buildResults());
+
+        // If we appear to be stuck in a loop, then we probably have an unstable
+        // graph, bail. We guess this based on a rough heuristic that it should
+        // only take a certain number of steps to solve a graph with a given
+        // number of connections.
+        // TODO(rnystrom): These numbers here are magic and arbitrary. Tune
+        // when we have a better picture of real-world package topologies.
+        _numIterations++;
+        if (_numIterations > math.max(50, _packages.length * 5)) {
+          throw new CouldNotSolveException();
+        }
+
+        // Run the first work item.
+        var future = _work.removeFirst().process(this);
+
+        // If we have an async operation to perform, chain the loop to resume
+        // when it's done. Otherwise, just loop synchronously.
+        if (future != null) {
+          return future.then(processNextWorkItem);
+        }
+      }
+    }
+
+    return processNextWorkItem(null);
+  }
+
+  void enqueue(WorkItem work) {
+    _work.add(work);
+  }
+
+  DependencyNode getDependency(String package) {
+    // There can be unused dependencies in the graph, so just create an empty
+    // one if needed.
+    _packages.putIfAbsent(package, () => new DependencyNode(package));
+    return _packages[package];
+  }
+
+  /// Sets the best selected version of [package] to [version].
+  void setVersion(String package, Version version) {
+    _packages[package].version = version;
+  }
+
+  /// Returns the most recent version of [dependency] that satisfies all of its
+  /// version constraints.
+  Future<Version> getBestVersion(DependencyNode dependency) {
+    return cache.getVersions(dependency.name,
+        dependency.source, dependency.description).then((versions) {
+      var best = null;
+      for (var ref in versions) {
+        if (dependency.useLatestVersion ||
+            dependency.constraint.allows(ref.version)) {
+          if (best == null || ref.version > best) best = ref.version;
+        }
+      }
+
+      // TODO(rnystrom): Better exception.
+      if (best == null) {
+        if (tryUnlockDepender(dependency)) return null;
+        throw new NoVersionException(dependency.name, dependency.constraint,
+            dependency.toList());
+      } else if (!dependency.constraint.allows(best)) {
+        if (tryUnlockDepender(dependency)) return null;
+        throw new CouldNotUpdateException(
+            dependency.name, dependency.constraint, best);
+      }
+
+      return best;
+    });
+  }
+
+  /// Looks for a package that depends (transitively) on [dependency] and has
+  /// its version locked in the lockfile. If one is found, enqueues an
+  /// [UnlockPackage] work item for it and returns true. Otherwise, returns
+  /// false.
+  ///
+  /// This does a breadth-first search; immediate dependers will be unlocked
+  /// first, followed by transitive dependers.
+  bool tryUnlockDepender(DependencyNode dependency, [Set<String> seen]) {
+    if (seen == null) seen = new Set();
+    // Avoid an infinite loop if there are circular dependencies.
+    if (seen.contains(dependency.name)) return false;
+    seen.add(dependency.name);
+
+    for (var dependerName in dependency.dependers) {
+      var depender = getDependency(dependerName);
+      var locked = lockFile.packages[dependerName];
+      if (locked != null && depender.version == locked.version &&
+          depender.source.name == locked.source.name) {
+        enqueue(new UnlockPackage(depender));
+        return true;
+      }
+    }
+
+    return dependency.dependers.map(getDependency).any((subdependency) =>
+        tryUnlockDepender(subdependency, seen));
+  }
+
+  List<PackageId> buildResults() {
+    return _packages.values
+        .where((dep) => dep.isDependedOn)
+        .map(_dependencyToPackageId)
+        .toList();
+  }
+
+  PackageId _dependencyToPackageId(DependencyNode dep) {
+    var description = dep.description;
+
+    // If the lockfile contains a fully-resolved description for the package,
+    // use that. This allows e.g. Git to ensure that the same commit is used.
+    var lockedPackage = lockFile.packages[dep.name];
+    if (lockedPackage != null && lockedPackage.version == dep.version &&
+        lockedPackage.source.name == dep.source.name &&
+        dep.source.descriptionsEqual(
+            description, lockedPackage.description)) {
+      description = lockedPackage.description;
+    }
+
+    return new PackageId(dep.name, dep.source, dep.version, description);
+  }
+}
+
+/// The constraint solver works by iteratively processing a queue of work items.
+/// Each item is a single atomic change to the dependency graph. Handling them
+/// in a queue lets us handle asynchrony (resolving versions requires
+/// information from servers) as well as avoid deeply nested recursion.
+abstract class WorkItem {
+  /// Processes this work item. Returns a future that completes when the work is
+  /// done. If `null` is returned, that means the work has completed
+  /// synchronously and the next item can be started immediately.
+  Future process(GreedyVersionSolver solver);
+}
+
+/// The best selected version for a package has changed to [version]. If the
+/// previous version of the package is `null`, that means the package is being
+/// added to the graph. If [version] is `null`, it is being removed.
+class ChangeVersion implements WorkItem {
+  /// The name of the package whose version is being changed.
+  final String package;
+
+  /// The source of the package whose version is changing.
+  final Source source;
+
+  /// The description identifying the package whose version is changing.
+  final description;
+
+  /// The new selected version.
+  final Version version;
+
+  ChangeVersion(this.package, this.source, this.description, this.version);
+
+  Future process(GreedyVersionSolver solver) {
+    log.fine("Changing $package to version $version.");
+
+    var dependency = solver.getDependency(package);
+    var oldVersion = dependency.version;
+    solver.setVersion(package, version);
+
+    // The dependencies between the old and new version may be different. Walk
+    // them both and update any constraints that differ between the two.
+    return Future.wait([
+        getDependencyRefs(solver, oldVersion),
+        getDependencyRefs(solver, version)]).then((list) {
+      var oldDependencyRefs = list[0];
+      var newDependencyRefs = list[1];
+
+      for (var oldRef in oldDependencyRefs.values) {
+        if (newDependencyRefs.containsKey(oldRef.name)) {
+          // The dependency is in both versions of this package, but its
+          // constraint may have changed.
+          var newRef = newDependencyRefs.remove(oldRef.name);
+          solver.enqueue(new AddConstraint(package, newRef));
+        } else {
+          // The dependency is not in the new version of the package, so just
+          // remove its constraint.
+          solver.enqueue(new RemoveConstraint(package, oldRef.name));
+        }
+      }
+
+      // Everything that's left is a depdendency that's only in the new
+      // version of the package.
+      for (var newRef in newDependencyRefs.values) {
+        solver.enqueue(new AddConstraint(package, newRef));
+      }
+    });
+  }
+
+  /// Get the dependencies at [version] of the package being changed.
+  Future<Map<String, PackageRef>> getDependencyRefs(VersionSolver solver,
+      Version version) {
+    // If there is no version, it means no package, so no dependencies.
+    if (version == null) {
+      return new Future<Map<String, PackageRef>>.value(<String, PackageRef>{});
+    }
+
+    var id = new PackageId(package, source, version, description);
+    return solver.cache.getPubspec(id).then((pubspec) {
+      var dependencies = <String, PackageRef>{};
+      for (var dependency in pubspec.dependencies) {
+        dependencies[dependency.name] = dependency;
+      }
+
+      // Include dev dependencies only from the root package.
+      if (id.isRoot) {
+        for (var dependency in pubspec.devDependencies) {
+          dependencies[dependency.name] = dependency;
+        }
+      }
+
+      return dependencies;
+    });
+  }
+}
+
+/// A constraint that a depending package places on a dependent package has
+/// changed.
+///
+/// This is an abstract class that contains logic for updating the dependency
+/// graph once a dependency has changed. Changing the dependency is the
+/// responsibility of subclasses.
+abstract class ChangeConstraint implements WorkItem {
+  Future process(GreedyVersionSolver solver);
+
+  void undo(GreedyVersionSolver solver);
+
+  Future _processChange(GreedyVersionSolver solver,
+                        DependencyNode oldDependency,
+                        DependencyNode newDependency) {
+    var name = newDependency.name;
+    var source = oldDependency.source != null ?
+      oldDependency.source : newDependency.source;
+    var description = oldDependency.description != null ?
+      oldDependency.description : newDependency.description;
+    var oldConstraint = oldDependency.constraint;
+    var newConstraint = newDependency.constraint;
+
+    // If the package is over-constrained, i.e. the packages depending have
+    // disjoint constraints, then try unlocking a depender that's locked by the
+    // lockfile. If there are no remaining locked dependencies, throw an error.
+    if (newConstraint != null && newConstraint.isEmpty) {
+      if (solver.tryUnlockDepender(newDependency)) {
+        undo(solver);
+        return null;
+      }
+
+      throw new DisjointConstraintException(name, newDependency.toList());
+    }
+
+    // If this constraint change didn't cause the overall constraint on the
+    // package to change, then we don't need to do any further work.
+    if (oldConstraint == newConstraint) return null;
+
+    // If the dependency has been cut free from the graph, just remove it.
+    if (!newDependency.isDependedOn) {
+      solver.enqueue(new ChangeVersion(name, source, description, null));
+      return null;
+    }
+
+    // If the dependency is on the root package, then we don't need to do
+    // anything since it's already at the best version.
+    if (name == solver.root.name) {
+      solver.enqueue(new ChangeVersion(
+          name, source, description, solver.root.version));
+      return null;
+    }
+
+    // If the dependency is on a package in the lockfile, use the lockfile's
+    // version for that package if it's valid given the other constraints.
+    var lockedPackage = solver.lockFile.packages[name];
+    if (lockedPackage != null && newDependency.source == lockedPackage.source) {
+      var lockedVersion = lockedPackage.version;
+      if (newConstraint.allows(lockedVersion)) {
+        solver.enqueue(
+            new ChangeVersion(name, source, description, lockedVersion));
+        return null;
+      }
+    }
+
+    // The constraint has changed, so see what the best version of the package
+    // that meets the new constraint is.
+    return solver.getBestVersion(newDependency).then((best) {
+      if (best == null) {
+        undo(solver);
+      } else if (newDependency.version != best) {
+        solver.enqueue(new ChangeVersion(name, source, description, best));
+      }
+    });
+  }
+}
+
+/// The constraint given by [ref] is being placed by [depender].
+class AddConstraint extends ChangeConstraint {
+  /// The package that has the dependency.
+  final String depender;
+
+  /// The package being depended on and the constraints being placed on it. The
+  /// source, version, and description in this ref are all considered
+  /// constraints on the dependent package.
+  final PackageRef ref;
+
+  AddConstraint(this.depender, this.ref);
+
+  Future process(GreedyVersionSolver solver) {
+    log.fine("Adding $depender's constraint $ref.");
+
+    var dependency = solver.getDependency(ref.name);
+    var oldDependency = dependency.clone();
+    dependency.placeConstraint(depender, ref);
+    return _processChange(solver, oldDependency, dependency);
+  }
+
+  void undo(GreedyVersionSolver solver) {
+    solver.getDependency(ref.name).removeConstraint(depender);
+  }
+}
+
+/// [depender] is no longer placing a constraint on [dependent].
+class RemoveConstraint extends ChangeConstraint {
+  /// The package that was placing a constraint on [dependent].
+  String depender;
+
+  /// The package that was being depended on.
+  String dependent;
+
+  /// The constraint that was removed.
+  PackageRef _removed;
+
+  RemoveConstraint(this.depender, this.dependent);
+
+  Future process(GreedyVersionSolver solver) {
+    log.fine("Removing $depender's constraint ($_removed) on $dependent.");
+
+    var dependency = solver.getDependency(dependent);
+    var oldDependency = dependency.clone();
+    _removed = dependency.removeConstraint(depender);
+    return _processChange(solver, oldDependency, dependency);
+  }
+
+  void undo(GreedyVersionSolver solver) {
+    solver.getDependency(dependent).placeConstraint(depender, _removed);
+  }
+}
+
+/// [package]'s version is no longer constrained by the lockfile.
+class UnlockPackage implements WorkItem {
+  /// The package being unlocked.
+  DependencyNode package;
+
+  UnlockPackage(this.package);
+
+  Future process(GreedyVersionSolver solver) {
+    log.fine("Unlocking ${package.name}.");
+
+    solver.lockFile.packages.remove(package.name);
+    return solver.getBestVersion(package).then((best) {
+      if (best == null) return null;
+      solver.enqueue(new ChangeVersion(
+          package.name, package.source, package.description, best));
+    });
+  }
+}
+
+/// Describes one [Package] in the [DependencyGraph] and keeps track of which
+/// packages depend on it and what constraints they place on it.
+class DependencyNode {
+  /// The name of the this dependency's package.
+  final String name;
+
+  /// The [PackageRefs] that represent constraints that depending packages have
+  /// placed on this one.
+  final Map<String, PackageRef> _refs;
+
+  /// The currently-selected best version for this dependency.
+  Version version;
+
+  /// Whether this dependency should always select the latest version.
+  bool useLatestVersion = false;
+
+  /// Gets whether or not any other packages are currently depending on this
+  /// one. If `false`, then it means this package is not part of the dependency
+  /// graph and should be omitted.
+  bool get isDependedOn => !_refs.isEmpty;
+
+  /// The names of all the packages that depend on this dependency.
+  Iterable<String> get dependers => _refs.keys;
+
+  /// Gets the overall constraint that all packages are placing on this one.
+  /// If no packages have a constraint on this one (which can happen when this
+  /// package is in the process of being added to the graph), returns `null`.
+  VersionConstraint get constraint {
+    if (_refs.isEmpty) return null;
+    return new VersionConstraint.intersection(
+        _refs.values.map((ref) => ref.constraint));
+  }
+
+  /// The source of this dependency's package.
+  Source get source {
+     var canonical = _canonicalRef();
+     if (canonical == null) return null;
+     return canonical.source;
+  }
+
+  /// The description of this dependency's package.
+  get description {
+     var canonical = _canonicalRef();
+     if (canonical == null) return null;
+     return canonical.description;
+  }
+
+  /// Return the PackageRef that has the canonical source and description for
+  /// this package. If any dependency is on the root package, that will be used;
+  /// otherwise, it will be the source and description that all dependencies
+  /// agree upon.
+  PackageRef _canonicalRef() {
+    if (_refs.isEmpty) return null;
+    var refs = _refs.values;
+    for (var ref in refs) {
+      if (ref.isRoot) return ref;
+    }
+    return refs.first;
+  }
+
+  DependencyNode(this.name)
+      : _refs = <String, PackageRef>{};
+
+  DependencyNode._clone(DependencyNode other)
+      : name = other.name,
+        version = other.version,
+        _refs = new Map<String, PackageRef>.from(other._refs);
+
+  /// Creates a copy of this dependency.
+  DependencyNode clone() => new DependencyNode._clone(this);
+
+  /// Places [ref] as a constraint from [package] onto this.
+  void placeConstraint(String package, PackageRef ref) {
+    var requiredDepender = _requiredDepender();
+    if (requiredDepender != null) {
+      var required = _refs[requiredDepender];
+      if (required.source.name != ref.source.name) {
+        throw new SourceMismatchException(name, [
+            new Dependency(requiredDepender, required),
+            new Dependency(package, ref)]);
+      } else if (!required.descriptionEquals(ref)) {
+        throw new DescriptionMismatchException(name, [
+            new Dependency(requiredDepender, required),
+            new Dependency(package, ref)]);
+      }
+    }
+
+    _refs[package] = ref;
+  }
+
+  /// Returns the name of a package whose constraint source and description
+  /// all other constraints must match. Returns null if there are no
+  /// requirements on new constraints.
+  String _requiredDepender() {
+    if (_refs.isEmpty) return null;
+
+    var dependers = _refs.keys.toList();
+    if (dependers.length == 1) {
+      var depender = dependers[0];
+      if (_refs[depender].isRoot) return null;
+      return depender;
+    }
+
+    return dependers[1];
+  }
+
+  /// Removes the constraint from [package] onto this.
+  PackageRef removeConstraint(String package) => _refs.remove(package);
+
+  /// Converts this to a list of [Dependency] objects like the error types
+  /// expect.
+  List<Dependency> toList() {
+    var result = <Dependency>[];
+    _refs.forEach((name, ref) {
+      result.add(new Dependency(name, ref));
+    });
+    return result;
+  }
+}