diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index d5c30c7f5e..2ff993659a 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,61 @@ +2009-05-11: Version 1.2.3 + + Fixed bug in reporting of out-of-memory situations. + + Introduced hidden prototypes on certain builtin prototype objects + such as String.prototype to emulate JSC's behavior of restoring + the original function when deleting functions from those prototype + objects. + + Fixed crash bug in the register allocator. + + +2009-05-04: Version 1.2.2 + + Fixed bug in array sorting for sparse arrays (issue 326). + + Added support for adding a soname when building a shared library + on Linux (issue 151). + + Fixed bug caused by morphing internal ASCII strings to external + two-byte strings. Slices over ASCII strings have to forward ASCII + checks to the underlying buffer string. + + Allowed API call-as-function handlers to be called as + constructors. + + Fixed a crash bug where an external string was disposed but a + slice of the external string survived as a symbol. + + +2009-04-27: Version 1.2.1 + + Added EcmaScript 5 JSON object. + + Fix bug in preemption support on ARM. + + +2009-04-23: Version 1.2.0 + + Optimized floating-point operations on ARM. + + Added a number of extensions to the debugger API. + + Changed the enumeration order for unsigned integer keys to always + be numerical order. + + Added a "read" extension to the shell sample. + + Added support for Array.prototype.reduce and + Array.prototype.reduceRight. + + Added an option to the SCons build to control Microsoft Visual C++ + link-time code generation. + + Fixed a number of bugs (in particular issue 315, issue 316, + issue 317 and issue 318). + + 2009-04-15: Version 1.1.10 Fixed crash bug that occurred when loading a const variable in the @@ -27,13 +85,13 @@ Changed test-debug/ThreadedDebugging to be non-flaky (issue 96). - Fixed step-in handling for Function.prototype.apply and call in + Fixed step-in handling for Function.prototype.apply and call in the debugger (issue 269). Fixed v8::Object::DeleteHiddenValue to not bail out when there are no hidden properties. - Added workaround for crash bug, where external symbol table + Added workaround for crash bug, where external symbol table entries with deleted resources would lead to NPEs when looking up in the symbol table. diff --git a/deps/v8/SConstruct b/deps/v8/SConstruct index 01083cc5d6..0c506790e8 100644 --- a/deps/v8/SConstruct +++ b/deps/v8/SConstruct @@ -35,6 +35,7 @@ root_dir = dirname(File('SConstruct').rfile().abspath) sys.path.append(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. @@ -83,7 +84,8 @@ ANDROID_LINKFLAGS = ['-nostdlib', LIBRARY_FLAGS = { 'all': { - 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'] + 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'], + 'CPPPATH': [join(root_dir, 'src')] }, 'gcc': { 'all': { @@ -94,6 +96,7 @@ LIBRARY_FLAGS = { 'CCFLAGS': ['-g', '-O0'], 'CPPDEFINES': ['ENABLE_DISASSEMBLER', 'DEBUG'], 'os:android': { + 'CPPDEFINES': ['ENABLE_DEBUGGER_SUPPORT'], 'CCFLAGS': ['-mthumb'] } }, @@ -102,13 +105,13 @@ LIBRARY_FLAGS = { '-ffunction-sections'], 'os:android': { 'CCFLAGS': ['-mthumb', '-Os'], - 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] + 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG', 'ENABLE_DEBUGGER_SUPPORT'] } }, 'os:linux': { 'CCFLAGS': ['-ansi'], 'library:shared': { - 'LIBS': ['pthread', 'rt'] + 'LIBS': ['pthread'] } }, 'os:macos': { @@ -129,9 +132,30 @@ LIBRARY_FLAGS = { '-Wstrict-aliasing=2'], 'CPPPATH': ANDROID_INCLUDES, }, + 'wordsize:32': { + 'arch:x64': { + 'CCFLAGS': ['-m64'], + 'LINKFLAGS': ['-m64'] + } + }, 'wordsize:64': { - 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + 'arch:ia32': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, + 'arch:arm': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + } + }, + 'arch:ia32': { + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] + }, + 'arch:arm': { + 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'] + }, + 'arch:x64': { + 'CPPDEFINES': ['V8_TARGET_ARCH_X64'] }, 'prof:oprofile': { 'CPPDEFINES': ['ENABLE_OPROFILE_AGENT'] @@ -148,6 +172,9 @@ LIBRARY_FLAGS = { 'ARFLAGS': ['/NOLOGO'], 'CCPDBFLAGS': ['/Zi'] }, + 'arch:ia32': { + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] + }, 'mode:debug': { 'CCFLAGS': ['/Od', '/Gm'], 'CPPDEFINES': ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'], @@ -160,16 +187,20 @@ LIBRARY_FLAGS = { } }, 'mode:release': { - 'CCFLAGS': ['/O2', '/GL'], - 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'], - 'ARFLAGS': ['/LTCG'], + 'CCFLAGS': ['/O2'], + 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'], 'msvcrt:static': { 'CCFLAGS': ['/MT'] }, 'msvcrt:shared': { 'CCFLAGS': ['/MD'] + }, + 'msvcltcg:on': { + 'CCFLAGS': ['/GL'], + 'LINKFLAGS': ['/LTCG'], + 'ARFLAGS': ['/LTCG'], } - }, + } } } @@ -181,17 +212,16 @@ V8_EXTRA_FLAGS = { 'WARNINGFLAGS': ['-Wall', '-Werror', '-W', '-Wno-unused-parameter'] }, - 'arch:arm': { - 'CPPDEFINES': ['ARM'] - }, - 'arch:android': { - 'CPPDEFINES': ['ARM'] - }, 'os:win32': { 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long'] }, 'os:linux': { - 'WARNINGFLAGS': ['-pedantic'] + 'WARNINGFLAGS': ['-pedantic'], + 'library:shared': { + 'soname:on': { + 'LINKFLAGS': ['-Wl,-soname,${SONAME}'] + } + } }, 'os:macos': { 'WARNINGFLAGS': ['-pedantic'] @@ -209,7 +239,7 @@ V8_EXTRA_FLAGS = { 'LIBS': ['winmm', 'ws2_32'] }, 'arch:arm': { - 'CPPDEFINES': ['ARM'], + 'CPPDEFINES': ['V8_TARGET_ARCH_ARM'], # /wd4996 is to silence the warning about sscanf # used by the arm simulator. 'WARNINGFLAGS': ['/wd4996'] @@ -224,7 +254,7 @@ V8_EXTRA_FLAGS = { MKSNAPSHOT_EXTRA_FLAGS = { 'gcc': { 'os:linux': { - 'LIBS': ['pthread', 'rt'], + 'LIBS': ['pthread'], }, 'os:macos': { 'LIBS': ['pthread'], @@ -238,6 +268,7 @@ MKSNAPSHOT_EXTRA_FLAGS = { }, 'msvc': { 'all': { + 'CPPDEFINES': ['_HAS_EXCEPTIONS=0'], 'LIBS': ['winmm', 'ws2_32'] } } @@ -268,7 +299,7 @@ CCTEST_EXTRA_FLAGS = { 'LIBPATH': [abspath('.')] }, 'os:linux': { - 'LIBS': ['pthread', 'rt'], + 'LIBS': ['pthread'], }, 'os:macos': { 'LIBS': ['pthread'], @@ -279,10 +310,34 @@ CCTEST_EXTRA_FLAGS = { 'os:win32': { 'LIBS': ['winmm', 'ws2_32'] }, - 'wordsize:64': { - 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + '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': ['c', 'stdc++', 'm'], + 'mode:release': { + 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] + } }, + 'wordsize:32': { + 'arch:x64': { + 'CCFLAGS': ['-m64'], + 'LINKFLAGS': ['-m64'] + } + }, + 'wordsize:64': { + 'arch:ia32': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, + 'arch:arm': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + } + } }, 'msvc': { 'all': { @@ -291,6 +346,9 @@ CCTEST_EXTRA_FLAGS = { }, 'library:shared': { 'CPPDEFINES': ['USING_V8_SHARED'] + }, + 'arch:ia32': { + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] } } } @@ -307,7 +365,7 @@ SAMPLE_FLAGS = { 'CCFLAGS': ['-fno-rtti', '-fno-exceptions'] }, 'os:linux': { - 'LIBS': ['pthread', 'rt'], + 'LIBS': ['pthread'], }, 'os:macos': { 'LIBS': ['pthread'], @@ -330,9 +388,21 @@ SAMPLE_FLAGS = { 'CPPDEFINES': ['SK_RELEASE', 'NDEBUG'] } }, + 'wordsize:32': { + 'arch:x64': { + 'CCFLAGS': ['-m64'], + 'LINKFLAGS': ['-m64'] + } + }, 'wordsize:64': { - 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + 'arch:ia32': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, + 'arch:arm': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + } }, 'mode:release': { 'CCFLAGS': ['-O2'] @@ -359,14 +429,21 @@ SAMPLE_FLAGS = { }, 'mode:release': { 'CCFLAGS': ['/O2'], - 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'], + 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF'], 'msvcrt:static': { 'CCFLAGS': ['/MT'] }, 'msvcrt:shared': { 'CCFLAGS': ['/MD'] + }, + 'msvcltcg:on': { + 'CCFLAGS': ['/GL'], + 'LINKFLAGS': ['/LTCG'], } }, + 'arch:ia32': { + 'CPPDEFINES': ['V8_TARGET_ARCH_IA32'] + }, 'mode:debug': { 'CCFLAGS': ['/Od'], 'LINKFLAGS': ['/DEBUG'], @@ -387,7 +464,7 @@ D8_FLAGS = { 'LIBS': ['readline'] }, 'os:linux': { - 'LIBS': ['pthread', 'rt'], + 'LIBS': ['pthread'], }, 'os:macos': { 'LIBS': ['pthread'], @@ -443,17 +520,17 @@ SIMPLE_OPTIONS = { 'toolchain': { 'values': ['gcc', 'msvc'], 'default': TOOLCHAIN_GUESS, - 'help': 'the toolchain to use' + 'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')' }, 'os': { 'values': ['freebsd', 'linux', 'macos', 'win32', 'android'], 'default': OS_GUESS, - 'help': 'the os to build for' + 'help': 'the os to build for (' + OS_GUESS + ')' }, 'arch': { - 'values':['arm', 'ia32'], + 'values':['arm', 'ia32', 'x64'], 'default': ARCH_GUESS, - 'help': 'the architecture to build for' + 'help': 'the architecture to build for (' + ARCH_GUESS + ')' }, 'snapshot': { 'values': ['on', 'off', 'nobuild'], @@ -470,10 +547,20 @@ SIMPLE_OPTIONS = { 'default': 'static', 'help': 'the type of library to produce' }, + 'soname': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'turn on setting soname for Linux shared library' + }, 'msvcrt': { 'values': ['static', 'shared'], 'default': 'static', - 'help': 'the type of MSVCRT library to use' + 'help': 'the type of Microsoft Visual C++ runtime library to use' + }, + 'msvcltcg': { + 'values': ['on', 'off'], + 'default': 'on', + 'help': 'use Microsoft Visual C++ link-time code generation' }, 'wordsize': { 'values': ['64', '32'], @@ -515,6 +602,49 @@ def GetOptions(): return result +def GetVersionComponents(): + MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)") + MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)") + BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)") + PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)") + + patterns = [MAJOR_VERSION_PATTERN, + MINOR_VERSION_PATTERN, + BUILD_NUMBER_PATTERN, + PATCH_LEVEL_PATTERN] + + source = open(join(root_dir, 'src', 'version.cc')).read() + version_components = [] + for pattern in patterns: + match = pattern.search(source) + if match: + version_components.append(match.group(1).strip()) + else: + version_components.append('0') + + return version_components + + +def GetVersion(): + version_components = GetVersionComponents() + + if version_components[len(version_components) - 1] == '0': + version_components.pop() + return '.'.join(version_components) + + +def GetSpecificSONAME(): + SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"") + + source = open(join(root_dir, 'src', 'version.cc')).read() + match = SONAME_PATTERN.search(source) + + if match: + return match.group(1).strip() + else: + return '' + + def SplitList(str): return [ s for s in str.split(",") if len(s) > 0 ] @@ -537,6 +667,12 @@ def VerifyOptions(env): 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['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.") + if env['arch'] == 'x64' and env['os'] != 'linux': + Abort("X64 compilation only allowed on Linux OS.") for (name, option) in SIMPLE_OPTIONS.iteritems(): if (not option.get('default')) and (name not in ARGUMENTS): message = ("A value for option %s must be specified (%s)." % @@ -565,13 +701,13 @@ class BuildContext(object): def AddRelevantFlags(self, initial, flags): result = initial.copy() - self.AppendFlags(result, flags.get('all')) toolchain = self.options['toolchain'] if toolchain in flags: self.AppendFlags(result, flags[toolchain].get('all')) for option in sorted(self.options.keys()): value = self.options[option] self.AppendFlags(result, flags[toolchain].get(option + ':' + value)) + self.AppendFlags(result, flags.get('all')) return result def AddRelevantSubFlags(self, options, flags): @@ -667,11 +803,23 @@ def BuildSpecific(env, mode, env_overrides): 'd8': d8_flags } + # Generate library base name. target_id = mode suffix = SUFFIXES[target_id] library_name = 'v8' + 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': + soname = GetSpecificSONAME() + if soname == '': + soname = 'lib' + library_name + '.so' + env['SONAME'] = soname + # Build the object files by invoking SCons recursively. (object_files, shell_files, mksnapshot) = env.SConscript( join('src', 'SConscript'), diff --git a/deps/v8/include/v8-debug.h b/deps/v8/include/v8-debug.h index 4c639c1833..3adc0a0d57 100644 --- a/deps/v8/include/v8-debug.h +++ b/deps/v8/include/v8-debug.h @@ -25,8 +25,8 @@ // (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_DEBUG_H_ -#define V8_DEBUG_H_ +#ifndef V8_V8_DEBUG_H_ +#define V8_V8_DEBUG_H_ #include "v8.h" @@ -79,48 +79,116 @@ enum DebugEvent { }; -/** - * Debug event callback function. - * - * \param event the type of the debug event that triggered the callback - * (enum DebugEvent) - * \param exec_state execution state (JavaScript object) - * \param event_data event specific data (JavaScript object) - * \param data value passed by the user to SetDebugEventListener - */ -typedef void (*DebugEventCallback)(DebugEvent event, - Handle exec_state, - Handle event_data, - Handle data); - - -/** - * Debug message callback function. - * - * \param message the debug message - * \param length length of the message - * \param data the data value passed when registering the message handler - * A DebugMessageHandler does not take posession of the message string, - * and must not rely on the data persisting after the handler returns. - */ -typedef void (*DebugMessageHandler)(const uint16_t* message, int length, - void* data); - -/** - * Debug host dispatch callback function. - * - * \param dispatch the dispatch value - * \param data the data value passed when registering the dispatch handler - */ -typedef void (*DebugHostDispatchHandler)(void* dispatch, - void* data); - - - class EXPORT Debug { public: + /** + * A client object passed to the v8 debugger whose ownership will be taken by + * it. v8 is always responsible for deleting the object. + */ + class ClientData { + public: + virtual ~ClientData() {} + }; + + + /** + * A message object passed to the debug message handler. + */ + class Message { + public: + /** + * Check type of message. + */ + virtual bool IsEvent() const = 0; + virtual bool IsResponse() const = 0; + virtual DebugEvent GetEvent() const = 0; + + /** + * Indicate whether this is a response to a continue command which will + * start the VM running after this is processed. + */ + virtual bool WillStartRunning() const = 0; + + /** + * Access to execution state and event data. Don't store these cross + * callbacks as their content becomes invalid. These objects are from the + * debugger event that started the debug message loop. + */ + virtual Handle GetExecutionState() const = 0; + virtual Handle GetEventData() const = 0; + + /** + * Get the debugger protocol JSON. + */ + virtual Handle GetJSON() 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 it's own context which is entered at this point. + */ + virtual Handle GetEventContext() const = 0; + + /** + * Client data passed with the corresponding request if any. This is the + * client_data data value passed into Debug::SendCommand along with the + * request that led to the message or NULL if the message is an event. The + * debugger takes ownership of the data and will delete it even if there is + * no message handler. + */ + virtual ClientData* GetClientData() const = 0; + + virtual ~Message() {} + }; + + + /** + * Debug event callback function. + * + * \param event the type of the debug event that triggered the callback + * (enum DebugEvent) + * \param exec_state execution state (JavaScript object) + * \param event_data event specific data (JavaScript object) + * \param data value passed by the user to SetDebugEventListener + */ + typedef void (*EventCallback)(DebugEvent event, + Handle exec_state, + Handle event_data, + Handle data); + + + /** + * Debug message callback function. + * + * \param message the debug message handler message object + * \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, + * and must not rely on the data persisting after the handler returns. + * + * This message handler is deprecated. Use MessageHandler2 instead. + */ + typedef void (*MessageHandler)(const uint16_t* message, int length, + ClientData* client_data); + + /** + * Debug message callback function. + * + * \param message the debug message handler message object + + * A MessageHandler does not take posession of the message data, + * and must not rely on the data persisting after the handler returns. + */ + typedef void (*MessageHandler2)(const Message& message); + + /** + * Debug host dispatch callback function. + */ + typedef void (*HostDispatchHandler)(); + // Set a C debug event listener. - static bool SetDebugEventListener(DebugEventCallback that, + static bool SetDebugEventListener(EventCallback that, Handle data = Handle()); // Set a JavaScript debug event listener. @@ -130,15 +198,17 @@ class EXPORT Debug { // Break execution of JavaScript. static void DebugBreak(); - // Message based interface. The message protocol is JSON. - static void SetMessageHandler(DebugMessageHandler handler, void* data = NULL, - bool message_handler_thread = true); - static void SendCommand(const uint16_t* command, int length); + // 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); + static void SendCommand(const uint16_t* command, int length, + ClientData* client_data = NULL); // Dispatch interface. - static void SetHostDispatchHandler(DebugHostDispatchHandler handler, - void* data = NULL); - static void SendHostDispatch(void* dispatch); + static void SetHostDispatchHandler(HostDispatchHandler handler, + int period = 100); /** * Run a JavaScript function in the debugger. @@ -176,4 +246,4 @@ class EXPORT Debug { #undef EXPORT -#endif // V8_DEBUG_H_ +#endif // V8_V8_DEBUG_H_ diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 1ddaee02c9..9f59e4e6b0 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -41,10 +41,15 @@ #include #ifdef _WIN32 +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 unsigned short uint16_t; // NOLINT -typedef long long int64_t; // NOLINT +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +// intptr_t is defined in crtdefs.h through stdio.h. // 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 @@ -529,6 +534,13 @@ class V8EXPORT Script { * Returns the script id value. */ Local Id(); + + /** + * Associate an additional data object with the script. This is mainly used + * with the debugger as this data object is only available through the + * debugger API. + */ + void SetData(Handle data); }; @@ -540,8 +552,18 @@ class V8EXPORT Message { Local Get() const; Local GetSourceLine() const; + /** + * Returns the resource name for the script from where the function causing + * the error originates. + */ Handle GetScriptResourceName() const; + /** + * Returns the resource data for the script from where the function causing + * the error originates. + */ + Handle GetScriptData() const; + /** * Returns the number, 1-based, of the line where the error occurred. */ @@ -805,14 +827,14 @@ class V8EXPORT String : public Primitive { }; /** - * Get the ExternalStringResource for an external string. Only - * valid if IsExternal() returns true. + * Get the ExternalStringResource for an external string. Returns + * NULL if IsExternal() doesn't return true. */ ExternalStringResource* GetExternalStringResource() const; /** * Get the ExternalAsciiStringResource for an external ascii string. - * Only valid if IsExternalAscii() returns true. + * Returns NULL if IsExternalAscii() doesn't return true. */ ExternalAsciiStringResource* GetExternalAsciiStringResource() const; @@ -1028,6 +1050,18 @@ class V8EXPORT Object : public Value { bool Set(Handle key, Handle value, PropertyAttribute attribs = None); + + // Sets a local property on this object, bypassing interceptors and + // overriding accessors or read-only properties. + // + // Note that if the object has an interceptor the property will be set + // locally, but since the interceptor takes precedence the local property + // will only be returned if the interceptor doesn't return a value. + // + // Note also that this only works for named properties. + bool ForceSet(Handle key, + Handle value, + PropertyAttribute attribs = None); Local Get(Handle key); // TODO(1245389): Replace the type-specific versions of these @@ -1093,6 +1127,9 @@ class V8EXPORT Object : public Value { /** * Returns the identity hash for this object. The current implemenation uses * a hidden property on the object to store the identity hash. + * + * The return value will never be 0. Also, it is not guaranteed to be + * unique. */ int GetIdentityHash(); @@ -2042,6 +2079,24 @@ class V8EXPORT V8 { */ static void ResumeProfiler(); + /** + * If logging is performed into a memory buffer (via --logfile=*), allows to + * retrieve previously written messages. This can be used for retrieving + * profiler log data in the application. This function is thread-safe. + * + * Caller provides a destination buffer that must exist during GetLogLines + * call. Only whole log lines are copied into the buffer. + * + * \param from_pos specified a point in a buffer to read from, 0 is the + * beginning of a buffer. It is assumed that caller updates its current + * position using returned size value from the previous call. + * \param dest_buf destination buffer for log data. + * \param max_size size of the destination buffer. + * \returns actual size of log data copied into buffer. + */ + static int GetLogLines(int from_pos, char* dest_buf, int max_size); + + /** * Releases any resources used by v8 and stops any utility threads * that may be running. Note that disposing v8 is permanent, it @@ -2222,6 +2277,14 @@ class V8EXPORT Context { /** Returns true if V8 has a current context. */ static bool InContext(); + /** + * Associate an additional data object with the context. This is mainly used + * with the debugger to provide additional information on the context through + * the debugger API. + */ + void SetData(Handle data); + Local GetData(); + /** * Stack-allocated class which sets the execution context for all * operations executed within a local scope. diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index 087d4fd46b..27ed293e7e 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -38,6 +38,7 @@ bool ExecuteString(v8::Handle source, bool print_result, bool report_exceptions); v8::Handle Print(const v8::Arguments& args); +v8::Handle Read(const v8::Arguments& args); v8::Handle Load(const v8::Arguments& args); v8::Handle Quit(const v8::Arguments& args); v8::Handle Version(const v8::Arguments& args); @@ -52,6 +53,8 @@ int RunMain(int argc, char* argv[]) { v8::Handle global = v8::ObjectTemplate::New(); // Bind the global 'print' function to the C++ Print callback. global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print)); + // Bind the global 'read' function to the C++ Read callback. + global->Set(v8::String::New("read"), v8::FunctionTemplate::New(Read)); // Bind the global 'load' function to the C++ Load callback. global->Set(v8::String::New("load"), v8::FunctionTemplate::New(Load)); // Bind the 'quit' function @@ -135,6 +138,25 @@ v8::Handle Print(const v8::Arguments& args) { } +// The callback that is invoked by v8 whenever the JavaScript 'read' +// function is called. This function loads the content of the file named in +// the argument into a JavaScript string. +v8::Handle Read(const v8::Arguments& args) { + if (args.Length() != 1) { + return v8::ThrowException(v8::String::New("Bad parameters")); + } + v8::String::Utf8Value file(args[0]); + if (*file == NULL) { + return v8::ThrowException(v8::String::New("Error loading file")); + } + v8::Handle source = ReadFile(*file); + if (source.IsEmpty()) { + return v8::ThrowException(v8::String::New("Error loading file")); + } + return source; +} + + // The callback that is invoked by v8 whenever the JavaScript 'load' // function is called. Loads, compiles and executes its argument // JavaScript file. diff --git a/deps/v8/src/SConscript b/deps/v8/src/SConscript old mode 100644 new mode 100755 index 97fb7d6caa..59c452b7ca --- a/deps/v8/src/SConscript +++ b/deps/v8/src/SConscript @@ -50,23 +50,36 @@ SOURCES = { 'scopeinfo.cc', 'scopes.cc', 'serialize.cc', 'snapshot-common.cc', 'spaces.cc', 'string-stream.cc', 'stub-cache.cc', 'token.cc', 'top.cc', 'unicode.cc', 'usage-analyzer.cc', 'utils.cc', 'v8-counters.cc', - 'v8.cc', 'v8threads.cc', 'variables.cc', 'virtual-frame.cc', 'zone.cc' + 'v8.cc', 'v8threads.cc', 'variables.cc', 'version.cc', + 'virtual-frame.cc', 'zone.cc' ], 'arch:arm': [ - 'assembler-arm.cc', 'builtins-arm.cc', 'codegen-arm.cc', 'cpu-arm.cc', - 'disasm-arm.cc', 'debug-arm.cc', 'frames-arm.cc', 'ic-arm.cc', - 'jump-target-arm.cc', 'macro-assembler-arm.cc', - 'regexp-macro-assembler-arm.cc', 'register-allocator-arm.cc', - 'stub-cache-arm.cc', 'virtual-frame-arm.cc' + 'arm/assembler-arm.cc', 'arm/builtins-arm.cc', + 'arm/codegen-arm.cc', 'arm/cpu-arm.cc', 'arm/disasm-arm.cc', + 'arm/debug-arm.cc', 'arm/frames-arm.cc', 'arm/ic-arm.cc', + 'arm/jump-target-arm.cc', 'arm/macro-assembler-arm.cc', + 'arm/regexp-macro-assembler-arm.cc', + 'arm/register-allocator-arm.cc', 'arm/stub-cache-arm.cc', + 'arm/virtual-frame-arm.cc' ], 'arch:ia32': [ - 'assembler-ia32.cc', 'builtins-ia32.cc', 'codegen-ia32.cc', - 'cpu-ia32.cc', 'disasm-ia32.cc', 'debug-ia32.cc', 'frames-ia32.cc', - 'ic-ia32.cc', 'jump-target-ia32.cc', 'macro-assembler-ia32.cc', - 'regexp-macro-assembler-ia32.cc', 'register-allocator-ia32.cc', - 'stub-cache-ia32.cc', 'virtual-frame-ia32.cc' + 'ia32/assembler-ia32.cc', 'ia32/builtins-ia32.cc', + 'ia32/codegen-ia32.cc', 'ia32/cpu-ia32.cc', 'ia32/disasm-ia32.cc', + 'ia32/debug-ia32.cc', 'ia32/frames-ia32.cc', 'ia32/ic-ia32.cc', + 'ia32/jump-target-ia32.cc', 'ia32/macro-assembler-ia32.cc', + 'ia32/regexp-macro-assembler-ia32.cc', + 'ia32/register-allocator-ia32.cc', 'ia32/stub-cache-ia32.cc', + 'ia32/virtual-frame-ia32.cc' ], - 'simulator:arm': ['simulator-arm.cc'], + 'arch:x64': [ + 'x64/assembler-x64.cc', 'x64/builtins-x64.cc', + 'x64/codegen-x64.cc', 'x64/cpu-x64.cc', 'x64/disasm-x64.cc', + 'x64/debug-x64.cc', 'x64/frames-x64.cc', 'x64/ic-x64.cc', + 'x64/jump-target-x64.cc', 'x64/macro-assembler-x64.cc', + # 'x64/regexp-macro-assembler-x64.cc', + 'x64/stub-cache-x64.cc' + ], + 'simulator:arm': ['arm/simulator-arm.cc'], 'os:freebsd': ['platform-freebsd.cc', 'platform-posix.cc'], 'os:linux': ['platform-linux.cc', 'platform-posix.cc'], 'os:android': ['platform-linux.cc', 'platform-posix.cc'], @@ -121,6 +134,7 @@ debug-delay.js mirror-delay.js date-delay.js regexp-delay.js +json-delay.js '''.split() diff --git a/deps/v8/src/accessors.cc b/deps/v8/src/accessors.cc index d779eb26ae..4cd93be870 100644 --- a/deps/v8/src/accessors.cc +++ b/deps/v8/src/accessors.cc @@ -251,6 +251,24 @@ const AccessorDescriptor Accessors::ScriptColumnOffset = { }; +// +// Accessors::ScriptData +// + + +Object* Accessors::ScriptGetData(Object* object, void*) { + Object* script = JSValue::cast(object)->value(); + return Script::cast(script)->data(); +} + + +const AccessorDescriptor Accessors::ScriptData = { + ScriptGetData, + IllegalSetter, + 0 +}; + + // // Accessors::ScriptType // @@ -289,6 +307,25 @@ const AccessorDescriptor Accessors::ScriptLineEnds = { }; +// +// Accessors::ScriptGetContextData +// + + +Object* Accessors::ScriptGetContextData(Object* object, void*) { + HandleScope scope; + Handle