Merge V8 5.3.332.45.  DO NOT MERGE

Test: Manual

FPIIM-449

Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/gypfiles/get_landmines.py b/gypfiles/get_landmines.py
index 2bbf7a6..9fcca4b 100755
--- a/gypfiles/get_landmines.py
+++ b/gypfiles/get_landmines.py
@@ -27,6 +27,7 @@
   print 'Switching to pinned msvs toolchain.'
   print 'Clobbering to hopefully resolve problem with mksnapshot'
   print 'Clobber after ICU roll.'
+  print 'Clobber after Android NDK update.'
   return 0
 
 
diff --git a/gypfiles/gyp_environment.py b/gypfiles/gyp_environment.py
index 7a4e622..76ae841 100644
--- a/gypfiles/gyp_environment.py
+++ b/gypfiles/gyp_environment.py
@@ -31,6 +31,7 @@
   supported_vars = ( 'V8_GYP_FILE',
                      'V8_GYP_SYNTAX_CHECK',
                      'GYP_DEFINES',
+                     'GYP_GENERATORS',
                      'GYP_GENERATOR_FLAGS',
                      'GYP_GENERATOR_OUTPUT', )
   for var in supported_vars:
@@ -51,4 +52,9 @@
     # Update the environment based on v8.gyp_env
     gyp_env_path = os.path.join(os.path.dirname(V8_ROOT), 'v8.gyp_env')
     apply_gyp_environment(gyp_env_path)
+
+    if not os.environ.get('GYP_GENERATORS'):
+      # Default to ninja on all platforms.
+      os.environ['GYP_GENERATORS'] = 'ninja'
+
     vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
diff --git a/gypfiles/gyp_v8 b/gypfiles/gyp_v8
index e97507a..8be39d9 100755
--- a/gypfiles/gyp_v8
+++ b/gypfiles/gyp_v8
@@ -118,6 +118,10 @@
 if __name__ == '__main__':
   args = sys.argv[1:]
 
+  if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
+    print 'Skipping gyp_v8 due to GYP_CHROMIUM_NO_ACTION env var.'
+    sys.exit(0)
+
   gyp_environment.set_environment()
 
   # This could give false positives since it doesn't actually do real option
diff --git a/gypfiles/has_valgrind.py b/gypfiles/has_valgrind.py
deleted file mode 100755
index 83a848d..0000000
--- a/gypfiles/has_valgrind.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2016 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-VALGRIND_DIR = os.path.join(BASE_DIR, 'third_party', 'valgrind')
-LINUX32_DIR = os.path.join(VALGRIND_DIR, 'linux_x86')
-LINUX64_DIR = os.path.join(VALGRIND_DIR, 'linux_x64')
-
-
-def DoMain(_):
-  """Hook to be called from gyp without starting a separate python
-  interpreter."""
-  return int(os.path.exists(LINUX32_DIR) and os.path.exists(LINUX64_DIR))
-
-
-if __name__ == '__main__':
-  print DoMain([])
diff --git a/gypfiles/isolate.gypi b/gypfiles/isolate.gypi
index a9614b5..085ed5d 100644
--- a/gypfiles/isolate.gypi
+++ b/gypfiles/isolate.gypi
@@ -73,7 +73,7 @@
         '--config-variable', 'cfi_vptr=<(cfi_vptr)',
         '--config-variable', 'gcmole=<(gcmole)',
         '--config-variable', 'has_valgrind=<(has_valgrind)',
-        '--config-variable', 'icu_use_data_file_flag=0',
+        '--config-variable', 'icu_use_data_file_flag=<(icu_use_data_file_flag)',
         '--config-variable', 'msan=<(msan)',
         '--config-variable', 'tsan=<(tsan)',
         '--config-variable', 'coverage=<(coverage)',
