diff --git a/.gitignore b/.gitignore index e5687e730e8..72196753bc8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,12 +14,22 @@ *.pdb #*# *~ +.cpplint-cache d8 d8_g shell shell_g +/build/gyp /obj/ +/test/es5conform/data/ +/test/mozilla/data/ +/test/sputnik/sputniktests/ +/test/test262/data/ +/tools/oom_dump/oom_dump +/tools/oom_dump/oom_dump.o /tools/visual_studio/Debug /tools/visual_studio/Release /xcodebuild/ TAGS +Makefile +*.Makefile diff --git a/AUTHORS b/AUTHORS index de8cabb0b1b..60d5998e5e8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,18 +4,41 @@ # Name/Organization Google Inc. +Sigma Designs Inc. +ARM Ltd. +Hewlett-Packard Development Company, LP +Akinori MUSHA Alexander Botero-Lowry +Alexander Karpinsky Alexandre Vassalotti +Andreas Anyuru +Bert Belder +Burcu Dogan Craig Schlenter Daniel Andersson Daniel James +Dineel D Sule +Erich Ocean Jan de Mooij Jay Freeman Joel Stanley +John Jozwiak +Kun Zhang +Martyn Capewell Matt Hanselman +Maxim Mossienko +Michael Smith +Mike Gilbert Paolo Giarrusso +Patrick Gansterer +Peter Varga Rafal Krypa Rene Rebe +Rodolph Perfetta Ryan Dahl -Patrick Gansterer +Sanjoy Das +Subrato K De +Vlad Burlik +Yuqiang Xian +Zaheer Ahmad diff --git a/ChangeLog b/ChangeLog index 8ee83766a47..6ee826a78a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,1527 @@ +2011-06-08: Version 3.4.3 + + Clear the global thread table when an isolate is disposed + (issue 1433). + + Converted time zone name to UTF8 on Windows (issue 1290). + + Limited the number of arguments in a function call to 32766 + (issue 1413). + + Compress sources of JS libraries in addition to the snapshot. + + Fixed a bug in Lithium environment iteration. + + Performance improvements on all platforms. + +2011-06-06: Version 3.4.2 + + More work on ES-Harmony proxies. Still hidden behind a flag. + + Fixed some crash bugs and improved performance. + + Fixed building with gdb debugging support. + + Do not install SIGPROF handler until it is needed. + + Added DateTimeFormat to i18n API. + + Fixed compilation on OpenBSD. + + Take the ulimit into account when sizing the heap. OpenBSD users + may still have to increase the default ulimit to run heavy pages in + the browser. + +2011-06-01: Version 3.4.1 + + Fixed JSON stringify issue with arrays. + + Changed calls to JS builtins to be passed undefined when called with + implicit receiver. + + Implemented the set trap for Harmony proxies. Proxies still need to + be enabled with the --harmony-proxies flag. + + +2011-05-30: Version 3.4.0 + + Changed calls to undefined property setters to not throw (issue 1355). + + Made RegExp objects not callable. + + Fixed issues on special case large JSON strings in new json parser + (issues http://crbug.com/83877 and http://crbug.com/84186). + + Performance improvements on all platforms. + + +2011-05-25: Version 3.3.10 + + Fixed calls of strict mode function with an implicit receiver. + + Fixed fast handling of arrays to properly deal with changes to the + Object prototype (issue 1403). + + Changed strict mode poison pill to be the same type error function + (issue 1387). + + Fixed a debug crash in arguments object handling (issue 1227). + + Fixed a bug in deoptimization on x64 (issue 1404). + + Performance improvements and bug fixes on all platforms. + + +2011-05-23: Version 3.3.9 + + Added DateTimeFormat class to experimental i18n API. + + Extended preparser to give early errors for some strict mode + restrictions. + + Removed legacy execScript function from V8. + + Extended isolate API with the ability to add embedder-specific + data to an isolate. + + Added basic support for polymorphic loads from JS and external + arrays. + + Fixed bug in handling of switch statements in the optimizing + compiler. + + +2011-05-18: Version 3.3.8 + + Added MarkIndependent to the persistent handle API. Independent + handles are independent of all other persistent handles and can be + garbage collected more frequently. + + Implemented the get trap for Harmony proxies. Proxies are enabled + with the --harmony-proxies flag. + + Performance improvements and bug fixes on all platforms. + + +2011-05-16: Version 3.3.7 + + Updated MIPS infrastructure files. + + Performance improvements and bug fixes on all platforms. + + +2011-05-11: Version 3.3.6 + + Updated MIPS infrastructure files. + + Added method IsCallable for Object to the API. + Patch by Peter Varga. + + +2011-05-09: Version 3.3.5 + + Fixed build on FreeBSD. Patch by Akinori MUSHA. + + Added check that receiver is JSObject on API calls. + + Implemented CallAsConstructor method for Object in the API (Issue 1348). + Patch by Peter Varga. + + Added CallAsFunction method to the Object class in the API (Issue 1336). + Patch by Peter Varga. + + Added per-isolate locking and unlocking. + + Fixed bug in x64 >>> operator (Issue 1359). + + +2011-05-04: Version 3.3.4 + + Implemented API to disallow code generation from strings for a context + (issue 1258). + + Fixed bug with whitespaces in parseInt (issue 955). + + Fixed bug with == comparison of Date objects (issue 1356). + + Added GYP variables for ARM code generation: + v8_can_use_vfp_instructions, v8_can_use_unaligned_accesses + and v8_use_arm_eabi_hardfloat. + + +2011-05-02: Version 3.3.3 + + Added support for generating Visual Studio solution and project files + using GYP. + + Implemented support for ARM EABI calling convention variation where + floating-point arguments are passed in registers (hardfloat). + + Added Object::HasOwnProperty() to the API. + + Added support for compressing startup data to reduce binary size. This + includes build time support and an API for the embedder to decompress + the startup data before initializing V8. + + Reduced the profiling hooks overhead from >400% to 25% when using + ll_prof. + + Performance improvements and bug fixes on all platforms. + + +2011-04-27: Version 3.3.2 + + Fixed crash bug on ARM with no VFP3 hardware. + + Fixed compilation of V8 without debugger support. + + Improved performance on JSLint. + + Added support Float64 WebGL arrays. + + Fixed crash bug in regexp replace. + + +2011-04-20: Version 3.3.1 + + Reduced V8 binary size by removing virtual functions from hydrogen. + + Fixed crash bug on x64. + + Performance improvements on ARM and IA32. + + +2011-04-18: Version 3.3.0 + + Fixed bug in floating point rounding in Crankshaft on ARM + (issue 958) + + Fixed a number of issues with running without VFPv3 support on ARM + (issue 1315) + + Introduced v8Locale.Collator, a partial implementation of Collator + per last ECMAScript meeting + mailing list. + + Minor performance improvements and bug fixes. + + +2011-04-13: Version 3.2.10 + + Fixed bug in external float arrays on ARM (issue 1323). + + Minor performance improvements and bug fixes. + + +2011-04-11: Version 3.2.9 + + Removed support for ABI prior to EABI on ARM. + + Fixed multiple crash bugs. + + Added GCMole to the repository, a simple static analysis tool that + searches for GC-unsafe evaluation order dependent callsites. + + Made preparser API be exported in shared libraries. + + Fixed multiple issues in EcmaScript 5 strict mode implementation. + + Fixed mutable __proto__ property if object is not extensible + (Issue 1309). + + Fixed auto suspension of the sampler thread. + + +2011-04-06: Version 3.2.8 + + Exposed WebGL typed array constructors in the shell sample. + + Performance improvements on all platforms. + + +2011-04-04: Version 3.2.7 + + Disabled the original 'classic' V8 code generator. Crankshaft is + now the default on all platforms. + + Changed the heap profiler to use more descriptive names. + + Performance and stability improvements to isolates on all platforms. + + +2011-03-30: Version 3.2.6 + + Fixed xcode build warning in shell.cc (out of order initialization). + + Fixed null-pointer dereference in the compiler when running without + SSE3 support (Chromium issue 77654). + + Fixed x64 compilation error due to some dead code. (Issue 1286) + + Introduced scons target to build the preparser stand-alone example. + + Made FreeBSD build and pass all tests. + + +2011-03-28: Version 3.2.5 + + Fixed build with Irregexp interpreter (issue 1266). + + Added Crankshaft support for external arrays. + + Fixed two potential crash bugs. + + +2011-03-23: Version 3.2.4 + + Added isolates which allows several V8 instances in the same process. + This is controlled through the new Isolate class in the API. + + Implemented more of EcmaScript 5 strict mode. + + Reduced the time it takes to make detailed heap snapshot. + + Added a number of commands to the ARM simulator and enhanced the ARM + disassembler. + + +2011-03-17: Version 3.2.3 + + Fixed a number of crash bugs. + + Fixed Array::New(length) to return an array with a length (issue 1256). + + Fixed FreeBSD build. + + Changed __defineGetter__ to not throw (matching the behavior of Safari). + + Implemented more of EcmaScript 5 strict mode. + + Improved Crankshaft performance on all platforms. + + +2011-03-14: Version 3.2.2 + + Fixed a number of crash and correctness bugs. + + Improved Crankshaft performance on all platforms. + + Fixed Crankshaft on Solaris/Illumos. + + +2011-03-10: Version 3.2.1 + + Fixed a number of crash bugs. + + Improved Crankshaft for x64 and ARM. + + Implemented more of EcmaScript 5 strict mode. + + +2011-03-07: Version 3.2.0 + + Fixed a number of crash bugs. + + Turned on Crankshaft by default on x64 and ARM. + + Improved Crankshaft for x64 and ARM. + + Implemented more of EcmaScript 5 strict mode. + + +2011-03-02: Version 3.1.8 + + Fixed a number of crash bugs. + + Improved Crankshaft for x64 and ARM. + + Implemented more of EcmaScript 5 strict mode. + + Fixed issue with unaligned reads and writes on ARM. + + Improved heap profiler support. + + +2011-02-28: Version 3.1.7 + + Fixed a number of crash bugs. + + Improved Crankshaft for x64 and ARM. + + Fixed implementation of indexOf/lastIndexOf for sparse + arrays (http://crbug.com/73940). + + Fixed bug in map space compaction (http://crbug.com/59688). + + Added support for direct getter accessors calls on ARM. + + +2011-02-24: Version 3.1.6 + + Fixed a number of crash bugs. + + Added support for Cygwin (issue 64). + + Improved Crankshaft for x64 and ARM. + + Added Crankshaft support for stores to pixel arrays. + + Fixed issue in CPU profiler with Crankshaft. + + +2011-02-16: Version 3.1.5 + + Change RegExp parsing to disallow /(*)/. + + Added GDB JIT support for ARM. + + Fixed several crash bugs. + + Performance improvements on the IA32 platform. + + +2011-02-14: Version 3.1.4 + + Fixed incorrect compare of prototypes of the global object (issue + 1082). + + Fixed a bug in optimizing calls to global functions (issue 1106). + + Made optimized Function.prototype.apply safe for non-JSObject first + arguments (issue 1128). + + Fixed an error related to element accessors on Object.prototype and + parser errors (issue 1130). + + Fixed a bug in sorting an array with large array indices (issue 1131). + + Properly treat exceptions thrown while compiling (issue 1132). + + Fixed bug in register requirements for function.apply (issue 1133). + + Fixed a representation change bug in the Hydrogen graph construction + (issue 1134). + + Fixed the semantics of delete on parameters (issue 1136). + + Fixed a optimizer bug related to moving instructions with side effects + (issue 1138). + + Added support for the global object in Object.keys (issue 1150). + + Fixed incorrect value for Math.LOG10E + (issue http://code.google.com/p/chromium/issues/detail?id=72555) + + Performance improvements on the IA32 platform. + + Implement assignment to undefined reference in ES5 Strict Mode. + + +2011-02-09: Version 3.1.3 + + Fixed a bug triggered by functions with huge numbers of declared + arguments. + + Fixed zap value aliasing a real object - debug mode only (issue 866). + + Fixed issue where Array.prototype.__proto__ had been set to null + (issue 1121). + + Fixed stability bugs in Crankshaft for x86. + + +2011-02-07: Version 3.1.2 + + Added better security checks when accessing properties via + Object.getOwnPropertyDescriptor. + + Fixed bug in Object.defineProperty and related access bugs (issues + 992, 1083 and 1092). + + Added LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to ease + copyright notice generation for embedders. + + +2011-02-02: Version 3.1.1 + + Perform security checks before fetching the value in + Object.getOwnPropertyDescriptor. + + Fixed a bug in Array.prototype.splice triggered by passing no + arguments. + + Fixed bugs in -0 in arithmetic and in Math.pow. + + Fixed bugs in the register allocator and in switching from optimized + to unoptimized code. + + +2011-01-31: Version 3.1.0 + + Performance improvements on all platforms. + + +2011-01-28: Version 3.0.12 + + Added support for strict mode parameter and object property + validation. + + Fixed a couple of crash bugs. + + +2011-01-25: Version 3.0.11 + + Fixed a bug in deletion of lookup slots that could cause global + variables to be accidentally deleted (http://crbug.com/70066). + + Added support for strict mode octal literal verification. + + Fixed a couple of crash bugs (issues 1070 and 1071). + + +2011-01-24: Version 3.0.10 + + Fixed External::Wrap for 64-bit addresses (issue 1037). + + Fixed incorrect .arguments variable proxy handling in the full + code generator (issue 1060). + + Introduced partial strict mode support. + + Changed formatting of recursive error messages to match Firefox and + Safari (issue http://crbug.com/70334). + + Fixed incorrect rounding for float-to-integer conversions for external + array types, which implement the Typed Array spec + (issue http://crbug.com/50972). + + Performance improvements on the IA32 platform. + + +2011-01-19: Version 3.0.9 + + Added basic GDB JIT Interface integration. + + Make invalid break/continue statements a syntax error instead of a + runtime error. + + +2011-01-17: Version 3.0.8 + + Exposed heap size limit to the heap statistics gathered by + the GetHeapStatistics API. + + Wrapped external pointers more carefully (issue 1037). + + Hardened the implementation of error objects to avoid setters + intercepting the properties set then throwing an error. + + Avoided trashing the FPSCR when calculating Math.floor on ARM. + + Performance improvements on the IA32 platform. + + +2011-01-10: Version 3.0.7 + + Stopped calling inherited setters when creating object literals + (issue 1015). + + Changed interpretation of malformed \c? escapes in RegExp to match + JSC. + + Enhanced the command-line debugger interface and fixed some minor + bugs in the debugger. + + Performance improvements on the IA32 platform. + + +2011-01-05: Version 3.0.6 + + Allowed getters and setters on JSArray elements (issue 900). + + Stopped JSON objects from hitting inherited setters (part of + issue 1015). + + Allowed numbers and strings as names of getters/setters in object + initializer (issue 820). + + Added use_system_v8 option to gyp (off by default), to make it easier + for Linux distributions to ship with system-provided V8 library. + + Exported external array data accessors (issue 1016). + + Added labelled thread names to help with debugging (on Linux). + + +2011-01-03: Version 3.0.5 + + Fixed a couple of cast errors for gcc-3.4.3. + + Performance improvements in GC and IA32 code generator. + + +2010-12-21: Version 3.0.4 + + Added Date::ResetCache() to the API so that the cached values in the + Date object can be reset to allow live DST / timezone changes. + + Extended existing support for printing (while debugging) the contents + of objects. Added support for printing objects from release builds. + + Fixed V8 issues 989, 1006, and 1007. + + +2010-12-17: Version 3.0.3 + + Reapplied all changes for version 3.0.1. + + Improved debugger protocol for remote debugging. + + Added experimental support for using gyp to generate build files + for V8. + + Fixed implementation of String::Write in the API (issue 975). + + +2010-12-15: Version 3.0.2 + + Revert version 3.0.1 and patch 3.0.1.1. + + +2010-12-13: Version 3.0.1 + + Added support for an experimental internationalization API as an + extension. This extension is disabled by default but can be enabled + when building V8. The ECMAScript internationalization strawman is + at http://wiki.ecmascript.org/doku.php?id=strawman:i18n_api. + + Made RegExp character class parsing stricter. This mirrors a change + to RegExp parsing in WebKit. + + Fixed a bug in Object.defineProperty when used to change attributes + of an existing property. It incorrectly set the property value to + undefined (issue 965). + + Fixed several different compilation failures on various platforms + caused by the 3.0.0 release. + + Optimized Math.pow so it can work on unboxed doubles. + + Sped up quoting of JSON strings by removing one traversal of the + string. + + +2010-12-07: Version 3.0.0 + + Improved performance by (partially) addressing issue 957 on + IA-32. Still needs more work for the other architectures. + + +2010-11-29: Version 2.5.9 + + Fixed crashes during GC caused by partially initialize heap + objects. + + Fixed bug in process sample that caused memory leaks. + + Improved performance on ARM by implementing missing stubs and + inlining. + + Improved heap profiler support. + + Added separate seeding on Windows of the random number generator + used internally by the compiler (issue 936). + + Exposed API for getting the name of the function used to construct + an object. + + Fixed date parser to handle one and two digit millisecond + values (issue 944). + + Fixed number parsing to disallow space between sign and + digits (issue 946). + + +2010-11-23: Version 2.5.8 + + Removed dependency on Gay's dtoa. + + Improved heap profiler precision and speed. + + Reduced overhead of callback invocations on ARM. + + +2010-11-18: Version 2.5.7 + + Fixed obscure evaluation order bug (issue 931). + + Split the random number state between JavaScript and the private API. + + Fixed performance bug causing GCs when generating stack traces on + code from very large scripts. + + Fixed bug in parser that allowed (foo):42 as a labelled statement + (issue 918). + + Provide more accurate results about used heap size via + GetHeapStatistics. + + Allow build-time customization of the max semispace size. + + Made String.prototype.split honor limit when separator is empty + (issue 929). + + Added missing failure check after expecting an identifier in + preparser (Chromium issue 62639). + + +2010-11-10: Version 2.5.6 + + Added support for VFP rounding modes to the ARM simulator. + + Fixed multiplication overflow bug (issue 927). + + Added a limit for the amount of executable memory (issue 925). + + +2010-11-08: Version 2.5.5 + + Added more aggressive GC of external objects in near out-of-memory + situations. + + Fixed a bug that gave the incorrect result for String.split called + on the empty string (issue 924). + + +2010-11-03: Version 2.5.4 + + Improved V8 VFPv3 runtime detection to address issue 914. + + +2010-11-01: Version 2.5.3 + + Fixed a bug that prevents constants from overwriting function values + in object literals (issue 907). + + Fixed a bug with reporting of impossible nested calls of DOM functions + (issue http://crbug.com/60753). + + +2010-10-27: Version 2.5.2 + + Improved sampler resolution on Linux. + + Allowed forcing the use of a simulator from the build script + independently of the host architecture. + + Fixed FreeBSD port (issue 912). + + Made windows-tick-processor respect D8_PATH. + + Implemented --noinline-new flag fully on IA32, X64 and ARM platforms. + + +2010-10-20: Version 2.5.1 + + Fixed bug causing spurious out of memory exceptions + (issue http://crbug.com/54580). + + Fixed compilation error on Solaris platform (issue 901). + + Fixed error in strtod (string to floating point number conversion) + due to glibc's use of 80-bit floats in the FPU on 32-bit linux. + + Adjusted randomized allocations of executable memory to have 64k + granularity (issue http://crbug.com/56036). + + Supported profiling using kernel perf_events on linux. Added ll_prof + script to tools and --ll-prof flag to V8. + + +2010-10-18: Version 2.5.0 + + Fixed bug in cache handling of lastIndex on global regexps + (issue http://crbug.com/58740). + + Added USE_SIMULATOR macro that explicitly indicates that we wish to use + the simulator as the execution engine (by Mark Lam + from Hewlett-Packard Development Company, LP). + + Fixed compilation error on ARM with gcc 4.4 (issue 894). + + +2010-10-13: Version 2.4.9 + + Fixed a bug in the handling of conditional expressions in test + contexts in compiler for top-level code. + + Added "//@ sourceURL" information to the StackTrace API. + + Exposed RegExp construction through the API. + + +2010-10-04: Version 2.4.8 + + Fixed a bug in ResumeProfilerEx causing it to not always write out the + whole snapshot (issue 868). + + Performance improvements on all platforms. + + +2010-09-30: Version 2.4.7 + + Changed the command-line flag --max-new-space-size to be in kB and the + flag --max-old-space-size to be in MB (previously they were in bytes). + + Added Debug::CancelDebugBreak to the debugger API. + + Fixed a bug in getters for negative numeric property names + (https://bugs.webkit.org/show_bug.cgi?id=46689). + + Performance improvements on all platforms. + + +2010-09-27: Version 2.4.6 + + Fixed assertion failure related to copy-on-write arrays (issue 876). + + Fixed build failure of 64-bit V8 on Windows. + + Fixed a bug in RegExp (issue http://crbug.com/52801). + + Improved the profiler's coverage to cover more functions (issue 858). + + Fixed error in shift operators on 64-bit V8 + (issue http://crbug.com/54521). + + +2010-09-22: Version 2.4.5 + + Changed the RegExp benchmark to exercise the regexp engine on different + inputs by scrambling the input strings. + + Fixed a bug in keyed loads on strings. + + Fixed a bug with loading global function prototypes. + + Fixed a bug with profiling RegExp calls (issue http://crbug.com/55999). + + Performance improvements on all platforms. + + +2010-09-15: Version 2.4.4 + + Fixed bug with hangs on very large sparse arrays. + + Now tries harder to free up memory when running out of space. + + Added heap snapshots to JSON format to API. + + Recalibrated benchmarks. + + +2010-09-13: Version 2.4.3 + + Made Date.parse properly handle TZ offsets (issue 857). + + Performance improvements on all platforms. + + +2010-09-08: Version 2.4.2 + + Fixed GC crash bug. + + Fixed stack corruption bug. + + Fixed compilation for newer C++ compilers that found Operand(0) + ambiguous. + + +2010-09-06: Version 2.4.1 + + Added the ability for an embedding application to receive a callback + when V8 allocates (V8::AddMemoryAllocationCallback) or deallocates + (V8::RemoveMemoryAllocationCallback) from the OS. + + Fixed several JSON bugs (including issue 855). + + Fixed memory overrun crash bug triggered during V8's tick-based + profiling. + + Performance improvements on all platforms. + + +2010-09-01: Version 2.4.0 + + Fixed bug in Object.freeze and Object.seal when Array.prototype or + Object.prototype are changed (issue 842). + + Updated Array.splice to follow Safari and Firefox when called + with zero arguments. + + Fixed a missing live register when breaking at keyed loads on ARM. + + Performance improvements on all platforms. + + +2010-08-25: Version 2.3.11 + + Fixed bug in RegExp related to copy-on-write arrays. + + Refactored tools/test.py script, including the introduction of + VARIANT_FLAGS that allows specification of sets of flags with which + all tests should be run. + + Fixed a bug in the handling of debug breaks in CallIC. + + Performance improvements on all platforms. + + +2010-08-23: Version 2.3.10 + + Fixed bug in bitops on ARM. + + Build fixes for unusual compilers. + + Track high water mark for RWX memory. + + Performance improvements on all platforms. + + +2010-08-18: Version 2.3.9 + + Fixed compilation for ARMv4 on OpenBSD/FreeBSD. + + Removed specialized handling of GCC 4.4 (issue 830). + + Fixed DST cache to take into account the suspension of DST in + Egypt during the 2010 Ramadan (issue http://crbug.com/51855). + + Performance improvements on all platforms. + + +2010-08-16: Version 2.3.8 + + Fixed build with strict aliasing on GCC 4.4 (issue 463). + + Fixed issue with incorrect handling of custom valueOf methods on + string wrappers (issue 760). + + Fixed compilation for ARMv4 (issue 590). + + Improved performance. + + +2010-08-11: Version 2.3.7 + + Reduced size of heap snapshots produced by heap profiler (issue 783). + + Introduced v8::Value::IsRegExp method. + + Fixed CPU profiler crash in start / stop sequence when non-existent + name is passed (issue http://crbug.com/51594). + + Introduced new indexed property query callbacks API (issue 816). This + API is guarded by USE_NEW_QUERY_CALLBACK define and is disabled + by default. + + Removed support for object literal get/set with number/string + property name. + + Fixed handling of JSObject::elements in CalculateNetworkSize + (issue 822). + + Allowed compiling with strict aliasing enabled on GCC 4.4 (issue 463). + + +2010-08-09: Version 2.3.6 + + RegExp literals create a new object every time they are evaluated + (issue 704). + + Object.seal and Object.freeze return the modified object (issue 809). + + Fixed building using GCC 4.4.4. + + +2010-08-04: Version 2.3.5 + + Added support for ES5 property names. Object initialisers and + dot-notation property access now allows keywords. Also allowed + non-identifiers after "get" or "set" in an object initialiser. + + Randomized the addresses of allocated executable memory on Windows. + + +2010-08-02: Version 2.3.4 + + Fixed problems in implementation of ES5 function.prototype.bind. + + Fixed error when using apply with arguments object on ARM (issue 784). + + Added setting of global flags to debugger protocol. + + Fixed an error affecting cached results of sin and cos (issue 792). + + Removed memory leak from a boundary case where V8 is not initialized. + + Fixed issue where debugger could set breakpoints outside the body + of a function. + + Fixed issue in debugger when using both live edit and step in features. + + Added Number-letter (Nl) category to Unicode tables. These characters + can now be used in identifiers. + + Fixed an assert failure on X64 (issue 806). + + Performance improvements on all platforms. + + +2010-07-26: Version 2.3.3 + + Fixed error when building the d8 shell in a fresh checkout. + + Implemented Function.prototype.bind (ES5 15.3.4.5). + + Fixed an error in inlined stores on ia32. + + Fixed an error when setting a breakpoint at the end of a function + that does not end with a newline character. + + Performance improvements on all platforms. + + +2010-07-21: Version 2.3.2 + + Fixed compiler warnings when building with LLVM. + + Fixed a bug with for-in applied to strings (issue 785). + + Performance improvements on all platforms. + + +2010-07-19: Version 2.3.1 + + Fixed compilation and linking with V8_INTERPRETED_REGEXP flag. + + Fixed bug related to code flushing while compiling a lazy + compilable function (issue http://crbug.com/49099). + + Performance improvements on all platforms. + + +2010-07-15: Version 2.3.0 + + Added ES5 Object.seal and Object.isSealed. + + Added debugger API for scheduling debugger commands from a + separate thread. + + +2010-07-14: Version 2.2.24 + + Added API for capturing stack traces for uncaught exceptions. + + Fixed crash bug when preparsing from a non-external V8 string + (issue 775). + + Fixed JSON.parse bug causing input not to be converted to string + (issue 764). + + Added ES5 Object.freeze and Object.isFrozen. + + Performance improvements on all platforms. + + +2010-07-07: Version 2.2.23 + + API change: Convert Unicode code points outside the basic multilingual + plane to the replacement character. Previous behavior was to silently + truncate the value to 16 bits. + + Fixed crash: handle all flat string types in regexp replace. + + Prevent invalid pre-parsing data passed in through the API from + crashing V8. + + Performance improvements on all platforms. + + +2010-07-05: Version 2.2.22 + + Added ES5 Object.isExtensible and Object.preventExtensions. + + Enabled building V8 as a DLL. + + Fixed a bug in date code where -0 was not interpreted as 0 + (issue 736). + + Performance improvements on all platforms. + + +2010-06-30: Version 2.2.21 + + Fixed bug in externalizing some ASCII strings (Chromium issue 47824). + + Updated JSON.stringify to floor the space parameter (issue 753). + + Updated the Mozilla test expectations to the newest version. + + Updated the ES5 Conformance Test expectations to the latest version. + + Updated the V8 benchmark suite. + + Provide actual breakpoints locations in response to setBreakpoint + and listBreakpoints requests. + + +2010-06-28: Version 2.2.20 + + Fixed bug with for-in on x64 platform (issue 748). + + Fixed crash bug on x64 platform (issue 756). + + Fixed bug in Object.getOwnPropertyNames. (chromium issue 41243). + + Fixed a bug on ARM that caused the result of 1 << x to be + miscalculated for some inputs. + + Performance improvements on all platforms. + + +2010-06-23: Version 2.2.19 + + Fixed bug that causes the build to break when profillingsupport=off + (issue 738). + + Added expose-externalize-string flag for testing extensions. + + Resolve linker issues with using V8 as a DLL causing a number of + problems with unresolved symbols. + + Fixed build failure for cctests when ENABLE_DEBUGGER_SUPPORT is not + defined. + + Performance improvements on all platforms. + + +2010-06-16: Version 2.2.18 + + Added API functions to retrieve information on indexed properties + managed by the embedding layer. Fixes bug 737. + + Made ES5 Object.defineProperty support array elements. Fixes bug 619. + + Added heap profiling to the API. + + Removed old named property query from the API. + + Incremental performance improvements. + + +2010-06-14: Version 2.2.17 + + Improved debugger support for stepping out of functions. + + Incremental performance improvements. + + +2010-06-09: Version 2.2.16 + + Removed the SetExternalStringDiposeCallback API. Changed the + disposal of external string resources to call a virtual Dispose + method on the resource. + + Added support for more precise break points when debugging and + stepping. + + Memory usage improvements on all platforms. + + +2010-06-07: Version 2.2.15 + + Added an API to control the disposal of external string resources. + + Added missing initialization of a couple of variables which makes + some compilers complaint when compiling with -Werror. + + Improved performance on all platforms. + + +2010-06-02: Version 2.2.14 + + Fixed a crash in code generated for String.charCodeAt. + + Fixed a compilation issue with some GCC versions (issue 727). + + Performance optimizations on x64 and ARM platforms. + + +2010-05-31: Version 2.2.13 + + Implemented Object.getOwnPropertyDescriptor for element indices and + strings (issue 599). + + Fixed bug for windows 64 bit C calls from generated code. + + Added new scons flag unalignedaccesses for arm builds. + + Performance improvements on all platforms. + + +2010-05-26: Version 2.2.12 + + Allowed accessors to be defined on objects rather than just object + templates. + + Changed the ScriptData API. + + +2010-05-21: Version 2.2.11 + + Fixed crash bug in liveedit on 64 bit. + + Use 'full compiler' when debugging is active. This should increase + the density of possible break points, making single step more fine + grained. This will only take effect for functions compiled after + debugging has been started, so recompilation of all functions is + required to get the full effect. IA32 and x64 only for now. + + Misc. fixes to the Solaris build. + + Added new flags --print-cumulative-gc-stat and --trace-gc-nvp. + + Added filtering of CPU profiles by security context. + + Fixed crash bug on ARM when running without VFP2 or VFP3. + + Incremental performance improvements in all backends. + + +2010-05-17: Version 2.2.10 + + Performance improvements in the x64 and ARM backends. + + +2010-05-10: Version 2.2.9 + + Allowed Object.create to be called with a function (issue 697). + + Fixed bug with Date.parse returning a non-NaN value when called on a + non date string (issue 696). + + Allowed unaligned memory accesses on ARM targets that support it (by + Subrato K De of CodeAurora ). + + C++ API for retrieving JavaScript stack trace information. + + +2010-05-05: Version 2.2.8 + + Performance improvements in the x64 and ARM backends. + + +2010-05-03: Version 2.2.7 + + Added support for ES5 date time string format to Date.parse. + + Performance improvements in the x64 backend. + + +2010-04-28: Version 2.2.6 + + Added "amd64" as recognized architecture in scons build script + (by Ryan Dahl ). + + Fixed bug in String search and replace with very simple RegExps. + + Fixed bug in RegExp containing "\b^". + + Performance improvements on all platforms. + + +2010-04-26: Version 2.2.5 + + Various performance improvements (especially for ARM and x64) + + Fixed bug in CPU profiling (http://crbug.com/42137) + + Fixed a bug with the natives cache. + + Fixed two bugs in the ARM code generator that can cause + wrong calculations. + + Fixed a bug that may cause a wrong result for shift operations. + + +2010-04-21: Version 2.2.4 + + Fixed warnings on arm on newer GCC versions. + + Fixed a number of minor bugs. + + Performance improvements on all platforms. + + +2010-04-14: Version 2.2.3 + + Added stack command and mem command to ARM simulator debugger. + + Fixed scons snapshot and ARM build, and Windows X64 build issues. + + Performance improvements on all platforms. + + +2010-04-12: Version 2.2.2 + + Introduced new profiler API. + + Fixed random number generator to produce full 32 random bits. + + +2010-04-06: Version 2.2.1 + + Debugger improvements. + + Fixed minor bugs. + + +2010-03-29: Version 2.2.0 + + Fixed a few minor bugs. + + Performance improvements for string operations. + + +2010-03-26: Version 2.1.10 + + Fixed scons build issues. + + Fixed a couple of minor bugs. + + +2010-03-25: Version 2.1.9 + + Added API support for reattaching a global object to a context. + + Extended debugger API with access to the internal debugger context. + + Fixed Chromium crashes (issues http://crbug.com/39128 and + http://crbug.com/39160) + + +2010-03-24: Version 2.1.8 + + Added fine-grained garbage collection callbacks to the API. + + Performance improvements on all platforms. + + +2010-03-22: Version 2.1.7 + + Fixed issue 650. + + Fixed a bug where __proto__ was sometimes enumerated (issue 646). + + Performance improvements for arithmetic operations. + + Performance improvements for string operations. + + Print script name and line number information in stack trace. + + +2010-03-17: Version 2.1.6 + + Performance improvements for arithmetic operations. + + Performance improvements for string operations. + + +2010-03-10: Version 2.1.4 + + Fixed code cache lookup for keyed IC's (issue http://crbug.com/37853). + + Performance improvements on all platforms. + + +2010-03-10: Version 2.1.3 + + Added API method for context-disposal notifications. + + Added API method for accessing elements by integer index. + + Added missing implementation of Uint32::Value and Value::IsUint32 + API methods. + + Added IsExecutionTerminating API method. + + Disabled strict aliasing for GCC 4.4. + + Fixed string-concatenation bug (issue 636). + + Performance improvements on all platforms. + + +2010-02-23: Version 2.1.2 + + Fixed a crash bug caused by wrong assert. + + Fixed a bug with register names on 64-bit V8 (issue 615). + + Performance improvements on all platforms. + + +2010-02-19: Version 2.1.1 + + [ES5] Implemented Object.defineProperty. + + Improved profiler support. + + Added SetPrototype method in the public V8 API. + + Added GetScriptOrigin and GetScriptLineNumber methods to Function + objects in the API. + + Performance improvements on all platforms. + + +2010-02-03: Version 2.1.0 + + Values are now always wrapped in objects when used as a receiver. + (issue 223). + + [ES5] Implemented Object.getOwnPropertyNames. + + [ES5] Restrict JSON.parse to only accept strings that conforms to the + JSON grammar. + + Improvement of debugger agent (issue 549 and 554). + + Fixed problem with skipped stack frame in profiles (issue 553). + + Solaris support by Erich Ocean and Ryan Dahl + . + + Fixed a bug that Math.round() returns incorrect results for huge + integers. + + Fixed enumeration order for objects created from some constructor + functions (isue http://crbug.com/3867). + + Fixed arithmetic on some integer constants (issue 580). + + Numerous performance improvements including porting of previous IA-32 + optimizations to x64 and ARM architectures. + + +2010-01-14: Version 2.0.6 + + Added ES5 Object.getPrototypeOf, GetOwnPropertyDescriptor, + GetOwnProperty, FromPropertyDescriptor. + + Fixed Mac x64 build errors. + + Improved performance of some math and string operations. + + Improved performance of some regexp operations. + + Improved performance of context creation. + + Improved performance of hash tables. + + +2009-12-18: Version 2.0.5 + + Extended to upper limit of map space to allow for 7 times as many map + to be allocated (issue 524). + + Improved performance of code using closures. + + Improved performance of some binary operations involving doubles. + + +2009-12-16: Version 2.0.4 + + Added ECMAScript 5 Object.create. + + Improved performance of Math.max and Math.min. + + Optimized adding of strings on 64-bit platforms. + + Improved handling of external strings by using a separate table + instead of weak handles. This improves garbage collection + performance and uses less memory. + + Changed code generation for object and array literals in toplevel + code to be more compact by doing more work in the runtime. + + Fixed a crash bug triggered when garbage collection happened during + generation of a callback load inline cache stub. + + Fixed crash bug sometimes triggered when local variables shadowed + parameters in functions that used the arguments object. + + +2009-12-03: Version 2.0.3 + + Optimized handling and adding of strings, for-in and Array.join. + + Heap serialization is now non-destructive. + + Improved profiler support with information on time spend in C++ + callbacks registered through the API. + + Added commands to the debugger protocol for starting/stopping + profiling. + + Enabled the non-optimizing compiler for top-level code. + + Changed the API to only allow strings to be set as data objects on + Contexts and scripts to avoid potentially keeping global objects + around for too long (issue 528). + + OpenBSD support patch by Peter Valchev . + + Fixed bugs. + + +2009-11-24: Version 2.0.2 + + Improved profiler support. + + Fixed bug that broke compilation of d8 with readline support. + + +2009-11-20: Version 2.0.1 + + Fixed crash bug in String.prototype.replace. + + Reverted a change which caused Chromium interactive ui test + failures. + + +2009-11-18: Version 2.0.0 + + Added support for VFP on ARM. + + Added TryCatch::ReThrow method to the API. + + Reduced the size of snapshots and improved the snapshot load time. + + Improved heap profiler support. + + 64-bit version now supported on Windows. + + Fixed a number of debugger issues. + + Fixed bugs. + + 2009-10-29: Version 1.3.18 Reverted a change which caused crashes in RegExp replace. - Reverted a change which caused Chromium ui_tests failure. + Reverted a change which caused Chromium ui_tests failure. 2009-10-28: Version 1.3.17 @@ -25,14 +1544,14 @@ 2009-10-16: Version 1.3.16 - + X64: Convert smis to holding 32 bits of payload. - Introduce v8::Integer::NewFromUnsigned method. + Introduced v8::Integer::NewFromUnsigned method. - Add missing null check in Context::GetCurrent. + Added missing null check in Context::GetCurrent. - Add trim, trimLeft and trimRight methods to String + Added trim, trimLeft and trimRight methods to String Patch by Jan de Mooij Implement ES5 Array.isArray @@ -40,14 +1559,15 @@ Skip access checks for hidden properties. - Add String::Concat(Handle left, Handle right) to the V8 API. + Added String::Concat(Handle left, Handle right) to the + V8 API. - Fix GYP-based builds of V8. + Fixed GYP-based builds of V8. 2009-10-07: Version 1.3.15 - Expand the maximum size of the code space to 512MB for 64-bit mode. + Expanded the maximum size of the code space to 512MB for 64-bit mode. Fixed a crash bug happening when starting profiling (issue http://crbug.com/23768). @@ -59,10 +1579,10 @@ located on the object or in the prototype chain skipping any interceptors. - Fix the stack limits setting API to work correctly with threads. The + Fixed the stack limits setting API to work correctly with threads. The stack limit now needs to be set to each thread thich is used with V8. - Remove the high-priority flag from IdleNotification() + Removed the high-priority flag from IdleNotification() Ensure V8 is initialized before locking and unlocking threads. @@ -130,7 +1650,7 @@ Implemented missing pieces of debugger infrastructure on ARM. The debugger is now fully functional on ARM. - Make 'hidden' the default visibility for gcc. + Made 'hidden' the default visibility for gcc. 2009-09-09: Version 1.3.10 @@ -170,7 +1690,7 @@ notifications when V8 has not yet been initialized. Fixed ARM simulator compilation problem on Windows. - + 2009-08-25: Version 1.3.7 @@ -185,9 +1705,9 @@ 2009-08-21: Version 1.3.6 - Add support for forceful termination of JavaScript execution. + Added support for forceful termination of JavaScript execution. - Add low memory notification to the API. The embedding host can signal + Added low memory notification to the API. The embedding host can signal a low memory situation to V8. Changed the handling of global handles (persistent handles in the API @@ -201,9 +1721,9 @@ 2009-08-19: Version 1.3.5 - Optimize initialization of some arrays in the builtins. + Optimized initialization of some arrays in the builtins. - Fix mac-nm script to support filenames with spaces. + Fixed mac-nm script to support filenames with spaces. Support for using the V8 profiler when V8 is embedded in a Windows DLL. @@ -216,7 +1736,7 @@ Added API for getting object mirrors. - Make sure that SSE3 instructions are used whenever possible even when + Made sure that SSE3 instructions are used whenever possible even when running off a snapshot generated without using SSE3 instructions. Tweaked the handling of the initial size and growth policy of the heap. @@ -238,20 +1758,20 @@ 2009-08-12: Version 1.3.3 - Fix issue 417: incorrect %t placeholder expansion. + Fixed issue 417: incorrect %t placeholder expansion. - Add .gitignore file similar to Chromium's one. + Added .gitignore file similar to Chromium's one. - Fix SConstruct file to build with new logging code for Android. + Fixed SConstruct file to build with new logging code for Android. API: added function to find instance of template in prototype chain. Inlined Object::IsInstanceOf. Land change to notify valgrind when we modify code on x86. - Add api call to determine whether a string can be externalized. + Added api call to determine whether a string can be externalized. - Add a write() command to d8. + Added a write() command to d8. 2009-08-05: Version 1.3.2 @@ -285,9 +1805,9 @@ function is a built-in. Initial implementation of constructor heap profile for JS objects. - + More fine grained control of profiling aspects through the API. - + Optimized the called as constructor check for API calls. @@ -312,8 +1832,8 @@ Added an external allocation limit to avoid issues where small V8 objects would hold on to large amounts of external memory without causing garbage collections. - - Finished more of the inline caching stubs for x64 targets. + + Finished more of the inline caching stubs for x64 targets. 2009-07-13: Version 1.2.14 @@ -393,9 +1913,9 @@ Fixed a bug in the string type inference. Fixed a bug in the handling of 'constant function' properties. - + Improved overall performance. - + 2009-06-16: Version 1.2.8 @@ -534,7 +2054,7 @@ Added EcmaScript 5 JSON object. - Fix bug in preemption support on ARM. + Fixed bug in preemption support on ARM. 2009-04-23: Version 1.2.0 diff --git a/LICENSE b/LICENSE index e3ed242d427..e435050e909 100644 --- a/LICENSE +++ b/LICENSE @@ -12,9 +12,6 @@ are: based on layout tests from webkit.org which are copyrighted by Apple Computer, Inc. and released under a 3-clause BSD license. - - Dtoa, located under third_party/dtoa. This code is copyrighted by - David M. Gay and released under an MIT license. - - Strongtalk assembler, the basis of the files assembler-arm-inl.h, assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h, assembler-ia32.cc, assembler-ia32.h, assembler.cc and assembler.h. @@ -27,7 +24,7 @@ are: These libraries have their own licenses; we recommend you read them, as their terms may differ from the terms below. -Copyright 2006-2009, Google Inc. All rights reserved. +Copyright 2006-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: diff --git a/LICENSE.strongtalk b/LICENSE.strongtalk new file mode 100644 index 00000000000..9bd62e4f231 --- /dev/null +++ b/LICENSE.strongtalk @@ -0,0 +1,29 @@ +Copyright (c) 1994-2006 Sun Microsystems Inc. +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. + +- Redistribution 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 Sun Microsystems or the names of 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. diff --git a/LICENSE.v8 b/LICENSE.v8 new file mode 100644 index 00000000000..933718a9ef9 --- /dev/null +++ b/LICENSE.v8 @@ -0,0 +1,26 @@ +Copyright 2006-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. diff --git a/LICENSE.valgrind b/LICENSE.valgrind new file mode 100644 index 00000000000..fd8ebaf5099 --- /dev/null +++ b/LICENSE.valgrind @@ -0,0 +1,45 @@ +---------------------------------------------------------------- + +Notice that the following BSD-style license applies to this one +file (valgrind.h) only. The rest of Valgrind is licensed under the +terms of the GNU General Public License, version 2, unless +otherwise indicated. See the COPYING file in the source +distribution for details. + +---------------------------------------------------------------- + +This file is part of Valgrind, a dynamic binary instrumentation +framework. + +Copyright (C) 2000-2007 Julian Seward. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + +4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. diff --git a/SConstruct b/SConstruct old mode 100755 new mode 100644 index 2b2ce1d0f19..11751062480 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,4 @@ -# Copyright 2008 the V8 project authors. All rights reserved. +# 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: @@ -27,87 +27,63 @@ import platform import re +import subprocess import sys import os from os.path import join, dirname, abspath from types import DictType, StringTypes root_dir = dirname(File('SConstruct').rfile().abspath) -sys.path.append(join(root_dir, 'tools')) +sys.path.insert(0, join(root_dir, 'tools')) import js2c, utils - -# ANDROID_TOP is the top of the Android checkout, fetched from the environment -# variable 'TOP'. You will also need to set the CXX, CC, AR and RANLIB -# environment variables to the cross-compiling tools. -ANDROID_TOP = os.environ.get('TOP') -if ANDROID_TOP is None: - ANDROID_TOP="" - -# TODO: Sort these issues out properly but as a temporary solution for gcc 4.4 -# on linux we need these compiler flags to avoid crashes in the v8 test suite -# and avoid dtoa.c strict aliasing issues -if os.environ.get('GCC_VERSION') == '44': - GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp'] - GCC_DTOA_EXTRA_CCFLAGS = ['-fno-strict-aliasing'] +# ARM_TARGET_LIB is the path to the dynamic library to use on the target +# machine if cross-compiling to an arm machine. You will also need to set +# the additional cross-compiling environment variables to the cross compiler. +ARM_TARGET_LIB = os.environ.get('ARM_TARGET_LIB') +if ARM_TARGET_LIB: + ARM_LINK_FLAGS = ['-Wl,-rpath=' + ARM_TARGET_LIB + '/lib:' + + ARM_TARGET_LIB + '/usr/lib', + '-Wl,--dynamic-linker=' + ARM_TARGET_LIB + + '/lib/ld-linux.so.3'] else: - GCC_EXTRA_CCFLAGS = [] - GCC_DTOA_EXTRA_CCFLAGS = [] - -ANDROID_FLAGS = ['-march=armv5te', - '-mtune=xscale', - '-msoft-float', - '-fpic', - '-mthumb-interwork', - '-funwind-tables', - '-fstack-protector', - '-fno-short-enums', - '-fmessage-length=0', - '-finline-functions', - '-fno-inline-functions-called-once', - '-fgcse-after-reload', - '-frerun-cse-after-loop', - '-frename-registers', - '-fomit-frame-pointer', - '-fno-strict-aliasing', - '-finline-limit=64', - '-MD'] - -ANDROID_INCLUDES = [ANDROID_TOP + '/bionic/libc/arch-arm/include', - ANDROID_TOP + '/bionic/libc/include', - ANDROID_TOP + '/bionic/libstdc++/include', - ANDROID_TOP + '/bionic/libc/kernel/common', - ANDROID_TOP + '/bionic/libc/kernel/arch-arm', - ANDROID_TOP + '/bionic/libm/include', - ANDROID_TOP + '/bionic/libm/include/arch/arm', - ANDROID_TOP + '/bionic/libthread_db/include', - ANDROID_TOP + '/frameworks/base/include', - ANDROID_TOP + '/system/core/include'] - -ANDROID_LINKFLAGS = ['-nostdlib', - '-Bdynamic', - '-Wl,-T,' + ANDROID_TOP + '/build/core/armelf.x', - '-Wl,-dynamic-linker,/system/bin/linker', - '-Wl,--gc-sections', - '-Wl,-z,nocopyreloc', - '-Wl,-rpath-link=' + ANDROID_TOP + '/out/target/product/generic/obj/lib', - ANDROID_TOP + '/out/target/product/generic/obj/lib/crtbegin_dynamic.o', - ANDROID_TOP + '/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a', - ANDROID_TOP + '/out/target/product/generic/obj/lib/crtend_android.o']; + ARM_LINK_FLAGS = [] + +GCC_EXTRA_CCFLAGS = [] +GCC_DTOA_EXTRA_CCFLAGS = [] LIBRARY_FLAGS = { 'all': { 'CPPPATH': [join(root_dir, 'src')], - 'regexp:native': { - 'CPPDEFINES': ['V8_NATIVE_REGEXP'] + 'regexp:interpreted': { + 'CPPDEFINES': ['V8_INTERPRETED_REGEXP'] }, 'mode:debug': { - 'CPPDEFINES': ['V8_ENABLE_CHECKS'] + 'CPPDEFINES': ['V8_ENABLE_CHECKS', 'OBJECT_PRINT'] + }, + 'vmstate:on': { + 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING'], + }, + 'objectprint:on': { + 'CPPDEFINES': ['OBJECT_PRINT'], + }, + 'protectheap:on': { + 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_HEAP_PROTECTION'], }, 'profilingsupport:on': { - 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'], + 'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_LOGGING_AND_PROFILING'], }, 'debuggersupport:on': { 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'], + }, + 'inspector:on': { + 'CPPDEFINES': ['INSPECTOR'], + }, + 'fasttls:on': { + 'CPPDEFINES': ['V8_FAST_TLS'], + }, + 'liveobjectlist:on': { + 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT', 'INSPECTOR', + 'LIVE_OBJECT_LIST', 'OBJECT_PRINT'], } }, 'gcc': { @@ -119,20 +95,16 @@ LIBRARY_FLAGS = { # Use visibility=default to disable this. 'CXXFLAGS': ['-fvisibility=hidden'] }, + 'strictaliasing:off': { + 'CCFLAGS': ['-fno-strict-aliasing'] + }, 'mode:debug': { 'CCFLAGS': ['-g', '-O0'], 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'], - 'os:android': { - 'CCFLAGS': ['-mthumb'] - } }, 'mode:release': { 'CCFLAGS': ['-O3', '-fomit-frame-pointer', '-fdata-sections', '-ffunction-sections'], - 'os:android': { - 'CCFLAGS': ['-mthumb', '-Os'], - 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] - } }, 'os:linux': { 'CCFLAGS': ['-ansi'] + GCC_EXTRA_CCFLAGS, @@ -143,43 +115,116 @@ LIBRARY_FLAGS = { }, 'os:macos': { 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'], + 'library:shared': { + 'CPPDEFINES': ['V8_SHARED'] + } }, 'os:freebsd': { 'CPPPATH' : ['/usr/local/include'], 'LIBPATH' : ['/usr/local/lib'], 'CCFLAGS': ['-ansi'], + 'LIBS': ['execinfo'] + }, + 'os:openbsd': { + 'CPPPATH' : ['/usr/local/include'], + 'LIBPATH' : ['/usr/local/lib'], + 'CCFLAGS': ['-ansi'], + }, + 'os:solaris': { + # On Solaris, to get isinf, INFINITY, fpclassify and other macros one + # needs to define __C99FEATURES__. + 'CPPDEFINES': ['__C99FEATURES__'], + 'CPPPATH' : ['/usr/local/include'], + 'LIBPATH' : ['/usr/local/lib'], + 'CCFLAGS': ['-ansi'], }, 'os:win32': { 'CCFLAGS': ['-DWIN32'], 'CXXFLAGS': ['-DWIN32'], }, - 'os:android': { - 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', - '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], - 'CCFLAGS': ANDROID_FLAGS, - 'WARNINGFLAGS': ['-Wall', '-Wno-unused', '-Werror=return-type', - '-Wstrict-aliasing=2'], - 'CPPPATH': ANDROID_INCLUDES, - }, 'arch:ia32': { 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'], 'CCFLAGS': ['-m32'], 'LINKFLAGS': ['-m32'] }, 'arch:arm': { - 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'] + 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'], + 'unalignedaccesses:on' : { + 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=1'] + }, + 'unalignedaccesses:off' : { + 'CPPDEFINES' : ['CAN_USE_UNALIGNED_ACCESSES=0'] + }, + 'armeabi:soft' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=soft'], + } + }, + 'armeabi:softfp' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0', 'CAN_USE_VFP_INSTRUCTIONS'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=softfp'], + } + }, + 'armeabi:hard' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1', 'CAN_USE_VFP_INSTRUCTIONS'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=hard'], + } + } }, 'simulator:arm': { 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + 'LINKFLAGS': ['-m32'], + }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'mips_arch_variant:mips32r2': { + 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2'] + }, + 'simulator:none': { + 'CCFLAGS': ['-EL'], + 'LINKFLAGS': ['-EL'], + 'mips_arch_variant:mips32r2': { + 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2'] + }, + 'mips_arch_variant:mips32r1': { + 'CCFLAGS': ['-mips32', '-Wa,-mips32'] + }, + 'library:static': { + 'LINKFLAGS': ['-static', '-static-libgcc'] + }, + 'mipsabi:softfloat': { + 'CCFLAGS': ['-msoft-float'], + 'LINKFLAGS': ['-msoft-float'] + }, + 'mipsabi:hardfloat': { + 'CCFLAGS': ['-mhard-float'], + 'LINKFLAGS': ['-mhard-float'] + } + } + }, + 'simulator:mips': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'], + 'mipsabi:softfloat': { + 'CPPDEFINES': ['__mips_soft_float=1'], + }, + 'mipsabi:hardfloat': { + 'CPPDEFINES': ['__mips_hard_float=1'], + } }, 'arch:x64': { 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], 'CCFLAGS': ['-m64'], 'LINKFLAGS': ['-m64'], }, - 'prof:oprofile': { - 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT'] + 'gdbjit:on': { + 'CPPDEFINES': ['ENABLE_GDB_JIT_INTERFACE'] + }, + 'compress_startup_data:bz2': { + 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'] } }, 'msvc': { @@ -226,8 +271,16 @@ LIBRARY_FLAGS = { }, 'msvcltcg:on': { 'CCFLAGS': ['/GL'], - 'LINKFLAGS': ['/LTCG'], 'ARFLAGS': ['/LTCG'], + 'pgo:off': { + 'LINKFLAGS': ['/LTCG'], + }, + 'pgo:instrument': { + 'LINKFLAGS': ['/LTCG:PGI'] + }, + 'pgo:optimize': { + 'LINKFLAGS': ['/LTCG:PGO'] + } } } } @@ -257,30 +310,35 @@ V8_EXTRA_FLAGS = { 'os:macos': { 'WARNINGFLAGS': ['-pedantic'] }, + 'arch:arm': { + # This is to silence warnings about ABI changes that some versions of the + # CodeSourcery G++ tool chain produce for each occurrence of varargs. + 'WARNINGFLAGS': ['-Wno-abi'] + }, 'disassembler:on': { 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] } }, 'msvc': { 'all': { - 'WARNINGFLAGS': ['/WX', '/wd4355', '/wd4800'] + 'WARNINGFLAGS': ['/W3', '/WX', '/wd4351', '/wd4355', '/wd4800'] }, 'library:shared': { 'CPPDEFINES': ['BUILDING_V8_SHARED'], 'LIBS': ['winmm', 'ws2_32'] }, - 'arch:ia32': { - 'WARNINGFLAGS': ['/W3'] - }, - 'arch:x64': { - 'WARNINGFLAGS': ['/W2'] - }, 'arch:arm': { 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'], # /wd4996 is to silence the warning about sscanf # used by the arm simulator. 'WARNINGFLAGS': ['/wd4996'] }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'mips_arch_variant:mips32r2': { + 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2'] + }, + }, 'disassembler:on': { 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] } @@ -299,9 +357,21 @@ MKSNAPSHOT_EXTRA_FLAGS = { 'os:freebsd': { 'LIBS': ['execinfo', 'pthread'] }, + 'os:solaris': { + 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'], + 'LINKFLAGS': ['-mt'] + }, + 'os:openbsd': { + 'LIBS': ['execinfo', 'pthread'] + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'], }, + 'compress_startup_data:bz2': { + 'os:linux': { + 'LIBS': ['bz2'] + } + }, }, 'msvc': { 'all': { @@ -330,11 +400,13 @@ DTOA_EXTRA_FLAGS = { CCTEST_EXTRA_FLAGS = { 'all': { 'CPPPATH': [join(root_dir, 'src')], - 'LIBS': ['$LIBRARY'] }, 'gcc': { 'all': { - 'LIBPATH': [abspath('.')] + 'LIBPATH': [abspath('.')], + 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], + 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], + 'LINKFLAGS': ['$CCFLAGS'], }, 'os:linux': { 'LIBS': ['pthread'], @@ -345,20 +417,18 @@ CCTEST_EXTRA_FLAGS = { 'os:freebsd': { 'LIBS': ['execinfo', 'pthread'] }, + 'os:solaris': { + 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'], + 'LINKFLAGS': ['-mt'] + }, + 'os:openbsd': { + 'LIBS': ['execinfo', 'pthread'] + }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'] }, - 'os:android': { - 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', - '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], - 'CCFLAGS': ANDROID_FLAGS, - 'CPPPATH': ANDROID_INCLUDES, - 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], - 'LINKFLAGS': ANDROID_LINKFLAGS, - 'LIBS': ['log', 'c', 'stdc++', 'm'], - 'mode:release': { - 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] - } + 'arch:arm': { + 'LINKFLAGS': ARM_LINK_FLAGS }, }, 'msvc': { @@ -383,12 +453,13 @@ CCTEST_EXTRA_FLAGS = { SAMPLE_FLAGS = { 'all': { 'CPPPATH': [join(abspath('.'), 'include')], - 'LIBS': ['$LIBRARY'], }, 'gcc': { 'all': { - 'LIBPATH': ['.'], - 'CCFLAGS': ['-fno-rtti', '-fno-exceptions'] + 'LIBPATH': ['.'], + 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], + 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], + 'LINKFLAGS': ['$CCFLAGS'], }, 'os:linux': { 'LIBS': ['pthread'], @@ -397,22 +468,40 @@ SAMPLE_FLAGS = { 'LIBS': ['pthread'], }, 'os:freebsd': { - 'LIBPATH' : ['/usr/local/lib'], + 'LIBPATH' : ['/usr/local/lib'], + 'LIBS': ['execinfo', 'pthread'] + }, + 'os:solaris': { + 'LIBPATH' : ['/usr/local/lib'], + 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'], + 'LINKFLAGS': ['-mt'] + }, + 'os:openbsd': { + 'LIBPATH' : ['/usr/local/lib'], 'LIBS': ['execinfo', 'pthread'] }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'] }, - 'os:android': { - 'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__', - '__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'], - 'CCFLAGS': ANDROID_FLAGS, - 'CPPPATH': ANDROID_INCLUDES, - 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], - 'LINKFLAGS': ANDROID_LINKFLAGS, - 'LIBS': ['log', 'c', 'stdc++', 'm'], - 'mode:release': { - 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] + 'arch:arm': { + 'LINKFLAGS': ARM_LINK_FLAGS, + 'armeabi:soft' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=soft'], + } + }, + 'armeabi:softfp' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=softfp'], + } + }, + 'armeabi:hard' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=1', 'CAN_USE_VFP_INSTRUCTIONS'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=hard'], + } } }, 'arch:ia32': { @@ -423,20 +512,206 @@ SAMPLE_FLAGS = { 'CCFLAGS': ['-m64'], 'LINKFLAGS': ['-m64'] }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'mips_arch_variant:mips32r2': { + 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2'] + }, + 'simulator:none': { + 'CCFLAGS': ['-EL'], + 'LINKFLAGS': ['-EL'], + 'mips_arch_variant:mips32r2': { + 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2'] + }, + 'mips_arch_variant:mips32r1': { + 'CCFLAGS': ['-mips32', '-Wa,-mips32'] + }, + 'library:static': { + 'LINKFLAGS': ['-static', '-static-libgcc'] + }, + 'mipsabi:softfloat': { + 'CCFLAGS': ['-msoft-float'], + 'LINKFLAGS': ['-msoft-float'] + }, + 'mipsabi:hardfloat': { + 'CCFLAGS': ['-mhard-float'], + 'LINKFLAGS': ['-mhard-float'] + } + } + }, 'simulator:arm': { 'CCFLAGS': ['-m32'], 'LINKFLAGS': ['-m32'] }, + 'simulator:mips': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, 'mode:release': { 'CCFLAGS': ['-O2'] }, 'mode:debug': { - 'CCFLAGS': ['-g', '-O0'] + 'CCFLAGS': ['-g', '-O0'], + 'CPPDEFINES': ['DEBUG'] + }, + 'compress_startup_data:bz2': { + 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'], + 'os:linux': { + 'LIBS': ['bz2'] + } + }, + }, + 'msvc': { + 'all': { + 'LIBS': ['winmm', 'ws2_32'] + }, + 'verbose:off': { + 'CCFLAGS': ['/nologo'], + 'LINKFLAGS': ['/NOLOGO'] + }, + 'verbose:on': { + 'LINKFLAGS': ['/VERBOSE'] }, - 'prof:oprofile': { - 'LIBPATH': ['/usr/lib32', '/usr/lib32/oprofile'], - 'LIBS': ['opagent'] + 'library:shared': { + 'CPPDEFINES': ['USING_V8_SHARED'] + }, + 'prof:on': { + 'LINKFLAGS': ['/MAP'] + }, + 'mode:release': { + 'CCFLAGS': ['/O2'], + 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'], + 'msvcrt:static': { + 'CCFLAGS': ['/MT'] + }, + 'msvcrt:shared': { + 'CCFLAGS': ['/MD'] + }, + 'msvcltcg:on': { + 'CCFLAGS': ['/GL'], + 'pgo:off': { + 'LINKFLAGS': ['/LTCG'], + }, + }, + 'pgo:instrument': { + 'LINKFLAGS': ['/LTCG:PGI'] + }, + 'pgo:optimize': { + 'LINKFLAGS': ['/LTCG:PGO'] + } + }, + 'arch:ia32': { + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'], + 'LINKFLAGS': ['/MACHINE:X86'] + }, + 'arch:x64': { + 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'], + 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752'] + }, + 'mode:debug': { + 'CCFLAGS': ['/Od'], + 'LINKFLAGS': ['/DEBUG'], + 'CPPDEFINES': ['DEBUG'], + 'msvcrt:static': { + 'CCFLAGS': ['/MTd'] + }, + 'msvcrt:shared': { + 'CCFLAGS': ['/MDd'] + } } + } +} + + +PREPARSER_FLAGS = { + 'all': { + 'CPPPATH': [join(abspath('.'), 'include'), join(abspath('.'), 'src')] + }, + 'gcc': { + 'all': { + 'LIBPATH': ['.'], + 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], + 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], + 'LINKFLAGS': ['$CCFLAGS'], + }, + 'os:win32': { + 'LIBS': ['winmm', 'ws2_32'] + }, + 'arch:arm': { + 'LINKFLAGS': ARM_LINK_FLAGS, + 'armeabi:soft' : { + 'CPPDEFINES' : ['USE_EABI_HARDFLOAT=0'], + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=soft'], + } + }, + 'armeabi:softfp' : { + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=softfp'], + } + }, + 'armeabi:hard' : { + 'simulator:none': { + 'CCFLAGS': ['-mfloat-abi=hard'], + } + } + }, + 'arch:ia32': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, + 'arch:x64': { + 'CCFLAGS': ['-m64'], + 'LINKFLAGS': ['-m64'] + }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'mips_arch_variant:mips32r2': { + 'CPPDEFINES': ['_MIPS_ARCH_MIPS32R2'] + }, + 'simulator:none': { + 'CCFLAGS': ['-EL'], + 'LINKFLAGS': ['-EL'], + 'mips_arch_variant:mips32r2': { + 'CCFLAGS': ['-mips32r2', '-Wa,-mips32r2'] + }, + 'mips_arch_variant:mips32r1': { + 'CCFLAGS': ['-mips32', '-Wa,-mips32'] + }, + 'library:static': { + 'LINKFLAGS': ['-static', '-static-libgcc'] + }, + 'mipsabi:softfloat': { + 'CCFLAGS': ['-msoft-float'], + 'LINKFLAGS': ['-msoft-float'] + }, + 'mipsabi:hardfloat': { + 'CCFLAGS': ['-mhard-float'], + 'LINKFLAGS': ['-mhard-float'] + } + } + }, + 'simulator:arm': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, + 'simulator:mips': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'], + 'mipsabi:softfloat': { + 'CPPDEFINES': ['__mips_soft_float=1'], + }, + 'mipsabi:hardfloat': { + 'CPPDEFINES': ['__mips_hard_float=1'], + } + }, + 'mode:release': { + 'CCFLAGS': ['-O2'] + }, + 'mode:debug': { + 'CCFLAGS': ['-g', '-O0'], + 'CPPDEFINES': ['DEBUG'] + }, }, 'msvc': { 'all': { @@ -466,25 +741,34 @@ SAMPLE_FLAGS = { }, 'msvcltcg:on': { 'CCFLAGS': ['/GL'], - 'LINKFLAGS': ['/LTCG'], + 'pgo:off': { + 'LINKFLAGS': ['/LTCG'], + }, + }, + 'pgo:instrument': { + 'LINKFLAGS': ['/LTCG:PGI'] + }, + 'pgo:optimize': { + 'LINKFLAGS': ['/LTCG:PGO'] } }, 'arch:ia32': { - 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'], + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32', 'WIN32'], 'LINKFLAGS': ['/MACHINE:X86'] }, 'arch:x64': { - 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], + 'CPPDEFINES': ['V8_TARGET_ARCH_X64', 'WIN32'], 'LINKFLAGS': ['/MACHINE:X64', '/STACK:2091752'] }, 'mode:debug': { - 'CCFLAGS': ['/Od'], - 'LINKFLAGS': ['/DEBUG'], + 'CCFLAGS': ['/Od'], + 'LINKFLAGS': ['/DEBUG'], + 'CPPDEFINES': ['DEBUG'], 'msvcrt:static': { - 'CCFLAGS': ['/MTd'] + 'CCFLAGS': ['/MTd'] }, 'msvcrt:shared': { - 'CCFLAGS': ['/MDd'] + 'CCFLAGS': ['/MDd'] } } } @@ -493,6 +777,11 @@ SAMPLE_FLAGS = { D8_FLAGS = { 'gcc': { + 'all': { + 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], + 'CXXFLAGS': ['$CCFLAGS', '-fno-rtti', '-fno-exceptions'], + 'LINKFLAGS': ['$CCFLAGS'], + }, 'console:readline': { 'LIBS': ['readline'] }, @@ -505,14 +794,25 @@ D8_FLAGS = { 'os:freebsd': { 'LIBS': ['pthread'], }, - 'os:android': { - 'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'], - 'LINKFLAGS': ANDROID_LINKFLAGS, - 'LIBS': ['log', 'c', 'stdc++', 'm'], + 'os:solaris': { + 'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'], + 'LINKFLAGS': ['-mt'] + }, + 'os:openbsd': { + 'LIBS': ['pthread'], }, 'os:win32': { 'LIBS': ['winmm', 'ws2_32'], }, + 'arch:arm': { + 'LINKFLAGS': ARM_LINK_FLAGS + }, + 'compress_startup_data:bz2': { + 'CPPDEFINES': ['COMPRESS_STARTUP_DATA_BZ2'], + 'os:linux': { + 'LIBS': ['bz2'] + } + } }, 'msvc': { 'all': { @@ -533,8 +833,16 @@ def Abort(message): sys.exit(1) -def GuessToolchain(os): - tools = Environment()['TOOLS'] +def GuessOS(env): + return utils.GuessOS() + + +def GuessArch(env): + return utils.GuessArchitecture() + + +def GuessToolchain(env): + tools = env['TOOLS'] if 'gcc' in tools: return 'gcc' elif 'msvc' in tools: @@ -543,27 +851,53 @@ def GuessToolchain(os): return None -OS_GUESS = utils.GuessOS() -TOOLCHAIN_GUESS = GuessToolchain(OS_GUESS) -ARCH_GUESS = utils.GuessArchitecture() - - -SIMPLE_OPTIONS = { - 'toolchain': { - 'values': ['gcc', 'msvc'], - 'default': TOOLCHAIN_GUESS, - 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')' +def GuessVisibility(env): + os = env['os'] + toolchain = env['toolchain']; + if (os == 'win32' or os == 'cygwin') and toolchain == 'gcc': + # MinGW / Cygwin can't do it. + return 'default' + elif os == 'solaris': + return 'default' + else: + return 'hidden' + + +def GuessStrictAliasing(env): + # There seems to be a problem with gcc 4.5.x. + # See http://code.google.com/p/v8/issues/detail?id=884 + # It can be worked around by disabling strict aliasing. + toolchain = env['toolchain']; + if toolchain == 'gcc': + env = Environment(tools=['gcc']) + # The gcc version should be available in env['CCVERSION'], + # but when scons detects msvc this value is not set. + version = subprocess.Popen([env['CC'], '-dumpversion'], + stdout=subprocess.PIPE).communicate()[0] + if version.find('4.5') == 0: + return 'off' + return 'default' + + +PLATFORM_OPTIONS = { + 'arch': { + 'values': ['arm', 'ia32', 'x64', 'mips'], + 'guess': GuessArch, + 'help': 'the architecture to build for' }, 'os': { - 'values': ['freebsd', 'linux', 'macos', 'win32', 'android'], - 'default': OS_GUESS, - 'help': 'the os to build for (' + OS_GUESS + ')' - }, - 'arch': { - 'values':['arm', 'ia32', 'x64'], - 'default': ARCH_GUESS, - 'help': 'the architecture to build for (' + ARCH_GUESS + ')' + 'values': ['freebsd', 'linux', 'macos', 'win32', 'openbsd', 'solaris', 'cygwin'], + 'guess': GuessOS, + 'help': 'the os to build for' }, + 'toolchain': { + 'values': ['gcc', 'msvc'], + 'guess': GuessToolchain, + 'help': 'the toolchain to use' + } +} + +SIMPLE_OPTIONS = { 'regexp': { 'values': ['native', 'interpreted'], 'default': 'native', @@ -575,15 +909,35 @@ SIMPLE_OPTIONS = { 'help': 'build using snapshots for faster start-up' }, 'prof': { - 'values': ['on', 'off', 'oprofile'], + 'values': ['on', 'off'], 'default': 'off', 'help': 'enable profiling of build target' }, + 'gdbjit': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable GDB JIT interface' + }, 'library': { 'values': ['static', 'shared'], 'default': 'static', 'help': 'the type of library to produce' }, + 'vmstate': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable VM state tracking' + }, + 'objectprint': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable object printing' + }, + 'protectheap': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable heap protection' + }, 'profilingsupport': { 'values': ['on', 'off'], 'default': 'on', @@ -594,6 +948,16 @@ SIMPLE_OPTIONS = { 'default': 'on', 'help': 'enable debugging of JavaScript code' }, + 'inspector': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable inspector features' + }, + 'liveobjectlist': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable live object list features in the debugger' + }, 'soname': { 'values': ['on', 'off'], 'default': 'off', @@ -610,15 +974,26 @@ SIMPLE_OPTIONS = { 'help': 'use Microsoft Visual C++ link-time code generation' }, 'simulator': { - 'values': ['arm', 'none'], + 'values': ['arm', 'mips', 'none'], 'default': 'none', 'help': 'build with simulator' }, + 'unalignedaccesses': { + 'values': ['default', 'on', 'off'], + 'default': 'default', + 'help': 'set whether the ARM target supports unaligned accesses' + }, 'disassembler': { 'values': ['on', 'off'], 'default': 'off', 'help': 'enable the disassembler to inspect generated code' }, + 'fasttls': { + 'values': ['on', 'off'], + 'default': 'on', + 'help': 'enable fast thread local storage support ' + '(if available on the current architecture/platform)' + }, 'sourcesignatures': { 'values': ['MD5', 'timestamp'], 'default': 'MD5', @@ -636,24 +1011,82 @@ SIMPLE_OPTIONS = { }, 'visibility': { 'values': ['default', 'hidden'], - 'default': 'hidden', + 'guess': GuessVisibility, 'help': 'shared library symbol visibility' - } + }, + 'strictaliasing': { + 'values': ['default', 'off'], + 'guess': GuessStrictAliasing, + 'help': 'assume strict aliasing while optimizing' + }, + 'pgo': { + 'values': ['off', 'instrument', 'optimize'], + 'default': 'off', + 'help': 'select profile guided optimization variant', + }, + 'armeabi': { + 'values': ['hard', 'softfp', 'soft'], + 'default': 'softfp', + 'help': 'generate calling conventiont according to selected ARM EABI variant' + }, + 'mipsabi': { + 'values': ['hardfloat', 'softfloat', 'none'], + 'default': 'hardfloat', + 'help': 'generate calling conventiont according to selected mips ABI' + }, + 'mips_arch_variant': { + 'values': ['mips32r2', 'mips32r1'], + 'default': 'mips32r2', + 'help': 'mips variant' + }, + 'compress_startup_data': { + 'values': ['off', 'bz2'], + 'default': 'off', + 'help': 'compress startup data (snapshot) [Linux only]' + }, } +ALL_OPTIONS = dict(PLATFORM_OPTIONS, **SIMPLE_OPTIONS) + + +def AddOptions(options, result): + guess_env = Environment(options=result) + for (name, option) in options.iteritems(): + if 'guess' in option: + # Option has a guess function + guess = option.get('guess') + default = guess(guess_env) + else: + # Option has a fixed default + default = option.get('default') + help = '%s (%s)' % (option.get('help'), ", ".join(option['values'])) + result.Add(name, help, default) + def GetOptions(): result = Options() result.Add('mode', 'compilation mode (debug, release)', 'release') - result.Add('sample', 'build sample (shell, process)', '') + result.Add('sample', 'build sample (shell, process, lineprocessor)', '') + result.Add('cache', 'directory to use for scons build cache', '') result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '') result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') - for (name, option) in SIMPLE_OPTIONS.iteritems(): - help = '%s (%s)' % (name, ", ".join(option['values'])) - result.Add(name, help, option.get('default')) + AddOptions(PLATFORM_OPTIONS, result) + AddOptions(SIMPLE_OPTIONS, result) return result +def GetTools(opts): + env = Environment(options=opts) + os = env['os'] + toolchain = env['toolchain'] + if os == 'win32' and toolchain == 'gcc': + return ['mingw'] + elif os == 'win32' and toolchain == 'msvc': + return ['msvc', 'mslink', 'mslib', 'msvs'] + else: + return ['default'] + + def GetVersionComponents(): MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)") MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)") @@ -713,20 +1146,30 @@ def IsLegal(env, option, values): def VerifyOptions(env): if not IsLegal(env, 'mode', ['debug', 'release']): return False - if not IsLegal(env, 'sample', ["shell", "process"]): + if not IsLegal(env, 'sample', ["shell", "process", "lineprocessor"]): return False if not IsLegal(env, 'regexp', ["native", "interpreted"]): return False if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on': Abort("Profiling on windows only supported for static library.") - if env['prof'] == 'oprofile' and env['os'] != 'linux': - Abort("OProfile is only supported on Linux.") + if env['gdbjit'] == 'on' and (env['os'] != 'linux' or (env['arch'] != 'ia32' and env['arch'] != 'x64' and env['arch'] != 'arm')): + Abort("GDBJIT interface is supported only for Intel-compatible (ia32 or x64) Linux target.") if env['os'] == 'win32' and env['soname'] == 'on': Abort("Shared Object soname not applicable for Windows.") if env['soname'] == 'on' and env['library'] == 'static': Abort("Shared Object soname not applicable for static library.") - for (name, option) in SIMPLE_OPTIONS.iteritems(): - if (not option.get('default')) and (name not in ARGUMENTS): + if env['os'] != 'win32' and env['pgo'] != 'off': + Abort("Profile guided optimization only supported on Windows.") + if env['cache'] and not os.path.isdir(env['cache']): + Abort("The specified cache directory does not exist.") + if not (env['arch'] == 'arm' or env['simulator'] == 'arm') and ('unalignedaccesses' in ARGUMENTS): + print env['arch'] + print env['simulator'] + Abort("Option unalignedaccesses only supported for the ARM architecture.") + if env['os'] != 'linux' and env['compress_startup_data'] != 'off': + Abort("Startup data compression is only available on Linux") + for (name, option) in ALL_OPTIONS.iteritems(): + if (not name in env): message = ("A value for option %s must be specified (%s)." % (name, ", ".join(option['values']))) Abort(message) @@ -747,6 +1190,7 @@ class BuildContext(object): self.options = options self.env_overrides = env_overrides self.samples = samples + self.preparser_targets = [] self.use_snapshot = (options['snapshot'] != 'off') self.build_snapshot = (options['snapshot'] == 'on') self.flags = None @@ -810,7 +1254,7 @@ class BuildContext(object): env['ENV'] = self.env_overrides -def PostprocessOptions(options): +def PostprocessOptions(options, os): # Adjust architecture if the simulator option has been set if (options['simulator'] != 'none') and (options['arch'] != options['simulator']): if 'arch' in ARGUMENTS: @@ -821,6 +1265,19 @@ def PostprocessOptions(options): # Print a warning if profiling is enabled without profiling support print "Warning: forcing profilingsupport on when prof is on" options['profilingsupport'] = 'on' + if os == 'win32' and options['pgo'] != 'off' and options['msvcltcg'] == 'off': + if 'msvcltcg' in ARGUMENTS: + print "Warning: forcing msvcltcg on as it is required for pgo (%s)" % options['pgo'] + options['msvcltcg'] = 'on' + if (options['mipsabi'] != 'none') and (options['arch'] != 'mips') and (options['simulator'] != 'mips'): + options['mipsabi'] = 'none' + if options['liveobjectlist'] == 'on': + if (options['debuggersupport'] != 'on') or (options['mode'] == 'release'): + # Print a warning that liveobjectlist will implicitly enable the debugger + print "Warning: forcing debuggersupport on for liveobjectlist" + options['debuggersupport'] = 'on' + options['inspector'] = 'on' + options['objectprint'] = 'on' def ParseEnvOverrides(arg, imports): @@ -838,11 +1295,11 @@ def ParseEnvOverrides(arg, imports): return overrides -def BuildSpecific(env, mode, env_overrides): +def BuildSpecific(env, mode, env_overrides, tools): options = {'mode': mode} - for option in SIMPLE_OPTIONS: + for option in ALL_OPTIONS: options[option] = env[option] - PostprocessOptions(options) + PostprocessOptions(options, env['os']) context = BuildContext(options, env_overrides, samples=SplitList(env['sample'])) @@ -860,6 +1317,7 @@ def BuildSpecific(env, mode, env_overrides): dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) sample_flags = context.AddRelevantFlags(user_environ, SAMPLE_FLAGS) + preparser_flags = context.AddRelevantFlags(user_environ, PREPARSER_FLAGS) d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS) context.flags = { @@ -868,18 +1326,19 @@ def BuildSpecific(env, mode, env_overrides): 'dtoa': dtoa_flags, 'cctest': cctest_flags, 'sample': sample_flags, - 'd8': d8_flags + 'd8': d8_flags, + 'preparser': preparser_flags } # Generate library base name. target_id = mode suffix = SUFFIXES[target_id] library_name = 'v8' + suffix + preparser_library_name = 'v8preparser' + suffix version = GetVersion() if context.options['soname'] == 'on': # When building shared object with SONAME version the library name. library_name += '-' + version - env['LIBRARY'] = library_name # Generate library SONAME if required by the build. if context.options['soname'] == 'on': @@ -889,10 +1348,10 @@ def BuildSpecific(env, mode, env_overrides): env['SONAME'] = soname # Build the object files by invoking SCons recursively. - (object_files, shell_files, mksnapshot) = env.SConscript( + (object_files, shell_files, mksnapshot, preparser_files) = env.SConscript( join('src', 'SConscript'), build_dir=join('obj', target_id), - exports='context', + exports='context tools', duplicate=False ) @@ -900,30 +1359,40 @@ def BuildSpecific(env, mode, env_overrides): # Link the object files into a library. env.Replace(**context.flags['v8']) + context.ApplyEnvOverrides(env) if context.options['library'] == 'static': library = env.StaticLibrary(library_name, object_files) + preparser_library = env.StaticLibrary(preparser_library_name, + preparser_files) else: # There seems to be a glitch in the way scons decides where to put # PDB files when compiling using MSVC so we specify it manually. # This should not affect any other platforms. pdb_name = library_name + '.dll.pdb' library = env.SharedLibrary(library_name, object_files, PDB=pdb_name) + preparser_pdb_name = preparser_library_name + '.dll.pdb'; + preparser_library = env.SharedLibrary(preparser_library_name, + preparser_files, + PDB=preparser_pdb_name) context.library_targets.append(library) + context.library_targets.append(preparser_library) - d8_env = Environment() + d8_env = Environment(tools=tools) d8_env.Replace(**context.flags['d8']) + context.ApplyEnvOverrides(d8_env) shell = d8_env.Program('d8' + suffix, object_files + shell_files) context.d8_targets.append(shell) for sample in context.samples: - sample_env = Environment(LIBRARY=library_name) + sample_env = Environment(tools=tools) sample_env.Replace(**context.flags['sample']) + sample_env.Prepend(LIBS=[library_name]) context.ApplyEnvOverrides(sample_env) sample_object = sample_env.SConscript( join('samples', 'SConscript'), build_dir=join('obj', 'sample', sample, target_id), - exports='sample context', + exports='sample context tools', duplicate=False ) sample_name = sample + suffix @@ -931,20 +1400,39 @@ def BuildSpecific(env, mode, env_overrides): sample_env.Depends(sample_program, library) context.sample_targets.append(sample_program) - cctest_program = env.SConscript( + cctest_env = env.Copy() + cctest_env.Prepend(LIBS=[library_name]) + cctest_program = cctest_env.SConscript( join('test', 'cctest', 'SConscript'), build_dir=join('obj', 'test', target_id), - exports='context object_files', + exports='context object_files tools', duplicate=False ) context.cctest_targets.append(cctest_program) + preparser_env = env.Copy() + preparser_env.Replace(**context.flags['preparser']) + preparser_env.Prepend(LIBS=[preparser_library_name]) + context.ApplyEnvOverrides(preparser_env) + preparser_object = preparser_env.SConscript( + join('preparser', 'SConscript'), + build_dir=join('obj', 'preparser', target_id), + exports='context', + duplicate=False + ) + preparser_name = join('obj', 'preparser', target_id, 'preparser') + preparser_program = preparser_env.Program(preparser_name, preparser_object); + preparser_env.Depends(preparser_program, preparser_library) + context.preparser_targets.append(preparser_program) + return context def Build(): opts = GetOptions() - env = Environment(options=opts) + tools = GetTools(opts) + env = Environment(options=opts, tools=tools) + Help(opts.GenerateHelpText(env)) VerifyOptions(env) env_overrides = ParseEnvOverrides(env['env'], env['importenv']) @@ -955,14 +1443,16 @@ def Build(): mksnapshots = [] cctests = [] samples = [] + preparsers = [] d8s = [] modes = SplitList(env['mode']) for mode in modes: - context = BuildSpecific(env.Copy(), mode, env_overrides) + context = BuildSpecific(env.Copy(), mode, env_overrides, tools) libraries += context.library_targets mksnapshots += context.mksnapshot_targets cctests += context.cctest_targets samples += context.sample_targets + preparsers += context.preparser_targets d8s += context.d8_targets env.Alias('library', libraries) @@ -970,12 +1460,15 @@ def Build(): env.Alias('cctests', cctests) env.Alias('sample', samples) env.Alias('d8', d8s) + env.Alias('preparser', preparsers) if env['sample']: env.Default('sample') else: env.Default('library') + if env['cache']: + CacheDir(env['cache']) # We disable deprecation warnings because we need to be able to use # env.Copy without getting warnings for compatibility with older diff --git a/benchmarks/README.txt b/benchmarks/README.txt index eb759cc92cc..6676f37556e 100644 --- a/benchmarks/README.txt +++ b/benchmarks/README.txt @@ -61,3 +61,19 @@ Removed duplicate line in random seed code, and changed the name of the Object.prototype.inherits function in the DeltaBlue benchmark to inheritsFrom to avoid name clashes when running in Chromium with extensions enabled. + + +Changes from Version 5 to Version 6 +=================================== + +Removed dead code from the RayTrace benchmark and fixed a couple of +typos in the DeltaBlue implementation. Changed the Splay benchmark to +avoid converting the same numeric key to a string over and over again +and to avoid inserting and removing the same element repeatedly thus +increasing pressure on the memory subsystem. Changed the RegExp +benchmark to exercise the regular expression engine on different +input strings. + +Furthermore, the benchmark runner was changed to run the benchmarks +for at least a few times to stabilize the reported numbers on slower +machines. diff --git a/benchmarks/base.js b/benchmarks/base.js index 67cddd205ea..ffabf24ddaf 100644 --- a/benchmarks/base.js +++ b/benchmarks/base.js @@ -78,7 +78,7 @@ BenchmarkSuite.suites = []; // Scores are not comparable across versions. Bump the version if // you're making changes that will affect that scores, e.g. if you add // a new benchmark or change an existing one. -BenchmarkSuite.version = '5'; +BenchmarkSuite.version = '6'; // To make the benchmark results predictable, we replace Math.random @@ -198,15 +198,33 @@ BenchmarkSuite.prototype.NotifyError = function(error) { // Runs a single benchmark for at least a second and computes the // average time it takes to run a single iteration. -BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark) { - var elapsed = 0; - var start = new Date(); - for (var n = 0; elapsed < 1000; n++) { - benchmark.run(); - elapsed = new Date() - start; +BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark, data) { + function Measure(data) { + var elapsed = 0; + var start = new Date(); + for (var n = 0; elapsed < 1000; n++) { + benchmark.run(); + elapsed = new Date() - start; + } + if (data != null) { + data.runs += n; + data.elapsed += elapsed; + } + } + + if (data == null) { + // Measure the benchmark once for warm up and throw the result + // away. Return a fresh data object. + Measure(null); + return { runs: 0, elapsed: 0 }; + } else { + Measure(data); + // If we've run too few iterations, we continue for another second. + if (data.runs < 32) return data; + var usec = (data.elapsed * 1000) / data.runs; + this.NotifyStep(new BenchmarkResult(benchmark, usec)); + return null; } - var usec = (elapsed * 1000) / n; - this.NotifyStep(new BenchmarkResult(benchmark, usec)); } @@ -220,6 +238,7 @@ BenchmarkSuite.prototype.RunStep = function(runner) { var length = this.benchmarks.length; var index = 0; var suite = this; + var data; // Run the setup, the actual benchmark, and the tear down in three // separate steps to allow the framework to yield between any of the @@ -241,12 +260,13 @@ BenchmarkSuite.prototype.RunStep = function(runner) { function RunNextBenchmark() { try { - suite.RunSingleBenchmark(suite.benchmarks[index]); + data = suite.RunSingleBenchmark(suite.benchmarks[index], data); } catch (e) { suite.NotifyError(e); return null; } - return RunNextTearDown; + // If data is null, we're done with this benchmark. + return (data == null) ? RunNextTearDown : RunNextBenchmark(); } function RunNextTearDown() { diff --git a/benchmarks/crypto.js b/benchmarks/crypto.js index 12b88ef2947..ffa69b53bbf 100644 --- a/benchmarks/crypto.js +++ b/benchmarks/crypto.js @@ -31,7 +31,7 @@ // The code has been adapted for use as a benchmark by Google. -var Crypto = new BenchmarkSuite('Crypto', 203037, [ +var Crypto = new BenchmarkSuite('Crypto', 266181, [ new Benchmark("Encrypt", encrypt), new Benchmark("Decrypt", decrypt) ]); diff --git a/benchmarks/deltablue.js b/benchmarks/deltablue.js index 7e25d2e13f3..548fd96ffbd 100644 --- a/benchmarks/deltablue.js +++ b/benchmarks/deltablue.js @@ -23,13 +23,13 @@ // more like a JavaScript program. -var DeltaBlue = new BenchmarkSuite('DeltaBlue', 71104, [ +var DeltaBlue = new BenchmarkSuite('DeltaBlue', 66118, [ new Benchmark('DeltaBlue', deltaBlue) ]); /** - * A JavaScript implementation of the DeltaBlue constrain-solving + * A JavaScript implementation of the DeltaBlue constraint-solving * algorithm, as described in: * * "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver" @@ -349,13 +349,13 @@ function BinaryConstraint(var1, var2, strength) { BinaryConstraint.inheritsFrom(Constraint); /** - * Decides if this constratint can be satisfied and which way it + * Decides if this constraint can be satisfied and which way it * should flow based on the relative strength of the variables related, * and record that decision. */ BinaryConstraint.prototype.chooseMethod = function (mark) { if (this.v1.mark == mark) { - this.direction = (this.v1.mark != mark && Strength.stronger(this.strength, this.v2.walkStrength)) + this.direction = (this.v2.mark != mark && Strength.stronger(this.strength, this.v2.walkStrength)) ? Direction.FORWARD : Direction.NONE; } diff --git a/benchmarks/earley-boyer.js b/benchmarks/earley-boyer.js index 3c7f922c4d9..1be480e8eeb 100644 --- a/benchmarks/earley-boyer.js +++ b/benchmarks/earley-boyer.js @@ -1,7 +1,7 @@ // This file is automatically generated by scheme2js, except for the // benchmark harness code at the beginning and end of the file. -var EarleyBoyer = new BenchmarkSuite('EarleyBoyer', 765819, [ +var EarleyBoyer = new BenchmarkSuite('EarleyBoyer', 666463, [ new Benchmark("Earley", function () { BgL_earleyzd2benchmarkzd2(); }), new Benchmark("Boyer", function () { BgL_nboyerzd2benchmarkzd2(); }) ]); diff --git a/benchmarks/raytrace.js b/benchmarks/raytrace.js index c68b0383a33..971ef7218ee 100644 --- a/benchmarks/raytrace.js +++ b/benchmarks/raytrace.js @@ -8,7 +8,7 @@ // untouched. This file also contains a copy of parts of the Prototype // JavaScript framework which is used by the ray tracer. -var RayTrace = new BenchmarkSuite('RayTrace', 932666, [ +var RayTrace = new BenchmarkSuite('RayTrace', 739989, [ new Benchmark('RayTrace', renderScene) ]); @@ -205,12 +205,6 @@ Flog.RayTracer.Light.prototype = { this.intensity = (intensity ? intensity : 10.0); }, - getIntensity: function(distance){ - if(distance >= intensity) return 0; - - return Math.pow((intensity - distance) / strength, 0.2); - }, - toString : function () { return 'Light [' + this.position.x + ',' + this.position.y + ',' + this.position.z + ']'; } @@ -420,31 +414,6 @@ if(typeof(Flog) == 'undefined') var Flog = {}; if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; -Flog.RayTracer.Shape.BaseShape = Class.create(); - -Flog.RayTracer.Shape.BaseShape.prototype = { - position: null, - material: null, - - initialize : function() { - this.position = new Vector(0,0,0); - this.material = new Flog.RayTracer.Material.SolidMaterial( - new Flog.RayTracer.Color(1,0,1), - 0, - 0, - 0 - ); - }, - - toString : function () { - return 'Material [gloss=' + this.gloss + ', transparency=' + this.transparency + ', hasTexture=' + this.hasTexture +']'; - } -} -/* Fake a Flog.* namespace */ -if(typeof(Flog) == 'undefined') var Flog = {}; -if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; -if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; - Flog.RayTracer.Shape.Sphere = Class.create(); Flog.RayTracer.Shape.Sphere.prototype = { diff --git a/benchmarks/regexp.js b/benchmarks/regexp.js index dce15b8e37d..71b9e6362c4 100644 --- a/benchmarks/regexp.js +++ b/benchmarks/regexp.js @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2010 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: @@ -25,21 +25,51 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Automatically generated on 2009-01-30. +// Automatically generated on 2009-01-30. Manually updated on 2010-09-17. // This benchmark is generated by loading 50 of the most popular pages // on the web and logging all regexp operations performed. Each // operation is given a weight that is calculated from an estimate of // the popularity of the pages where it occurs and the number of times -// it is executed while loading each page. Finally the literal +// it is executed while loading each page. Furthermore the literal // letters in the data are encoded using ROT13 in a way that does not -// affect how the regexps match their input. +// affect how the regexps match their input. Finally the strings are +// scrambled to exercise the regexp engine on different input strings. -var RegRxp = new BenchmarkSuite('RegExp', 995230, [ - new Benchmark("RegExp", runRegExpBenchmark) + +var RegExp = new BenchmarkSuite('RegExp', 910985, [ + new Benchmark("RegExp", RegExpRun, RegExpSetup, RegExpTearDown) ]); -function runRegExpBenchmark() { +var regExpBenchmark = null; + +function RegExpSetup() { + regExpBenchmark = new RegExpBenchmark(); + RegExpRun(); // run once to get system initialized +} + +function RegExpRun() { + regExpBenchmark.run(); +} + +function RegExpTearDown() { + regExpBenchmark = null; +} + +// Returns an array of n different variants of the input string str. +// The variants are computed by randomly rotating one random +// character. +function computeInputVariants(str, n) { + var variants = [ str ]; + for (var i = 1; i < n; i++) { + var pos = Math.floor(Math.random() * str.length); + var chr = String.fromCharCode((str.charCodeAt(pos) + Math.floor(Math.random() * 128)) % 128); + variants[i] = str.substring(0, pos) + chr + str.substring(pos + 1, str.length); + } + return variants; +} + +function RegExpBenchmark() { var re0 = /^ba/; var re1 = /(((\w+):\/\/)([^\/:]*)(:(\d+))?)?([^#?]*)(\?([^#]*))?(#(.*))?/; var re2 = /^\s*|\s*$/g; @@ -59,77 +89,105 @@ function runRegExpBenchmark() { var re14 = /\s+/g; var re15 = /^\s*(\S*(\s+\S+)*)\s*$/; var re16 = /(-[a-z])/i; + + var s0 = computeInputVariants('pyvpx', 6511); + var s1 = computeInputVariants('uggc://jjj.snprobbx.pbz/ybtva.cuc', 1844); + var s2 = computeInputVariants('QBZPbageby_cynprubyqre', 739); + var s3 = computeInputVariants('uggc://jjj.snprobbx.pbz/', 598); + var s4 = computeInputVariants('uggc://jjj.snprobbx.pbz/fepu.cuc', 454); + var s5 = computeInputVariants('qqqq, ZZZ q, llll', 352); + var s6 = computeInputVariants('vachggrkg QBZPbageby_cynprubyqre', 312); + var s7 = computeInputVariants('/ZlFcnprUbzrcntr/Vaqrk-FvgrUbzr,10000000', 282); + var s8 = computeInputVariants('vachggrkg', 177); + var s9 = computeInputVariants('528.9', 170); + var s10 = computeInputVariants('528', 170); + var s11 = computeInputVariants('VCPhygher=ra-HF', 156); + var s12 = computeInputVariants('CersreerqPhygher=ra-HF', 156); + var s13 = computeInputVariants('xrlcerff', 144); + var s14 = computeInputVariants('521', 139); + var s15 = computeInputVariants(str0, 139); + var s16 = computeInputVariants('qvi .so_zrah', 137); + var s17 = computeInputVariants('qvi.so_zrah', 137); + var s18 = computeInputVariants('uvqqra_ryrz', 117); + var s19 = computeInputVariants('sevraqfgre_naba=nvq%3Qn6ss9p85n868ro9s059pn854735956o3%26ers%3Q%26df%3Q%26vpgl%3QHF', 95); + var s20 = computeInputVariants('uggc://ubzr.zlfcnpr.pbz/vaqrk.psz', 93); + var s21 = computeInputVariants(str1, 92); + var s22 = computeInputVariants('svefg', 85); + var s23 = computeInputVariants('uggc://cebsvyr.zlfcnpr.pbz/vaqrk.psz', 85); + var s24 = computeInputVariants('ynfg', 85); + var s25 = computeInputVariants('qvfcynl', 85); + function runBlock0() { for (var i = 0; i < 6511; i++) { - re0.exec('pyvpx'); + re0.exec(s0[i]); } for (var i = 0; i < 1844; i++) { - re1.exec('uggc://jjj.snprobbx.pbz/ybtva.cuc'); + re1.exec(s1[i]); } for (var i = 0; i < 739; i++) { - 'QBZPbageby_cynprubyqre'.replace(re2, ''); + s2[i].replace(re2, ''); } for (var i = 0; i < 598; i++) { - re1.exec('uggc://jjj.snprobbx.pbz/'); + re1.exec(s3[i]); } for (var i = 0; i < 454; i++) { - re1.exec('uggc://jjj.snprobbx.pbz/fepu.cuc'); + re1.exec(s4[i]); } for (var i = 0; i < 352; i++) { - /qqqq|qqq|qq|q|ZZZZ|ZZZ|ZZ|Z|llll|ll|l|uu|u|UU|U|zz|z|ff|f|gg|g|sss|ss|s|mmm|mm|m/g.exec('qqqq, ZZZ q, llll'); + /qqqq|qqq|qq|q|ZZZZ|ZZZ|ZZ|Z|llll|ll|l|uu|u|UU|U|zz|z|ff|f|gg|g|sss|ss|s|mmm|mm|m/g.exec(s5[i]); } for (var i = 0; i < 312; i++) { - re3.exec('vachggrkg QBZPbageby_cynprubyqre'); + re3.exec(s6[i]); } for (var i = 0; i < 282; i++) { - re4.exec('/ZlFcnprUbzrcntr/Vaqrk-FvgrUbzr,10000000'); + re4.exec(s7[i]); } for (var i = 0; i < 177; i++) { - 'vachggrkg'.replace(re5, ''); + s8[i].replace(re5, ''); } for (var i = 0; i < 170; i++) { - '528.9'.replace(re6, ''); - re7.exec('528'); + s9[i].replace(re6, ''); + re7.exec(s10[i]); } for (var i = 0; i < 156; i++) { - re8.exec('VCPhygher=ra-HF'); - re8.exec('CersreerqPhygher=ra-HF'); + re8.exec(s11[i]); + re8.exec(s12[i]); } for (var i = 0; i < 144; i++) { - re0.exec('xrlcerff'); + re0.exec(s13[i]); } for (var i = 0; i < 139; i++) { - '521'.replace(re6, ''); - re7.exec('521'); + s14[i].replace(re6, ''); + re7.exec(s14[i]); re9.exec(''); - /JroXvg\/(\S+)/.exec(str0); + /JroXvg\/(\S+)/.exec(s15[i]); } for (var i = 0; i < 137; i++) { - 'qvi .so_zrah'.replace(re10, ''); - 'qvi .so_zrah'.replace(/\[/g, ''); - 'qvi.so_zrah'.replace(re11, ''); + s16[i].replace(re10, ''); + s16[i].replace(/\[/g, ''); + s17[i].replace(re11, ''); } for (var i = 0; i < 117; i++) { - 'uvqqra_ryrz'.replace(re2, ''); + s18[i].replace(re2, ''); } for (var i = 0; i < 95; i++) { - /(?:^|;)\s*sevraqfgre_ynat=([^;]*)/.exec('sevraqfgre_naba=nvq%3Qn6ss9p85n868ro9s059pn854735956o3%26ers%3Q%26df%3Q%26vpgl%3QHF'); + /(?:^|;)\s*sevraqfgre_ynat=([^;]*)/.exec(s19[i]); } for (var i = 0; i < 93; i++) { - 'uggc://ubzr.zlfcnpr.pbz/vaqrk.psz'.replace(re12, ''); - re13.exec('uggc://ubzr.zlfcnpr.pbz/vaqrk.psz'); + s20[i].replace(re12, ''); + re13.exec(s20[i]); } for (var i = 0; i < 92; i++) { - str1.replace(/([a-zA-Z]|\s)+/, ''); + s21[i].replace(/([a-zA-Z]|\s)+/, ''); } for (var i = 0; i < 85; i++) { - 'svefg'.replace(re14, ''); - 'svefg'.replace(re15, ''); - 'uggc://cebsvyr.zlfcnpr.pbz/vaqrk.psz'.replace(re12, ''); - 'ynfg'.replace(re14, ''); - 'ynfg'.replace(re15, ''); - re16.exec('qvfcynl'); - re13.exec('uggc://cebsvyr.zlfcnpr.pbz/vaqrk.psz'); + s22[i].replace(re14, ''); + s22[i].replace(re15, ''); + s23[i].replace(re12, ''); + s24[i].replace(re14, ''); + s24[i].replace(re15, ''); + re16.exec(s25[i]); + re13.exec(s23[i]); } } var re17 = /(^|[^\\])\"\\\/Qngr\((-?[0-9]+)\)\\\/\"/g; @@ -145,64 +203,98 @@ function runRegExpBenchmark() { var str7 = ';;jvaqbj.IjPurpxZbhfrCbfvgvbaNQ_VQ=shapgvba(r){vs(!r)ine r=jvaqbj.rirag;ine c=-1;vs(d1)c=d1.EbyybssCnary;ine bo=IjTrgBow("IjCnayNQ_VQ_"+c);vs(bo&&bo.fglyr.ivfvovyvgl=="ivfvoyr"){ine fns=IjFns?8:0;ine pheK=r.pyvragK+IjBOFpe("U")+fns,pheL=r.pyvragL+IjBOFpe("I")+fns;ine y=IjBOEC(NQ_VQ,bo,"Y"),g=IjBOEC(NQ_VQ,bo,"G");ine e=y+d1.Cnaryf[c].Jvqgu,o=g+d1.Cnaryf[c].Urvtug;vs((pheKe)||(pheLo)){vs(jvaqbj.IjBaEbyybssNQ_VQ)IjBaEbyybssNQ_VQ(c);ryfr IjPybfrNq(NQ_VQ,c,gehr,"");}ryfr erghea;}IjPnapryZbhfrYvfgrareNQ_VQ();};;jvaqbj.IjFrgEbyybssCnaryNQ_VQ=shapgvba(c){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;c=IjTc(NQ_VQ,c);vs(d1&&d1.EbyybssCnary>-1)IjPnapryZbhfrYvfgrareNQ_VQ();vs(d1)d1.EbyybssCnary=c;gel{vs(q.nqqRiragYvfgrare)q.nqqRiragYvfgrare(z,s,snyfr);ryfr vs(q.nggnpuRirag)q.nggnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjPnapryZbhfrYvfgrareNQ_VQ=shapgvba(){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;vs(d1)d1.EbyybssCnary=-1;gel{vs(q.erzbirRiragYvfgrare)q.erzbirRiragYvfgrare(z,s,snyfr);ryfr vs(q.qrgnpuRirag)q.qrgnpuRirag("ba"+z,s);}pngpu(r){}};;d1.IjTc=d2(n,c){ine nq=d1;vs(vfAnA(c)){sbe(ine v=0;v0){vs(nq.FzV.yratgu>0)nq.FzV+="/";nq.FzV+=vh[v];nq.FtZ[nq.FtZ.yratgu]=snyfr;}}};;d1.IjYvzvg0=d2(n,f){ine nq=d1,vh=f.fcyvg("/");sbe(ine v=0;v0){vs(nq.OvC.yratgu>0)nq.OvC+="/";nq.OvC+=vh[v];}}};;d1.IjRVST=d2(n,c){jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]=IjTrgBow("IjCnayNQ_VQ_"+c+"_Bow");vs(jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]==ahyy)frgGvzrbhg("IjRVST(NQ_VQ,"+c+")",d1.rvsg);};;d1.IjNavzSHC=d2(n,c){ine nq=d1;vs(c>nq.Cnaryf.yratgu)erghea;ine cna=nq.Cnaryf[c],nn=gehr,on=gehr,yn=gehr,en=gehr,cn=nq.Cnaryf[0],sf=nq.ShF,j=cn.Jvqgu,u=cn.Urvtug;vs(j=="100%"){j=sf;en=snyfr;yn=snyfr;}vs(u=="100%"){u=sf;nn=snyfr;on=snyfr;}vs(cn.YnY=="Y")yn=snyfr;vs(cn.YnY=="E")en=snyfr;vs(cn.GnY=="G")nn=snyfr;vs(cn.GnY=="O")on=snyfr;ine k=0,l=0;fjvgpu(nq.NshP%8){pnfr 0:oernx;pnfr 1:vs(nn)l=-sf;oernx;pnfr 2:k=j-sf;oernx;pnfr 3:vs(en)k=j;oernx;pnfr 4:k=j-sf;l=u-sf;oernx;pnfr 5:k=j-sf;vs(on)l=u;oernx;pnfr 6:l=u-sf;oernx;pnfr 7:vs(yn)k=-sf;l=u-sf;oernx;}vs(nq.NshP++ 0)||(nethzragf.yratgu==3&&bG>0))){pyrneGvzrbhg(cay.UgU);cay.UgU=frgGvzrbhg(cay.UvqrNpgvba,(nethzragf.yratgu==3?bG:cay.UvqrGvzrbhgInyhr));}};;d1.IjErfrgGvzrbhg=d2(n,c,bG){c=IjTc(n,c);IjPnapryGvzrbhg(n,c);riny("IjFgnegGvzrbhg(NQ_VQ,c"+(nethzragf.yratgu==3?",bG":"")+")");};;d1.IjErfrgNyyGvzrbhgf=d2(n){sbe(ine c=0;c'.replace(re55, ''); ''.replace(re55, ''); - str1.replace(/^.*\s+(\S+\s+\S+$)/, ''); + s21[i].replace(/^.*\s+(\S+\s+\S+$)/, ''); 'tzk%2Subzrcntr%2Sfgneg%2Sqr%2S'.replace(re30, ''); 'tzk'.replace(re30, ''); 'uggc://${ubfg}${cngu}/${dz}'.replace(/(\$\{ubfg\})|(\$ubfg\b)/g, ''); @@ -549,61 +671,70 @@ function runRegExpBenchmark() { var re62 = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; var str34 = '${1}://${2}${3}${4}${5}'; var str35 = ' O=6gnyg0g4znrrn&o=3&f=gc; Q=_lyu=K3bQZGSxnT4lZzD3OS9GNmV3ZGLkAQxRpTyxNmRlZmRmAmNkAQLRqTImqNZjOUEgpTjQnJ5xMKtgoN--; SCF=qy'; + var s83 = computeInputVariants(str27, 11); + var s84 = computeInputVariants(str28, 11); + var s85 = computeInputVariants(str29, 11); + var s86 = computeInputVariants(str30, 11); + var s87 = computeInputVariants(str31, 11); + var s88 = computeInputVariants(str32, 11); + var s89 = computeInputVariants(str33, 11); + var s90 = computeInputVariants(str34, 11); + function runBlock6() { for (var i = 0; i < 11; i++) { - str27.replace(/##yv0##/gi, ''); - str27.replace(re57, ''); - str28.replace(re58, ''); - str29.replace(re59, ''); - str30.replace(/##\/o##/gi, ''); - str30.replace(/##\/v##/gi, ''); - str30.replace(/##\/h##/gi, ''); - str30.replace(/##o##/gi, ''); - str30.replace(/##oe##/gi, ''); - str30.replace(/##v##/gi, ''); - str30.replace(/##h##/gi, ''); - str31.replace(/##n##/gi, ''); - str32.replace(/##\/n##/gi, ''); - str33.replace(/#~#argjbexybtb#~#/g, ''); - / Zbovyr\//.exec(str0); - /##yv1##/gi.exec(str27); - /##yv10##/gi.exec(str28); - /##yv11##/gi.exec(str28); - /##yv12##/gi.exec(str28); - /##yv13##/gi.exec(str28); - /##yv14##/gi.exec(str28); - /##yv15##/gi.exec(str28); - re58.exec(str28); - /##yv17##/gi.exec(str29); - /##yv18##/gi.exec(str29); - re59.exec(str29); - /##yv2##/gi.exec(str27); - /##yv20##/gi.exec(str30); - /##yv21##/gi.exec(str30); - /##yv22##/gi.exec(str30); - /##yv23##/gi.exec(str30); - /##yv3##/gi.exec(str27); - re57.exec(str27); - /##yv5##/gi.exec(str28); - /##yv6##/gi.exec(str28); - /##yv7##/gi.exec(str28); - /##yv8##/gi.exec(str28); - /##yv9##/gi.exec(str28); + s83[i].replace(/##yv0##/gi, ''); + s83[i].replace(re57, ''); + s84[i].replace(re58, ''); + s85[i].replace(re59, ''); + s86[i].replace(/##\/o##/gi, ''); + s86[i].replace(/##\/v##/gi, ''); + s86[i].replace(/##\/h##/gi, ''); + s86[i].replace(/##o##/gi, ''); + s86[i].replace(/##oe##/gi, ''); + s86[i].replace(/##v##/gi, ''); + s86[i].replace(/##h##/gi, ''); + s87[i].replace(/##n##/gi, ''); + s88[i].replace(/##\/n##/gi, ''); + s89[i].replace(/#~#argjbexybtb#~#/g, ''); + / Zbovyr\//.exec(s15[i]); + /##yv1##/gi.exec(s83[i]); + /##yv10##/gi.exec(s84[i]); + /##yv11##/gi.exec(s84[i]); + /##yv12##/gi.exec(s84[i]); + /##yv13##/gi.exec(s84[i]); + /##yv14##/gi.exec(s84[i]); + /##yv15##/gi.exec(s84[i]); + re58.exec(s84[i]); + /##yv17##/gi.exec(s85[i]); + /##yv18##/gi.exec(s85[i]); + re59.exec(s85[i]); + /##yv2##/gi.exec(s83[i]); + /##yv20##/gi.exec(s86[i]); + /##yv21##/gi.exec(s86[i]); + /##yv22##/gi.exec(s86[i]); + /##yv23##/gi.exec(s86[i]); + /##yv3##/gi.exec(s83[i]); + re57.exec(s83[i]); + /##yv5##/gi.exec(s84[i]); + /##yv6##/gi.exec(s84[i]); + /##yv7##/gi.exec(s84[i]); + /##yv8##/gi.exec(s84[i]); + /##yv9##/gi.exec(s84[i]); re8.exec('473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29'); re8.exec('SbeprqRkcvengvba=633669325184628362'); re8.exec('FrffvbaQQS2=473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29'); - /AbxvnA[^\/]*/.exec(str0); + /AbxvnA[^\/]*/.exec(s15[i]); } for (var i = 0; i < 10; i++) { ' bss'.replace(/(?:^|\s+)bss(?:\s+|$)/g, ''); - str34.replace(/(\$\{0\})|(\$0\b)/g, ''); - str34.replace(/(\$\{1\})|(\$1\b)/g, ''); - str34.replace(/(\$\{pbzcyrgr\})|(\$pbzcyrgr\b)/g, ''); - str34.replace(/(\$\{sentzrag\})|(\$sentzrag\b)/g, ''); - str34.replace(/(\$\{ubfgcbeg\})|(\$ubfgcbeg\b)/g, ''); - str34.replace(re56, ''); - str34.replace(/(\$\{cebgbpby\})|(\$cebgbpby\b)/g, ''); - str34.replace(/(\$\{dhrel\})|(\$dhrel\b)/g, ''); + s90[i].replace(/(\$\{0\})|(\$0\b)/g, ''); + s90[i].replace(/(\$\{1\})|(\$1\b)/g, ''); + s90[i].replace(/(\$\{pbzcyrgr\})|(\$pbzcyrgr\b)/g, ''); + s90[i].replace(/(\$\{sentzrag\})|(\$sentzrag\b)/g, ''); + s90[i].replace(/(\$\{ubfgcbeg\})|(\$ubfgcbeg\b)/g, ''); + s90[i].replace(re56, ''); + s90[i].replace(/(\$\{cebgbpby\})|(\$cebgbpby\b)/g, ''); + s90[i].replace(/(\$\{dhrel\})|(\$dhrel\b)/g, ''); 'nqfvmr'.replace(re29, ''); 'nqfvmr'.replace(re30, ''); 'uggc://${2}${3}${4}${5}'.replace(/(\$\{2\})|(\$2\b)/g, ''); @@ -629,7 +760,7 @@ function runRegExpBenchmark() { re9.exec('zrqvgobk'); re9.exec('hsgy'); re9.exec('lhv-h'); - /Fnsnev|Xbadhrebe|XUGZY/gi.exec(str0); + /Fnsnev|Xbadhrebe|XUGZY/gi.exec(s15[i]); re61.exec('uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/onfr.wf'); re62.exec('#Ybtva_rznvy'); } @@ -640,6 +771,9 @@ function runRegExpBenchmark() { var str38 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231364057761&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231364057761&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Ssevraqf.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1667363813.1231364061&tn_fvq=1231364061&tn_uvq=1917563877&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; var str39 = 'ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669321699093060&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; var str40 = 'ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669321699093060&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var s91 = computeInputVariants(str36, 9); + var s92 = computeInputVariants(str37, 9); + var s93 = computeInputVariants(str38, 9); function runBlock7() { for (var i = 0; i < 9; i++) { '0'.replace(re40, ''); @@ -660,15 +794,15 @@ function runRegExpBenchmark() { for (var i = 0; i < 8; i++) { 'Pybfr {0}'.replace(re63, ''); 'Bcra {0}'.replace(re63, ''); - str36.split(re32); - str37.split(re32); + s91[i].split(re32); + s92[i].split(re32); 'puvyq p1 svefg gnournqref'.replace(re14, ''); 'puvyq p1 svefg gnournqref'.replace(re15, ''); 'uqy_fcb'.replace(re14, ''); 'uqy_fcb'.replace(re15, ''); 'uvag'.replace(re14, ''); 'uvag'.replace(re15, ''); - str38.replace(re33, ''); + s93[i].replace(re33, ''); 'yvfg'.replace(re14, ''); 'yvfg'.replace(re15, ''); 'at_bhgre'.replace(re30, ''); @@ -697,8 +831,8 @@ function runRegExpBenchmark() { re8.exec('__hgzo=144631658.0.10.1231364074'); re8.exec('__hgzm=144631658.1231364074.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); re8.exec('p98s8o9q42nr21or1r61pqorn1n002nsss569635984s6qp7'); - re34.exec(str36); - re34.exec(str37); + re34.exec(s91[i]); + re34.exec(s92[i]); } } var re64 = /\b[a-z]/g; @@ -707,7 +841,7 @@ function runRegExpBenchmark() { var str41 = 'uggc://cebsvyr.zlfcnpr.pbz/Zbqhyrf/Nccyvpngvbaf/Cntrf/Pnainf.nfck'; function runBlock8() { for (var i = 0; i < 7; i++) { - str1.match(/\d+/g); + s21[i].match(/\d+/g); 'nsgre'.replace(re64, ''); 'orsber'.replace(re64, ''); 'obggbz'.replace(re64, ''); @@ -741,9 +875,9 @@ function runRegExpBenchmark() { re19.exec('gno6'); re19.exec('gno7'); re19.exec('gno8'); - /NqborNVE\/([^\s]*)/.exec(str0); - /NccyrJroXvg\/([^ ]*)/.exec(str0); - /XUGZY/gi.exec(str0); + /NqborNVE\/([^\s]*)/.exec(s15[i]); + /NccyrJroXvg\/([^ ]*)/.exec(s15[i]); + /XUGZY/gi.exec(s15[i]); /^(?:obql|ugzy)$/i.exec('YV'); re38.exec('ohggba'); re38.exec('vachg'); @@ -774,14 +908,14 @@ function runRegExpBenchmark() { 'freivpr'.replace(re46, ''); 'freivpr'.replace(re47, ''); 'freivpr'.replace(re48, ''); - /((ZFVR\s+([6-9]|\d\d)\.))/.exec(str0); + /((ZFVR\s+([6-9]|\d\d)\.))/.exec(s15[i]); re66.exec(''); re50.exec('fryrpgrq'); re8.exec('8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn'); re8.exec('SbeprqRkcvengvba=633669340386893867'); re8.exec('VC=74.125.75.17'); re8.exec('FrffvbaQQS2=8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn'); - /Xbadhrebe|Fnsnev|XUGZY/.exec(str0); + /Xbadhrebe|Fnsnev|XUGZY/.exec(s15[i]); re13.exec(str41); re49.exec('unfsbphf'); } @@ -826,12 +960,23 @@ function runRegExpBenchmark() { var str61 = 'uggc://gx2.fgp.f-zfa.pbz/oe/uc/11/ra-hf/pff/v/g.tvs#uggc://gx2.fgo.f-zfa.pbz/v/29/4RQP4969777N048NPS4RRR3PO2S7S.wct'; var str62 = 'uggc://gx2.fgp.f-zfa.pbz/oe/uc/11/ra-hf/pff/v/g.tvs#uggc://gx2.fgo.f-zfa.pbz/v/OQ/63NP9O94NS5OQP1249Q9S1ROP7NS3.wct'; var str63 = 'zbmvyyn/5.0 (jvaqbjf; h; jvaqbjf ag 5.1; ra-hf) nccyrjroxvg/528.9 (xugzy, yvxr trpxb) puebzr/2.0.157.0 fnsnev/528.9'; + var s94 = computeInputVariants(str42, 5); + var s95 = computeInputVariants(str43, 5); + var s96 = computeInputVariants(str44, 5); + var s97 = computeInputVariants(str47, 5); + var s98 = computeInputVariants(str48, 5); + var s99 = computeInputVariants(str49, 5); + var s100 = computeInputVariants(str50, 5); + var s101 = computeInputVariants(str51, 5); + var s102 = computeInputVariants(str52, 5); + var s103 = computeInputVariants(str53, 5); + function runBlock9() { for (var i = 0; i < 5; i++) { - str42.split(re32); - str43.split(re32); + s94[i].split(re32); + s95[i].split(re32); 'svz_zlfcnpr_hfre-ivrj-pbzzragf,svz_zlfcnpr_havgrq-fgngrf'.split(re20); - str44.replace(re33, ''); + s96[i].replace(re33, ''); 'zrah_arj zrah_arj_gbttyr zrah_gbttyr'.replace(re67, ''); 'zrah_byq zrah_byq_gbttyr zrah_gbttyr'.replace(re67, ''); re8.exec('102n9o0o9pq60132qn0337rr867p75953502q2s27s2s5r98'); @@ -855,12 +1000,12 @@ function runRegExpBenchmark() { ' yvfg2'.replace(re15, ''); ' frneputebhc1'.replace(re14, ''); ' frneputebhc1'.replace(re15, ''); - str47.replace(re68, ''); - str47.replace(re18, ''); + s97[i].replace(re68, ''); + s97[i].replace(re18, ''); ''.replace(/&/g, ''); ''.replace(re35, ''); '(..-{0})(\|(\d+)|)'.replace(re63, ''); - str48.replace(re18, ''); + s98[i].replace(re18, ''); '//vzt.jro.qr/vij/FC/${cngu}/${anzr}/${inyhr}?gf=${abj}'.replace(re56, ''); '//vzt.jro.qr/vij/FC/tzk_uc/${anzr}/${inyhr}?gf=${abj}'.replace(/(\$\{anzr\})|(\$anzr\b)/g, ''); 'Jvaqbjf Yvir Ubgznvy{1}'.replace(re69, ''); @@ -872,8 +1017,8 @@ function runRegExpBenchmark() { 'Zncf'.replace(re15, ''); 'Zbq-Vasb-Vasb-WninFpevcgUvag'.replace(re39, ''); 'Arjf'.replace(re15, ''); - str49.split(re32); - str50.split(re32); + s99[i].split(re32); + s100[i].split(re32); 'Ivqrb'.replace(re15, ''); 'Jro'.replace(re15, ''); 'n'.replace(re39, ''); @@ -907,17 +1052,17 @@ function runRegExpBenchmark() { 'uc_fubccvatobk'.replace(re30, ''); 'ugzy%2Rvq'.replace(re29, ''); 'ugzy%2Rvq'.replace(re30, ''); - str51.replace(re33, ''); + s101[i].replace(re33, ''); 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/cebgbglcr.wf${4}${5}'.replace(re71, ''); 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/cebgbglcr.wf${5}'.replace(re72, ''); - str52.replace(re73, ''); + s102[i].replace(re73, ''); 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/f55332979829981?[NDO]&{1}&{2}&[NDR]'.replace(re69, ''); 'vztZFSG'.replace(re14, ''); 'vztZFSG'.replace(re15, ''); 'zfasbbg1 ps'.replace(re14, ''); 'zfasbbg1 ps'.replace(re15, ''); - str53.replace(re14, ''); - str53.replace(re15, ''); + s103[i].replace(re14, ''); + s103[i].replace(re15, ''); 'cnerag puebzr6 fvatyr1 gno fryrpgrq ovaq'.replace(re14, ''); 'cnerag puebzr6 fvatyr1 gno fryrpgrq ovaq'.replace(re15, ''); 'cevznel'.replace(re14, ''); @@ -945,11 +1090,11 @@ function runRegExpBenchmark() { re8.exec('__hgzn=144631658.2770915348920628700.1231367708.1231367708.1231367708.1'); re8.exec('__hgzo=144631658.0.10.1231367708'); re8.exec('__hgzm=144631658.1231367708.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); - re34.exec(str49); - re34.exec(str50); - /ZFVR\s+5[.]01/.exec(str0); + re34.exec(s99[i]); + re34.exec(s100[i]); + /ZFVR\s+5[.]01/.exec(s15[i]); /HF(?=;)/i.exec(str56); - re74.exec(str47); + re74.exec(s97[i]); re28.exec('svefg npgvir svefgNpgvir'); re28.exec('ynfg'); /\bp:(..)/i.exec('m:94043|yn:37.4154|yb:-122.0585|p:HF'); @@ -967,15 +1112,15 @@ function runRegExpBenchmark() { re79.exec(str60); re79.exec(str59); /\|p:([a-z]{2})/i.exec('m:94043|yn:37.4154|yb:-122.0585|p:HF|ue:1'); - re80.exec(str47); + re80.exec(s97[i]); re61.exec('cebgbglcr.wf'); - re68.exec(str47); - re81.exec(str47); - re82.exec(str47); - /^Fubpxjnir Synfu (\d)/.exec(str1); - /^Fubpxjnir Synfu (\d+)/.exec(str1); + re68.exec(s97[i]); + re81.exec(s97[i]); + re82.exec(s97[i]); + /^Fubpxjnir Synfu (\d)/.exec(s21[i]); + /^Fubpxjnir Synfu (\d+)/.exec(s21[i]); re83.exec('[bowrpg tybony]'); - re62.exec(str47); + re62.exec(s97[i]); re84.exec(str61); re84.exec(str62); /jroxvg/.exec(str63); @@ -1597,18 +1742,23 @@ function runRegExpBenchmark() { /jvaqbjf/.exec(str63); } } - for (var i = 0; i < 5; i++) { - runBlock0(); - runBlock1(); - runBlock2(); - runBlock3(); - runBlock4(); - runBlock5(); - runBlock6(); - runBlock7(); - runBlock8(); - runBlock9(); - runBlock10(); - runBlock11(); + + function run() { + for (var i = 0; i < 5; i++) { + runBlock0(); + runBlock1(); + runBlock2(); + runBlock3(); + runBlock4(); + runBlock5(); + runBlock6(); + runBlock7(); + runBlock8(); + runBlock9(); + runBlock10(); + runBlock11(); + } } + + this.run = run; } diff --git a/benchmarks/revisions.html b/benchmarks/revisions.html index 99d7be42b96..6ff75be1e13 100644 --- a/benchmarks/revisions.html +++ b/benchmarks/revisions.html @@ -20,6 +20,20 @@

