Support for synchronized native methods.

This change adds support for synchronized native methods by using
calls to MonitorEnter and MonitorExit on the JNIEnv*. There is
some tidying of the assembler and a straw man JNIEnv implementation.
The JNIEnv implementation just warns when MonitorEnter/Exit are called
and doesn't adhere to the correct JNIEnv layout.

Change-Id: I90ed6ec8f85f5b01b929f16e0dbdecadd0b01359
diff --git a/src/object.cc b/src/object.cc
index 95e8b67..c8bd353 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -1,8 +1,8 @@
 // Copyright 2011 Google Inc. All Rights Reserved.
 
 #include "src/object.h"
-#include <algorithm>
 #include <string.h>
+#include <algorithm>
 #include "src/globals.h"
 #include "src/logging.h"
 #include "src/dex_file.h"
@@ -127,14 +127,8 @@
   return (shorty_[param] == 'J') || (shorty_[param] == 'D');
 }
 
-size_t Method::ParamSizeInBytes(unsigned int param) const {
-  CHECK_LT(param, NumArgs());
-  if (IsStatic()) {
-    param++;  // 0th argument must skip return value at start of the shorty
-  } else if (param == 0) {
-    return kPointerSize;  // this argument
-  }
-  switch (shorty_[param]) {
+static size_t ShortyCharToSize(char x) {
+  switch (x) {
     case '[': return kPointerSize;
     case 'L': return kPointerSize;
     case 'D': return 8;
@@ -143,6 +137,20 @@
   }
 }
 
+size_t Method::ParamSize(unsigned int param) const {
+  CHECK_LT(param, NumArgs());
+  if (IsStatic()) {
+    param++;  // 0th argument must skip return value at start of the shorty
+  } else if (param == 0) {
+    return kPointerSize;  // this argument
+  }
+  return ShortyCharToSize(shorty_[param]);
+}
+
+size_t Method::ReturnSize() const {
+  return ShortyCharToSize(shorty_[0]);
+}
+
 bool Method::HasSameArgumentTypes(const Method* that) const {
   const RawDexFile* raw1 = this->GetClass()->GetDexFile()->GetRaw();
   const RawDexFile::ProtoId& proto1 = raw1->GetProtoId(this->proto_idx_);