Upgrade to 3.29

Update V8 to 3.29.88.17 and update makefiles to support building on
all the relevant platforms.

Bug: 17370214

Change-Id: Ia3407c157fd8d72a93e23d8318ccaf6ecf77fa4e
diff --git a/tools/gcmole/gcmole.lua b/tools/gcmole/gcmole.lua
index 09db547..d287f7b 100644
--- a/tools/gcmole/gcmole.lua
+++ b/tools/gcmole/gcmole.lua
@@ -66,7 +66,7 @@
    end
 end
 
-local ARCHS = ARGS[1] and { ARGS[1] } or { 'ia32', 'arm', 'x64' }
+local ARCHS = ARGS[1] and { ARGS[1] } or { 'ia32', 'arm', 'x64', 'arm64' }
 
 local io = require "io"
 local os = require "os"
@@ -80,25 +80,35 @@
 -- Clang invocation
 
 local CLANG_BIN = os.getenv "CLANG_BIN"
+local CLANG_PLUGINS = os.getenv "CLANG_PLUGINS"
 
 if not CLANG_BIN or CLANG_BIN == "" then
    error "CLANG_BIN not set"
 end
 
+if not CLANG_PLUGINS or CLANG_PLUGINS == "" then
+   CLANG_PLUGINS = DIR
+end
+
 local function MakeClangCommandLine(plugin, plugin_args, triple, arch_define)
    if plugin_args then
      for i = 1, #plugin_args do
-        plugin_args[i] = "-plugin-arg-" .. plugin .. " " .. plugin_args[i]
+        plugin_args[i] = "-Xclang -plugin-arg-" .. plugin
+           .. " -Xclang " .. plugin_args[i]
      end
      plugin_args = " " .. table.concat(plugin_args, " ")
    end
-   return CLANG_BIN .. "/clang -cc1 -load " .. DIR .. "/libgcmole.so"
-      .. " -plugin "  .. plugin
+   return CLANG_BIN .. "/clang++ -std=c++11 -c "
+      .. " -Xclang -load -Xclang " .. CLANG_PLUGINS .. "/libgcmole.so"
+      .. " -Xclang -plugin -Xclang "  .. plugin
       .. (plugin_args or "")
-      .. " -triple " .. triple
+      .. " -Xclang -triple -Xclang " .. triple
       .. " -D" .. arch_define
       .. " -DENABLE_DEBUGGER_SUPPORT"
-      .. " -Isrc"
+      .. " -DV8_I18N_SUPPORT"
+      .. " -I./"
+      .. " -Ithird_party/icu/source/common"
+      .. " -Ithird_party/icu/source/i18n"
 end
 
 function InvokeClangPluginForEachFile(filenames, cfg, func)
@@ -108,40 +118,42 @@
                                          cfg.arch_define)
    for _, filename in ipairs(filenames) do
       log("-- %s", filename)
-      local action = cmd_line .. " src/" .. filename .. " 2>&1"
+      local action = cmd_line .. " " .. filename .. " 2>&1"
       if FLAGS.verbose then print('popen ', action) end
       local pipe = io.popen(action)
       func(filename, pipe:lines())
-      pipe:close()
+      local success = pipe:close()
+      if not success then error("Failed to run: " .. action) end
    end
 end
 
 -------------------------------------------------------------------------------
--- SConscript parsing
+-- GYP file parsing
 
-local function ParseSConscript()
-   local f = assert(io.open("src/SConscript"), "failed to open SConscript")
-   local sconscript = f:read('*a')
-   f:close()
-
-   local SOURCES = sconscript:match "SOURCES = {(.-)}";
-
-   local sources = {}
-
-   for condition, list in
-      SOURCES:gmatch "'([^']-)': Split%(\"\"\"(.-)\"\"\"%)" do
-      local files = {}
-      for file in list:gmatch "[^%s]+" do table.insert(files, file) end
-      sources[condition] = files
+local function ParseGYPFile()
+   local gyp = ""
+   local gyp_files = { "tools/gyp/v8.gyp", "test/cctest/cctest.gyp" }
+   for i = 1, #gyp_files do
+      local f = assert(io.open(gyp_files[i]), "failed to open GYP file")
+      local t = f:read('*a')
+      gyp = gyp .. t
+      f:close()
    end
 
-   for condition, list in SOURCES:gmatch "'([^']-)': %[(.-)%]" do
-      local files = {}
-      for file in list:gmatch "'([^']-)'" do table.insert(files, file) end
-      sources[condition] = files
+   local result = {}
+
+   for condition, sources in
+      gyp:gmatch "'sources': %[.-### gcmole%((.-)%) ###(.-)%]" do
+      if result[condition] == nil then result[condition] = {} end
+      for file in sources:gmatch "'%.%./%.%./src/([^']-%.cc)'" do
+         table.insert(result[condition], "src/" .. file)
+      end
+      for file in sources:gmatch "'(test-[^']-%.cc)'" do
+         table.insert(result[condition], "test/cctest/" .. file)
+      end
    end
 
-   return sources
+   return result
 end
 
 local function EvaluateCondition(cond, props)
@@ -165,7 +177,7 @@
    return list
 end
 
-local sources = ParseSConscript()
+local sources = ParseGYPFile()
 
 local function FilesForArch(arch)
    return BuildFileList(sources, { os = 'linux',
@@ -193,7 +205,9 @@
    arm = config { triple = "i586-unknown-linux",
                   arch_define = "V8_TARGET_ARCH_ARM" },
    x64 = config { triple = "x86_64-unknown-linux",
-                  arch_define = "V8_TARGET_ARCH_X64" }
+                  arch_define = "V8_TARGET_ARCH_X64" },
+   arm64 = config { triple = "x86_64-unknown-linux",
+                    arch_define = "V8_TARGET_ARCH_ARM64" },
 }
 
 -------------------------------------------------------------------------------