Merge f102554eca50205a55947b046c2ac1ed8336bba4 on remote branch

Change-Id: Ibfc33caa9765c18074e02e528ce2fc6ea4be26b5
diff --git a/Android.base.bp b/Android.base.bp
index e4a18a1..df62d0a 100644
--- a/Android.base.bp
+++ b/Android.base.bp
@@ -40,4 +40,9 @@
             srcs: ["src/base/platform/platform-macos.cc"],
         },
     },
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
diff --git a/Android.bp b/Android.bp
index a5859f2..c124423 100644
--- a/Android.bp
+++ b/Android.bp
@@ -101,6 +101,11 @@
         "libicui18n_headers",
     ],
     generated_headers: ["v8_torque_file"],
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
 
 cc_binary_host {
@@ -230,6 +235,11 @@
         "libv8gen",
     ],
     export_include_dirs: ["include"],
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
 
 // The bare 'd8' name conflicts with d8 from prebuilts/r8
@@ -276,4 +286,4 @@
     ],
     out: ["d8-js.cc"],
 }
-*/
\ No newline at end of file
+*/
diff --git a/Android.platform.bp b/Android.platform.bp
index 3a228b1..826ef43 100644
--- a/Android.platform.bp
+++ b/Android.platform.bp
@@ -19,4 +19,9 @@
         "src",
         "include",
     ],
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
diff --git a/Android.sampler.bp b/Android.sampler.bp
index 081744e..b6a3f35 100644
--- a/Android.sampler.bp
+++ b/Android.sampler.bp
@@ -8,4 +8,9 @@
         "src",
         "include",
     ],
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
diff --git a/Android.v8.bp b/Android.v8.bp
index 539d342..09f14da 100644
--- a/Android.v8.bp
+++ b/Android.v8.bp
@@ -657,4 +657,9 @@
         cfi: true,
         blacklist: "./tools/cfi/blacklist.txt",
     },
+
+    apex_available: [
+        "com.android.art.debug",
+        "com.android.art.release",
+    ],
 }
diff --git a/src/heap/factory.cc b/src/heap/factory.cc
index c8528f9..2ac0d99 100644
--- a/src/heap/factory.cc
+++ b/src/heap/factory.cc
@@ -469,7 +469,7 @@
                                                     PretenureFlag pretenure) {
   DCHECK_LE(0, length);
   if (length == 0) return empty_fixed_array();
-  if (length > FixedDoubleArray::kMaxLength) {
+  if (length < 0 || length > FixedDoubleArray::kMaxLength) {
     isolate()->heap()->FatalProcessOutOfMemory("invalid array length");
   }
   int size = FixedDoubleArray::SizeFor(length);