diff --git a/configure b/configure index 14455f4f77..7d80e62f0c 100755 --- a/configure +++ b/configure @@ -435,9 +435,6 @@ def configure_arm(o): def configure_node(o): if options.dest_os == 'android': o['variables']['OS'] = 'android' - o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0 - o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs. - o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables. o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '') o['variables']['node_install_npm'] = b(not options.without_npm) o['default_configuration'] = 'Debug' if options.debug else 'Release' @@ -565,8 +562,13 @@ def configure_libuv(o): def configure_v8(o): - o['variables']['v8_use_snapshot'] = b(not options.without_snapshot) o['variables']['node_shared_v8'] = b(options.shared_v8) + o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0 + o['variables']['v8_enable_i18n_support'] = 0 # Don't require libicu. + o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs. + o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds. + o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables. + o['variables']['v8_use_snapshot'] = b(not options.without_snapshot) # assume shared_v8 if one of these is set? if options.shared_v8_libpath: diff --git a/deps/v8/.gitignore b/deps/v8/.gitignore index 282e463fc5..d554ec65d2 100644 --- a/deps/v8/.gitignore +++ b/deps/v8/.gitignore @@ -37,24 +37,16 @@ shell_g /out /perf.data /perf.data.old -/test/benchmarks/benchmarks.status2 /test/benchmarks/CHECKED_OUT_* /test/benchmarks/downloaded_* /test/benchmarks/kraken /test/benchmarks/octane /test/benchmarks/sunspider -/test/cctest/cctest.status2 -/test/message/message.status2 -/test/mjsunit/mjsunit.status2 /test/mozilla/CHECKED_OUT_VERSION /test/mozilla/data /test/mozilla/downloaded_* -/test/mozilla/mozilla.status2 -/test/preparser/preparser.status2 /test/test262/data /test/test262/test262-* -/test/test262/test262.status2 -/test/webkit/webkit.status2 /third_party /tools/jsfunfuzz /tools/jsfunfuzz.zip diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index b3eba3661a..97895d3693 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,226 @@ +2013-10-31: Version 3.22.24 + + Fixed uint32-to-smi conversion in Lithium. + (Chromium issue 309623) + + Performance and stability improvements on all platforms. + + +2013-10-28: Version 3.22.23 + + Renamed deprecated __attribute__((no_address_safety_analysis)) to + __attribute__((no_sanitize_address)) (Chromium issue 311283) + + Defined DEBUG for v8_optimized_debug=2 + + Performance and stability improvements on all platforms. + + +2013-10-25: Version 3.22.22 + + Record allocation stack traces. (Chromium issue 277984,v8:2949) + + Performance and stability improvements on all platforms. + + +2013-10-24: Version 3.22.21 + + Performance and stability improvements on all platforms. + + +2013-10-24: Version 3.22.20 + + Made Array.prototype.pop throw if the last element is not configurable. + + Fixed HObjectAccess for loads from migrating prototypes. + (Chromium issue 305309) + + Enabled preaging of code objects when --optimize-for-size. + (Chromium issue 280984) + + Exposed v8::Function::GetDisplayName to public API. + (Chromium issue 17356) + + Performance and stability improvements on all platforms. + + +2013-10-23: Version 3.22.19 + + Fix materialization of captured objects with field tracking. + (Chromium issue 298990) + + Performance and stability improvements on all platforms. + + +2013-10-22: Version 3.22.18 + + Add tool to visualize machine code/lithium. + + Handle misaligned loads and stores in load elimination. Do not track + misaligned loads and be conservative about invalidating misaligned + stores. (issue 2934) + + Performance and stability improvements on all platforms. + + +2013-10-21: Version 3.22.17 + + Harmony: Implement Math.trunc and Math.sign. (issue 2938) + + Performance and stability improvements on all platforms. + + +2013-10-21: Version 3.22.16 + + Performance and stability improvements on all platforms. + + +2013-10-18: Version 3.22.15 + + Enabled calling the SetReference* & SetObjectGroupId functions with a + Persistent. + + Performance and stability improvements on all platforms. + + +2013-10-17: Version 3.22.14 + + Performance and stability improvements on all platforms. + + +2013-10-16: Version 3.22.13 + + Do not look up ArrayBuffer on global object in typed array constructor. + (issue 2931) + + Performance and stability improvements on all platforms. + + +2013-10-15: Version 3.22.12 + + Added histograms to track fraction of heap spaces and percentage of + generated crankshaft code. + + Moved v8_optimized_debug default value to standalone.gypi. + + Track JS allocations as they arrive with no affection on performance + when tracking is switched off (Chromium issue 277984). + + Performance and stability improvements on all platforms. + + +2013-10-14: Version 3.22.11 + + Performance and stability improvements on all platforms. + + +2013-10-11: Version 3.22.10 + + Fixed timezone issues with date-time/parse-* tests. + (Chromium issue 2919) + + Added column getter to CpuProfileNode (Chromium issue 302537) + + Performance and stability improvements on all platforms. + + +2013-10-10: Version 3.22.9 + + Ensure only whitelisted stubs have sse2 versions in the snapshot. + (fix for chromium 304565) + + Implement ArrayBuffer.isView. + + Performance and stability improvements on all platforms. + + +2013-10-04: Version 3.22.8 + + Performance and stability improvements on all platforms. + + +2013-10-03: Version 3.22.7 + + Debug: Allow stepping into on a given call frame + (Chromium issue 296963). + + Always use timeGetTime() for TimeTicks::Now() on Windows + (Chromium issue 288924). + + Performance and stability improvements on all platforms. + + +2013-10-02: Version 3.22.6 + + Performance and stability improvements on all platforms. + + +2013-10-01: Version 3.22.5 + + Disabled externalization of sliced/cons strings in old pointer space + (Chromium issue 276357). + + Turned on handle zapping for release builds + + Performance and stability improvements on all platforms. + + +2013-09-30: Version 3.22.4 + + Function::Call and Object::CallAsFunction APIs should allow v8::Value as + a receiver (issue 2915). + + Removed unnecessary mutex (Chromium issue 291236). + + Removed ArrayBufferView::BaseAddress method. + + Performance and stability improvements on all platforms. + + +2013-09-27: Version 3.22.3 + + Added methods to enable configuration of ResourceConstraints based on + limits derived at runtime. + (Chromium issue 292928) + + Added -optimize-for-size flag to optimize for memory size (will be used + by pre-aging CL), and removed the is_memory_constrained + ResourceConstraint. + (Chromium issue 292928) + + Performance and stability improvements on all platforms. + + +2013-09-26: Version 3.22.2 + + Performance and stability improvements on all platforms. + + +2013-09-25: Version 3.22.1 + + Sped up creating typed arrays from array-like objects. + (Chromium issue 270507) + + Performance and stability improvements on all platforms. + + +2013-09-23: Version 3.22.0 + + LiveEdit to mark more closure functions for re-instantiation when scope + layout changes. + (issue 2872) + + Made bounds check elimination iterative instead of recursive. + (Chromium issue 289706) + + Turned on i18n support by default. + + Set the proper instance-type on HAllocate in BuildFastLiteral. + (Chromium issue 284577) + + Performance and stability improvements on all platforms. + + 2013-09-18: Version 3.21.17 Implemented local load/store elimination on basic blocks. diff --git a/deps/v8/Makefile b/deps/v8/Makefile index 288c257396..bbec44076e 100644 --- a/deps/v8/Makefile +++ b/deps/v8/Makefile @@ -76,10 +76,10 @@ ifeq ($(snapshot), off) endif # extrachecks=on/off ifeq ($(extrachecks), on) - GYPFLAGS += -Dv8_enable_extra_checks=1 + GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1 endif ifeq ($(extrachecks), off) - GYPFLAGS += -Dv8_enable_extra_checks=0 + GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0 endif # gdbjit=on/off ifeq ($(gdbjit), on) @@ -124,10 +124,15 @@ endif ifeq ($(regexp), interpreted) GYPFLAGS += -Dv8_interpreted_regexp=1 endif -# i18nsupport=on -ifeq ($(i18nsupport), on) - GYPFLAGS += -Dv8_enable_i18n_support=1 +# i18nsupport=off +ifeq ($(i18nsupport), off) + GYPFLAGS += -Dv8_enable_i18n_support=0 + TESTFLAGS += --noi18n endif +# deprecation_warnings=on +ifeq ($(deprecationwarnings), on) + GYPFLAGS += -Dv8_deprecation_warnings=1 +endif # arm specific flags. # armv7=false/true ifeq ($(armv7), false) @@ -217,8 +222,8 @@ NACL_ARCHES = nacl_ia32 nacl_x64 # List of files that trigger Makefile regeneration: GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \ - build/toolchain.gypi preparser/preparser.gyp samples/samples.gyp \ - src/d8.gyp test/cctest/cctest.gyp tools/gyp/v8.gyp + build/toolchain.gypi samples/samples.gyp src/d8.gyp \ + test/cctest/cctest.gyp tools/gyp/v8.gyp # If vtunejit=on, the v8vtune.gyp will be appended. ifeq ($(vtunejit), on) @@ -323,7 +328,7 @@ $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ --arch-and-mode=$(basename $@) \ --timeout=600 \ - --command-prefix="tools/android-run.py" + --command-prefix="tools/android-run.py" $(TESTFLAGS) $(addsuffix .check, $(ANDROID_ARCHES)): \ $(addprefix $$(basename $$@).,$(MODES)).check @@ -331,7 +336,7 @@ $(addsuffix .check, $(ANDROID_ARCHES)): \ $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@) @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ --arch-and-mode=$(basename $@) \ - --timeout=600 --nopresubmit \ + --timeout=600 --nopresubmit --noi18n \ --command-prefix="tools/nacl-run.py" $(addsuffix .check, $(NACL_ARCHES)): \ diff --git a/deps/v8/Makefile.nacl b/deps/v8/Makefile.nacl index 02e83ef2bc..2c79ef113e 100644 --- a/deps/v8/Makefile.nacl +++ b/deps/v8/Makefile.nacl @@ -74,6 +74,9 @@ endif # For mksnapshot host generation. GYPENV += host_os=${HOST_OS} +# ICU doesn't support NaCl. +GYPENV += v8_enable_i18n_support=0 + NACL_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(NACL_ARCHES)) .SECONDEXPANSION: # For some reason the $$(basename $$@) expansion didn't work here... diff --git a/deps/v8/OWNERS b/deps/v8/OWNERS index 6fe40e21e3..450e9b217c 100644 --- a/deps/v8/OWNERS +++ b/deps/v8/OWNERS @@ -2,12 +2,14 @@ bmeurer@chromium.org danno@chromium.org dslomov@chromium.org hpayer@chromium.org +ishell@chromium.org jkummerow@chromium.org -mmassi@chromium.org +machenbach@chromium.org mstarzinger@chromium.org mvstanton@chromium.org rossberg@chromium.org svenpanne@chromium.org +titzer@chromium.org ulan@chromium.org vegorov@chromium.org verwaest@chromium.org diff --git a/deps/v8/PRESUBMIT.py b/deps/v8/PRESUBMIT.py index 819331f9e5..75e16e3bd7 100644 --- a/deps/v8/PRESUBMIT.py +++ b/deps/v8/PRESUBMIT.py @@ -58,6 +58,17 @@ def _CommonChecks(input_api, output_api): return results +def _SkipTreeCheck(input_api, output_api): + """Check the env var whether we want to skip tree check. + Only skip if src/version.cc has been updated.""" + src_version = 'src/version.cc' + FilterFile = lambda file: file.LocalPath() == src_version + if not input_api.AffectedSourceFiles( + lambda file: file.LocalPath() == src_version): + return False + return input_api.environ.get('PRESUBMIT_TREE_CHECK') == 'skip' + + def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) @@ -69,7 +80,8 @@ def CheckChangeOnCommit(input_api, output_api): results.extend(_CommonChecks(input_api, output_api)) results.extend(input_api.canned_checks.CheckChangeHasDescription( input_api, output_api)) - results.extend(input_api.canned_checks.CheckTreeIsOpen( - input_api, output_api, - json_url='http://v8-status.appspot.com/current?format=json')) + if not _SkipTreeCheck(input_api, output_api): + results.extend(input_api.canned_checks.CheckTreeIsOpen( + input_api, output_api, + json_url='http://v8-status.appspot.com/current?format=json')) return results diff --git a/deps/v8/tools/status-file-converter.py b/deps/v8/WATCHLISTS old mode 100755 new mode 100644 similarity index 76% rename from deps/v8/tools/status-file-converter.py rename to deps/v8/WATCHLISTS index ba063ee8c7..9c2bce9c55 --- a/deps/v8/tools/status-file-converter.py +++ b/deps/v8/WATCHLISTS @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright 2012 the V8 project authors. All rights reserved. +# Copyright 2013 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: @@ -27,13 +25,22 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# Watchlist Rules +# Refer: http://dev.chromium.org/developers/contributing-code/watchlists -import sys -from testrunner.local import old_statusfile +# IMPORTANT: The regular expression filepath is tested against each path using +# re.search, so it is not usually necessary to add .*. -if len(sys.argv) != 2: - print "Usage: %s foo.status" % sys.argv[0] - print "Will read foo.status and print the converted version to stdout." - sys.exit(1) +{ + 'WATCHLIST_DEFINITIONS': { + 'public_api': { + 'filepath': 'include/', + }, + }, -print old_statusfile.ConvertNotation(sys.argv[1]).GetOutput() + 'WATCHLISTS': { + 'public_api': [ + 'phajdan.jr@chromium.org', + ], + }, +} diff --git a/deps/v8/benchmarks/deltablue.js b/deps/v8/benchmarks/deltablue.js index 548fd96ffb..dacee3f13f 100644 --- a/deps/v8/benchmarks/deltablue.js +++ b/deps/v8/benchmarks/deltablue.js @@ -121,23 +121,23 @@ Strength.strongest = function (s1, s2) { Strength.prototype.nextWeaker = function () { switch (this.strengthValue) { - case 0: return Strength.WEAKEST; - case 1: return Strength.WEAK_DEFAULT; - case 2: return Strength.NORMAL; - case 3: return Strength.STRONG_DEFAULT; - case 4: return Strength.PREFERRED; - case 5: return Strength.REQUIRED; + case 0: return Strength.STRONG_PREFERRED; + case 1: return Strength.PREFERRED; + case 2: return Strength.STRONG_DEFAULT; + case 3: return Strength.NORMAL; + case 4: return Strength.WEAK_DEFAULT; + case 5: return Strength.WEAKEST; } } // Strength constants. -Strength.REQUIRED = new Strength(0, "required"); -Strength.STONG_PREFERRED = new Strength(1, "strongPreferred"); -Strength.PREFERRED = new Strength(2, "preferred"); -Strength.STRONG_DEFAULT = new Strength(3, "strongDefault"); -Strength.NORMAL = new Strength(4, "normal"); -Strength.WEAK_DEFAULT = new Strength(5, "weakDefault"); -Strength.WEAKEST = new Strength(6, "weakest"); +Strength.REQUIRED = new Strength(0, "required"); +Strength.STRONG_PREFERRED = new Strength(1, "strongPreferred"); +Strength.PREFERRED = new Strength(2, "preferred"); +Strength.STRONG_DEFAULT = new Strength(3, "strongDefault"); +Strength.NORMAL = new Strength(4, "normal"); +Strength.WEAK_DEFAULT = new Strength(5, "weakDefault"); +Strength.WEAKEST = new Strength(6, "weakest"); /* --- * * C o n s t r a i n t diff --git a/deps/v8/build/all.gyp b/deps/v8/build/all.gyp index 4b2fe52989..ad71fb0e45 100644 --- a/deps/v8/build/all.gyp +++ b/deps/v8/build/all.gyp @@ -8,7 +8,6 @@ 'target_name': 'All', 'type': 'none', 'dependencies': [ - '../preparser/preparser.gyp:*', '../samples/samples.gyp:*', '../src/d8.gyp:d8', '../test/cctest/cctest.gyp:*', diff --git a/deps/v8/build/features.gypi b/deps/v8/build/features.gypi index 3c6d25f758..7863b1c43a 100644 --- a/deps/v8/build/features.gypi +++ b/deps/v8/build/features.gypi @@ -54,7 +54,10 @@ # Enable ECMAScript Internationalization API. Enabling this feature will # add a dependency on the ICU library. - 'v8_enable_i18n_support%': 0, + 'v8_enable_i18n_support%': 1, + + # Enable compiler warnings when using V8_DEPRECATED apis. + 'v8_deprecation_warnings%': 0, }, 'target_defaults': { 'conditions': [ @@ -76,6 +79,9 @@ ['v8_interpreted_regexp==1', { 'defines': ['V8_INTERPRETED_REGEXP',], }], + ['v8_deprecation_warnings==1', { + 'defines': ['V8_DEPRECATION_WARNINGS',], + }], ['v8_enable_i18n_support==1', { 'defines': ['V8_I18N_SUPPORT',], }], @@ -89,21 +95,29 @@ 'Debug': { 'variables': { 'v8_enable_extra_checks%': 1, + 'v8_enable_handle_zapping%': 1, }, 'conditions': [ ['v8_enable_extra_checks==1', { 'defines': ['ENABLE_EXTRA_CHECKS',], }], + ['v8_enable_handle_zapping==1', { + 'defines': ['ENABLE_HANDLE_ZAPPING',], + }], ], }, # Debug 'Release': { 'variables': { 'v8_enable_extra_checks%': 0, + 'v8_enable_handle_zapping%': 0, }, 'conditions': [ ['v8_enable_extra_checks==1', { 'defines': ['ENABLE_EXTRA_CHECKS',], }], + ['v8_enable_handle_zapping==1', { + 'defines': ['ENABLE_HANDLE_ZAPPING',], + }], ], # conditions }, # Release }, # configurations diff --git a/deps/v8/build/standalone.gypi b/deps/v8/build/standalone.gypi index 5c017d5f50..4cb5e00bcc 100644 --- a/deps/v8/build/standalone.gypi +++ b/deps/v8/build/standalone.gypi @@ -36,7 +36,7 @@ 'clang%': 0, 'visibility%': 'hidden', 'v8_enable_backtrace%': 0, - 'v8_enable_i18n_support%': 0, + 'v8_enable_i18n_support%': 1, 'msvs_multi_core_compile%': '1', 'mac_deployment_target%': '10.5', 'variables': { @@ -77,6 +77,23 @@ # as errors. 'v8_code%': 0, + # Speeds up Debug builds: + # 0 - Compiler optimizations off (debuggable) (default). This may + # be 5x slower than Release (or worse). + # 1 - Turn on compiler optimizations. This may be hard or impossible to + # debug. This may still be 2x slower than Release (or worse). + # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG + # (but leave V8_ENABLE_CHECKS and most other assertions enabled. + # This may cause some v8 tests to fail in the Debug configuration. + # This roughly matches the performance of a Release build and can + # be used by embedders that need to build their own code as debug + # but don't want or need a debug version of V8. This should produce + # near-release speeds. + 'v8_optimized_debug%': 0, + + # Relative path to icu.gyp from this file. + 'icu_gyp_path': '../third_party/icu/icu.gyp', + 'conditions': [ ['(v8_target_arch=="arm" and host_arch!="arm") or \ (v8_target_arch=="mipsel" and host_arch!="mipsel") or \ diff --git a/deps/v8/build/toolchain.gypi b/deps/v8/build/toolchain.gypi index c1066ebe94..de41fe0d00 100644 --- a/deps/v8/build/toolchain.gypi +++ b/deps/v8/build/toolchain.gypi @@ -60,20 +60,6 @@ 'v8_enable_backtrace%': 0, - # Speeds up Debug builds: - # 0 - Compiler optimizations off (debuggable) (default). This may - # be 5x slower than Release (or worse). - # 1 - Turn on compiler optimizations. This may be hard or impossible to - # debug. This may still be 2x slower than Release (or worse). - # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG - # (but leave V8_ENABLE_CHECKS and most other assertions enabled. - # This may cause some v8 tests to fail in the Debug configuration. - # This roughly matches the performance of a Release build and can - # be used by embedders that need to build their own code as debug - # but don't want or need a debug version of V8. This should produce - # near-release speeds. - 'v8_optimized_debug%': 0, - # Enable profiling support. Only required on Windows. 'v8_enable_prof%': 0, @@ -450,6 +436,7 @@ 'V8_ENABLE_CHECKS', 'OBJECT_PRINT', 'VERIFY_HEAP', + 'DEBUG' ], 'msvs_settings': { 'VCCLCompilerTool': { @@ -517,15 +504,6 @@ }, }, 'conditions': [ - ['v8_optimized_debug==2', { - 'defines': [ - 'NDEBUG', - ], - }, { - 'defines': [ - 'DEBUG', - ], - }], ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { 'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter', '-Wnon-virtual-dtor', '-Woverloaded-virtual', @@ -567,6 +545,9 @@ '-fdata-sections', '-ffunction-sections', ], + 'defines': [ + 'OPTIMIZED_DEBUG' + ], 'conditions': [ # TODO(crbug.com/272548): Avoid -O3 in NaCl ['nacl_target_arch=="none"', { diff --git a/deps/v8/include/v8-debug.h b/deps/v8/include/v8-debug.h index 053b81d2c5..1a86a061e9 100755 --- a/deps/v8/include/v8-debug.h +++ b/deps/v8/include/v8-debug.h @@ -212,9 +212,13 @@ class V8_EXPORT Debug { // If no isolate is provided the default isolate is // used. + // TODO(dcarney): remove static void SendCommand(const uint16_t* command, int length, ClientData* client_data = NULL, Isolate* isolate = NULL); + static void SendCommand(Isolate* isolate, + const uint16_t* command, int length, + ClientData* client_data = NULL); // Dispatch interface. static void SetHostDispatchHandler(HostDispatchHandler handler, diff --git a/deps/v8/include/v8-defaults.h b/deps/v8/include/v8-defaults.h new file mode 100644 index 0000000000..381a48210d --- /dev/null +++ b/deps/v8/include/v8-defaults.h @@ -0,0 +1,54 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef V8_V8_DEFAULTS_H_ +#define V8_V8_DEFAULTS_H_ + +#include "v8.h" + +/** + * Default configuration support for the V8 JavaScript engine. + */ +namespace v8 { + +/** + * Configures the constraints with reasonable default values based on the + * capabilities of the current device the VM is running on. + */ +bool V8_EXPORT ConfigureResourceConstraintsForCurrentPlatform( + ResourceConstraints* constraints); + + +/** + * Convience function which performs SetResourceConstraints with the settings + * returned by ConfigureResourceConstraintsForCurrentPlatform. + */ +bool V8_EXPORT SetDefaultResourceConstraintsForCurrentPlatform(); + +} // namespace v8 + +#endif // V8_V8_DEFAULTS_H_ diff --git a/deps/v8/include/v8-preparser.h b/deps/v8/include/v8-preparser.h deleted file mode 100644 index 1da77185af..0000000000 --- a/deps/v8/include/v8-preparser.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2011 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef PREPARSER_H -#define PREPARSER_H - -#include "v8.h" -#include "v8stdint.h" - -namespace v8 { - -// The result of preparsing is either a stack overflow error, or an opaque -// blob of data that can be passed back into the parser. -class V8_EXPORT PreParserData { - public: - PreParserData(size_t size, const uint8_t* data) - : data_(data), size_(size) { } - - // Create a PreParserData value where stack_overflow reports true. - static PreParserData StackOverflow() { return PreParserData(0, NULL); } - - // Whether the pre-parser stopped due to a stack overflow. - // If this is the case, size() and data() should not be used. - bool stack_overflow() { return size_ == 0u; } - - // The size of the data in bytes. - size_t size() const { return size_; } - - // Pointer to the data. - const uint8_t* data() const { return data_; } - - private: - const uint8_t* const data_; - const size_t size_; -}; - - -// Interface for a stream of Unicode characters. -class V8_EXPORT UnicodeInputStream { // NOLINT - V8_EXPORT is not a class name. - public: - virtual ~UnicodeInputStream(); - - // Returns the next Unicode code-point in the input, or a negative value when - // there is no more input in the stream. - virtual int32_t Next() = 0; -}; - - -// Preparse a JavaScript program. The source code is provided as a -// UnicodeInputStream. The max_stack_size limits the amount of stack -// space that the preparser is allowed to use. If the preparser uses -// more stack space than the limit provided, the result's stack_overflow() -// method will return true. Otherwise the result contains preparser -// data that can be used by the V8 parser to speed up parsing. -PreParserData V8_EXPORT Preparse(UnicodeInputStream* input, - size_t max_stack_size); - -} // namespace v8. - -#endif // PREPARSER_H diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 217a938329..0882d64527 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -57,16 +57,17 @@ class V8_EXPORT CpuProfileNode { */ int GetLineNumber() const; + /** + * Returns 1-based number of the column where the function originates. + * kNoColumnNumberInfo if no column number information is available. + */ + int GetColumnNumber() const; + /** Returns bailout reason for the function * if the optimization was disabled for it. */ const char* GetBailoutReason() const; - /** DEPRECATED. Please use GetHitCount instead. - * Returns the count of samples where function was currently executing. - */ - V8_DEPRECATED(double GetSelfSamplesCount() const); - /** * Returns the count of samples where the function was currently executing. */ @@ -85,6 +86,7 @@ class V8_EXPORT CpuProfileNode { const CpuProfileNode* GetChild(int index) const; static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; + static const int kNoColumnNumberInfo = Message::kNoColumnInfo; }; @@ -473,6 +475,19 @@ class V8_EXPORT HeapProfiler { */ void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); + /** + * Starts recording JS allocations immediately as they arrive and tracking of + * heap objects population statistics. + */ + void StartRecordingHeapAllocations(); + + /** + * Stops recording JS allocations and tracking of heap objects population + * statistics, cleans all collected heap objects population statistics data. + */ + void StopRecordingHeapAllocations(); + + private: HeapProfiler(); ~HeapProfiler(); diff --git a/deps/v8/include/v8-testing.h b/deps/v8/include/v8-testing.h index 97b467a91b..ba4fcc44ec 100644 --- a/deps/v8/include/v8-testing.h +++ b/deps/v8/include/v8-testing.h @@ -68,8 +68,4 @@ class V8_EXPORT Testing { } // namespace v8 - -#undef V8_EXPORT - - #endif // V8_V8_TEST_H_ diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index de2733838f..44a74ed5fe 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -135,6 +135,7 @@ class DeclaredAccessorDescriptor; class ObjectOperationDescriptor; class RawOperationDescriptor; class CallHandlerHelper; +class EscapableHandleScope; namespace internal { class Arguments; @@ -377,7 +378,6 @@ template class Local : public Handle { * The referee is kept alive by the local handle even when * the original handle is destroyed/disposed. */ - V8_INLINE static Local New(Handle that); V8_INLINE static Local New(Isolate* isolate, Handle that); template V8_INLINE static Local New(Isolate* isolate, @@ -401,6 +401,7 @@ template class Local : public Handle { friend class Context; template friend class internal::CustomArguments; friend class HandleScope; + friend class EscapableHandleScope; V8_INLINE static Local New(Isolate* isolate, T* that); }; @@ -479,6 +480,22 @@ class NonCopyablePersistentTraits { }; +/** + * Helper class traits to allow copying and assignment of Persistent. + * This will clone the contents of storage cell, but not any of the flags, etc. + */ +template +struct CopyablePersistentTraits { + typedef Persistent > CopyablePersistent; + static const bool kResetInDestructor = true; + template + static V8_INLINE void Copy(const Persistent& source, + CopyablePersistent* dest) { + // do nothing, just allow copy + } +}; + + /** * An object reference that is independent of any handle scope. Where * a Local handle only lives as long as the HandleScope in which it was @@ -567,9 +584,9 @@ template class Persistent { */ template V8_INLINE void Reset(Isolate* isolate, const Persistent& other); - // TODO(dcarney): deprecate - V8_INLINE void Dispose() { Reset(); } - V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); } + + V8_DEPRECATED("Use Reset instead", + V8_INLINE void Dispose()) { Reset(); } V8_INLINE bool IsEmpty() const { return val_ == 0; } @@ -625,22 +642,22 @@ template class Persistent { P* parameter, typename WeakCallbackData::Callback callback); - // TODO(dcarney): deprecate template - V8_INLINE void MakeWeak( - P* parameter, - typename WeakReferenceCallbacks::Revivable callback); + V8_DEPRECATED( + "Use SetWeak instead", + V8_INLINE void MakeWeak( + P* parameter, + typename WeakReferenceCallbacks::Revivable callback)); - // TODO(dcarney): deprecate template - V8_INLINE void MakeWeak( - P* parameter, - typename WeakReferenceCallbacks::Revivable callback); + V8_DEPRECATED( + "Use SetWeak instead", + V8_INLINE void MakeWeak( + P* parameter, + typename WeakReferenceCallbacks::Revivable callback)); V8_INLINE void ClearWeak(); - V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); } - /** * Marks the reference to this object independent. Garbage collector is free * to ignore any object groups containing this object. Weak callback for an @@ -649,10 +666,6 @@ template class Persistent { */ V8_INLINE void MarkIndependent(); - V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) { - MarkIndependent(); - } - /** * Marks the reference to this object partially dependent. Partially dependent * handles only depend on other partially dependent handles and these @@ -663,56 +676,31 @@ template class Persistent { */ V8_INLINE void MarkPartiallyDependent(); - V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) { - MarkPartiallyDependent(); - } - V8_INLINE bool IsIndependent() const; - V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) { - return IsIndependent(); - } - /** Checks if the handle holds the only reference to an object. */ V8_INLINE bool IsNearDeath() const; - V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) { - return IsNearDeath(); - } - /** Returns true if the handle's reference is weak. */ V8_INLINE bool IsWeak() const; - V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) { - return IsWeak(); - } - /** * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface * description in v8-profiler.h for details. */ V8_INLINE void SetWrapperClassId(uint16_t class_id); - V8_DEPRECATED( - V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id)) { - SetWrapperClassId(class_id); - } - /** * Returns the class ID previously assigned to this handle or 0 if no class ID * was previously assigned. */ V8_INLINE uint16_t WrapperClassId() const; - V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) { - return WrapperClassId(); - } - - // TODO(dcarney): remove - V8_INLINE T* ClearAndLeak(); + V8_DEPRECATED("This will be removed", + V8_INLINE T* ClearAndLeak()); - // TODO(dcarney): remove - V8_INLINE void Clear() { val_ = 0; } + V8_DEPRECATED("This will be removed", + V8_INLINE void Clear()) { val_ = 0; } // TODO(dcarney): remove #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR @@ -724,6 +712,7 @@ template class Persistent { V8_INLINE T* operator*() const { return val_; } private: + friend class Isolate; friend class Utils; template friend class Handle; template friend class Local; @@ -757,27 +746,28 @@ class V8_EXPORT HandleScope { ~HandleScope(); - /** - * Closes the handle scope and returns the value as a handle in the - * previous scope, which is the new current scope after the call. - */ - template Local Close(Handle value); + template + V8_DEPRECATED("Use EscapableHandleScope::Escape instead", + Local Close(Handle value)); /** * Counts the number of allocated handles. */ static int NumberOfHandles(); + private: /** * Creates a new handle with the given value. */ - static internal::Object** CreateHandle(internal::Object* value); static internal::Object** CreateHandle(internal::Isolate* isolate, internal::Object* value); - // Faster version, uses HeapObject to obtain the current Isolate. - static internal::Object** CreateHandle(internal::HeapObject* value); + // Uses HeapObject to obtain the current Isolate. + static internal::Object** CreateHandle(internal::HeapObject* heap_object, + internal::Object* value); + + V8_INLINE HandleScope() {} + void Initialize(Isolate* isolate); - private: // Make it hard to create heap-allocated or illegal handle scopes by // disallowing certain operations. HandleScope(const HandleScope&); @@ -798,19 +788,58 @@ class V8_EXPORT HandleScope { } }; - void Initialize(Isolate* isolate); void Leave(); internal::Isolate* isolate_; internal::Object** prev_next_; internal::Object** prev_limit_; + // TODO(dcarney): remove this field // Allow for the active closing of HandleScopes which allows to pass a handle // from the HandleScope being closed to the next top most HandleScope. bool is_closed_; internal::Object** RawClose(internal::Object** value); friend class ImplementationUtilities; + friend class EscapableHandleScope; + template friend class Handle; + template friend class Local; + friend class Object; + friend class Context; +}; + + +/** + * A HandleScope which first allocates a handle in the current scope + * which will be later filled with the escape value. + */ +class V8_EXPORT EscapableHandleScope : public HandleScope { + public: + EscapableHandleScope(Isolate* isolate); + V8_INLINE ~EscapableHandleScope() {} + + /** + * Pushes the value into the previous scope and returns a handle to it. + * Cannot be called twice. + */ + template + V8_INLINE Local Escape(Local value) { + internal::Object** slot = + Escape(reinterpret_cast(*value)); + return Local(reinterpret_cast(slot)); + } + + private: + internal::Object** Escape(internal::Object** escape_value); + + // Make it hard to create heap-allocated or illegal handle scopes by + // disallowing certain operations. + EscapableHandleScope(const EscapableHandleScope&); + void operator=(const EscapableHandleScope&); + void* operator new(size_t size); + void operator delete(void*, size_t); + + internal::Object** escape_slot_; }; @@ -857,7 +886,9 @@ class V8_EXPORT ScriptData { // NOLINT * \param input Pointer to UTF-8 script source code. * \param length Length of UTF-8 script source code. */ - static ScriptData* PreCompile(const char* input, int length); + static ScriptData* PreCompile(Isolate* isolate, + const char* input, + int length); /** * Pre-compiles the specified script (context-independent). @@ -1009,9 +1040,8 @@ class V8_EXPORT Script { /** * Returns the script id value. - * DEPRECATED: Please use GetId(). */ - Local Id(); + V8_DEPRECATED("Use GetId instead", Local Id()); /** * Returns the script id. @@ -1463,6 +1493,7 @@ class V8_EXPORT Value : public Data { /** JS == */ bool Equals(Handle that) const; bool StrictEquals(Handle that) const; + bool SameValue(Handle that) const; template V8_INLINE static Value* Cast(T* value); @@ -1515,11 +1546,6 @@ class V8_EXPORT String : public Primitive { */ int Utf8Length() const; - /** - * This function is no longer useful. - */ - V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; } - /** * Returns whether this string is known to contain only one byte data. * Does not read the string. @@ -1570,11 +1596,6 @@ class V8_EXPORT String : public Primitive { int start = 0, int length = -1, int options = NO_OPTIONS) const; - // ASCII characters. - V8_DEPRECATED(int WriteAscii(char* buffer, - int start = 0, - int length = -1, - int options = NO_OPTIONS) const); // One byte characters. int WriteOneByte(uint8_t* buffer, int start = 0, @@ -1705,24 +1726,29 @@ class V8_EXPORT String : public Primitive { V8_INLINE static String* Cast(v8::Value* obj); - // TODO(dcarney): deprecate /** * Allocates a new string from either UTF-8 encoded or ASCII data. * The second parameter 'length' gives the buffer length. If omitted, * the function calls 'strlen' to determine the buffer length. */ - V8_INLINE static Local New(const char* data, int length = -1); + V8_DEPRECATED( + "Use NewFromOneByte instead", + V8_INLINE static Local New(const char* data, int length = -1)); - // TODO(dcarney): deprecate /** Allocates a new string from 16-bit character codes.*/ - V8_INLINE static Local New(const uint16_t* data, int length = -1); + V8_DEPRECATED( + "Use NewFromTwoByte instead", + V8_INLINE static Local New( + const uint16_t* data, int length = -1)); - // TODO(dcarney): deprecate /** * Creates an internalized string (historically called a "symbol", * not to be confused with ES6 symbols). Returns one if it exists already. */ - V8_INLINE static Local NewSymbol(const char* data, int length = -1); + V8_DEPRECATED( + "Use NewFromUtf8 instead", + V8_INLINE static Local NewSymbol( + const char* data, int length = -1)); enum NewStringType { kNormalString, kInternalizedString, kUndetectableString @@ -1801,15 +1827,17 @@ class V8_EXPORT String : public Primitive { */ bool CanMakeExternal(); - // TODO(dcarney): deprecate /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ - V8_INLINE static Local NewUndetectable(const char* data, - int length = -1); + V8_DEPRECATED( + "Use NewFromUtf8 instead", + V8_INLINE static Local NewUndetectable(const char* data, + int length = -1)); - // TODO(dcarney): deprecate /** Creates an undetectable string from the supplied 16-bit character codes.*/ - V8_INLINE static Local NewUndetectable(const uint16_t* data, - int length = -1); + V8_DEPRECATED( + "Use NewFromTwoByte instead", + V8_INLINE static Local NewUndetectable(const uint16_t* data, + int length = -1)); /** * Converts an object to a UTF-8-encoded character array. Useful if @@ -1843,8 +1871,8 @@ class V8_EXPORT String : public Primitive { */ class V8_EXPORT AsciiValue { public: - // TODO(dcarney): deprecate - explicit AsciiValue(Handle obj); + V8_DEPRECATED("Use Utf8Value instead", + explicit AsciiValue(Handle obj)); ~AsciiValue(); char* operator*() { return str_; } const char* operator*() const { return str_; } @@ -2265,7 +2293,7 @@ class V8_EXPORT Object : public Value { * Call an Object as a function if a callback is set by the * ObjectTemplate::SetCallAsFunctionHandler method. */ - Local CallAsFunction(Handle recv, + Local CallAsFunction(Handle recv, int argc, Handle argv[]); @@ -2364,17 +2392,18 @@ class FunctionCallbackInfo { V8_INLINE Isolate* GetIsolate() const; V8_INLINE ReturnValue GetReturnValue() const; // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 6; + static const int kArgsLength = 7; protected: friend class internal::FunctionCallbackArguments; friend class internal::CustomArguments; - static const int kReturnValueIndex = 0; - static const int kReturnValueDefaultValueIndex = -1; - static const int kIsolateIndex = -2; - static const int kDataIndex = -3; - static const int kCalleeIndex = -4; - static const int kHolderIndex = -5; + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kCalleeIndex = 5; + static const int kContextSaveIndex = 6; V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, internal::Object** values, @@ -2406,12 +2435,12 @@ class PropertyCallbackInfo { friend class MacroAssembler; friend class internal::PropertyCallbackArguments; friend class internal::CustomArguments; - static const int kThisIndex = 0; - static const int kDataIndex = -1; - static const int kReturnValueIndex = -2; - static const int kReturnValueDefaultValueIndex = -3; - static const int kIsolateIndex = -4; - static const int kHolderIndex = -5; + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kThisIndex = 5; V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {} internal::Object** args_; @@ -2437,7 +2466,7 @@ class V8_EXPORT Function : public Object { Local NewInstance() const; Local NewInstance(int argc, Handle argv[]) const; - Local Call(Handle recv, int argc, Handle argv[]); + Local Call(Handle recv, int argc, Handle argv[]); void SetName(Handle name); Handle GetName() const; @@ -2449,6 +2478,12 @@ class V8_EXPORT Function : public Object { */ Handle GetInferredName() const; + /** + * User-defined name assigned to the "displayName" property of this function. + * Used to facilitate debugging and profiling of JavaScript code. + */ + Handle GetDisplayName() const; + /** * Returns zero based line number of function body and * kLineOffsetNotFound if no information available. @@ -2460,11 +2495,15 @@ class V8_EXPORT Function : public Object { */ int GetScriptColumnNumber() const; + /** + * Tells whether this function is builtin. + */ + bool IsBuiltin() const; + /** * Returns scriptId object. - * DEPRECATED: use ScriptId() instead. */ - Handle GetScriptId() const; + V8_DEPRECATED("Use ScriptId instead", Handle GetScriptId()) const; /** * Returns scriptId. @@ -2627,10 +2666,6 @@ class V8_EXPORT ArrayBufferView : public Object { * Size of a view in bytes. */ size_t ByteLength(); - /** - * Base address of a view. - */ - void* BaseAddress(); V8_INLINE static ArrayBufferView* Cast(Value* obj); @@ -2830,9 +2865,9 @@ class V8_EXPORT Date : public Object { public: static Local New(double time); - // Deprecated, use Date::ValueOf() instead. - // TODO(svenpanne) Actually deprecate when Chrome is adapted. - double NumberValue() const { return ValueOf(); } + V8_DEPRECATED( + "Use ValueOf instead", + double NumberValue()) const { return ValueOf(); } /** * A specialization of Value::NumberValue that is more efficient @@ -2868,9 +2903,9 @@ class V8_EXPORT NumberObject : public Object { public: static Local New(double value); - // Deprecated, use NumberObject::ValueOf() instead. - // TODO(svenpanne) Actually deprecate when Chrome is adapted. - double NumberValue() const { return ValueOf(); } + V8_DEPRECATED( + "Use ValueOf instead", + double NumberValue()) const { return ValueOf(); } /** * Returns the Number held by the object. @@ -2891,9 +2926,9 @@ class V8_EXPORT BooleanObject : public Object { public: static Local New(bool value); - // Deprecated, use BooleanObject::ValueOf() instead. - // TODO(svenpanne) Actually deprecate when Chrome is adapted. - bool BooleanValue() const { return ValueOf(); } + V8_DEPRECATED( + "Use ValueOf instead", + bool BooleanValue()) const { return ValueOf(); } /** * Returns the Boolean held by the object. @@ -2914,9 +2949,9 @@ class V8_EXPORT StringObject : public Object { public: static Local New(Handle value); - // Deprecated, use StringObject::ValueOf() instead. - // TODO(svenpanne) Actually deprecate when Chrome is adapted. - Local StringValue() const { return ValueOf(); } + V8_DEPRECATED( + "Use ValueOf instead", + Local StringValue()) const { return ValueOf(); } /** * Returns the String held by the object. @@ -2939,9 +2974,9 @@ class V8_EXPORT SymbolObject : public Object { public: static Local New(Isolate* isolate, Handle value); - // Deprecated, use SymbolObject::ValueOf() instead. - // TODO(svenpanne) Actually deprecate when Chrome is adapted. - Local SymbolValue() const { return ValueOf(); } + V8_DEPRECATED( + "Use ValueOf instead", + Local SymbolValue()) const { return ValueOf(); } /** * Returns the Symbol held by the object. @@ -3744,23 +3779,18 @@ class V8_EXPORT ResourceConstraints { uint32_t* stack_limit() const { return stack_limit_; } // Sets an address beyond which the VM's stack may not grow. void set_stack_limit(uint32_t* value) { stack_limit_ = value; } - Maybe is_memory_constrained() const { return is_memory_constrained_; } - // If set to true, V8 will limit it's memory usage, at the potential cost of - // lower performance. Note, this option is a tentative addition to the API - // and may be removed or modified without warning. - void set_memory_constrained(bool value) { - is_memory_constrained_ = Maybe(value); - } private: int max_young_space_size_; int max_old_space_size_; int max_executable_size_; uint32_t* stack_limit_; - Maybe is_memory_constrained_; }; +/** + * Sets the given ResourceConstraints on the current isolate. + */ bool V8_EXPORT SetResourceConstraints(ResourceConstraints* constraints); @@ -3773,13 +3803,9 @@ typedef void (*FatalErrorCallback)(const char* location, const char* message); typedef void (*MessageCallback)(Handle message, Handle error); -/** - * Schedules an exception to be thrown when returning to JavaScript. When an - * exception has been scheduled it is illegal to invoke any JavaScript - * operation; the caller must return immediately and only after the exception - * has been handled does it become legal to invoke JavaScript operations. - */ -Handle V8_EXPORT ThrowException(Handle exception); +V8_DEPRECATED( + "Use Isolate::ThrowException instead", + Handle V8_EXPORT ThrowException(Handle exception)); /** * Create new error objects by calling the corresponding error object @@ -3870,8 +3896,6 @@ enum GCCallbackFlags { typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); -typedef void (*GCCallback)(); - /** * Collection of V8 heap information. @@ -4019,9 +4043,30 @@ class V8_EXPORT Isolate { */ CpuProfiler* GetCpuProfiler(); + /** Returns true if this isolate has a current context. */ + bool InContext(); + /** Returns the context that is on the top of the stack. */ Local GetCurrentContext(); + /** + * Returns the context of the calling JavaScript code. That is the + * context of the top-most JavaScript frame. If there are no + * JavaScript frames an empty handle is returned. + */ + Local GetCallingContext(); + + /** Returns the last entered context. */ + Local GetEnteredContext(); + + /** + * Schedules an exception to be thrown when returning to JavaScript. When an + * exception has been scheduled it is illegal to invoke any JavaScript + * operation; the caller must return immediately and only after the exception + * has been handled does it become legal to invoke JavaScript operations. + */ + Local ThrowException(Local exception); + /** * Allows the host application to group objects together. If one * object in the group is alive, all objects in the group are alive. @@ -4033,8 +4078,8 @@ class V8_EXPORT Isolate { * garbage collection types it is sufficient to provide object groups * for partially dependent handles only. */ - void SetObjectGroupId(const Persistent& object, - UniqueId id); + template void SetObjectGroupId(const Persistent& object, + UniqueId id); /** * Allows the host application to declare implicit references from an object @@ -4043,8 +4088,8 @@ class V8_EXPORT Isolate { * are removed. It is intended to be used in the before-garbage-collection * callback function. */ - void SetReferenceFromGroup(UniqueId id, - const Persistent& child); + template void SetReferenceFromGroup(UniqueId id, + const Persistent& child); /** * Allows the host application to declare implicit references from an object @@ -4052,8 +4097,53 @@ class V8_EXPORT Isolate { * too. After each garbage collection, all implicit references are removed. It * is intended to be used in the before-garbage-collection callback function. */ - void SetReference(const Persistent& parent, - const Persistent& child); + template + void SetReference(const Persistent& parent, const Persistent& child); + + typedef void (*GCPrologueCallback)(Isolate* isolate, + GCType type, + GCCallbackFlags flags); + typedef void (*GCEpilogueCallback)(Isolate* isolate, + GCType type, + GCCallbackFlags flags); + + /** + * Enables the host application to receive a notification before a + * garbage collection. Allocations are not allowed in the + * callback function, you therefore cannot manipulate objects (set + * or delete properties for example) since it is possible such + * operations will result in the allocation of objects. It is possible + * to specify the GCType filter for your callback. But it is not possible to + * register the same callback function two times with different + * GCType filters. + */ + void AddGCPrologueCallback( + GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); + + /** + * This function removes callback which was installed by + * AddGCPrologueCallback function. + */ + void RemoveGCPrologueCallback(GCPrologueCallback callback); + + /** + * Enables the host application to receive a notification after a + * garbage collection. Allocations are not allowed in the + * callback function, you therefore cannot manipulate objects (set + * or delete properties for example) since it is possible such + * operations will result in the allocation of objects. It is possible + * to specify the GCType filter for your callback. But it is not possible to + * register the same callback function two times with different + * GCType filters. + */ + void AddGCEpilogueCallback( + GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); + + /** + * This function removes callback which was installed by + * AddGCEpilogueCallback function. + */ + void RemoveGCEpilogueCallback(GCEpilogueCallback callback); private: Isolate(); @@ -4062,8 +4152,11 @@ class V8_EXPORT Isolate { Isolate& operator=(const Isolate&); void* operator new(size_t size); void operator delete(void*, size_t); -}; + void SetObjectGroupId(internal::Object** object, UniqueId id); + void SetReferenceFromGroup(UniqueId id, internal::Object** object); + void SetReference(internal::Object** parent, internal::Object** child); +}; class V8_EXPORT StartupData { public: @@ -4411,16 +4504,6 @@ class V8_EXPORT V8 { */ static void RemoveGCPrologueCallback(GCPrologueCallback callback); - /** - * The function is deprecated. Please use AddGCPrologueCallback instead. - * Enables the host application to receive a notification before a - * garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. - */ - V8_DEPRECATED(static void SetGlobalGCPrologueCallback(GCCallback)); - /** * Enables the host application to receive a notification after a * garbage collection. Allocations are not allowed in the @@ -4440,16 +4523,6 @@ class V8_EXPORT V8 { */ static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); - /** - * The function is deprecated. Please use AddGCEpilogueCallback instead. - * Enables the host application to receive a notification after a - * major garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. - */ - V8_DEPRECATED(static void SetGlobalGCEpilogueCallback(GCCallback)); - /** * Enables the host application to provide a mechanism to be notified * and perform custom logging when V8 Allocates Executable Memory. @@ -4497,11 +4570,6 @@ class V8_EXPORT V8 { static void SetReturnAddressLocationResolver( ReturnAddressLocationResolver return_address_resolver); - /** - * Deprecated, use the variant with the Isolate parameter below instead. - */ - V8_DEPRECATED(static bool SetFunctionEntryHook(FunctionEntryHook entry_hook)); - /** * Allows the host application to provide the address of a function that's * invoked on entry to every V8-generated function. @@ -4541,10 +4609,10 @@ class V8_EXPORT V8 { static void SetJitCodeEventHandler(JitCodeEventOptions options, JitCodeEventHandler event_handler); - // TODO(svenpanne) Really deprecate me when Chrome is fixed. - /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */ - static intptr_t AdjustAmountOfExternalAllocatedMemory( - intptr_t change_in_bytes); + V8_DEPRECATED( + "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead", + static intptr_t AdjustAmountOfExternalAllocatedMemory( + intptr_t change_in_bytes)); /** * Forcefully terminate the current thread of JavaScript execution @@ -4599,9 +4667,6 @@ class V8_EXPORT V8 { */ static bool Dispose(); - /** Deprecated. Use Isolate::GetHeapStatistics instead. */ - V8_DEPRECATED(static void GetHeapStatistics(HeapStatistics* heap_statistics)); - /** * Iterates through all external resources referenced from current isolate * heap. GC is not invoked prior to iterating, therefore there is no @@ -4899,25 +4964,14 @@ class V8_EXPORT Context { Handle global_template = Handle(), Handle global_object = Handle()); - /** Deprecated. Use Isolate version instead. */ - V8_DEPRECATED(static Persistent New( - ExtensionConfiguration* extensions = NULL, - Handle global_template = Handle(), - Handle global_object = Handle())); + V8_DEPRECATED("Use Isolate::GetEnteredContext instead", + static Local GetEntered()); - /** Returns the last entered context. */ - static Local GetEntered(); + V8_DEPRECATED("Use Isolate::GetCurrentContext instead", + static Local GetCurrent()); - // TODO(svenpanne) Actually deprecate this. - /** Deprecated. Use Isolate::GetCurrentContext instead. */ - static Local GetCurrent(); - - /** - * Returns the context of the calling JavaScript code. That is the - * context of the top-most JavaScript frame. If there are no - * JavaScript frames an empty handle is returned. - */ - static Local GetCalling(); + V8_DEPRECATED("Use Isolate::GetCallingContext instead", + static Local GetCalling()); /** * Sets the security token for the context. To access an object in @@ -4948,8 +5002,8 @@ class V8_EXPORT Context { /** Returns true if the context has experienced an out of memory situation. */ bool HasOutOfMemoryException(); - /** Returns true if V8 has a current context. */ - static bool InContext(); + V8_DEPRECATED("Use Isolate::InContext instead", + static bool InContext()); /** Returns an isolate associated with a current context. */ v8::Isolate* GetIsolate(); @@ -5020,8 +5074,9 @@ class V8_EXPORT Context { explicit V8_INLINE Scope(Handle context) : context_(context) { context_->Enter(); } - // TODO(dcarney): deprecate - V8_INLINE Scope(Isolate* isolate, Persistent& context) // NOLINT + V8_DEPRECATED( + "Use Handle version instead", + V8_INLINE Scope(Isolate* isolate, Persistent& context)) // NOLINT : context_(Handle::New(isolate, context)) { context_->Enter(); } @@ -5125,9 +5180,6 @@ class V8_EXPORT Unlocker { */ V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); } - /** Deprecated. Use Isolate version instead. */ - V8_DEPRECATED(Unlocker()); - ~Unlocker(); private: void Initialize(Isolate* isolate); @@ -5143,9 +5195,6 @@ class V8_EXPORT Locker { */ V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } - /** Deprecated. Use Isolate version instead. */ - V8_DEPRECATED(Locker()); - ~Locker(); /** @@ -5155,12 +5204,12 @@ class V8_EXPORT Locker { * that will switch between multiple threads that are in contention * for the V8 lock. */ - static void StartPreemption(int every_n_ms); + static void StartPreemption(Isolate* isolate, int every_n_ms); /** * Stop preemption. */ - static void StopPreemption(); + static void StopPreemption(Isolate* isolate); /** * Returns whether or not the locker for a given isolate, is locked by the @@ -5359,7 +5408,7 @@ class Internals { static const int kNullValueRootIndex = 7; static const int kTrueValueRootIndex = 8; static const int kFalseValueRootIndex = 9; - static const int kEmptyStringRootIndex = 131; + static const int kEmptyStringRootIndex = 132; static const int kNodeClassIdOffset = 1 * kApiPointerSize; static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; @@ -5370,7 +5419,7 @@ class Internals { static const int kNodeIsIndependentShift = 4; static const int kNodeIsPartiallyDependentShift = 5; - static const int kJSObjectType = 0xb1; + static const int kJSObjectType = 0xb2; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; static const int kForeignType = 0x87; @@ -5378,7 +5427,7 @@ class Internals { static const int kUndefinedOddballKind = 5; static const int kNullOddballKind = 3; - static void CheckInitializedImpl(v8::Isolate* isolate); + V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate); V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { #ifdef V8_ENABLE_CHECKS CheckInitializedImpl(isolate); @@ -5493,19 +5542,6 @@ template Local::Local() : Handle() { } -template -Local Local::New(Handle that) { - if (that.IsEmpty()) return Local(); - T* that_ptr = *that; - internal::Object** p = reinterpret_cast(that_ptr); - if (internal::Internals::CanCastToHeapObject(that_ptr)) { - return Local(reinterpret_cast(HandleScope::CreateHandle( - reinterpret_cast(*p)))); - } - return Local(reinterpret_cast(HandleScope::CreateHandle(*p))); -} - - template Local Local::New(Isolate* isolate, Handle that) { return New(isolate, that.val_); @@ -5847,7 +5883,7 @@ FunctionCallbackInfo::FunctionCallbackInfo(internal::Object** implicit_args, template Local FunctionCallbackInfo::operator[](int i) const { - if (i < 0 || length_ <= i) return Local(*Undefined()); + if (i < 0 || length_ <= i) return Local(*Undefined(GetIsolate())); return Local(reinterpret_cast(values_ - i)); } @@ -5929,7 +5965,8 @@ Handle ScriptOrigin::ResourceIsSharedCrossOrigin() const { Handle Boolean::New(bool value) { - return value ? True() : False(); + Isolate* isolate = Isolate::GetCurrent(); + return value ? True(isolate) : False(isolate); } @@ -5941,6 +5978,7 @@ void Template::Set(const char* name, v8::Handle value) { Local Object::GetInternalField(int index) { #ifndef V8_ENABLE_CHECKS typedef internal::Object O; + typedef internal::HeapObject HO; typedef internal::Internals I; O* obj = *reinterpret_cast(this); // Fast path: If the object is a plain JSObject, which is the common case, we @@ -5948,7 +5986,7 @@ Local Object::GetInternalField(int index) { if (I::GetInstanceType(obj) == I::kJSObjectType) { int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); O* value = I::ReadField(obj, offset); - O** result = HandleScope::CreateHandle(value); + O** result = HandleScope::CreateHandle(reinterpret_cast(obj), value); return Local(reinterpret_cast(result)); } #endif @@ -6397,11 +6435,41 @@ void* Isolate::GetData() { } +template +void Isolate::SetObjectGroupId(const Persistent& object, + UniqueId id) { + TYPE_CHECK(Value, T); + SetObjectGroupId(reinterpret_cast(object.val_), id); +} + + +template +void Isolate::SetReferenceFromGroup(UniqueId id, + const Persistent& object) { + TYPE_CHECK(Value, T); + SetReferenceFromGroup(id, + reinterpret_cast(object.val_)); +} + + +template +void Isolate::SetReference(const Persistent& parent, + const Persistent& child) { + TYPE_CHECK(Object, T); + TYPE_CHECK(Value, S); + SetReference(reinterpret_cast(parent.val_), + reinterpret_cast(child.val_)); +} + + Local Context::GetEmbedderData(int index) { #ifndef V8_ENABLE_CHECKS typedef internal::Object O; + typedef internal::HeapObject HO; typedef internal::Internals I; - O** result = HandleScope::CreateHandle(I::ReadEmbedderData(this, index)); + HO* context = *reinterpret_cast(this); + O** result = + HandleScope::CreateHandle(context, I::ReadEmbedderData(this, index)); return Local(reinterpret_cast(result)); #else return SlowGetEmbedderData(index); diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h index 6fe5c5aabc..834f9c50ec 100644 --- a/deps/v8/include/v8config.h +++ b/deps/v8/include/v8config.h @@ -245,6 +245,7 @@ // older compilers. # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) +# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ @@ -320,12 +321,16 @@ // A macro to mark classes or functions as deprecated. -#if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED -# define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) -#elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED -# define V8_DEPRECATED(declarator) __declspec(deprecated) declarator +#if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE +# define V8_DEPRECATED(message, declarator) \ +declarator __attribute__((deprecated(message))) +#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED +# define V8_DEPRECATED(message, declarator) \ +declarator __attribute__((deprecated)) +#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED +# define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator #else -# define V8_DEPRECATED(declarator) declarator +# define V8_DEPRECATED(message, declarator) declarator #endif diff --git a/deps/v8/preparser/preparser-process.cc b/deps/v8/preparser/preparser-process.cc deleted file mode 100644 index b816744303..0000000000 --- a/deps/v8/preparser/preparser-process.cc +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2012 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include -#include -#include -#include - -#include "../include/v8.h" -#include "../include/v8stdint.h" -#include "../include/v8-preparser.h" - -#include "../src/preparse-data-format.h" - -namespace i = v8::internal; - -// This file is only used for testing the preparser. -// The first argument must be the path of a JavaScript source file, or -// the flags "-e" and the next argument is then the source of a JavaScript -// program. -// Optionally this can be followed by the word "throws" (case sensitive), -// which signals that the parsing is expected to throw - the default is -// to expect the parsing to not throw. -// The command line can further be followed by a message text (the -// *type* of the exception to throw), and even more optionally, the -// start and end position reported with the exception. -// -// This source file is preparsed and tested against the expectations, and if -// successful, the resulting preparser data is written to stdout. -// Diagnostic output is output on stderr. -// The source file must contain only ASCII characters (UTF-8 isn't supported). -// The file is read into memory, so it should have a reasonable size. - - -// Adapts an ASCII string to the UnicodeInputStream interface. -class AsciiInputStream : public v8::UnicodeInputStream { - public: - AsciiInputStream(const uint8_t* buffer, size_t length) - : buffer_(buffer), - end_offset_(static_cast(length)), - offset_(0) { } - - virtual ~AsciiInputStream() { } - - virtual void PushBack(int32_t ch) { - offset_--; -#ifdef DEBUG - if (offset_ < 0 || - (ch != ((offset_ >= end_offset_) ? -1 : buffer_[offset_]))) { - fprintf(stderr, "Invalid pushback: '%c' at offset %d.", ch, offset_); - exit(1); - } -#endif - } - - virtual int32_t Next() { - if (offset_ >= end_offset_) { - offset_++; // Increment anyway to allow symmetric pushbacks. - return -1; - } - uint8_t next_char = buffer_[offset_]; -#ifdef DEBUG - if (next_char > 0x7fu) { - fprintf(stderr, "Non-ASCII character in input: '%c'.", next_char); - exit(1); - } -#endif - offset_++; - return static_cast(next_char); - } - - private: - const uint8_t* buffer_; - const int end_offset_; - int offset_; -}; - - -bool ReadBuffer(FILE* source, void* buffer, size_t length) { - size_t actually_read = fread(buffer, 1, length, source); - return (actually_read == length); -} - - -bool WriteBuffer(FILE* dest, const void* buffer, size_t length) { - size_t actually_written = fwrite(buffer, 1, length, dest); - return (actually_written == length); -} - - -class PreparseDataInterpreter { - public: - PreparseDataInterpreter(const uint8_t* data, int length) - : data_(data), length_(length), message_(NULL) { } - - ~PreparseDataInterpreter() { - if (message_ != NULL) delete[] message_; - } - - bool valid() { - int header_length = - i::PreparseDataConstants::kHeaderSize * sizeof(int); // NOLINT - return length_ >= header_length; - } - - bool throws() { - return valid() && - word(i::PreparseDataConstants::kHasErrorOffset) != 0; - } - - const char* message() { - if (message_ != NULL) return message_; - if (!throws()) return NULL; - int text_pos = i::PreparseDataConstants::kHeaderSize + - i::PreparseDataConstants::kMessageTextPos; - int length = word(text_pos); - char* buffer = new char[length + 1]; - for (int i = 1; i <= length; i++) { - int character = word(text_pos + i); - buffer[i - 1] = character; - } - buffer[length] = '\0'; - message_ = buffer; - return buffer; - } - - int beg_pos() { - if (!throws()) return -1; - return word(i::PreparseDataConstants::kHeaderSize + - i::PreparseDataConstants::kMessageStartPos); - } - - int end_pos() { - if (!throws()) return -1; - return word(i::PreparseDataConstants::kHeaderSize + - i::PreparseDataConstants::kMessageEndPos); - } - - private: - int word(int offset) { - const int* word_data = reinterpret_cast(data_); - if (word_data + offset < reinterpret_cast(data_ + length_)) { - return word_data[offset]; - } - return -1; - } - - const uint8_t* const data_; - const int length_; - const char* message_; -}; - - -template -class ScopedPointer { - public: - explicit ScopedPointer() : pointer_(NULL) {} - explicit ScopedPointer(T* pointer) : pointer_(pointer) {} - ~ScopedPointer() { if (pointer_ != NULL) delete[] pointer_; } - T& operator[](int index) { return pointer_[index]; } - T* operator*() { return pointer_ ;} - T* operator=(T* new_value) { - if (pointer_ != NULL) delete[] pointer_; - pointer_ = new_value; - return new_value; - } - private: - T* pointer_; -}; - - - -void fail(v8::PreParserData* data, const char* message, ...) { - va_list args; - va_start(args, message); - vfprintf(stderr, message, args); - va_end(args); - fflush(stderr); - if (data != NULL) { - // Print preparser data to stdout. - uint32_t size = static_cast(data->size()); - fprintf(stderr, "LOG: data size: %u\n", size); - if (!WriteBuffer(stdout, data->data(), size)) { - perror("ERROR: Writing data"); - fflush(stderr); - } - } - exit(EXIT_FAILURE); -} - - -bool IsFlag(const char* arg) { - // Anything starting with '-' is considered a flag. - // It's summarily ignored for now. - return arg[0] == '-'; -} - - -struct ExceptionExpectation { - ExceptionExpectation() - : throws(false), type(NULL), beg_pos(-1), end_pos(-1) { } - bool throws; - const char* type; - int beg_pos; - int end_pos; -}; - - -void CheckException(v8::PreParserData* data, - ExceptionExpectation* expects) { - PreparseDataInterpreter reader(data->data(), static_cast(data->size())); - if (expects->throws) { - if (!reader.throws()) { - if (expects->type == NULL) { - fail(data, "Didn't throw as expected\n"); - } else { - fail(data, "Didn't throw \"%s\" as expected\n", expects->type); - } - } - if (expects->type != NULL) { - const char* actual_message = reader.message(); - if (strcmp(expects->type, actual_message)) { - fail(data, "Wrong error message. Expected <%s>, found <%s> at %d..%d\n", - expects->type, actual_message, reader.beg_pos(), reader.end_pos()); - } - } - if (expects->beg_pos >= 0) { - if (expects->beg_pos != reader.beg_pos()) { - fail(data, "Wrong error start position: Expected %i, found %i\n", - expects->beg_pos, reader.beg_pos()); - } - } - if (expects->end_pos >= 0) { - if (expects->end_pos != reader.end_pos()) { - fail(data, "Wrong error end position: Expected %i, found %i\n", - expects->end_pos, reader.end_pos()); - } - } - } else if (reader.throws()) { - const char* message = reader.message(); - fail(data, "Throws unexpectedly with message: %s at location %d-%d\n", - message, reader.beg_pos(), reader.end_pos()); - } -} - - -ExceptionExpectation ParseExpectation(int argc, const char* argv[]) { - // Parse ["throws" [ [ []]]]. - ExceptionExpectation expects; - int arg_index = 0; - while (argc > arg_index && strncmp("throws", argv[arg_index], 7)) { - arg_index++; - } - if (argc > arg_index) { - expects.throws = true; - arg_index++; - if (argc > arg_index && !IsFlag(argv[arg_index])) { - expects.type = argv[arg_index]; - arg_index++; - if (argc > arg_index && !IsFlag(argv[arg_index])) { - expects.beg_pos = atoi(argv[arg_index]); // NOLINT - arg_index++; - if (argc > arg_index && !IsFlag(argv[arg_index])) { - expects.end_pos = atoi(argv[arg_index]); // NOLINT - } - } - } - } - return expects; -} - - -int main(int argc, const char* argv[]) { - // Parse command line. - // Format: preparser ( | -e "") - // ["throws" [ [ []]]] - // Any flags (except an initial -e) are ignored. - // Flags must not separate "throws" and its arguments. - - // Check for mandatory filename argument. - int arg_index = 1; - if (argc <= arg_index) { - fail(NULL, "ERROR: No filename on command line.\n"); - } - const uint8_t* source = NULL; - const char* filename = argv[arg_index]; - if (!strcmp(filename, "-e")) { - arg_index++; - if (argc <= arg_index) { - fail(NULL, "ERROR: No source after -e on command line.\n"); - } - source = reinterpret_cast(argv[arg_index]); - } - // Check remainder of command line for exception expectations. - arg_index++; - ExceptionExpectation expects = - ParseExpectation(argc - arg_index, argv + arg_index); - - v8::V8::Initialize(); - - ScopedPointer buffer; - size_t length; - - if (source == NULL) { - // Open JS file. - FILE* input = fopen(filename, "rb"); - if (input == NULL) { - perror("ERROR: Error opening file"); - fflush(stderr); - return EXIT_FAILURE; - } - // Find length of JS file. - if (fseek(input, 0, SEEK_END) != 0) { - perror("ERROR: Error during seek"); - fflush(stderr); - return EXIT_FAILURE; - } - length = static_cast(ftell(input)); - rewind(input); - // Read JS file into memory buffer. - buffer = new uint8_t[length]; - if (!ReadBuffer(input, *buffer, length)) { - perror("ERROR: Reading file"); - fflush(stderr); - return EXIT_FAILURE; - } - fclose(input); - source = *buffer; - } else { - length = strlen(reinterpret_cast(source)); - } - - // Preparse input file. - AsciiInputStream input_buffer(source, length); - size_t kMaxStackSize = 64 * 1024 * sizeof(void*); // NOLINT - v8::PreParserData data = v8::Preparse(&input_buffer, kMaxStackSize); - - // Fail if stack overflow. - if (data.stack_overflow()) { - fail(&data, "ERROR: Stack overflow\n"); - } - - // Check that the expected exception is thrown, if an exception is - // expected. - CheckException(&data, &expects); - - return EXIT_SUCCESS; -} diff --git a/deps/v8/preparser/preparser.gyp b/deps/v8/preparser/preparser.gyp deleted file mode 100644 index 23cbfff644..0000000000 --- a/deps/v8/preparser/preparser.gyp +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2011 the V8 project authors. All rights reserved. -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -{ - 'variables': { - 'v8_code': 1, - }, - 'includes': ['../build/toolchain.gypi', '../build/features.gypi'], - 'targets': [ - { - 'target_name': 'preparser', - 'type': 'executable', - 'conditions': [ - # preparser can't link against a shared library, so link against - # the underlying static targets. - ['v8_use_snapshot=="true"', { - 'dependencies': ['../tools/gyp/v8.gyp:v8_snapshot'], - }, { - 'dependencies': [ - '../tools/gyp/v8.gyp:v8_nosnapshot.<(v8_target_arch)', - ], - }], - ], - 'include_dirs+': [ - '../src', - ], - 'sources': [ - 'preparser-process.cc', - '../include/v8-preparser.h', - '../src/preparser-api.cc', - ], - }, - ], -} diff --git a/deps/v8/samples/lineprocessor.cc b/deps/v8/samples/lineprocessor.cc index 42048202fd..5068c885e9 100644 --- a/deps/v8/samples/lineprocessor.cc +++ b/deps/v8/samples/lineprocessor.cc @@ -259,7 +259,7 @@ int RunMain(int argc, char* argv[]) { if (cycle_type == CycleInCpp) { bool res = RunCppCycle(script, - v8::Context::GetCurrent(), + isolate->GetCurrentContext(), report_exceptions); return !res; } else { @@ -296,7 +296,7 @@ bool RunCppCycle(v8::Handle script, v8::HandleScope handle_scope(isolate); v8::Handle input_line = ReadLine(); - if (input_line == v8::Undefined()) { + if (input_line == v8::Undefined(isolate)) { continue; } @@ -306,7 +306,7 @@ bool RunCppCycle(v8::Handle script, v8::Handle result; { v8::TryCatch try_catch; - result = process_fun->Call(v8::Context::GetCurrent()->Global(), + result = process_fun->Call(isolate->GetCurrentContext()->Global(), argc, argv); if (try_catch.HasCaught()) { if (report_exceptions) @@ -417,7 +417,7 @@ void Print(const v8::FunctionCallbackInfo& args) { // function is called. Reads a string from standard input and returns. void ReadLine(const v8::FunctionCallbackInfo& args) { if (args.Length() > 0) { - v8::ThrowException(v8::String::New("Unexpected arguments")); + args.GetIsolate()->ThrowException(v8::String::New("Unexpected arguments")); return; } args.GetReturnValue().Set(ReadLine()); @@ -436,7 +436,7 @@ v8::Handle ReadLine() { res = fgets(buffer, kBufferSize, stdin); } if (res == NULL) { - v8::Handle t = v8::Undefined(); + v8::Handle t = v8::Undefined(v8::Isolate::GetCurrent()); return v8::Handle::Cast(t); } // Remove newline char diff --git a/deps/v8/samples/samples.gyp b/deps/v8/samples/samples.gyp index be7b9ea696..dfc7410070 100644 --- a/deps/v8/samples/samples.gyp +++ b/deps/v8/samples/samples.gyp @@ -28,7 +28,7 @@ { 'variables': { 'v8_code': 1, - 'v8_enable_i18n_support%': 0, + 'v8_enable_i18n_support%': 1, }, 'includes': ['../build/toolchain.gypi', '../build/features.gypi'], 'target_defaults': { @@ -42,13 +42,13 @@ 'conditions': [ ['v8_enable_i18n_support==1', { 'dependencies': [ - '<(DEPTH)/third_party/icu/icu.gyp:icui18n', - '<(DEPTH)/third_party/icu/icu.gyp:icuuc', + '<(icu_gyp_path):icui18n', + '<(icu_gyp_path):icuuc', ], }], ['OS=="win" and v8_enable_i18n_support==1', { 'dependencies': [ - '<(DEPTH)/third_party/icu/icu.gyp:icudata', + '<(icu_gyp_path):icudata', ], }], ], diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index 710547c341..06bd8f67eb 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -140,17 +140,20 @@ void Print(const v8::FunctionCallbackInfo& args) { // the argument into a JavaScript string. void Read(const v8::FunctionCallbackInfo& args) { if (args.Length() != 1) { - v8::ThrowException(v8::String::New("Bad parameters")); + args.GetIsolate()->ThrowException( + v8::String::New("Bad parameters")); return; } v8::String::Utf8Value file(args[0]); if (*file == NULL) { - v8::ThrowException(v8::String::New("Error loading file")); + args.GetIsolate()->ThrowException( + v8::String::New("Error loading file")); return; } v8::Handle source = ReadFile(*file); if (source.IsEmpty()) { - v8::ThrowException(v8::String::New("Error loading file")); + args.GetIsolate()->ThrowException( + v8::String::New("Error loading file")); return; } args.GetReturnValue().Set(source); @@ -165,12 +168,14 @@ void Load(const v8::FunctionCallbackInfo& args) { v8::HandleScope handle_scope(args.GetIsolate()); v8::String::Utf8Value file(args[i]); if (*file == NULL) { - v8::ThrowException(v8::String::New("Error loading file")); + args.GetIsolate()->ThrowException( + v8::String::New("Error loading file")); return; } v8::Handle source = ReadFile(*file); if (source.IsEmpty()) { - v8::ThrowException(v8::String::New("Error loading file")); + args.GetIsolate()->ThrowException( + v8::String::New("Error loading file")); return; } if (!ExecuteString(args.GetIsolate(), @@ -178,7 +183,8 @@ void Load(const v8::FunctionCallbackInfo& args) { v8::String::New(*file), false, false)) { - v8::ThrowException(v8::String::New("Error executing file")); + args.GetIsolate()->ThrowException( + v8::String::New("Error executing file")); return; } } diff --git a/deps/v8/src/OWNERS b/deps/v8/src/OWNERS new file mode 100644 index 0000000000..f38fecad4e --- /dev/null +++ b/deps/v8/src/OWNERS @@ -0,0 +1,2 @@ +per-file i18n.*=cira@chromium.org +per-file i18n.*=mnita@google.com diff --git a/deps/v8/src/accessors.cc b/deps/v8/src/accessors.cc index 669c02baf3..50232661c1 100644 --- a/deps/v8/src/accessors.cc +++ b/deps/v8/src/accessors.cc @@ -78,6 +78,61 @@ MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate, } +static V8_INLINE bool CheckForName(Handle name, + String* property_name, + int offset, + int* object_offset) { + if (name->Equals(property_name)) { + *object_offset = offset; + return true; + } + return false; +} + + +bool Accessors::IsJSObjectFieldAccessor( + Handle map, Handle name, + int* object_offset) { + Isolate* isolate = map->GetIsolate(); + switch (map->instance_type()) { + case JS_ARRAY_TYPE: + return + CheckForName(name, isolate->heap()->length_string(), + JSArray::kLengthOffset, object_offset); + case JS_TYPED_ARRAY_TYPE: + return + CheckForName(name, isolate->heap()->length_string(), + JSTypedArray::kLengthOffset, object_offset) || + CheckForName(name, isolate->heap()->byte_length_string(), + JSTypedArray::kByteLengthOffset, object_offset) || + CheckForName(name, isolate->heap()->byte_offset_string(), + JSTypedArray::kByteOffsetOffset, object_offset) || + CheckForName(name, isolate->heap()->buffer_string(), + JSTypedArray::kBufferOffset, object_offset); + case JS_ARRAY_BUFFER_TYPE: + return + CheckForName(name, isolate->heap()->byte_length_string(), + JSArrayBuffer::kByteLengthOffset, object_offset); + case JS_DATA_VIEW_TYPE: + return + CheckForName(name, isolate->heap()->byte_length_string(), + JSDataView::kByteLengthOffset, object_offset) || + CheckForName(name, isolate->heap()->byte_offset_string(), + JSDataView::kByteOffsetOffset, object_offset) || + CheckForName(name, isolate->heap()->buffer_string(), + JSDataView::kBufferOffset, object_offset); + default: { + if (map->instance_type() < FIRST_NONSTRING_TYPE) { + return + CheckForName(name, isolate->heap()->length_string(), + String::kLengthOffset, object_offset); + } + return false; + } + } +} + + // // Accessors::ArrayLength // diff --git a/deps/v8/src/accessors.h b/deps/v8/src/accessors.h index d9a2130f61..b2dee27932 100644 --- a/deps/v8/src/accessors.h +++ b/deps/v8/src/accessors.h @@ -86,6 +86,13 @@ class Accessors : public AllStatic { static Handle MakeModuleExport( Handle name, int index, PropertyAttributes attributes); + // Returns true for properties that are accessors to object fields. + // If true, *object_offset contains offset of object field. + static bool IsJSObjectFieldAccessor( + Handle map, Handle name, + int* object_offset); + + private: // Accessor functions only used through the descriptor. static MaybeObject* FunctionSetPrototype(Isolate* isolate, diff --git a/deps/v8/src/allocation-site-scopes.cc b/deps/v8/src/allocation-site-scopes.cc new file mode 100644 index 0000000000..8097045b27 --- /dev/null +++ b/deps/v8/src/allocation-site-scopes.cc @@ -0,0 +1,108 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "allocation-site-scopes.h" + +namespace v8 { +namespace internal { + + +Handle AllocationSiteCreationContext::EnterNewScope() { + Handle scope_site; + if (top().is_null()) { + // We are creating the top level AllocationSite as opposed to a nested + // AllocationSite. + InitializeTraversal(isolate()->factory()->NewAllocationSite()); + scope_site = Handle(*top(), isolate()); + if (FLAG_trace_creation_allocation_sites) { + PrintF("*** Creating top level AllocationSite %p\n", + static_cast(*scope_site)); + } + } else { + ASSERT(!current().is_null()); + scope_site = isolate()->factory()->NewAllocationSite(); + if (FLAG_trace_creation_allocation_sites) { + PrintF("Creating nested site (top, current, new) (%p, %p, %p)\n", + static_cast(*top()), + static_cast(*current()), + static_cast(*scope_site)); + } + current()->set_nested_site(*scope_site); + update_current_site(*scope_site); + } + ASSERT(!scope_site.is_null()); + return scope_site; +} + + +void AllocationSiteCreationContext::ExitScope( + Handle scope_site, + Handle object) { + if (!object.is_null() && !object->IsFailure()) { + bool top_level = !scope_site.is_null() && + top().is_identical_to(scope_site); + + scope_site->set_transition_info(*object); + if (FLAG_trace_creation_allocation_sites) { + if (top_level) { + PrintF("*** Setting AllocationSite %p transition_info %p\n", + static_cast(*scope_site), + static_cast(*object)); + } else { + PrintF("Setting AllocationSite (%p, %p) transition_info %p\n", + static_cast(*top()), + static_cast(*scope_site), + static_cast(*object)); + } + } + } +} + + +Handle AllocationSiteUsageContext::EnterNewScope() { + if (top().is_null()) { + InitializeTraversal(top_site_); + } else { + // Advance current site + Object* nested_site = current()->nested_site(); + // Something is wrong if we advance to the end of the list here. + ASSERT(nested_site->IsAllocationSite()); + update_current_site(AllocationSite::cast(nested_site)); + } + return Handle(*current(), isolate()); +} + + +void AllocationSiteUsageContext::ExitScope( + Handle scope_site, + Handle object) { + // This assert ensures that we are pointing at the right sub-object in a + // recursive walk of a nested literal. + ASSERT(object.is_null() || *object == scope_site->transition_info()); +} + +} } // namespace v8::internal diff --git a/deps/v8/src/allocation-site-scopes.h b/deps/v8/src/allocation-site-scopes.h new file mode 100644 index 0000000000..1c3afdf369 --- /dev/null +++ b/deps/v8/src/allocation-site-scopes.h @@ -0,0 +1,115 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef V8_ALLOCATION_SITE_SCOPES_H_ +#define V8_ALLOCATION_SITE_SCOPES_H_ + +#include "ast.h" +#include "handles.h" +#include "objects.h" +#include "zone.h" + +namespace v8 { +namespace internal { + + +// AllocationSiteContext is the base class for walking and copying a nested +// boilerplate with AllocationSite and AllocationMemento support. +class AllocationSiteContext { + public: + AllocationSiteContext(Isolate* isolate, bool activated) { + isolate_ = isolate; + activated_ = activated; + }; + virtual ~AllocationSiteContext() {} + + Handle top() { return top_; } + Handle current() { return current_; } + + // If activated, then recursively create mementos + bool activated() const { return activated_; } + + // Returns the AllocationSite that matches this scope. + virtual Handle EnterNewScope() = 0; + + // scope_site should be the handle returned by the matching EnterNewScope() + virtual void ExitScope(Handle scope_site, + Handle object) = 0; + + protected: + void update_current_site(AllocationSite* site) { + *(current_.location()) = site; + } + + Isolate* isolate() { return isolate_; } + void InitializeTraversal(Handle site) { + top_ = site; + current_ = Handle(*top_, isolate()); + } + + private: + Isolate* isolate_; + Handle top_; + Handle current_; + bool activated_; +}; + + +// AllocationSiteCreationContext aids in the creation of AllocationSites to +// accompany object literals. +class AllocationSiteCreationContext : public AllocationSiteContext { + public: + explicit AllocationSiteCreationContext(Isolate* isolate) + : AllocationSiteContext(isolate, true) { } + + virtual Handle EnterNewScope() V8_OVERRIDE; + virtual void ExitScope(Handle site, + Handle object) V8_OVERRIDE; +}; + + +// AllocationSiteUsageContext aids in the creation of AllocationMementos placed +// behind some/all components of a copied object literal. +class AllocationSiteUsageContext : public AllocationSiteContext { + public: + AllocationSiteUsageContext(Isolate* isolate, Handle site, + bool activated) + : AllocationSiteContext(isolate, activated), + top_site_(site) { } + + virtual Handle EnterNewScope() V8_OVERRIDE; + virtual void ExitScope(Handle site, + Handle object) V8_OVERRIDE; + + private: + Handle top_site_; +}; + + +} } // namespace v8::internal + +#endif // V8_ALLOCATION_SITE_SCOPES_H_ diff --git a/deps/v8/src/allocation-tracker.cc b/deps/v8/src/allocation-tracker.cc new file mode 100644 index 0000000000..586ce3c45a --- /dev/null +++ b/deps/v8/src/allocation-tracker.cc @@ -0,0 +1,279 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "v8.h" + +#include "allocation-tracker.h" + +#include "heap-snapshot-generator.h" +#include "frames-inl.h" + +namespace v8 { +namespace internal { + +AllocationTraceNode::AllocationTraceNode( + AllocationTraceTree* tree, SnapshotObjectId shared_function_info_id) + : tree_(tree), + function_id_(shared_function_info_id), + total_size_(0), + allocation_count_(0), + id_(tree->next_node_id()) { +} + + +AllocationTraceNode::~AllocationTraceNode() { +} + + +AllocationTraceNode* AllocationTraceNode::FindChild(SnapshotObjectId id) { + for (int i = 0; i < children_.length(); i++) { + AllocationTraceNode* node = children_[i]; + if (node->function_id() == id) return node; + } + return NULL; +} + + +AllocationTraceNode* AllocationTraceNode::FindOrAddChild(SnapshotObjectId id) { + AllocationTraceNode* child = FindChild(id); + if (child == NULL) { + child = new AllocationTraceNode(tree_, id); + children_.Add(child); + } + return child; +} + + +void AllocationTraceNode::AddAllocation(unsigned size) { + total_size_ += size; + ++allocation_count_; +} + + +void AllocationTraceNode::Print(int indent, AllocationTracker* tracker) { + OS::Print("%10u %10u %*c", total_size_, allocation_count_, indent, ' '); + if (tracker != NULL) { + const char* name = ""; + if (function_id_ != 0) { + AllocationTracker::FunctionInfo* info = + tracker->GetFunctionInfo(function_id_); + if (info != NULL) { + name = info->name; + } + } + OS::Print("%s #%u", name, id_); + } else { + OS::Print("%u #%u", function_id_, id_); + } + OS::Print("\n"); + indent += 2; + for (int i = 0; i < children_.length(); i++) { + children_[i]->Print(indent, tracker); + } +} + + +AllocationTraceTree::AllocationTraceTree() + : next_node_id_(1), + root_(this, 0) { +} + + +AllocationTraceTree::~AllocationTraceTree() { +} + + +AllocationTraceNode* AllocationTraceTree::AddPathFromEnd( + const Vector& path) { + AllocationTraceNode* node = root(); + for (SnapshotObjectId* entry = path.start() + path.length() - 1; + entry != path.start() - 1; + --entry) { + node = node->FindOrAddChild(*entry); + } + return node; +} + + +void AllocationTraceTree::Print(AllocationTracker* tracker) { + OS::Print("[AllocationTraceTree:]\n"); + OS::Print("Total size | Allocation count | Function id | id\n"); + root()->Print(0, tracker); +} + +void AllocationTracker::DeleteUnresolvedLocation( + UnresolvedLocation** location) { + delete *location; +} + + +AllocationTracker::FunctionInfo::FunctionInfo() + : name(""), + script_name(""), + script_id(0), + line(-1), + column(-1) { +} + + +static bool AddressesMatch(void* key1, void* key2) { + return key1 == key2; +} + + +AllocationTracker::AllocationTracker( + HeapObjectsMap* ids, StringsStorage* names) + : ids_(ids), + names_(names), + id_to_function_info_(AddressesMatch) { +} + + +AllocationTracker::~AllocationTracker() { + unresolved_locations_.Iterate(DeleteUnresolvedLocation); +} + + +void AllocationTracker::PrepareForSerialization() { + List copy(unresolved_locations_.length()); + copy.AddAll(unresolved_locations_); + unresolved_locations_.Clear(); + for (int i = 0; i < copy.length(); i++) { + copy[i]->Resolve(); + delete copy[i]; + } +} + + +void AllocationTracker::NewObjectEvent(Address addr, int size) { + DisallowHeapAllocation no_allocation; + Heap* heap = ids_->heap(); + + // Mark the new block as FreeSpace to make sure the heap is iterable + // while we are capturing stack trace. + FreeListNode::FromAddress(addr)->set_size(heap, size); + ASSERT_EQ(HeapObject::FromAddress(addr)->Size(), size); + ASSERT(FreeListNode::IsFreeListNode(HeapObject::FromAddress(addr))); + + Isolate* isolate = heap->isolate(); + int length = 0; + StackTraceFrameIterator it(isolate); + while (!it.done() && length < kMaxAllocationTraceLength) { + JavaScriptFrame* frame = it.frame(); + SharedFunctionInfo* shared = frame->function()->shared(); + SnapshotObjectId id = ids_->FindEntry(shared->address()); + allocation_trace_buffer_[length++] = id; + AddFunctionInfo(shared, id); + it.Advance(); + } + AllocationTraceNode* top_node = trace_tree_.AddPathFromEnd( + Vector(allocation_trace_buffer_, length)); + top_node->AddAllocation(size); +} + + +static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { + return ComputeIntegerHash(static_cast(id), + v8::internal::kZeroHashSeed); +} + + +AllocationTracker::FunctionInfo* AllocationTracker::GetFunctionInfo( + SnapshotObjectId id) { + HashMap::Entry* entry = id_to_function_info_.Lookup( + reinterpret_cast(id), SnapshotObjectIdHash(id), false); + if (entry == NULL) { + return NULL; + } + return reinterpret_cast(entry->value); +} + + +void AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, + SnapshotObjectId id) { + HashMap::Entry* entry = id_to_function_info_.Lookup( + reinterpret_cast(id), SnapshotObjectIdHash(id), true); + if (entry->value == NULL) { + FunctionInfo* info = new FunctionInfo(); + info->name = names_->GetFunctionName(shared->DebugName()); + if (shared->script()->IsScript()) { + Script* script = Script::cast(shared->script()); + if (script->name()->IsName()) { + Name* name = Name::cast(script->name()); + info->script_name = names_->GetName(name); + } + info->script_id = script->id()->value(); + // Converting start offset into line and column may cause heap + // allocations so we postpone them until snapshot serialization. + unresolved_locations_.Add(new UnresolvedLocation( + script, + shared->start_position(), + info)); + } + entry->value = info; + } +} + + +AllocationTracker::UnresolvedLocation::UnresolvedLocation( + Script* script, int start, FunctionInfo* info) + : start_position_(start), + info_(info) { + script_ = Handle + + + + + + +
+ +
+ +
+ + + + +
+
+
+
+
+ + + + + diff --git a/deps/v8/tools/sodium/sodium.js b/deps/v8/tools/sodium/sodium.js new file mode 100644 index 0000000000..44475a177f --- /dev/null +++ b/deps/v8/tools/sodium/sodium.js @@ -0,0 +1,409 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +var Sodium = (function() { + "use strict"; + + var kinds = ["FUNCTION", "OPTIMIZED_FUNCTION", "STUB", "BUILTIN", + "LOAD_IC", "KEYED_LOAD_IC", "CALL_IC", "KEYED_CALL_IC", + "STORE_IC", "KEYED_STORE_IC", "BINARY_OP_IC", "COMPARE_IC", + "COMPARE_NIL_IC", "TO_BOOLEAN_IC"]; + var kindsWithSource = { + 'FUNCTION': true, + 'OPTIMIZED_FUNCTION': true + }; + + var addressRegEx = "0x[0-9a-f]{8,16}"; + var nameFinder = new RegExp("^name = (.+)$"); + var kindFinder = new RegExp("^kind = (.+)$"); + var firstPositionFinder = new RegExp("^source_position = (\\d+)$"); + var separatorFilter = new RegExp("^--- (.)+ ---$"); + var rawSourceFilter = new RegExp("^--- Raw source ---$"); + var codeEndFinder = new RegExp("^--- End code ---$"); + var whiteSpaceLineFinder = new RegExp("^\\W*$"); + var instructionBeginFinder = + new RegExp("^Instructions\\W+\\(size = \\d+\\)"); + var instructionFinder = + new RegExp("^\(" + addressRegEx + "\)\(\\W+\\d+\\W+.+\)"); + var positionFinder = + new RegExp("^(" + addressRegEx + ")\\W+position\\W+\\((\\d+)\\)"); + var addressFinder = new RegExp("\(" + addressRegEx + "\)"); + var addressReplacer = new RegExp("\(" + addressRegEx + "\)", "gi"); + + var fileContent = ""; + var selectedFunctionKind = ""; + var currentFunctionKind = ""; + + var currentFunctionName = ""; + var firstSourcePosition = 0; + var startAddress = ""; + var readingSource = false; + var readingAsm = false; + var sourceBegin = -1; + var sourceEnd = -1; + var asmBegin = -1; + var asmEnd = -1; + var codeObjects = []; + var selectedAsm = null; + var selectedSource = null; + var selectedSourceClass = ""; + + function Code(name, kind, sourceBegin, sourceEnd, asmBegin, asmEnd, + firstSourcePosition, startAddress) { + this.name = name; + this.kind = kind; + this.sourceBegin = sourceBegin; + this.sourceEnd = sourceEnd; + this.asmBegin = asmBegin; + this.asmEnd = asmEnd; + this.firstSourcePosition = firstSourcePosition; + this.startAddress = startAddress; + } + + function getCurrentCodeObject() { + var functionSelect = document.getElementById('function-selector-id'); + return functionSelect.options[functionSelect.selectedIndex].codeObject; + } + + function getCurrentSourceText() { + var code = getCurrentCodeObject(); + if (code.sourceBegin == -1 || code.sourceEnd == -1) return ""; + return fileContent.substring(code.sourceBegin, code.sourceEnd); + } + + function getCurrentAsmText() { + var code = getCurrentCodeObject(); + if (code.asmBegin == -1 || code.asmEnd == -1) return ""; + return fileContent.substring(code.asmBegin, code.asmEnd); + } + + function setKindByIndex(index) { + selectedFunctionKind = kinds[index]; + } + + function processLine(text, begin, end) { + var line = text.substring(begin, end); + if (readingSource) { + if (separatorFilter.exec(line) != null) { + readingSource = false; + } else { + if (sourceBegin == -1) { + sourceBegin = begin; + } + sourceEnd = end; + } + } else { + if (readingAsm) { + if (codeEndFinder.exec(line) != null) { + readingAsm = false; + asmEnd = begin; + var newCode = + new Code(currentFunctionName, currentFunctionKind, + sourceBegin, sourceEnd, asmBegin, asmEnd, + firstSourcePosition, startAddress); + codeObjects.push(newCode); + currentFunctionKind = null; + } else { + if (asmBegin == -1) { + matches = instructionBeginFinder.exec(line); + if (matches != null) { + asmBegin = begin; + } + } + if (startAddress == "") { + matches = instructionFinder.exec(line); + if (matches != null) { + startAddress = matches[1]; + } + } + } + } else { + var matches = kindFinder.exec(line); + if (matches != null) { + currentFunctionKind = matches[1]; + if (!kindsWithSource[currentFunctionKind]) { + sourceBegin = -1; + sourceEnd = -1; + } + } else if (currentFunctionKind != null) { + matches = nameFinder.exec(line); + if (matches != null) { + readingAsm = true; + asmBegin = -1; + currentFunctionName = matches[1]; + } + } else if (rawSourceFilter.exec(line) != null) { + readingSource = true; + sourceBegin = -1; + } else { + var matches = firstPositionFinder.exec(line); + if (matches != null) { + firstSourcePosition = parseInt(matches[1]); + } + } + } + } + } + + function processLines(source, size, processLine) { + var firstChar = 0; + for (var x = 0; x < size; x++) { + var curChar = source[x]; + if (curChar == '\n' || curChar == '\r') { + processLine(source, firstChar, x); + firstChar = x + 1; + } + } + if (firstChar != size - 1) { + processLine(source, firstChar, size - 1); + } + } + + function processFileContent() { + document.getElementById('source-text-pre').innerHTML = ''; + sourceBegin = -1; + codeObjects = []; + processLines(fileContent, fileContent.length, processLine); + var functionSelectElement = document.getElementById('function-selector-id'); + functionSelectElement.innerHTML = ''; + var length = codeObjects.length; + for (var i = 0; i < codeObjects.length; ++i) { + var code = codeObjects[i]; + if (code.kind == selectedFunctionKind) { + var optionElement = document.createElement("option"); + optionElement.codeObject = code; + optionElement.text = code.name; + functionSelectElement.add(optionElement, null); + } + } + } + + function asmClick(element) { + if (element == selectedAsm) return; + if (selectedAsm != null) { + selectedAsm.classList.remove('highlight-yellow'); + } + selectedAsm = element; + selectedAsm.classList.add('highlight-yellow'); + + var pc = element.firstChild.innerText; + var sourceLine = null; + if (addressFinder.exec(pc) != null) { + var position = findSourcePosition(pc); + var line = findSourceLine(position); + sourceLine = document.getElementById('source-line-' + line); + var sourceLineTop = sourceLine.offsetTop; + makeSourcePosVisible(sourceLineTop); + } + if (selectedSource == sourceLine) return; + if (selectedSource != null) { + selectedSource.classList.remove('highlight-yellow'); + selectedSource.classList.add(selectedSourceClass); + } + if (sourceLine != null) { + selectedSourceClass = sourceLine.classList[0]; + sourceLine.classList.remove(selectedSourceClass); + sourceLine.classList.add('highlight-yellow'); + } + selectedSource = sourceLine; + } + + function makeContainerPosVisible(container, newTop) { + var height = container.offsetHeight; + var margin = Math.floor(height / 4); + if (newTop < container.scrollTop + margin) { + newTop -= margin; + if (newTop < 0) newTop = 0; + container.scrollTop = newTop; + return; + } + if (newTop > (container.scrollTop + 3 * margin)) { + newTop = newTop - 3 * margin; + container.scrollTop = newTop; + } + } + + function makeAsmPosVisible(newTop) { + var asmContainer = document.getElementById('asm-container'); + makeContainerPosVisible(asmContainer, newTop); + } + + function makeSourcePosVisible(newTop) { + var sourceContainer = document.getElementById('source-container'); + makeContainerPosVisible(sourceContainer, newTop); + } + + function addressClick(element, event) { + event.stopPropagation(); + var asmLineId = 'address-' + element.innerText; + var asmLineElement = document.getElementById(asmLineId); + if (asmLineElement != null) { + var asmLineTop = asmLineElement.parentNode.offsetTop; + makeAsmPosVisible(asmLineTop); + asmLineElement.classList.add('highlight-flash-blue'); + window.setTimeout(function() { + asmLineElement.classList.remove('highlight-flash-blue'); + }, 1500); + } + } + + function prepareAsm(originalSource) { + var newSource = ""; + var lineNumber = 1; + var functionProcessLine = function(text, begin, end) { + var currentLine = text.substring(begin, end); + var matches = instructionFinder.exec(currentLine); + var clickHandler = ""; + if (matches != null) { + var restOfLine = matches[2]; + restOfLine = restOfLine.replace( + addressReplacer, + '\$1'); + currentLine = '' + + matches[1] + '' + restOfLine; + clickHandler = 'onclick=\'Sodium.asmClick(this)\' '; + } else if (whiteSpaceLineFinder.exec(currentLine)) { + currentLine = "
"; + } + newSource += '
' +
+        currentLine + '
'; + lineNumber++; + } + processLines(originalSource, originalSource.length, functionProcessLine); + return newSource; + } + + function findSourcePosition(pcToSearch) { + var position = 0; + var distance = 0x7FFFFFFF; + var pcToSearchOffset = parseInt(pcToSearch); + var processOneLine = function(text, begin, end) { + var currentLine = text.substring(begin, end); + var matches = positionFinder.exec(currentLine); + if (matches != null) { + var pcOffset = parseInt(matches[1]); + if (pcOffset <= pcToSearchOffset) { + var dist = pcToSearchOffset - pcOffset; + var pos = parseInt(matches[2]); + if ((dist < distance) || (dist == distance && pos > position)) { + position = pos; + distance = dist; + } + } + } + } + var asmText = getCurrentAsmText(); + processLines(asmText, asmText.length, processOneLine); + var code = getCurrentCodeObject(); + if (position == 0) return 0; + return position - code.firstSourcePosition; + } + + function findSourceLine(position) { + if (position == 0) return 1; + var line = 0; + var processOneLine = function(text, begin, end) { + if (begin < position) { + line++; + } + } + var sourceText = getCurrentSourceText(); + processLines(sourceText, sourceText.length, processOneLine); + return line; + } + + function functionChangedHandler() { + var functionSelect = document.getElementById('function-selector-id'); + var source = getCurrentSourceText(); + var sourceDivElement = document.getElementById('source-text'); + var code = getCurrentCodeObject(); + var newHtml = "
"
+      + 'function ' + code.name + source + "
"; + sourceDivElement.innerHTML = newHtml; + try { + // Wrap in try to work when offline. + PR.prettyPrint(); + } catch (e) { + } + var sourceLineContainer = sourceDivElement.firstChild.firstChild; + var lineCount = sourceLineContainer.childElementCount; + var current = sourceLineContainer.firstChild; + for (var i = 1; i < lineCount; ++i) { + current.id = "source-line-" + i; + current = current.nextElementSibling; + } + + var asm = getCurrentAsmText(); + document.getElementById('asm-text').innerHTML = prepareAsm(asm); + } + + function kindChangedHandler(element) { + setKindByIndex(element.selectedIndex); + processFileContent(); + functionChangedHandler(); + } + + function readLog(evt) { + //Retrieve the first (and only!) File from the FileList object + var f = evt.target.files[0]; + if (f) { + var r = new FileReader(); + r.onload = function(e) { + var file = evt.target.files[0]; + currentFunctionKind = ""; + fileContent = e.target.result; + processFileContent(); + functionChangedHandler(); + } + r.readAsText(f); + } else { + alert("Failed to load file"); + } + } + + function buildFunctionKindSelector(kindSelectElement) { + for (var x = 0; x < kinds.length; ++x) { + var optionElement = document.createElement("option"); + optionElement.value = x; + optionElement.text = kinds[x]; + kindSelectElement.add(optionElement, null); + } + kindSelectElement.selectedIndex = 1; + setKindByIndex(1); + } + + return { + buildFunctionKindSelector: buildFunctionKindSelector, + kindChangedHandler: kindChangedHandler, + functionChangedHandler: functionChangedHandler, + asmClick: asmClick, + addressClick: addressClick, + readLog: readLog + }; + +})(); diff --git a/deps/v8/tools/sodium/styles.css b/deps/v8/tools/sodium/styles.css new file mode 100755 index 0000000000..4f7d89ee78 --- /dev/null +++ b/deps/v8/tools/sodium/styles.css @@ -0,0 +1,70 @@ +#table-header { + background-color: rgba(150, 150, 255, 0.4); +} + +#asm-container { + background-color: rgba(200, 200, 255, 0.4); + position:absolute; + overflow:auto; + cursor:default; + width:50%; + height:92%; +} + +#source-container { + position:absolute; + overflow:auto; + width:48%; + left:51%; + height:92%; +} + +table { + border-collapse: collapse; +} + +.hover-underline:hover { + text-decoration: underline; +} + +.highlight-flash-blue { + -webkit-transition: all 1s ease; + background-color: rgba(50, 50, 245, 0.4); + border-radius: 10px; + -o-border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + + +.highlight-green { + background-color: rgba(0, 255, 0, 0.4); + border-radius: 10px; + -o-border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + +.highlight-yellow { + background-color: rgba(255, 255, 0, 0.4); + border-radius: 10px; + -o-border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + +.highlight-gray { + background-color: rgba(128, 128, 128, 0.4); + border-radius: 10px; + -o-border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + +.highlight-red { + background-color: rgba(255, 0, 0, 0.4); + border-radius: 10px; + -o-border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} diff --git a/deps/v8/tools/test-push-to-trunk.sh b/deps/v8/tools/test-push-to-trunk.sh new file mode 100755 index 0000000000..6c201e4628 --- /dev/null +++ b/deps/v8/tools/test-push-to-trunk.sh @@ -0,0 +1,246 @@ +#!/bin/bash +# Copyright 2013 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Tests the push-to-trunk.sh script. Needs to be run in V8 base dir: +# ./tools/test-push-to-trunk.sh + +# TODO(machenbach): Check automatically if expectations match. +# TODO(machenbach): Mock out version number retrieval. +# TODO(machenbach): Allow multiple different test cases. +# TODO(machenbach): Allow multi line mock output. +# TODO(machenbach): Represent test expectations/mock output without an array +# index increment. + +########## Stdin for push-to-trunk.sh + +# Confirm push to trunk commit ID +INPUT[0]="Y" +# Open editor +INPUT[1]="" +# Confirm increment version number +INPUT[2]="Y" +# Reviewer for V8 CL +INPUT[3]="reviewer@chromium.org" +# Enter LGTM for V8 CL +INPUT[4]="LGTM" +# Confirm checkout sanity +INPUT[5]="Y" +# Manually type in trunk revision +INPUT[6]="12345" +# Reviewer for Chromium CL +INPUT[7]="reviewer@chromium.org" + +########## Expected commands and mock output + +EXP[0]="git status -s -uno" +OUT[0]="" +EXP[1]="git status -s -b -uno" +OUT[1]="## some_branch" +EXP[2]="git svn fetch" +OUT[2]="" +EXP[3]="git branch" +OUT[3]="not the temp branch" +EXP[4]="git checkout -b prepare-push-temporary-branch-created-by-script" +OUT[4]="" +EXP[5]="git branch" +OUT[5]="not the branch" +EXP[6]="git branch" +OUT[6]="not the trunk branch" +EXP[7]="git checkout -b prepare-push svn/bleeding_edge" +OUT[7]="" +EXP[8]="git log -1 --format=%H ChangeLog" +OUT[8]="hash1" +EXP[9]="git log -1 hash1" +OUT[9]="" +EXP[10]="git log hash1..HEAD --format=%H" +OUT[10]="hash2" +EXP[11]="git log -1 hash2 --format=\"%w(80,8,8)%s\"" +OUT[11]="Log line..." +EXP[12]="git log -1 hash2 --format=\"%B\"" +OUT[12]="BUG=6789" +EXP[13]="git log -1 hash2 --format=\"%w(80,8,8)(%an)\"" +OUT[13]=" (author@chromium.org)" +EXP[14]="git commit -a -m \"Prepare push to trunk. Now working on version 3.4.5.\"" +OUT[14]="" +EXP[15]="git cl upload -r reviewer@chromium.org --send-mail" +OUT[15]="" +EXP[16]="git cl dcommit" +OUT[16]="" +EXP[17]="git svn fetch" +OUT[17]="" +EXP[18]="git checkout svn/bleeding_edge" +OUT[18]="" +EXP[19]="git log -1 --format=%H --grep=Prepare push to trunk. Now working on version 3.4.5." +OUT[19]="hash3" +EXP[20]="git diff svn/trunk" +OUT[20]="patch1" +EXP[21]="git checkout -b trunk-push svn/trunk" +OUT[21]="" +EXP[22]="git apply --index --reject /tmp/v8-push-to-trunk-tempfile-patch" +OUT[22]="" +EXP[23]="git add src/version.cc" +OUT[23]="" +EXP[24]="git commit -F /tmp/v8-push-to-trunk-tempfile-commitmsg" +OUT[24]="" +EXP[25]="git svn dcommit" +OUT[25]="r1234" +EXP[26]="git svn tag 3.4.5 -m \"Tagging version 3.4.5\"" +OUT[26]="" +EXP[27]="git status -s -uno" +OUT[27]="" +EXP[28]="git checkout master" +OUT[28]="" +EXP[29]="git pull" +OUT[29]="" +EXP[30]="git checkout -b v8-roll-12345" +OUT[30]="" +EXP[31]="git commit -am Update V8 to version 3.4.5." +OUT[31]="" +EXP[32]="git cl upload --send-mail" +OUT[32]="" +EXP[33]="git checkout -f some_branch" +OUT[33]="" +EXP[34]="git branch -D prepare-push-temporary-branch-created-by-script" +OUT[34]="" +EXP[35]="git branch -D prepare-push" +OUT[35]="" +EXP[36]="git branch -D trunk-push" +OUT[36]="" + +########## Global temp files for test input/output + +export TEST_OUTPUT=$(mktemp) +export INDEX=$(mktemp) +export MOCK_OUTPUT=$(mktemp) +export EXPECTED_COMMANDS=$(mktemp) + +########## Command index + +inc_index() { + local I="$(command cat $INDEX)" + let "I+=1" + echo "$I" > $INDEX + echo $I +} + +echo "-1" > $INDEX +export -f inc_index + +########## Mock output accessor + +get_mock_output() { + local I=$1 + let "I+=1" + command sed "${I}q;d" $MOCK_OUTPUT +} + +export -f get_mock_output + +for E in "${OUT[@]}"; do + echo $E +done > $MOCK_OUTPUT + +########## Expected commands accessor + +get_expected_command() { + local I=$1 + let "I+=1" + command sed "${I}q;d" $EXPECTED_COMMANDS +} + +export -f get_expected_command + +for E in "${EXP[@]}"; do + echo $E +done > $EXPECTED_COMMANDS + +########## Mock commands + +git() { + # All calls to git are mocked out. Expected calls and mock output are stored + # in the EXP/OUT arrays above. + local I=$(inc_index) + local OUT=$(get_mock_output $I) + local EXP=$(get_expected_command $I) + echo "#############################" >> $TEST_OUTPUT + echo "Com. Index: $I" >> $TEST_OUTPUT + echo "Expected: ${EXP}" >> $TEST_OUTPUT + echo "Actual: git $@" >> $TEST_OUTPUT + echo "Mock Output: ${OUT}" >> $TEST_OUTPUT + echo "${OUT}" +} + +mv() { + echo "#############################" >> $TEST_OUTPUT + echo "mv $@" >> $TEST_OUTPUT +} + +sed() { + # Only calls to sed * -i * are mocked out. + echo "#############################" >> $TEST_OUTPUT + local arr=$@ + if [[ "${arr[@]}" =~ "-i" || "${arr[${#arr[@]}-1]}" == "-i" ]]; then + echo "sed $@" >> $TEST_OUTPUT + else + echo "sed $@" >> $TEST_OUTPUT + command sed "$@" + fi +} + +editor() { + echo "#############################" >> $TEST_OUTPUT + echo "editor $@" >> $TEST_OUTPUT +} + +cd() { + echo "#############################" >> $TEST_OUTPUT + echo "cd $@" >> $TEST_OUTPUT +} + +export -f git +export -f mv +export -f sed +export -f cd +export -f editor +export EDITOR=editor + +########## Invoke script with test stdin + +for i in "${INPUT[@]}"; do + echo $i +done | tools/push-to-trunk.sh -c "path/to/chromium" + +echo "Collected output:" +command cat $TEST_OUTPUT + +########## Clean up + +rm -rf $TEST_OUTPUT +rm -rf $INDEX +rm -rf $MOCK_OUTPUT +rm -rf $EXPECTED_COMMANDS diff --git a/deps/v8/tools/testrunner/README b/deps/v8/tools/testrunner/README index 8f0c01f52a..0771ef9dc2 100644 --- a/deps/v8/tools/testrunner/README +++ b/deps/v8/tools/testrunner/README @@ -87,12 +87,6 @@ This section is written from the point of view of the tools/ directory. Implementation needed to run tests locally. Used by run-tests.py. Inspired by (and partly copied verbatim from) the original test.py script. -./testrunner/local/old_statusfile.py: - Provides functionality to read an old-style .status file and - convert it to new-style syntax. This can be removed once the new-style - syntax becomes authoritative (and old-style syntax is no longer supported). - ./status-file-converter.py provides a stand-alone interface to this. - ./testrunner/objects/*: A bunch of data container classes, used by the scripts in the various other directories; serializable for transmission over the network. diff --git a/deps/v8/tools/testrunner/local/old_statusfile.py b/deps/v8/tools/testrunner/local/old_statusfile.py deleted file mode 100644 index d634e3ec95..0000000000 --- a/deps/v8/tools/testrunner/local/old_statusfile.py +++ /dev/null @@ -1,462 +0,0 @@ -# Copyright 2012 the V8 project authors. All rights reserved. -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -import cStringIO -import re - -# These outcomes can occur in a TestCase's outcomes list: -SKIP = 'SKIP' -FAIL = 'FAIL' -PASS = 'PASS' -OKAY = 'OKAY' -TIMEOUT = 'TIMEOUT' -CRASH = 'CRASH' -SLOW = 'SLOW' -FLAKY = 'FLAKY' -# These are just for the status files and are mapped below in DEFS: -FAIL_OK = 'FAIL_OK' -PASS_OR_FAIL = 'PASS_OR_FAIL' - -KEYWORDS = {SKIP: SKIP, - FAIL: FAIL, - PASS: PASS, - OKAY: OKAY, - TIMEOUT: TIMEOUT, - CRASH: CRASH, - SLOW: SLOW, - FLAKY: FLAKY, - FAIL_OK: FAIL_OK, - PASS_OR_FAIL: PASS_OR_FAIL} - -class Expression(object): - pass - - -class Constant(Expression): - - def __init__(self, value): - self.value = value - - def Evaluate(self, env, defs): - return self.value - - -class Variable(Expression): - - def __init__(self, name): - self.name = name - - def GetOutcomes(self, env, defs): - if self.name in env: return set([env[self.name]]) - else: return set([]) - - def Evaluate(self, env, defs): - return env[self.name] - - def __str__(self): - return self.name - - def string(self, logical): - return self.__str__() - - -class Outcome(Expression): - - def __init__(self, name): - self.name = name - - def GetOutcomes(self, env, defs): - if self.name in defs: - return defs[self.name].GetOutcomes(env, defs) - else: - return set([self.name]) - - def __str__(self): - if self.name in KEYWORDS: - return "%s" % KEYWORDS[self.name] - return "'%s'" % self.name - - def string(self, logical): - if logical: - return "%s" % self.name - return self.__str__() - - -class Operation(Expression): - - def __init__(self, left, op, right): - self.left = left - self.op = op - self.right = right - - def Evaluate(self, env, defs): - if self.op == '||' or self.op == ',': - return self.left.Evaluate(env, defs) or self.right.Evaluate(env, defs) - elif self.op == 'if': - return False - elif self.op == '==': - return not self.left.GetOutcomes(env, defs).isdisjoint(self.right.GetOutcomes(env, defs)) - elif self.op == '!=': - return self.left.GetOutcomes(env, defs).isdisjoint(self.right.GetOutcomes(env, defs)) - else: - assert self.op == '&&' - return self.left.Evaluate(env, defs) and self.right.Evaluate(env, defs) - - def GetOutcomes(self, env, defs): - if self.op == '||' or self.op == ',': - return self.left.GetOutcomes(env, defs) | self.right.GetOutcomes(env, defs) - elif self.op == 'if': - if self.right.Evaluate(env, defs): return self.left.GetOutcomes(env, defs) - else: return set([]) - else: - assert self.op == '&&' - return self.left.GetOutcomes(env, defs) & self.right.GetOutcomes(env, defs) - - def __str__(self): - return self.string(False) - - def string(self, logical=False): - if self.op == 'if': - return "['%s', %s]" % (self.right.string(True), self.left.string(logical)) - elif self.op == "||" or self.op == ",": - if logical: - return "%s or %s" % (self.left.string(True), self.right.string(True)) - else: - return "%s, %s" % (self.left, self.right) - elif self.op == "&&": - return "%s and %s" % (self.left.string(True), self.right.string(True)) - return "%s %s %s" % (self.left.string(logical), self.op, - self.right.string(logical)) - - -def IsAlpha(string): - for char in string: - if not (char.isalpha() or char.isdigit() or char == '_'): - return False - return True - - -class Tokenizer(object): - """A simple string tokenizer that chops expressions into variables, - parens and operators""" - - def __init__(self, expr): - self.index = 0 - self.expr = expr - self.length = len(expr) - self.tokens = None - - def Current(self, length=1): - if not self.HasMore(length): return "" - return self.expr[self.index:self.index + length] - - def HasMore(self, length=1): - return self.index < self.length + (length - 1) - - def Advance(self, count=1): - self.index = self.index + count - - def AddToken(self, token): - self.tokens.append(token) - - def SkipSpaces(self): - while self.HasMore() and self.Current().isspace(): - self.Advance() - - def Tokenize(self): - self.tokens = [ ] - while self.HasMore(): - self.SkipSpaces() - if not self.HasMore(): - return None - if self.Current() == '(': - self.AddToken('(') - self.Advance() - elif self.Current() == ')': - self.AddToken(')') - self.Advance() - elif self.Current() == '$': - self.AddToken('$') - self.Advance() - elif self.Current() == ',': - self.AddToken(',') - self.Advance() - elif IsAlpha(self.Current()): - buf = "" - while self.HasMore() and IsAlpha(self.Current()): - buf += self.Current() - self.Advance() - self.AddToken(buf) - elif self.Current(2) == '&&': - self.AddToken('&&') - self.Advance(2) - elif self.Current(2) == '||': - self.AddToken('||') - self.Advance(2) - elif self.Current(2) == '==': - self.AddToken('==') - self.Advance(2) - elif self.Current(2) == '!=': - self.AddToken('!=') - self.Advance(2) - else: - return None - return self.tokens - - -class Scanner(object): - """A simple scanner that can serve out tokens from a given list""" - - def __init__(self, tokens): - self.tokens = tokens - self.length = len(tokens) - self.index = 0 - - def HasMore(self): - return self.index < self.length - - def Current(self): - return self.tokens[self.index] - - def Advance(self): - self.index = self.index + 1 - - -def ParseAtomicExpression(scan): - if scan.Current() == "true": - scan.Advance() - return Constant(True) - elif scan.Current() == "false": - scan.Advance() - return Constant(False) - elif IsAlpha(scan.Current()): - name = scan.Current() - scan.Advance() - return Outcome(name) - elif scan.Current() == '$': - scan.Advance() - if not IsAlpha(scan.Current()): - return None - name = scan.Current() - scan.Advance() - return Variable(name.lower()) - elif scan.Current() == '(': - scan.Advance() - result = ParseLogicalExpression(scan) - if (not result) or (scan.Current() != ')'): - return None - scan.Advance() - return result - else: - return None - - -BINARIES = ['==', '!='] -def ParseOperatorExpression(scan): - left = ParseAtomicExpression(scan) - if not left: return None - while scan.HasMore() and (scan.Current() in BINARIES): - op = scan.Current() - scan.Advance() - right = ParseOperatorExpression(scan) - if not right: - return None - left = Operation(left, op, right) - return left - - -def ParseConditionalExpression(scan): - left = ParseOperatorExpression(scan) - if not left: return None - while scan.HasMore() and (scan.Current() == 'if'): - scan.Advance() - right = ParseOperatorExpression(scan) - if not right: - return None - left = Operation(left, 'if', right) - return left - - -LOGICALS = ["&&", "||", ","] -def ParseLogicalExpression(scan): - left = ParseConditionalExpression(scan) - if not left: return None - while scan.HasMore() and (scan.Current() in LOGICALS): - op = scan.Current() - scan.Advance() - right = ParseConditionalExpression(scan) - if not right: - return None - left = Operation(left, op, right) - return left - - -def ParseCondition(expr): - """Parses a logical expression into an Expression object""" - tokens = Tokenizer(expr).Tokenize() - if not tokens: - print "Malformed expression: '%s'" % expr - return None - scan = Scanner(tokens) - ast = ParseLogicalExpression(scan) - if not ast: - print "Malformed expression: '%s'" % expr - return None - if scan.HasMore(): - print "Malformed expression: '%s'" % expr - return None - return ast - - -class Section(object): - """A section of the configuration file. Sections are enabled or - disabled prior to running the tests, based on their conditions""" - - def __init__(self, condition): - self.condition = condition - self.rules = [ ] - - def AddRule(self, rule): - self.rules.append(rule) - - -class Rule(object): - """A single rule that specifies the expected outcome for a single - test.""" - - def __init__(self, raw_path, path, value): - self.raw_path = raw_path - self.path = path - self.value = value - - def GetOutcomes(self, env, defs): - return self.value.GetOutcomes(env, defs) - - def Contains(self, path): - if len(self.path) > len(path): - return False - for i in xrange(len(self.path)): - if not self.path[i].match(path[i]): - return False - return True - - -HEADER_PATTERN = re.compile(r'\[([^]]+)\]') -RULE_PATTERN = re.compile(r'\s*([^: ]*)\s*:(.*)') -DEF_PATTERN = re.compile(r'^def\s*(\w+)\s*=(.*)$') -PREFIX_PATTERN = re.compile(r'^\s*prefix\s+([\w\_\.\-\/]+)$') - - -class ConvertNotation(object): - def __init__(self, path): - self.path = path - self.indent = "" - self.comment = [] - self.init = False - self.section = False - self.out = cStringIO.StringIO() - - def OpenGlobal(self): - if self.init: return - self.WriteComment() - print >> self.out, "[" - self.init = True - - def CloseGlobal(self): - if not self.init: self.OpenGlobal() - print >> self.out, "]" - self.init = False - - def OpenSection(self, condition="ALWAYS"): - if self.section: return - self.OpenGlobal() - if type(condition) != str: - condition = "'%s'" % condition.string(True) - print >> self.out, "%s[%s, {" % (self.indent, condition) - self.indent += " " * 2 - self.section = condition - - def CloseSection(self): - if not self.section: return - self.indent = self.indent[:-2] - print >> self.out, "%s}], # %s" % (self.indent, self.section) - self.section = False - - def WriteComment(self): - if not self.comment: return - for c in self.comment: - if len(c.strip()) == 0: - print >> self.out, "" - else: - print >> self.out, "%s%s" % (self.indent, c), - self.comment = [] - - def GetOutput(self): - with open(self.path) as f: - for line in f: - if line[0] == '#': - self.comment += [line] - continue - if len(line.strip()) == 0: - self.comment += [line] - continue - header_match = HEADER_PATTERN.match(line) - if header_match: - condition = ParseCondition(header_match.group(1).strip()) - self.CloseSection() - self.WriteComment() - self.OpenSection(condition) - continue - rule_match = RULE_PATTERN.match(line) - if rule_match: - self.OpenSection() - self.WriteComment() - path = rule_match.group(1).strip() - value_str = rule_match.group(2).strip() - comment = "" - if '#' in value_str: - pos = value_str.find('#') - comment = " %s" % value_str[pos:].strip() - value_str = value_str[:pos].strip() - value = ParseCondition(value_str) - print >> self.out, ("%s'%s': [%s],%s" % - (self.indent, path, value, comment)) - continue - def_match = DEF_PATTERN.match(line) - if def_match: - # Custom definitions are deprecated. - continue - prefix_match = PREFIX_PATTERN.match(line) - if prefix_match: - continue - print "Malformed line: '%s'." % line - self.CloseSection() - self.CloseGlobal() - result = self.out.getvalue() - self.out.close() - return result diff --git a/deps/v8/tools/testrunner/local/statusfile.py b/deps/v8/tools/testrunner/local/statusfile.py index 1d30fe3d3c..da0c797d0a 100644 --- a/deps/v8/tools/testrunner/local/statusfile.py +++ b/deps/v8/tools/testrunner/local/statusfile.py @@ -26,14 +26,6 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# These imports are required for the on-demand conversion from -# old to new status file format. -from os.path import exists -from os.path import getmtime - -from . import old_statusfile - - # These outcomes can occur in a TestCase's outcomes list: SKIP = "SKIP" FAIL = "FAIL" @@ -43,6 +35,7 @@ TIMEOUT = "TIMEOUT" CRASH = "CRASH" SLOW = "SLOW" FLAKY = "FLAKY" +NO_VARIANTS = "NO_VARIANTS" # These are just for the status files and are mapped below in DEFS: FAIL_OK = "FAIL_OK" PASS_OR_FAIL = "PASS_OR_FAIL" @@ -51,7 +44,7 @@ ALWAYS = "ALWAYS" KEYWORDS = {} for key in [SKIP, FAIL, PASS, OKAY, TIMEOUT, CRASH, SLOW, FLAKY, FAIL_OK, - PASS_OR_FAIL, ALWAYS]: + NO_VARIANTS, PASS_OR_FAIL, ALWAYS]: KEYWORDS[key] = key DEFS = {FAIL_OK: [FAIL, OKAY], @@ -60,7 +53,8 @@ DEFS = {FAIL_OK: [FAIL, OKAY], # Support arches, modes to be written as keywords instead of strings. VARIABLES = {ALWAYS: True} for var in ["debug", "release", "android_arm", "android_ia32", "arm", "ia32", - "mipsel", "x64", "nacl_ia32", "nacl_x64"]: + "mipsel", "x64", "nacl_ia32", "nacl_x64", "macos", "windows", + "linux"]: VARIABLES[var] = var @@ -68,6 +62,10 @@ def DoSkip(outcomes): return SKIP in outcomes or SLOW in outcomes +def OnlyStandardVariant(outcomes): + return NO_VARIANTS in outcomes + + def IsFlaky(outcomes): return FLAKY in outcomes @@ -116,18 +114,6 @@ def _ParseOutcomeList(rule, outcomes, target_dict, variables): def ReadStatusFile(path, variables): - # As long as the old-format .status files are authoritative, just - # create the converted version on demand and cache it to speed up - # subsequent runs. - if path.endswith(".status"): - newpath = path + "2" - if not exists(newpath) or getmtime(newpath) < getmtime(path): - print "Converting status file." - converted = old_statusfile.ConvertNotation(path).GetOutput() - with open(newpath, 'w') as f: - f.write(converted) - path = newpath - with open(path) as f: global KEYWORDS contents = eval(f.read(), KEYWORDS) diff --git a/deps/v8/tools/testrunner/local/testsuite.py b/deps/v8/tools/testrunner/local/testsuite.py index b0372e7f73..8517ce9f49 100644 --- a/deps/v8/tools/testrunner/local/testsuite.py +++ b/deps/v8/tools/testrunner/local/testsuite.py @@ -74,8 +74,10 @@ class TestSuite(object): def ListTests(self, context): raise NotImplementedError - def VariantFlags(self): - return None + def VariantFlags(self, testcase, default_flags): + if testcase.outcomes and statusfile.OnlyStandardVariant(testcase.outcomes): + return [[]] + return default_flags def DownloadData(self): pass diff --git a/deps/v8/tools/testrunner/local/utils.py b/deps/v8/tools/testrunner/local/utils.py index b7caa121f3..61ee7dac67 100644 --- a/deps/v8/tools/testrunner/local/utils.py +++ b/deps/v8/tools/testrunner/local/utils.py @@ -65,7 +65,7 @@ def GuessOS(): elif system == 'Windows' or system == 'Microsoft': # On Windows Vista platform.system() can return 'Microsoft' with some # versions of Python, see http://bugs.python.org/issue1082 - return 'win32' + return 'windows' elif system == 'FreeBSD': return 'freebsd' elif system == 'OpenBSD': @@ -105,4 +105,4 @@ def GuessWordsize(): def IsWindows(): - return GuessOS() == 'win32' + return GuessOS() == 'windows' diff --git a/deps/v8/tools/testrunner/objects/context.py b/deps/v8/tools/testrunner/objects/context.py index 3ea215a708..1f525b76b3 100644 --- a/deps/v8/tools/testrunner/objects/context.py +++ b/deps/v8/tools/testrunner/objects/context.py @@ -28,7 +28,7 @@ class Context(): def __init__(self, arch, mode, shell_dir, mode_flags, verbose, timeout, - isolates, command_prefix, extra_flags): + isolates, command_prefix, extra_flags, noi18n): self.arch = arch self.mode = mode self.shell_dir = shell_dir @@ -38,13 +38,14 @@ class Context(): self.isolates = isolates self.command_prefix = command_prefix self.extra_flags = extra_flags + self.noi18n = noi18n def Pack(self): return [self.arch, self.mode, self.mode_flags, self.timeout, self.isolates, - self.command_prefix, self.extra_flags] + self.command_prefix, self.extra_flags, self.noi18n] @staticmethod def Unpack(packed): # For the order of the fields, refer to Pack() above. return Context(packed[0], packed[1], None, packed[2], False, - packed[3], packed[4], packed[5], packed[6]) + packed[3], packed[4], packed[5], packed[6], packed[7]) diff --git a/deps/v8/tools/v8heapconst.py b/deps/v8/tools/v8heapconst.py index 1f72c37236..06141c2f96 100644 --- a/deps/v8/tools/v8heapconst.py +++ b/deps/v8/tools/v8heapconst.py @@ -71,53 +71,54 @@ INSTANCE_TYPES = { 144: "EXTERNAL_FLOAT_ARRAY_TYPE", 145: "EXTERNAL_DOUBLE_ARRAY_TYPE", 146: "EXTERNAL_PIXEL_ARRAY_TYPE", - 148: "FILLER_TYPE", - 149: "DECLARED_ACCESSOR_DESCRIPTOR_TYPE", - 150: "DECLARED_ACCESSOR_INFO_TYPE", - 151: "EXECUTABLE_ACCESSOR_INFO_TYPE", - 152: "ACCESSOR_PAIR_TYPE", - 153: "ACCESS_CHECK_INFO_TYPE", - 154: "INTERCEPTOR_INFO_TYPE", - 155: "CALL_HANDLER_INFO_TYPE", - 156: "FUNCTION_TEMPLATE_INFO_TYPE", - 157: "OBJECT_TEMPLATE_INFO_TYPE", - 158: "SIGNATURE_INFO_TYPE", - 159: "TYPE_SWITCH_INFO_TYPE", - 161: "ALLOCATION_MEMENTO_TYPE", - 160: "ALLOCATION_SITE_TYPE", - 162: "SCRIPT_TYPE", - 163: "CODE_CACHE_TYPE", - 164: "POLYMORPHIC_CODE_CACHE_TYPE", - 165: "TYPE_FEEDBACK_INFO_TYPE", - 166: "ALIASED_ARGUMENTS_ENTRY_TYPE", - 167: "BOX_TYPE", - 170: "FIXED_ARRAY_TYPE", + 149: "FILLER_TYPE", + 150: "DECLARED_ACCESSOR_DESCRIPTOR_TYPE", + 151: "DECLARED_ACCESSOR_INFO_TYPE", + 152: "EXECUTABLE_ACCESSOR_INFO_TYPE", + 153: "ACCESSOR_PAIR_TYPE", + 154: "ACCESS_CHECK_INFO_TYPE", + 155: "INTERCEPTOR_INFO_TYPE", + 156: "CALL_HANDLER_INFO_TYPE", + 157: "FUNCTION_TEMPLATE_INFO_TYPE", + 158: "OBJECT_TEMPLATE_INFO_TYPE", + 159: "SIGNATURE_INFO_TYPE", + 160: "TYPE_SWITCH_INFO_TYPE", + 162: "ALLOCATION_MEMENTO_TYPE", + 161: "ALLOCATION_SITE_TYPE", + 163: "SCRIPT_TYPE", + 164: "CODE_CACHE_TYPE", + 165: "POLYMORPHIC_CODE_CACHE_TYPE", + 166: "TYPE_FEEDBACK_INFO_TYPE", + 167: "ALIASED_ARGUMENTS_ENTRY_TYPE", + 168: "BOX_TYPE", + 171: "FIXED_ARRAY_TYPE", 147: "FIXED_DOUBLE_ARRAY_TYPE", - 171: "SHARED_FUNCTION_INFO_TYPE", - 172: "JS_MESSAGE_OBJECT_TYPE", - 175: "JS_VALUE_TYPE", - 176: "JS_DATE_TYPE", - 177: "JS_OBJECT_TYPE", - 178: "JS_CONTEXT_EXTENSION_OBJECT_TYPE", - 179: "JS_GENERATOR_OBJECT_TYPE", - 180: "JS_MODULE_TYPE", - 181: "JS_GLOBAL_OBJECT_TYPE", - 182: "JS_BUILTINS_OBJECT_TYPE", - 183: "JS_GLOBAL_PROXY_TYPE", - 184: "JS_ARRAY_TYPE", - 185: "JS_ARRAY_BUFFER_TYPE", - 186: "JS_TYPED_ARRAY_TYPE", - 187: "JS_DATA_VIEW_TYPE", - 174: "JS_PROXY_TYPE", - 188: "JS_SET_TYPE", - 189: "JS_MAP_TYPE", - 190: "JS_WEAK_MAP_TYPE", - 191: "JS_WEAK_SET_TYPE", - 192: "JS_REGEXP_TYPE", - 193: "JS_FUNCTION_TYPE", - 173: "JS_FUNCTION_PROXY_TYPE", - 168: "DEBUG_INFO_TYPE", - 169: "BREAK_POINT_INFO_TYPE", + 148: "CONSTANT_POOL_ARRAY_TYPE", + 172: "SHARED_FUNCTION_INFO_TYPE", + 173: "JS_MESSAGE_OBJECT_TYPE", + 176: "JS_VALUE_TYPE", + 177: "JS_DATE_TYPE", + 178: "JS_OBJECT_TYPE", + 179: "JS_CONTEXT_EXTENSION_OBJECT_TYPE", + 180: "JS_GENERATOR_OBJECT_TYPE", + 181: "JS_MODULE_TYPE", + 182: "JS_GLOBAL_OBJECT_TYPE", + 183: "JS_BUILTINS_OBJECT_TYPE", + 184: "JS_GLOBAL_PROXY_TYPE", + 185: "JS_ARRAY_TYPE", + 186: "JS_ARRAY_BUFFER_TYPE", + 187: "JS_TYPED_ARRAY_TYPE", + 188: "JS_DATA_VIEW_TYPE", + 175: "JS_PROXY_TYPE", + 189: "JS_SET_TYPE", + 190: "JS_MAP_TYPE", + 191: "JS_WEAK_MAP_TYPE", + 192: "JS_WEAK_SET_TYPE", + 193: "JS_REGEXP_TYPE", + 194: "JS_FUNCTION_TYPE", + 174: "JS_FUNCTION_PROXY_TYPE", + 169: "DEBUG_INFO_TYPE", + 170: "BREAK_POINT_INFO_TYPE", } # List of known V8 maps. @@ -126,85 +127,86 @@ KNOWN_MAPS = { 0x080a9: (129, "MetaMap"), 0x080d1: (131, "OddballMap"), 0x080f9: (4, "AsciiInternalizedStringMap"), - 0x08121: (170, "FixedArrayMap"), + 0x08121: (171, "FixedArrayMap"), 0x08149: (134, "HeapNumberMap"), 0x08171: (137, "FreeSpaceMap"), - 0x08199: (148, "OnePointerFillerMap"), - 0x081c1: (148, "TwoPointerFillerMap"), + 0x08199: (149, "OnePointerFillerMap"), + 0x081c1: (149, "TwoPointerFillerMap"), 0x081e9: (132, "CellMap"), 0x08211: (133, "GlobalPropertyCellMap"), - 0x08239: (171, "SharedFunctionInfoMap"), - 0x08261: (170, "NativeContextMap"), + 0x08239: (172, "SharedFunctionInfoMap"), + 0x08261: (171, "NativeContextMap"), 0x08289: (130, "CodeMap"), - 0x082b1: (170, "ScopeInfoMap"), - 0x082d9: (170, "FixedCOWArrayMap"), + 0x082b1: (171, "ScopeInfoMap"), + 0x082d9: (171, "FixedCOWArrayMap"), 0x08301: (147, "FixedDoubleArrayMap"), - 0x08329: (170, "HashTableMap"), - 0x08351: (128, "SymbolMap"), - 0x08379: (64, "StringMap"), - 0x083a1: (68, "AsciiStringMap"), - 0x083c9: (65, "ConsStringMap"), - 0x083f1: (69, "ConsAsciiStringMap"), - 0x08419: (67, "SlicedStringMap"), - 0x08441: (71, "SlicedAsciiStringMap"), - 0x08469: (66, "ExternalStringMap"), - 0x08491: (74, "ExternalStringWithOneByteDataMap"), - 0x084b9: (70, "ExternalAsciiStringMap"), - 0x084e1: (82, "ShortExternalStringMap"), - 0x08509: (90, "ShortExternalStringWithOneByteDataMap"), - 0x08531: (0, "InternalizedStringMap"), - 0x08559: (1, "ConsInternalizedStringMap"), - 0x08581: (5, "ConsAsciiInternalizedStringMap"), - 0x085a9: (2, "ExternalInternalizedStringMap"), - 0x085d1: (10, "ExternalInternalizedStringWithOneByteDataMap"), - 0x085f9: (6, "ExternalAsciiInternalizedStringMap"), - 0x08621: (18, "ShortExternalInternalizedStringMap"), - 0x08649: (26, "ShortExternalInternalizedStringWithOneByteDataMap"), - 0x08671: (22, "ShortExternalAsciiInternalizedStringMap"), - 0x08699: (86, "ShortExternalAsciiStringMap"), - 0x086c1: (64, "UndetectableStringMap"), - 0x086e9: (68, "UndetectableAsciiStringMap"), - 0x08711: (138, "ExternalByteArrayMap"), - 0x08739: (139, "ExternalUnsignedByteArrayMap"), - 0x08761: (140, "ExternalShortArrayMap"), - 0x08789: (141, "ExternalUnsignedShortArrayMap"), - 0x087b1: (142, "ExternalIntArrayMap"), - 0x087d9: (143, "ExternalUnsignedIntArrayMap"), - 0x08801: (144, "ExternalFloatArrayMap"), - 0x08829: (145, "ExternalDoubleArrayMap"), - 0x08851: (146, "ExternalPixelArrayMap"), - 0x08879: (170, "NonStrictArgumentsElementsMap"), - 0x088a1: (170, "FunctionContextMap"), - 0x088c9: (170, "CatchContextMap"), - 0x088f1: (170, "WithContextMap"), - 0x08919: (170, "BlockContextMap"), - 0x08941: (170, "ModuleContextMap"), - 0x08969: (170, "GlobalContextMap"), - 0x08991: (172, "JSMessageObjectMap"), - 0x089b9: (135, "ForeignMap"), - 0x089e1: (177, "NeanderMap"), - 0x08a09: (161, "AllocationMementoMap"), - 0x08a31: (160, "AllocationSiteMap"), - 0x08a59: (164, "PolymorphicCodeCacheMap"), - 0x08a81: (162, "ScriptMap"), - 0x08ad1: (177, "ExternalMap"), - 0x08af9: (167, "BoxMap"), - 0x08b21: (149, "DeclaredAccessorDescriptorMap"), - 0x08b49: (150, "DeclaredAccessorInfoMap"), - 0x08b71: (151, "ExecutableAccessorInfoMap"), - 0x08b99: (152, "AccessorPairMap"), - 0x08bc1: (153, "AccessCheckInfoMap"), - 0x08be9: (154, "InterceptorInfoMap"), - 0x08c11: (155, "CallHandlerInfoMap"), - 0x08c39: (156, "FunctionTemplateInfoMap"), - 0x08c61: (157, "ObjectTemplateInfoMap"), - 0x08c89: (158, "SignatureInfoMap"), - 0x08cb1: (159, "TypeSwitchInfoMap"), - 0x08cd9: (163, "CodeCacheMap"), - 0x08d01: (165, "TypeFeedbackInfoMap"), - 0x08d29: (166, "AliasedArgumentsEntryMap"), - 0x08d51: (168, "DebugInfoMap"), - 0x08d79: (169, "BreakPointInfoMap"), + 0x08329: (148, "ConstantPoolArrayMap"), + 0x08351: (171, "HashTableMap"), + 0x08379: (128, "SymbolMap"), + 0x083a1: (64, "StringMap"), + 0x083c9: (68, "AsciiStringMap"), + 0x083f1: (65, "ConsStringMap"), + 0x08419: (69, "ConsAsciiStringMap"), + 0x08441: (67, "SlicedStringMap"), + 0x08469: (71, "SlicedAsciiStringMap"), + 0x08491: (66, "ExternalStringMap"), + 0x084b9: (74, "ExternalStringWithOneByteDataMap"), + 0x084e1: (70, "ExternalAsciiStringMap"), + 0x08509: (82, "ShortExternalStringMap"), + 0x08531: (90, "ShortExternalStringWithOneByteDataMap"), + 0x08559: (0, "InternalizedStringMap"), + 0x08581: (1, "ConsInternalizedStringMap"), + 0x085a9: (5, "ConsAsciiInternalizedStringMap"), + 0x085d1: (2, "ExternalInternalizedStringMap"), + 0x085f9: (10, "ExternalInternalizedStringWithOneByteDataMap"), + 0x08621: (6, "ExternalAsciiInternalizedStringMap"), + 0x08649: (18, "ShortExternalInternalizedStringMap"), + 0x08671: (26, "ShortExternalInternalizedStringWithOneByteDataMap"), + 0x08699: (22, "ShortExternalAsciiInternalizedStringMap"), + 0x086c1: (86, "ShortExternalAsciiStringMap"), + 0x086e9: (64, "UndetectableStringMap"), + 0x08711: (68, "UndetectableAsciiStringMap"), + 0x08739: (138, "ExternalByteArrayMap"), + 0x08761: (139, "ExternalUnsignedByteArrayMap"), + 0x08789: (140, "ExternalShortArrayMap"), + 0x087b1: (141, "ExternalUnsignedShortArrayMap"), + 0x087d9: (142, "ExternalIntArrayMap"), + 0x08801: (143, "ExternalUnsignedIntArrayMap"), + 0x08829: (144, "ExternalFloatArrayMap"), + 0x08851: (145, "ExternalDoubleArrayMap"), + 0x08879: (146, "ExternalPixelArrayMap"), + 0x088a1: (171, "NonStrictArgumentsElementsMap"), + 0x088c9: (171, "FunctionContextMap"), + 0x088f1: (171, "CatchContextMap"), + 0x08919: (171, "WithContextMap"), + 0x08941: (171, "BlockContextMap"), + 0x08969: (171, "ModuleContextMap"), + 0x08991: (171, "GlobalContextMap"), + 0x089b9: (173, "JSMessageObjectMap"), + 0x089e1: (135, "ForeignMap"), + 0x08a09: (178, "NeanderMap"), + 0x08a31: (162, "AllocationMementoMap"), + 0x08a59: (161, "AllocationSiteMap"), + 0x08a81: (165, "PolymorphicCodeCacheMap"), + 0x08aa9: (163, "ScriptMap"), + 0x08af9: (178, "ExternalMap"), + 0x08b21: (168, "BoxMap"), + 0x08b49: (150, "DeclaredAccessorDescriptorMap"), + 0x08b71: (151, "DeclaredAccessorInfoMap"), + 0x08b99: (152, "ExecutableAccessorInfoMap"), + 0x08bc1: (153, "AccessorPairMap"), + 0x08be9: (154, "AccessCheckInfoMap"), + 0x08c11: (155, "InterceptorInfoMap"), + 0x08c39: (156, "CallHandlerInfoMap"), + 0x08c61: (157, "FunctionTemplateInfoMap"), + 0x08c89: (158, "ObjectTemplateInfoMap"), + 0x08cb1: (159, "SignatureInfoMap"), + 0x08cd9: (160, "TypeSwitchInfoMap"), + 0x08d01: (164, "CodeCacheMap"), + 0x08d29: (166, "TypeFeedbackInfoMap"), + 0x08d51: (167, "AliasedArgumentsEntryMap"), + 0x08d79: (169, "DebugInfoMap"), + 0x08da1: (170, "BreakPointInfoMap"), } # List of known V8 objects. @@ -250,6 +252,6 @@ KNOWN_OBJECTS = { ("OLD_DATA_SPACE", 0x082c9): "EmptyExternalPixelArray", ("OLD_DATA_SPACE", 0x082d5): "InfinityValue", ("OLD_DATA_SPACE", 0x082e1): "MinusZeroValue", - ("CODE_SPACE", 0x11141): "JsConstructEntryCode", - ("CODE_SPACE", 0x18da1): "JsEntryCode", + ("CODE_SPACE", 0x111a1): "JsConstructEntryCode", + ("CODE_SPACE", 0x18bc1): "JsEntryCode", } diff --git a/src/node.cc b/src/node.cc index f21aac6949..825b0227d4 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3068,8 +3068,6 @@ void Init(int* argc, V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1); } - const char typed_arrays_flag[] = "--harmony_typed_arrays"; - V8::SetFlagsFromString(typed_arrays_flag, sizeof(typed_arrays_flag) - 1); V8::SetArrayBufferAllocator(&ArrayBufferAllocator::the_singleton); // Fetch a reference to the main isolate, so we have a reference to it diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 5fc34416fb..17352995f5 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -256,7 +256,7 @@ bool StringBytes::GetExternalParts(Handle val, if (!val->IsString()) return false; - Local str = Local::New(val.As()); + Local str = val.As(); if (str->IsExternalAscii()) { const String::ExternalAsciiStringResource* ext; diff --git a/test/simple/test-event-emitter-memory-leak.js b/test/simple/test-event-emitter-memory-leak.js deleted file mode 100644 index 2cb56124cd..0000000000 --- a/test/simple/test-event-emitter-memory-leak.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// Flags: --expose-gc - -// Add and remove a lot of different events to an EventEmitter, then check -// that we didn't leak the event names. -var common = require('../common'); -var assert = require('assert'); -var events = require('events'); - -assert.equal(typeof gc, 'function', 'Run this test with --expose-gc'); -gc(); - -var before = process.memoryUsage().heapUsed; -var e = new events.EventEmitter(); - -for (var i = 0; i < 2.5e5; ++i) { - var name = 'a-pretty-long-event-name-' + i; - e.on(name, assert.fail); - e.removeListener(name, assert.fail); -} -gc(); - -var after = process.memoryUsage().heapUsed; -assert(after - before < 1024*1024, 'EventEmitter leaks event names.');