+

Version 6 (link)

+ +

Removed dead code from the RayTrace benchmark and fixed a couple of +typos in the DeltaBlue implementation. Changed the Splay benchmark to +avoid converting the same numeric key to a string over and over again +and to avoid inserting and removing the same element repeatedly thus +increasing pressure on the memory subsystem. Changed the RegExp +benchmark to exercise the regular expression engine on different input +strings.

+ +

Furthermore, the benchmark runner was changed to run the benchmarks +for at least a few times to stabilize the reported numbers on slower +machines.

+

Version 5 (link)

Removed duplicate line in random seed code, and changed the name of diff --git a/benchmarks/richards.js b/benchmarks/richards.js index c9368eff91a..054928db16f 100644 --- a/benchmarks/richards.js +++ b/benchmarks/richards.js @@ -35,7 +35,7 @@ // Martin Richards. -var Richards = new BenchmarkSuite('Richards', 34886, [ +var Richards = new BenchmarkSuite('Richards', 35302, [ new Benchmark("Richards", runRichards) ]); diff --git a/benchmarks/run.html b/benchmarks/run.html index ef2c186412b..36d2ad511b1 100644 --- a/benchmarks/run.html +++ b/benchmarks/run.html @@ -111,12 +111,12 @@

  • Richards
    OS kernel simulation benchmark, originally written in BCPL by Martin Richards (539 lines).
  • DeltaBlue
    One-way constraint solver, originally written in Smalltalk by John Maloney and Mario Wolczko (880 lines).
  • Crypto
    Encryption and decryption benchmark based on code by Tom Wu (1698 lines).
  • -
  • RayTrace
    Ray tracer benchmark based on code by Adam Burmister (935 lines).
  • -
  • EarleyBoyer
    Classic Scheme benchmarks, translated to JavaScript by Florian Loitsch's Scheme2Js compiler (4685 lines).
  • +
  • RayTrace
    Ray tracer benchmark based on code by Adam Burmister (904 lines).
  • +
  • EarleyBoyer
    Classic Scheme benchmarks, translated to JavaScript by Florian Loitsch's Scheme2Js compiler (4684 lines).
  • RegExp
    Regular expression benchmark generated by extracting regular expression operations from 50 of the most popular web pages -(1614 lines). +(1761 lines).
  • -
  • Splay
    Data manipulation benchmark that deals with splay trees and exercises the automatic memory management subsystem (378 lines).
  • +
  • Splay
    Data manipulation benchmark that deals with splay trees and exercises the automatic memory management subsystem (394 lines).
  • diff --git a/benchmarks/splay.js b/benchmarks/splay.js index 53fc72793e4..6b4f56d3213 100644 --- a/benchmarks/splay.js +++ b/benchmarks/splay.js @@ -33,7 +33,7 @@ // also has to deal with a lot of changes to the large tree object // graph. -var Splay = new BenchmarkSuite('Splay', 126125, [ +var Splay = new BenchmarkSuite('Splay', 81491, [ new Benchmark("Splay", SplayRun, SplaySetup, SplayTearDown) ]); @@ -46,16 +46,16 @@ var kSplayTreePayloadDepth = 5; var splayTree = null; -function GeneratePayloadTree(depth, key) { +function GeneratePayloadTree(depth, tag) { if (depth == 0) { return { array : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], - string : 'String for key ' + key + ' in leaf node' + string : 'String for key ' + tag + ' in leaf node' }; } else { return { - left: GeneratePayloadTree(depth - 1, key), - right: GeneratePayloadTree(depth - 1, key) + left: GeneratePayloadTree(depth - 1, tag), + right: GeneratePayloadTree(depth - 1, tag) }; } } @@ -74,7 +74,8 @@ function InsertNewNode() { do { key = GenerateKey(); } while (splayTree.find(key) != null); - splayTree.insert(key, GeneratePayloadTree(kSplayTreePayloadDepth, key)); + var payload = GeneratePayloadTree(kSplayTreePayloadDepth, String(key)); + splayTree.insert(key, payload); return key; } @@ -229,9 +230,24 @@ SplayTree.prototype.find = function(key) { }; +/** + * @return {SplayTree.Node} Node having the maximum key value. + */ +SplayTree.prototype.findMax = function(opt_startNode) { + if (this.isEmpty()) { + return null; + } + var current = opt_startNode || this.root_; + while (current.right) { + current = current.right; + } + return current; +}; + + /** * @return {SplayTree.Node} Node having the maximum key value that - * is less or equal to the specified key value. + * is less than the specified key value. */ SplayTree.prototype.findGreatestLessThan = function(key) { if (this.isEmpty()) { @@ -242,7 +258,7 @@ SplayTree.prototype.findGreatestLessThan = function(key) { this.splay_(key); // Now the result is either the root node or the greatest node in // the left subtree. - if (this.root_.key <= key) { + if (this.root_.key < key) { return this.root_; } else if (this.root_.left) { return this.findMax(this.root_.left); diff --git a/build/README.txt b/build/README.txt new file mode 100644 index 00000000000..c74b52051a8 --- /dev/null +++ b/build/README.txt @@ -0,0 +1,66 @@ +This directory contains the V8 GYP files used to generate actual project files +for different build systems. + +This is currently work in progress but this is expected to replace the SCons +based build system. + +To use this a checkout of GYP is needed inside this directory. From the root of +the V8 project do the following: + +$ svn co http://gyp.googlecode.com/svn/trunk build/gyp + +Note for the command lines below that Debug is the default configuration, +so specifying that on the command lines is not required. + + +To generate Makefiles on Linux: +------------------------------- + +$ build/gyp_v8 + +This will build makefiles for ia32, x64 and the ARM simulator with names +Makefile-ia32, Makefile-x64 and Makefile-armu respectively. + +To build and run for ia32 in debug and release version do: + +$ make -f Makefile-ia32 +$ out/Debug/shell +$ make -f Makefile-ia32 BUILDTYPE=Release +$ out/Release/shell + +Change the makefile to build and run for the other architectures. + + +To generate Xcode project files on Mac OS: +------------------------------------------ + +$ build/gyp_v8 + +This will make an Xcode project for the ia32 architecture. To build and run do: + +$ xcodebuild -project build/all.xcodeproj +$ samples/build/Debug/shell +$ xcodebuild -project build/all.xcodeproj -configuration Release +$ samples/build/Release/shell + + +To generate Visual Studio solution and project files on Windows: +---------------------------------------------------------------- + +On Windows an additional third party component is required. This is cygwin in +the same version as is used by the Chromium project. This can be checked out +from the Chromium repository. From the root of the V8 project do the following: + +> svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin + +To run GYP Python is required and it is reccomended to use the same version as +is used by the Chromium project. This can also be checked out from the Chromium +repository. From the root of the V8 project do the following: + +> svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@70627 third_party/python_26 + +Now generate Visual Studio solution and project files for the ia32 architecture: + +> third_party\python_26\python build/gyp_v8 + +Now open build\All.sln in Visual Studio. diff --git a/build/all.gyp b/build/all.gyp new file mode 100644 index 00000000000..544e2c299a3 --- /dev/null +++ b/build/all.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'All', + 'type': 'none', + 'dependencies': [ + '../samples/samples.gyp:*', + '../test/cctest/cctest.gyp:*', + '../src/d8.gyp:*', + ] + } + ] +} + diff --git a/build/armu.gypi b/build/armu.gypi new file mode 100644 index 00000000000..3f874c00f3e --- /dev/null +++ b/build/armu.gypi @@ -0,0 +1,36 @@ +# 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': { + 'target_arch': 'ia32', + 'v8_target_arch': 'arm', + 'armv7': 1, + 'arm_neon': 0, + 'arm_fpu': 'vfpv3', + } +} diff --git a/build/common.gypi b/build/common.gypi new file mode 100644 index 00000000000..702049581c1 --- /dev/null +++ b/build/common.gypi @@ -0,0 +1,183 @@ +# Copyright 2010 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': { + 'library%': 'static_library', + 'component%': 'static_library', + 'visibility%': 'hidden', + 'variables': { + 'conditions': [ + [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', { + # This handles the Linux platforms we generally deal with. Anything + # else gets passed through, which probably won't work very well; such + # hosts should pass an explicit target_arch to gyp. + 'host_arch%': + ' 2: + specified_includes.add(os.path.realpath(arg[2:])) + + result = [] + def AddInclude(path): + if os.path.realpath(path) not in specified_includes: + result.append(path) + + # Always include common.gypi & features_override.gypi + AddInclude(os.path.join(script_dir, 'common.gypi')) + + # Optionally add supplemental .gypi files if present. + supplements = glob.glob(os.path.join(v8_root, '*', 'supplement.gypi')) + for supplement in supplements: + AddInclude(supplement) + + return result + + +def run_gyp(args): + rc = gyp.main(args) + if rc != 0: + print 'Error running GYP' + sys.exit(rc) + + +if __name__ == '__main__': + args = sys.argv[1:] + + if 'SKIP_V8_GYP_ENV' not in os.environ: + # Update the environment based on v8.gyp_env + gyp_env_path = os.path.join(os.path.dirname(v8_root), 'v8.gyp_env') + apply_gyp_environment(gyp_env_path) + + # This could give false positives since it doesn't actually do real option + # parsing. Oh well. + gyp_file_specified = False + for arg in args: + if arg.endswith('.gyp'): + gyp_file_specified = True + break + + # If we didn't get a file, check an env var, and then fall back to + # assuming 'all.gyp' from the same directory as the script. + if not gyp_file_specified: + gyp_file = os.environ.get('V8_GYP_FILE') + if gyp_file: + # Note that V8_GYP_FILE values can't have backslashes as + # path separators even on Windows due to the use of shlex.split(). + args.extend(shlex.split(gyp_file)) + else: + args.append(os.path.join(script_dir, 'all.gyp')) + + args.extend(['-I' + i for i in additional_include_files(args)]) + + # There shouldn't be a circular dependency relationship between .gyp files + args.append('--no-circular-check') + + # Set the GYP DEPTH variable to the root of the V8 project. + args.append('--depth=' + v8_root) + + # If V8_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check + # to enfore syntax checking. + syntax_check = os.environ.get('V8_GYP_SYNTAX_CHECK') + if syntax_check and int(syntax_check): + args.append('--check') + + print 'Updating projects from gyp files...' + sys.stdout.flush() + + # Generate for the architectures supported on the given platform. + gyp_args = list(args) + gyp_args.append('-Dtarget_arch=ia32') + if utils.GuessOS() == 'linux': + gyp_args.append('-S-ia32') + run_gyp(gyp_args) + + if utils.GuessOS() == 'linux': + gyp_args = list(args) + gyp_args.append('-Dtarget_arch=x64') + gyp_args.append('-S-x64') + run_gyp(gyp_args) + + gyp_args = list(args) + gyp_args.append('-I' + v8_root + '/build/armu.gypi') + gyp_args.append('-S-armu') + run_gyp(gyp_args) diff --git a/build/v8-features.gypi b/build/v8-features.gypi new file mode 100644 index 00000000000..40374523ad5 --- /dev/null +++ b/build/v8-features.gypi @@ -0,0 +1,125 @@ +# 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. + +# TODO(sgjesse): This is currently copied from v8.gyp, should probably +# be refactored. +{ + 'variables': { + 'use_system_v8%': 0, + 'msvs_use_common_release': 0, + 'gcc_version%': 'unknown', + 'v8_compress_startup_data%': 'off', + 'v8_target_arch%': '<(target_arch)', + + # Setting 'v8_can_use_unaligned_accesses' to 'true' will allow the code + # generated by V8 to do unaligned memory access, and setting it to 'false' + # will ensure that the generated code will always do aligned memory + # accesses. The default value of 'default' will try to determine the correct + # setting. Note that for Intel architectures (ia32 and x64) unaligned memory + # access is allowed for all CPUs. + 'v8_can_use_unaligned_accesses%': 'default', + + # Setting 'v8_can_use_vfp_instructions' to 'true' will enable use of ARM VFP + # instructions in the V8 generated code. VFP instructions will be enabled + # both for the snapshot and for the ARM target. Leaving the default value + # of 'false' will avoid VFP instructions in the snapshot and use CPU feature + # probing when running on the target. + 'v8_can_use_vfp_instructions%': 'false', + + # Setting v8_use_arm_eabi_hardfloat to true will turn on V8 support for ARM + # EABI calling convention where double arguments are passed in VFP + # registers. Note that the GCC flag '-mfloat-abi=hard' should be used as + # well when compiling for the ARM target. + 'v8_use_arm_eabi_hardfloat%': 'false', + + 'v8_use_snapshot%': 'true', + 'host_os%': '<(OS)', + 'v8_use_liveobjectlist%': 'false', + }, + 'target_defaults': { + 'conditions': [ + ['OS!="mac"', { + 'conditions': [ + ['v8_target_arch=="arm"', { + 'defines': [ + 'V8_TARGET_ARCH_ARM', + ], + 'conditions': [ + [ 'v8_can_use_unaligned_accesses=="true"', { + 'defines': [ + 'CAN_USE_UNALIGNED_ACCESSES=1', + ], + }], + [ 'v8_can_use_unaligned_accesses=="false"', { + 'defines': [ + 'CAN_USE_UNALIGNED_ACCESSES=0', + ], + }], + [ 'v8_can_use_vfp_instructions=="true"', { + 'defines': [ + 'CAN_USE_VFP_INSTRUCTIONS', + ], + }], + [ 'v8_use_arm_eabi_hardfloat=="true"', { + 'defines': [ + 'USE_EABI_HARDFLOAT=1', + 'CAN_USE_VFP_INSTRUCTIONS', + ], + }], + ], + }], + ['v8_target_arch=="ia32"', { + 'defines': [ + 'V8_TARGET_ARCH_IA32', + ], + }], + ['v8_target_arch=="mips"', { + 'defines': [ + 'V8_TARGET_ARCH_MIPS', + ], + }], + ['v8_target_arch=="x64"', { + 'defines': [ + 'V8_TARGET_ARCH_X64', + ], + }], + ], + }], + ], + 'configurations': { + 'Debug': { + 'defines': [ + 'DEBUG', + '_DEBUG', + 'ENABLE_DISASSEMBLER', + 'V8_ENABLE_CHECKS', + 'OBJECT_PRINT', + ], + } + } + } +} diff --git a/include/v8-debug.h b/include/v8-debug.h old mode 100644 new mode 100755 index 3c5c923b3d5..504cbfed590 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -76,7 +76,8 @@ enum DebugEvent { NewFunction = 3, BeforeCompile = 4, AfterCompile = 5, - ScriptCollected = 6 + ScriptCollected = 6, + BreakForCommand = 7 }; @@ -126,7 +127,7 @@ class EXPORT Debug { /** * Get the context active when the debug event happened. Note this is not * the current active context as the JavaScript part of the debugger is - * running in it's own context which is entered at this point. + * running in its own context which is entered at this point. */ virtual Handle GetEventContext() const = 0; @@ -141,7 +142,48 @@ class EXPORT Debug { virtual ~Message() {} }; - + + + /** + * An event details object passed to the debug event listener. + */ + class EventDetails { + public: + /** + * Event type. + */ + virtual DebugEvent GetEvent() const = 0; + + /** + * Access to execution state and event data of the debug event. Don't store + * these cross callbacks as their content becomes invalid. + */ + virtual Handle GetExecutionState() const = 0; + virtual Handle GetEventData() const = 0; + + /** + * Get the context active when the debug event happened. Note this is not + * the current active context as the JavaScript part of the debugger is + * running in its own context which is entered at this point. + */ + virtual Handle GetEventContext() const = 0; + + /** + * Client data passed with the corresponding callback when it was + * registered. + */ + virtual Handle GetCallbackData() const = 0; + + /** + * Client data passed to DebugBreakForCommand function. The + * debugger takes ownership of the data and will delete it even if + * there is no message handler. + */ + virtual ClientData* GetClientData() const = 0; + + virtual ~EventDetails() {} + }; + /** * Debug event callback function. @@ -157,6 +199,15 @@ class EXPORT Debug { Handle event_data, Handle data); + /** + * Debug event callback function. + * + * \param event_details object providing information about the debug event + * + * A EventCallback2 does not take possession of the event data, + * and must not rely on the data persisting after the handler returns. + */ + typedef void (*EventCallback2)(const EventDetails& event_details); /** * Debug message callback function. @@ -165,7 +216,7 @@ class EXPORT Debug { * \param length length of the message * \param client_data the data value passed when registering the message handler - * A MessageHandler does not take posession of the message string, + * A MessageHandler does not take possession of the message string, * and must not rely on the data persisting after the handler returns. * * This message handler is deprecated. Use MessageHandler2 instead. @@ -177,8 +228,8 @@ class EXPORT Debug { * Debug message callback function. * * \param message the debug message handler message object - - * A MessageHandler does not take posession of the message data, + * + * A MessageHandler does not take possession of the message data, * and must not rely on the data persisting after the handler returns. */ typedef void (*MessageHandler2)(const Message& message); @@ -188,29 +239,69 @@ class EXPORT Debug { */ typedef void (*HostDispatchHandler)(); + /** + * Callback function for the host to ensure debug messages are processed. + */ + typedef void (*DebugMessageDispatchHandler)(); + // Set a C debug event listener. static bool SetDebugEventListener(EventCallback that, Handle data = Handle()); + static bool SetDebugEventListener2(EventCallback2 that, + Handle data = Handle()); // Set a JavaScript debug event listener. static bool SetDebugEventListener(v8::Handle that, Handle data = Handle()); - // Break execution of JavaScript. - static void DebugBreak(); + // Schedule a debugger break to happen when JavaScript code is run + // in the given isolate. If no isolate is provided the default + // isolate is used. + static void DebugBreak(Isolate* isolate = NULL); + + // Remove scheduled debugger break in given isolate if it has not + // happened yet. If no isolate is provided the default isolate is + // used. + static void CancelDebugBreak(Isolate* isolate = NULL); + + // Break execution of JavaScript in the given isolate (this method + // can be invoked from a non-VM thread) for further client command + // execution on a VM thread. Client data is then passed in + // EventDetails to EventCallback at the moment when the VM actually + // stops. If no isolate is provided the default isolate is used. + static void DebugBreakForCommand(ClientData* data = NULL, + Isolate* isolate = NULL); // Message based interface. The message protocol is JSON. NOTE the message // handler thread is not supported any more parameter must be false. static void SetMessageHandler(MessageHandler handler, bool message_handler_thread = false); static void SetMessageHandler2(MessageHandler2 handler); + + // If no isolate is provided the default isolate is + // used. static void SendCommand(const uint16_t* command, int length, - ClientData* client_data = NULL); + ClientData* client_data = NULL, + Isolate* isolate = NULL); // Dispatch interface. static void SetHostDispatchHandler(HostDispatchHandler handler, int period = 100); + /** + * Register a callback function to be called when a debug message has been + * received and is ready to be processed. For the debug messages to be + * processed V8 needs to be entered, and in certain embedding scenarios this + * callback can be used to make sure V8 is entered for the debug message to + * be processed. Note that debug messages will only be processed if there is + * a V8 break. This can happen automatically by using the option + * --debugger-auto-break. + * \param provide_locker requires that V8 acquires v8::Locker for you before + * calling handler + */ + static void SetDebugMessageDispatchHandler( + DebugMessageDispatchHandler handler, bool provide_locker = false); + /** * Run a JavaScript function in the debugger. * \param fun the function to call @@ -218,9 +309,10 @@ class EXPORT Debug { * With this call the debugger is entered and the function specified is called * with the execution state as the first argument. This makes it possible to * get access to information otherwise not available during normal JavaScript - * execution e.g. details on stack frames. The following example show a - * JavaScript function which when passed to v8::Debug::Call will return the - * current line of JavaScript execution. + * execution e.g. details on stack frames. Receiver of the function call will + * be the debugger context global object, however this is a subject to change. + * The following example shows a JavaScript function which when passed to + * v8::Debug::Call will return the current line of JavaScript execution. * * \code * function frame_source_line(exec_state) { @@ -241,8 +333,56 @@ class EXPORT Debug { * supplied TCP/IP port for remote debugger connection. * \param name the name of the embedding application * \param port the TCP/IP port to listen on + * \param wait_for_connection whether V8 should pause on a first statement + * allowing remote debugger to connect before anything interesting happened */ - static bool EnableAgent(const char* name, int port); + static bool EnableAgent(const char* name, int port, + bool wait_for_connection = false); + + /** + * Makes V8 process all pending debug messages. + * + * From V8 point of view all debug messages come asynchronously (e.g. from + * remote debugger) but they all must be handled synchronously: V8 cannot + * do 2 things at one time so normal script execution must be interrupted + * for a while. + * + * Generally when message arrives V8 may be in one of 3 states: + * 1. V8 is running script; V8 will automatically interrupt and process all + * pending messages (however auto_break flag should be enabled); + * 2. V8 is suspended on debug breakpoint; in this state V8 is dedicated + * to reading and processing debug messages; + * 3. V8 is not running at all or has called some long-working C++ function; + * by default it means that processing of all debug messages will be deferred + * until V8 gets control again; however, embedding application may improve + * this by manually calling this method. + * + * It makes sense to call this method whenever a new debug message arrived and + * V8 is not already running. Method v8::Debug::SetDebugMessageDispatchHandler + * should help with the former condition. + * + * Technically this method in many senses is equivalent to executing empty + * script: + * 1. It does nothing except for processing all pending debug messages. + * 2. It should be invoked with the same precautions and from the same context + * as V8 script would be invoked from, because: + * a. with "evaluate" command it can do whatever normal script can do, + * including all native calls; + * b. no other thread should call V8 while this method is running + * (v8::Locker may be used here). + * + * "Evaluate" debug command behavior currently is not specified in scope + * of this method. + */ + static void ProcessDebugMessages(); + + /** + * Debugger is running in its own context which is entered while debugger + * messages are being dispatched. This is an explicit getter for this + * debugger context. Note that the content of the debugger context is subject + * to change. + */ + static Local GetDebugContext(); }; diff --git a/include/v8-preparser.h b/include/v8-preparser.h new file mode 100644 index 00000000000..f11d05ef793 --- /dev/null +++ b/include/v8-preparser.h @@ -0,0 +1,117 @@ +// 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 "v8stdint.h" + +#ifdef _WIN32 + +// Setup for Windows DLL export/import. When building the V8 DLL the +// BUILDING_V8_SHARED needs to be defined. When building a program which uses +// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 +// static library or building a program which uses the V8 static library neither +// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. +#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) +#error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ + build configuration to ensure that at most one of these is set +#endif + +#ifdef BUILDING_V8_SHARED +#define V8EXPORT __declspec(dllexport) +#elif USING_V8_SHARED +#define V8EXPORT __declspec(dllimport) +#else +#define V8EXPORT +#endif // BUILDING_V8_SHARED + +#else // _WIN32 + +// Setup for Linux shared library export. There is no need to distinguish +// between building or using the V8 shared library, but we should not +// export symbols when we are building a static library. +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED) +#define V8EXPORT __attribute__ ((visibility("default"))) +#else // defined(__GNUC__) && (__GNUC__ >= 4) +#define V8EXPORT +#endif // defined(__GNUC__) && (__GNUC__ >= 4) + +#endif // _WIN32 + + +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 V8EXPORT 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 V8EXPORT UnicodeInputStream { // NOLINT - Thinks V8EXPORT is 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 V8EXPORT Preparse(UnicodeInputStream* input, + size_t max_stack_size); + +} // namespace v8. + +#endif // PREPARSER_H diff --git a/include/v8-profiler.h b/include/v8-profiler.h new file mode 100644 index 00000000000..940a35c152d --- /dev/null +++ b/include/v8-profiler.h @@ -0,0 +1,505 @@ +// Copyright 2010 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_PROFILER_H_ +#define V8_V8_PROFILER_H_ + +#include "v8.h" + +#ifdef _WIN32 +// Setup for Windows DLL export/import. See v8.h in this directory for +// information on how to build/use V8 as a DLL. +#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) +#error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ + build configuration to ensure that at most one of these is set +#endif + +#ifdef BUILDING_V8_SHARED +#define V8EXPORT __declspec(dllexport) +#elif USING_V8_SHARED +#define V8EXPORT __declspec(dllimport) +#else +#define V8EXPORT +#endif + +#else // _WIN32 + +// Setup for Linux shared library export. See v8.h in this directory for +// information on how to build/use V8 as shared library. +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED) +#define V8EXPORT __attribute__ ((visibility("default"))) +#else // defined(__GNUC__) && (__GNUC__ >= 4) +#define V8EXPORT +#endif // defined(__GNUC__) && (__GNUC__ >= 4) + +#endif // _WIN32 + + +/** + * Profiler support for the V8 JavaScript engine. + */ +namespace v8 { + + +/** + * CpuProfileNode represents a node in a call graph. + */ +class V8EXPORT CpuProfileNode { + public: + /** Returns function name (empty string for anonymous functions.) */ + Handle GetFunctionName() const; + + /** Returns resource name for script from where the function originates. */ + Handle GetScriptResourceName() const; + + /** + * Returns the number, 1-based, of the line where the function originates. + * kNoLineNumberInfo if no line number information is available. + */ + int GetLineNumber() const; + + /** + * Returns total (self + children) execution time of the function, + * in milliseconds, estimated by samples count. + */ + double GetTotalTime() const; + + /** + * Returns self execution time of the function, in milliseconds, + * estimated by samples count. + */ + double GetSelfTime() const; + + /** Returns the count of samples where function exists. */ + double GetTotalSamplesCount() const; + + /** Returns the count of samples where function was currently executing. */ + double GetSelfSamplesCount() const; + + /** Returns function entry UID. */ + unsigned GetCallUid() const; + + /** Returns child nodes count of the node. */ + int GetChildrenCount() const; + + /** Retrieves a child node by index. */ + const CpuProfileNode* GetChild(int index) const; + + static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; +}; + + +/** + * CpuProfile contains a CPU profile in a form of two call trees: + * - top-down (from main() down to functions that do all the work); + * - bottom-up call graph (in backward direction). + */ +class V8EXPORT CpuProfile { + public: + /** Returns CPU profile UID (assigned by the profiler.) */ + unsigned GetUid() const; + + /** Returns CPU profile title. */ + Handle GetTitle() const; + + /** Returns the root node of the bottom up call tree. */ + const CpuProfileNode* GetBottomUpRoot() const; + + /** Returns the root node of the top down call tree. */ + const CpuProfileNode* GetTopDownRoot() const; + + /** + * Deletes the profile and removes it from CpuProfiler's list. + * All pointers to nodes previously returned become invalid. + * Profiles with the same uid but obtained using different + * security token are not deleted, but become inaccessible + * using FindProfile method. It is embedder's responsibility + * to call Delete on these profiles. + */ + void Delete(); +}; + + +/** + * Interface for controlling CPU profiling. + */ +class V8EXPORT CpuProfiler { + public: + /** + * A note on security tokens usage. As scripts from different + * origins can run inside a single V8 instance, it is possible to + * have functions from different security contexts intermixed in a + * single CPU profile. To avoid exposing function names belonging to + * other contexts, filtering by security token is performed while + * obtaining profiling results. + */ + + /** + * Returns the number of profiles collected (doesn't include + * profiles that are being collected at the moment of call.) + */ + static int GetProfilesCount(); + + /** Returns a profile by index. */ + static const CpuProfile* GetProfile( + int index, + Handle security_token = Handle()); + + /** Returns a profile by uid. */ + static const CpuProfile* FindProfile( + unsigned uid, + Handle security_token = Handle()); + + /** + * Starts collecting CPU profile. Title may be an empty string. It + * is allowed to have several profiles being collected at + * once. Attempts to start collecting several profiles with the same + * title are silently ignored. While collecting a profile, functions + * from all security contexts are included in it. The token-based + * filtering is only performed when querying for a profile. + */ + static void StartProfiling(Handle title); + + /** + * Stops collecting CPU profile with a given title and returns it. + * If the title given is empty, finishes the last profile started. + */ + static const CpuProfile* StopProfiling( + Handle title, + Handle security_token = Handle()); + + /** + * Deletes all existing profiles, also cancelling all profiling + * activity. All previously returned pointers to profiles and their + * contents become invalid after this call. + */ + static void DeleteAllProfiles(); +}; + + +class HeapGraphNode; + + +/** + * HeapSnapshotEdge represents a directed connection between heap + * graph nodes: from retainers to retained nodes. + */ +class V8EXPORT HeapGraphEdge { + public: + enum Type { + kContextVariable = 0, // A variable from a function context. + kElement = 1, // An element of an array. + kProperty = 2, // A named object property. + kInternal = 3, // A link that can't be accessed from JS, + // thus, its name isn't a real property name + // (e.g. parts of a ConsString). + kHidden = 4, // A link that is needed for proper sizes + // calculation, but may be hidden from user. + kShortcut = 5 // A link that must not be followed during + // sizes calculation. + }; + + /** Returns edge type (see HeapGraphEdge::Type). */ + Type GetType() const; + + /** + * Returns edge name. This can be a variable name, an element index, or + * a property name. + */ + Handle GetName() const; + + /** Returns origin node. */ + const HeapGraphNode* GetFromNode() const; + + /** Returns destination node. */ + const HeapGraphNode* GetToNode() const; +}; + + +/** + * HeapGraphNode represents a node in a heap graph. + */ +class V8EXPORT HeapGraphNode { + public: + enum Type { + kHidden = 0, // Hidden node, may be filtered when shown to user. + kArray = 1, // An array of elements. + kString = 2, // A string. + kObject = 3, // A JS object (except for arrays and strings). + kCode = 4, // Compiled code. + kClosure = 5, // Function closure. + kRegExp = 6, // RegExp. + kHeapNumber = 7, // Number stored in the heap. + kNative = 8 // Native object (not from V8 heap). + }; + + /** Returns node type (see HeapGraphNode::Type). */ + Type GetType() const; + + /** + * Returns node name. Depending on node's type this can be the name + * of the constructor (for objects), the name of the function (for + * closures), string value, or an empty string (for compiled code). + */ + Handle GetName() const; + + /** + * Returns node id. For the same heap object, the id remains the same + * across all snapshots. Not applicable to aggregated heap snapshots + * as they only contain aggregated instances. + */ + uint64_t GetId() const; + + /** + * Returns the number of instances. Only applicable to aggregated + * heap snapshots. + */ + int GetInstancesCount() const; + + /** Returns node's own size, in bytes. */ + int GetSelfSize() const; + + /** + * Returns node's retained size, in bytes. That is, self + sizes of + * the objects that are reachable only from this object. In other + * words, the size of memory that will be reclaimed having this node + * collected. + * + * Exact retained size calculation has O(N) (number of nodes) + * computational complexity, while approximate has O(1). It is + * assumed that initially heap profiling tools provide approximate + * sizes for all nodes, and then exact sizes are calculated for the + * most 'interesting' nodes. + */ + int GetRetainedSize(bool exact) const; + + /** Returns child nodes count of the node. */ + int GetChildrenCount() const; + + /** Retrieves a child by index. */ + const HeapGraphEdge* GetChild(int index) const; + + /** Returns retainer nodes count of the node. */ + int GetRetainersCount() const; + + /** Returns a retainer by index. */ + const HeapGraphEdge* GetRetainer(int index) const; + + /** + * Returns a dominator node. This is the node that participates in every + * path from the snapshot root to the current node. + */ + const HeapGraphNode* GetDominatorNode() const; +}; + + +/** + * HeapSnapshots record the state of the JS heap at some moment. + */ +class V8EXPORT HeapSnapshot { + public: + enum Type { + kFull = 0, // Heap snapshot with all instances and references. + kAggregated = 1 // Snapshot doesn't contain individual heap entries, + // instead they are grouped by constructor name. + }; + enum SerializationFormat { + kJSON = 0 // See format description near 'Serialize' method. + }; + + /** Returns heap snapshot type. */ + Type GetType() const; + + /** Returns heap snapshot UID (assigned by the profiler.) */ + unsigned GetUid() const; + + /** Returns heap snapshot title. */ + Handle GetTitle() const; + + /** Returns the root node of the heap graph. */ + const HeapGraphNode* GetRoot() const; + + /** Returns a node by its id. */ + const HeapGraphNode* GetNodeById(uint64_t id) const; + + /** + * Deletes the snapshot and removes it from HeapProfiler's list. + * All pointers to nodes, edges and paths previously returned become + * invalid. + */ + void Delete(); + + /** + * Prepare a serialized representation of the snapshot. The result + * is written into the stream provided in chunks of specified size. + * The total length of the serialized snapshot is unknown in + * advance, it can be roughly equal to JS heap size (that means, + * it can be really big - tens of megabytes). + * + * For the JSON format, heap contents are represented as an object + * with the following structure: + * + * { + * snapshot: {title: "...", uid: nnn}, + * nodes: [ + * meta-info (JSON string), + * nodes themselves + * ], + * strings: [strings] + * } + * + * Outgoing node links are stored after each node. Nodes reference strings + * and other nodes by their indexes in corresponding arrays. + */ + void Serialize(OutputStream* stream, SerializationFormat format) const; +}; + + +class RetainedObjectInfo; + +/** + * Interface for controlling heap profiling. + */ +class V8EXPORT HeapProfiler { + public: + /** + * Callback function invoked for obtaining RetainedObjectInfo for + * the given JavaScript wrapper object. It is prohibited to enter V8 + * while the callback is running: only getters on the handle and + * GetPointerFromInternalField on the objects are allowed. + */ + typedef RetainedObjectInfo* (*WrapperInfoCallback) + (uint16_t class_id, Handle wrapper); + + /** Returns the number of snapshots taken. */ + static int GetSnapshotsCount(); + + /** Returns a snapshot by index. */ + static const HeapSnapshot* GetSnapshot(int index); + + /** Returns a profile by uid. */ + static const HeapSnapshot* FindSnapshot(unsigned uid); + + /** + * Takes a heap snapshot and returns it. Title may be an empty string. + * See HeapSnapshot::Type for types description. + */ + static const HeapSnapshot* TakeSnapshot( + Handle title, + HeapSnapshot::Type type = HeapSnapshot::kFull, + ActivityControl* control = NULL); + + /** + * Deletes all snapshots taken. All previously returned pointers to + * snapshots and their contents become invalid after this call. + */ + static void DeleteAllSnapshots(); + + /** Binds a callback to embedder's class ID. */ + static void DefineWrapperClass( + uint16_t class_id, + WrapperInfoCallback callback); + + /** + * Default value of persistent handle class ID. Must not be used to + * define a class. Can be used to reset a class of a persistent + * handle. + */ + static const uint16_t kPersistentHandleNoClassId = 0; +}; + + +/** + * Interface for providing information about embedder's objects + * held by global handles. This information is reported in two ways: + * + * 1. When calling AddObjectGroup, an embedder may pass + * RetainedObjectInfo instance describing the group. To collect + * this information while taking a heap snapshot, V8 calls GC + * prologue and epilogue callbacks. + * + * 2. When a heap snapshot is collected, V8 additionally + * requests RetainedObjectInfos for persistent handles that + * were not previously reported via AddObjectGroup. + * + * Thus, if an embedder wants to provide information about native + * objects for heap snapshots, he can do it in a GC prologue + * handler, and / or by assigning wrapper class ids in the following way: + * + * 1. Bind a callback to class id by calling DefineWrapperClass. + * 2. Call SetWrapperClassId on certain persistent handles. + * + * V8 takes ownership of RetainedObjectInfo instances passed to it and + * keeps them alive only during snapshot collection. Afterwards, they + * are freed by calling the Dispose class function. + */ +class V8EXPORT RetainedObjectInfo { // NOLINT + public: + /** Called by V8 when it no longer needs an instance. */ + virtual void Dispose() = 0; + + /** Returns whether two instances are equivalent. */ + virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; + + /** + * Returns hash value for the instance. Equivalent instances + * must have the same hash value. + */ + virtual intptr_t GetHash() = 0; + + /** + * Returns human-readable label. It must be a NUL-terminated UTF-8 + * encoded string. V8 copies its contents during a call to GetLabel. + */ + virtual const char* GetLabel() = 0; + + /** + * Returns element count in case if a global handle retains + * a subgraph by holding one of its nodes. + */ + virtual intptr_t GetElementCount() { return -1; } + + /** Returns embedder's object size in bytes. */ + virtual intptr_t GetSizeInBytes() { return -1; } + + protected: + RetainedObjectInfo() {} + virtual ~RetainedObjectInfo() {} + + private: + RetainedObjectInfo(const RetainedObjectInfo&); + RetainedObjectInfo& operator=(const RetainedObjectInfo&); +}; + + +} // namespace v8 + + +#undef V8EXPORT + + +#endif // V8_V8_PROFILER_H_ diff --git a/include/v8-testing.h b/include/v8-testing.h new file mode 100644 index 00000000000..245f74d878d --- /dev/null +++ b/include/v8-testing.h @@ -0,0 +1,104 @@ +// Copyright 2010 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_TEST_H_ +#define V8_V8_TEST_H_ + +#include "v8.h" + +#ifdef _WIN32 +// Setup for Windows DLL export/import. See v8.h in this directory for +// information on how to build/use V8 as a DLL. +#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) +#error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ + build configuration to ensure that at most one of these is set +#endif + +#ifdef BUILDING_V8_SHARED +#define V8EXPORT __declspec(dllexport) +#elif USING_V8_SHARED +#define V8EXPORT __declspec(dllimport) +#else +#define V8EXPORT +#endif + +#else // _WIN32 + +// Setup for Linux shared library export. See v8.h in this directory for +// information on how to build/use V8 as shared library. +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED) +#define V8EXPORT __attribute__ ((visibility("default"))) +#else // defined(__GNUC__) && (__GNUC__ >= 4) +#define V8EXPORT +#endif // defined(__GNUC__) && (__GNUC__ >= 4) + +#endif // _WIN32 + + +/** + * Testing support for the V8 JavaScript engine. + */ +namespace v8 { + +class V8EXPORT Testing { + public: + enum StressType { + kStressTypeOpt, + kStressTypeDeopt + }; + + /** + * Set the type of stressing to do. The default if not set is kStressTypeOpt. + */ + static void SetStressRunType(StressType type); + + /** + * Get the number of runs of a given test that is required to get the full + * stress coverage. + */ + static int GetStressRuns(); + + /** + * Indicate the number of the run which is about to start. The value of run + * should be between 0 and one less than the result from GetStressRuns() + */ + static void PrepareStressRun(int run); + + /** + * Force deoptimization of all functions. + */ + static void DeoptimizeAll(); +}; + + +} // namespace v8 + + +#undef V8EXPORT + + +#endif // V8_V8_TEST_H_ diff --git a/include/v8.h b/include/v8.h index 78b46136fd2..c3bccdc2413 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1,4 +1,4 @@ -// Copyright 2007-2009 the V8 project authors. All rights reserved. +// 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: @@ -38,33 +38,15 @@ #ifndef V8_H_ #define V8_H_ -#include +#include "v8stdint.h" #ifdef _WIN32 -// When compiling on MinGW stdint.h is available. -#ifdef __MINGW32__ -#include -#else // __MINGW32__ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; // NOLINT -typedef unsigned short uint16_t; // NOLINT -typedef int int32_t; -typedef unsigned int uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -// intptr_t and friends are defined in crtdefs.h through stdio.h. -#endif // __MINGW32__ // Setup for Windows DLL export/import. When building the V8 DLL the // BUILDING_V8_SHARED needs to be defined. When building a program which uses // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 // static library or building a program which uses the V8 static library neither // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. -// The reason for having both V8EXPORT and V8EXPORT_INLINE is that classes which -// have their code inside this header file need to have __declspec(dllexport) -// when building the DLL but cannot have __declspec(dllimport) when building -// a program which uses the DLL. #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ build configuration to ensure that at most one of these is set @@ -72,28 +54,21 @@ typedef unsigned __int64 uint64_t; #ifdef BUILDING_V8_SHARED #define V8EXPORT __declspec(dllexport) -#define V8EXPORT_INLINE __declspec(dllexport) #elif USING_V8_SHARED #define V8EXPORT __declspec(dllimport) -#define V8EXPORT_INLINE #else #define V8EXPORT -#define V8EXPORT_INLINE #endif // BUILDING_V8_SHARED #else // _WIN32 -#include - // Setup for Linux shared library export. There is no need to distinguish // between building or using the V8 shared library, but we should not // export symbols when we are building a static library. #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED) #define V8EXPORT __attribute__ ((visibility("default"))) -#define V8EXPORT_INLINE __attribute__ ((visibility("default"))) #else // defined(__GNUC__) && (__GNUC__ >= 4) #define V8EXPORT -#define V8EXPORT_INLINE #endif // defined(__GNUC__) && (__GNUC__ >= 4) #endif // _WIN32 @@ -126,22 +101,29 @@ template class Persistent; class FunctionTemplate; class ObjectTemplate; class Data; +class AccessorInfo; +class StackTrace; +class StackFrame; namespace internal { class Arguments; class Object; -class Top; - +class Heap; +class HeapObject; +class Isolate; } -// --- W e a k H a n d l e s +// --- Weak Handles --- /** * A weak reference callback function. * + * This callback should either explicitly invoke Dispose on |object| if + * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. + * * \param object the weak global object to be reclaimed by the garbage collector * \param parameter the value passed in when making the weak global object */ @@ -149,11 +131,11 @@ typedef void (*WeakReferenceCallback)(Persistent object, void* parameter); -// --- H a n d l e s --- +// --- Handles --- -#define TYPE_CHECK(T, S) \ - while (false) { \ - *(static_cast(0)) = static_cast(0); \ +#define TYPE_CHECK(T, S) \ + while (false) { \ + *(static_cast(0)) = static_cast(0); \ } /** @@ -177,13 +159,12 @@ typedef void (*WeakReferenceCallback)(Persistent object, * * It is safe to extract the object stored in the handle by * dereferencing the handle (for instance, to extract the Object* from - * an Handle); the value will still be governed by a handle + * a Handle); the value will still be governed by a handle * behind the scenes and the same rules apply to these values as to * their handles. */ -template class V8EXPORT_INLINE Handle { +template class Handle { public: - /** * Creates an empty handle. */ @@ -192,14 +173,14 @@ template class V8EXPORT_INLINE Handle { /** * Creates a new handle for the specified value. */ - explicit Handle(T* val) : val_(val) { } + inline explicit Handle(T* val) : val_(val) { } /** * Creates a handle for the contents of the specified handle. This * constructor allows you to pass handles as arguments by value and * to assign between handles. However, if you try to assign between * incompatible handles, for instance from a Handle to a - * Handle it will cause a compiletime error. Assigning + * Handle it will cause a compile-time error. Assigning * between compatible handles, for instance assigning a * Handle to a variable declared as Handle, is legal * because String is a subclass of Value. @@ -217,16 +198,16 @@ template class V8EXPORT_INLINE Handle { /** * Returns true if the handle is empty. */ - bool IsEmpty() const { return val_ == 0; } + inline bool IsEmpty() const { return val_ == 0; } - T* operator->() const { return val_; } + inline T* operator->() const { return val_; } - T* operator*() const { return val_; } + inline T* operator*() const { return val_; } /** * Sets the handle to be empty. IsEmpty() will then return true. */ - void Clear() { this->val_ = 0; } + inline void Clear() { this->val_ = 0; } /** * Checks whether two handles are the same. @@ -234,7 +215,7 @@ template class V8EXPORT_INLINE Handle { * to which they refer are identical. * The handles' references are not checked. */ - template bool operator==(Handle that) const { + template inline bool operator==(Handle that) const { internal::Object** a = reinterpret_cast(**this); internal::Object** b = reinterpret_cast(*that); if (a == 0) return b == 0; @@ -248,7 +229,7 @@ template class V8EXPORT_INLINE Handle { * the objects to which they refer are different. * The handles' references are not checked. */ - template bool operator!=(Handle that) const { + template inline bool operator!=(Handle that) const { return !operator==(that); } @@ -261,6 +242,10 @@ template class V8EXPORT_INLINE Handle { return Handle(T::Cast(*that)); } + template inline Handle As() { + return Handle::Cast(*this); + } + private: T* val_; }; @@ -273,7 +258,7 @@ template class V8EXPORT_INLINE Handle { * handle scope are destroyed when the handle scope is destroyed. Hence it * is not necessary to explicitly deallocate local handles. */ -template class V8EXPORT_INLINE Local : public Handle { +template class Local : public Handle { public: inline Local(); template inline Local(Local that) @@ -295,6 +280,10 @@ template class V8EXPORT_INLINE Local : public Handle { return Local(T::Cast(*that)); } + template inline Local As() { + return Local::Cast(*this); + } + /** Create a local handle for the content of another handle. * The referee is kept alive by the local handle even when * the original handle is destroyed/disposed. @@ -320,9 +309,8 @@ template class V8EXPORT_INLINE Local : public Handle { * different storage cells but rather two references to the same * storage cell. */ -template class V8EXPORT_INLINE Persistent : public Handle { +template class Persistent : public Handle { public: - /** * Creates an empty persistent handle that doesn't point to any * storage cell. @@ -335,7 +323,7 @@ template class V8EXPORT_INLINE Persistent : public Handle { * handles as arguments by value and to assign between persistent * handles. However, attempting to assign between incompatible * persistent handles, for instance from a Persistent to a - * Persistent will cause a compiletime error. Assigning + * Persistent will cause a compile-time error. Assigning * between compatible persistent handles, for instance assigning a * Persistent to a variable declared as Persistent, * is allowed as String is a subclass of Value. @@ -368,6 +356,10 @@ template class V8EXPORT_INLINE Persistent : public Handle { return Persistent(T::Cast(*that)); } + template inline Persistent As() { + return Persistent::Cast(*this); + } + /** * Creates a new persistent handle for an existing local or * persistent handle. @@ -377,7 +369,7 @@ template class V8EXPORT_INLINE Persistent : public Handle { /** * Releases the storage cell referenced by this persistent handle. * Does not remove the reference to the cell from any handles. - * This handle's reference, and any any other references to the storage + * This handle's reference, and any other references to the storage * cell remain and IsEmpty will still return false. */ inline void Dispose(); @@ -393,6 +385,15 @@ template class V8EXPORT_INLINE Persistent : public Handle { /** Clears the weak reference to this object.*/ inline void ClearWeak(); + /** + * Marks the reference to this object independent. Garbage collector + * is free to ignore any object groups containing this object. + * Weak callback for an independent handle should not + * assume that it will be preceded by a global GC prologue callback + * or followed by a global GC epilogue callback. + */ + inline void MarkIndependent(); + /** *Checks if the handle holds the only reference to an object. */ @@ -403,6 +404,12 @@ template class V8EXPORT_INLINE Persistent : public Handle { */ inline bool IsWeak() const; + /** + * Assigns a wrapper class ID to the handle. See RetainedObjectInfo + * interface description in v8-profiler.h for details. + */ + inline void SetWrapperClassId(uint16_t class_id); + private: friend class ImplementationUtilities; friend class ObjectTemplate; @@ -444,6 +451,8 @@ class V8EXPORT HandleScope { * Creates a new handle with the given value. */ static internal::Object** CreateHandle(internal::Object* value); + // Faster version, uses HeapObject to obtain the current Isolate. + static internal::Object** CreateHandle(internal::HeapObject* value); private: // Make it impossible to create heap-allocated or illegal handle @@ -457,16 +466,20 @@ class V8EXPORT HandleScope { // typedef in the ImplementationUtilities class. class V8EXPORT Data { public: - int extensions; internal::Object** next; internal::Object** limit; + int level; inline void Initialize() { - extensions = -1; next = limit = NULL; + level = 0; } }; - Data previous_; + void Leave(); + + internal::Isolate* isolate_; + internal::Object** prev_next_; + internal::Object** prev_limit_; // Allow for the active closing of HandleScopes which allows to pass a handle // from the HandleScope being closed to the next top most HandleScope. @@ -477,7 +490,7 @@ class V8EXPORT HandleScope { }; -// --- S p e c i a l o b j e c t s --- +// --- Special objects --- /** @@ -498,22 +511,61 @@ class V8EXPORT Data { class V8EXPORT ScriptData { // NOLINT public: virtual ~ScriptData() { } + + /** + * Pre-compiles the specified script (context-independent). + * + * \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* New(unsigned* data, int length); + /** + * Pre-compiles the specified script (context-independent). + * + * NOTE: Pre-compilation using this method cannot happen on another thread + * without using Lockers. + * + * \param source Script source code. + */ + static ScriptData* PreCompile(Handle source); + + /** + * Load previous pre-compilation data. + * + * \param data Pointer to data returned by a call to Data() of a previous + * ScriptData. Ownership is not transferred. + * \param length Length of data. + */ + static ScriptData* New(const char* data, int length); + + /** + * Returns the length of Data(). + */ virtual int Length() = 0; - virtual unsigned* Data() = 0; + + /** + * Returns a serialized representation of this ScriptData that can later be + * passed to New(). NOTE: Serialized data is platform-dependent. + */ + virtual const char* Data() = 0; + + /** + * Returns true if the source code could not be parsed. + */ + virtual bool HasError() = 0; }; /** * The origin, within a file, of a script. */ -class V8EXPORT ScriptOrigin { +class ScriptOrigin { public: - ScriptOrigin(Handle resource_name, - Handle resource_line_offset = Handle(), - Handle resource_column_offset = Handle()) + inline ScriptOrigin( + Handle resource_name, + Handle resource_line_offset = Handle(), + Handle resource_column_offset = Handle()) : resource_name_(resource_name), resource_line_offset_(resource_line_offset), resource_column_offset_(resource_column_offset) { } @@ -532,52 +584,76 @@ class V8EXPORT ScriptOrigin { */ class V8EXPORT Script { public: + /** + * Compiles the specified script (context-independent). + * + * \param source Script source code. + * \param origin Script origin, owned by caller, no references are kept + * when New() returns + * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() + * using pre_data speeds compilation if it's done multiple times. + * Owned by caller, no references are kept when New() returns. + * \param script_data Arbitrary data associated with script. Using + * this has same effect as calling SetData(), but allows data to be + * available to compile event handlers. + * \return Compiled script object (context independent; when run it + * will use the currently entered context). + */ + static Local