Support ForEachExpand on non-root functions.

BUG=6000538

Change-Id: I36e78ced0715b060af0938f1480df240cf6ba707
diff --git a/lib/ExecutionEngine/ScriptCached.cpp b/lib/ExecutionEngine/ScriptCached.cpp
index a7d21f7..30fc3fd 100644
--- a/lib/ExecutionEngine/ScriptCached.cpp
+++ b/lib/ExecutionEngine/ScriptCached.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010, The Android Open Source Project
+ * Copyright 2010-2012, The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@
   if (mpStringPoolRaw) { free(mpStringPoolRaw); }
   if (mpExportVars) { free(mpExportVars); }
   if (mpExportFuncs) { free(mpExportFuncs); }
+  if (mpExportForEach) { free(mpExportForEach); }
   if (mpObjectSlotList) { free(mpObjectSlotList); }
 }
 
@@ -72,6 +73,21 @@
 }
 
 
+void ScriptCached::getExportForEachList(size_t forEachListSize,
+                                        void **forEachList) {
+  if (forEachList) {
+    size_t forEachCount = getExportForEachCount();
+
+    if (forEachCount > forEachListSize) {
+      forEachCount = forEachListSize;
+    }
+
+    memcpy(forEachList, mpExportForEach->cached_addr_list,
+           sizeof(void *) * forEachCount);
+  }
+}
+
+
 void ScriptCached::getPragmaList(size_t pragmaListSize,
                                  char const **keyList,
                                  char const **valueList) {