diff --git a/gypfiles/standalone.gypi b/gypfiles/standalone.gypi
index 630c45e..c6c26fb 100644
--- a/gypfiles/standalone.gypi
+++ b/gypfiles/standalone.gypi
@@ -49,35 +49,70 @@
     'variables': {
       'variables': {
         'variables': {
-          'conditions': [
-            ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
-               OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
-              # This handles the Unix platforms we generally deal with.
-              # Anything else gets passed through, which probably won't work
-              # very well; such hosts should pass an explicit target_arch
-              # to gyp.
-              'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
-            }, {
-              # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
-              # OS!="netbsd" and OS!="mac" and OS!="aix"
-              'host_arch%': 'ia32',
-            }],
-          ],
+          'variables': {
+            'conditions': [
+              ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
+                 OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
+                # This handles the Unix platforms we generally deal with.
+                # Anything else gets passed through, which probably won't work
+                # very well; such hosts should pass an explicit target_arch
+                # to gyp.
+                'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
+              }, {
+                # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
+                # OS!="netbsd" and OS!="mac" and OS!="aix"
+                'host_arch%': 'ia32',
+              }],
+            ],
+          },
+          'host_arch%': '<(host_arch)',
+          'target_arch%': '<(host_arch)',
+
+          # By default we build against a stable sysroot image to avoid
+          # depending on the packages installed on the local machine. Set this
+          # to 0 to build against locally installed headers and libraries (e.g.
+          # if packaging for a linux distro)
+          'use_sysroot%': 1,
         },
         'host_arch%': '<(host_arch)',
-        'target_arch%': '<(host_arch)',
+        'target_arch%': '<(target_arch)',
+        'use_sysroot%': '<(use_sysroot)',
         'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
 
         # Instrument for code coverage and use coverage wrapper to exclude some
         # files. Uses gcov if clang=0 is set explicitly. Otherwise,
         # sanitizer_coverage must be set too.
         'coverage%': 0,
+
+        # Default sysroot if no sysroot can be provided.
+        'sysroot%': '',
+
+        'conditions': [
+          # The system root for linux builds.
+          ['OS=="linux" and use_sysroot==1', {
+            'conditions': [
+              ['target_arch=="arm"', {
+                'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_arm-sysroot',
+              }],
+              ['target_arch=="x64"', {
+                'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_amd64-sysroot',
+              }],
+              ['target_arch=="ia32"', {
+                'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_i386-sysroot',
+              }],
+              ['target_arch=="mipsel"', {
+                'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_mips-sysroot',
+              }],
+            ],
+          }], # OS=="linux" and use_sysroot==1
+        ],
       },
       'base_dir%': '<(base_dir)',
       'host_arch%': '<(host_arch)',
       'target_arch%': '<(target_arch)',
       'v8_target_arch%': '<(target_arch)',
       'coverage%': '<(coverage)',
+      'sysroot%': '<(sysroot)',
       'asan%': 0,
       'lsan%': 0,
       'msan%': 0,
@@ -112,11 +147,11 @@
       'use_goma%': 0,
       'gomadir%': '',
 
-      # Check if valgrind directories are present.
-      'has_valgrind%': '<!pymod_do_main(has_valgrind)',
-
       'test_isolation_mode%': 'noop',
 
+      # By default, use ICU data file (icudtl.dat).
+      'icu_use_data_file_flag%': 1,
+
       'conditions': [
         # Set default gomadir.
         ['OS=="win"', {
@@ -164,7 +199,8 @@
     'test_isolation_mode%': '<(test_isolation_mode)',
     'fastbuild%': '<(fastbuild)',
     'coverage%': '<(coverage)',
-    'has_valgrind%': '<(has_valgrind)',
+    'sysroot%': '<(sysroot)',
+    'icu_use_data_file_flag%': '<(icu_use_data_file_flag)',
 
     # Add a simple extras solely for the purpose of the cctests
     'v8_extra_library_files': ['../test/cctest/test-extra.js'],
@@ -258,12 +294,15 @@
             # because it is used at different levels in the GYP files.
             'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
             'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
+            # Version of the NDK. Used to ensure full rebuilds on NDK rolls.
+            'android_ndk_version%': 'r11c',
             'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
             'os_folder_name%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/darwin/')",
           },
 
           # Copy conditionally-set variables out one scope.
           'android_ndk_root%': '<(android_ndk_root)',
+          'android_ndk_version%': '<(android_ndk_version)',
           'host_os%': '<(host_os)',
           'os_folder_name%': '<(os_folder_name)',
 
@@ -308,6 +347,7 @@
         },
 
         # Copy conditionally-set variables out one scope.
+        'android_ndk_version%': '<(android_ndk_version)',
         'android_target_arch%': '<(android_target_arch)',
         'android_target_platform%': '<(android_target_platform)',
         'android_toolchain%': '<(android_toolchain)',
@@ -382,9 +422,6 @@
     # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
     #        detection
     'mips_fpu_mode%': 'fp32',
-
-    # Indicates if gcmole tools are downloaded by a hook.
-    'gcmole%': 0,
   },
   'target_defaults': {
     'variables': {
@@ -445,26 +482,6 @@
         # things when their commandline changes). Nothing should ever read this
         # define.
         'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
-        'conditions': [
-          ['host_clang==1', {
-            'target_conditions': [
-              ['_toolset=="host"', {
-                'cflags+': [
-                  '-Wno-format-pedantic',
-                 ],
-              }],
-           ],
-          }],
-          ['clang==1', {
-            'target_conditions': [
-              ['_toolset=="target"', {
-                'cflags+': [
-                  '-Wno-format-pedantic',
-                 ],
-              }],
-           ],
-          }],
-        ],
       }],
       ['clang==1 and target_arch=="ia32"', {
         'cflags': ['-mstack-alignment=16', '-mstackrealign'],
@@ -654,6 +671,18 @@
               '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
             ],
           }],
+          ['sysroot!="" and clang==1', {
+            'target_conditions': [
+              ['_toolset=="target"', {
+                'cflags': [
+                  '--sysroot=<(sysroot)',
+                ],
+                'ldflags': [
+                  '--sysroot=<(sysroot)',
+                  '<!(<(DEPTH)/build/linux/sysroot_ld_path.sh <(sysroot))',
+                ],
+              }]]
+          }],
         ],
       },
     }],
@@ -707,7 +736,6 @@
           '-Wall',
           '<(werror)',
           '-Wno-unused-parameter',
-          '-Wno-long-long',
           '-pthread',
           '-pedantic',
           '-Wmissing-field-initializers',
@@ -959,10 +987,6 @@
                   # pattern.
                   '-Wno-missing-field-initializers',
 
-                  # Many files use intrinsics without including this header.
-                  # TODO(hans): Fix those files, or move this to sub-GYPs.
-                  '/FIIntrin.h',
-
                   # TODO(hans): Make this list shorter eventually, http://crbug.com/504657
                   '-Qunused-arguments',  # http://crbug.com/504658
                   '-Wno-microsoft-enum-value',  # http://crbug.com/505296
@@ -1100,6 +1124,7 @@
               'HAVE_OFF64_T',
               'HAVE_SYS_UIO_H',
               'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
+              'ANDROID_NDK_VERSION=<(android_ndk_version)',
             ],
             'ldflags!': [
               '-pthread',  # Not supported by Android toolchain.
diff --git a/gypfiles/toolchain.gypi b/gypfiles/toolchain.gypi
index bc3ee5e..814d565 100644
--- a/gypfiles/toolchain.gypi
+++ b/gypfiles/toolchain.gypi
@@ -37,6 +37,8 @@
     'tsan%': 0,
     'ubsan%': 0,
     'ubsan_vptr%': 0,
+    'has_valgrind%': 0,
+    'coverage%': 0,
     'v8_target_arch%': '<(target_arch)',
     'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
     # Native Client builds currently use the V8 ARM JIT and
@@ -131,6 +133,9 @@
 
     # Link-Time Optimizations
     'use_lto%': 0,
+
+    # Indicates if gcmole tools are downloaded by a hook.
+    'gcmole%': 0,
   },
   'conditions': [
     ['host_arch=="ia32" or host_arch=="x64" or \
@@ -1084,6 +1089,7 @@
         'defines': [
           # Support for malloc(0)
           '_LINUX_SOURCE_COMPAT=1',
+          '__STDC_FORMAT_MACROS',
           '_ALL_SOURCE=1'],
         'conditions': [
           [ 'v8_target_arch=="ppc"', {
@@ -1091,7 +1097,7 @@
           }],
           [ 'v8_target_arch=="ppc64"', {
             'cflags': [ '-maix64' ],
-            'ldflags': [ '-maix64' ],
+            'ldflags': [ '-maix64 -Wl,-bbigtoc' ],
           }],
         ],
       }],