diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000000000000..7bdd7f775278 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,11 @@ +# Below is a list of people and organizations that have contributed +# to the V8 project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. + +Rene Rebe +Rafal Krypa +Jay Freeman +Daniel James diff --git a/ChangeLog b/ChangeLog index b93a44ce92cd..33cfd0b886f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,48 @@ +2008-09-11: Version 0.3.1 + + Fixed a number of build issues. + + Fixed problem with missing I-cache flusing on ARM. + + Changed space layout in memory management by splitting up + code space into old data space and code space. + + Added utf-8 conversion support to the API (issue 57). + + Optimized repeated calls to eval with the same strings. These + repeated calls are common in web applications. + + Added Xcode project file. + + Optimized a couple of Array operation. + + Fixed parser bug by checking for end-of-string when parsing break + and continue (issue 35). + + Fixed problem where asian characters were not categorized as + letters. + + Fixed bug that disallowed calling functions fetched from an array + using a string as an array index (issue 32). + + Fixed bug where the internal field count on object templates were + sometimes ignored (issue 54). + + Added -f option to the shell sample for compatibility with other + engines (issue 18). + + Added source info to TryCatches in the API. + + Fixed problem where the seed for the random number generator was + clipped in a double to unsigned int conversion. + + Fixed bug where cons string symbols were sometimes converted to + non-symbol flat strings during GC. + + Fixed bug in error reporting when attempting to convert null to an + object. + + 2008-09-04: Version 0.3.0 Added support for running tests on the ARM simulator. diff --git a/SConstruct b/SConstruct index 34f20d340ac7..a2bed5652c1c 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,4 @@ -# Copyright 2008 Google Inc. All rights reserved. +# Copyright 2008 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: @@ -30,6 +30,7 @@ import re import sys import os from os.path import join, dirname, abspath +from types import DictType root_dir = dirname(File('SConstruct').rfile().abspath) sys.path.append(join(root_dir, 'tools')) import js2c, utils @@ -55,8 +56,9 @@ LIBRARY_FLAGS = { 'CCFLAGS': ['-O2'] }, 'wordsize:64': { - 'CCFLAGS': ['-m32'] - }, + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + } }, 'msvc': { 'all': { @@ -95,6 +97,9 @@ V8_EXTRA_FLAGS = { 'arch:arm': { 'CPPDEFINES': ['ARM'] }, + 'disassembler:on': { + 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] + } }, 'msvc': { 'all': { @@ -106,6 +111,9 @@ V8_EXTRA_FLAGS = { 'arch:arm': { 'CPPDEFINES': ['ARM'] }, + 'disassembler:on': { + 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] + } } } @@ -182,6 +190,9 @@ SAMPLE_FLAGS = { 'CCFLAGS': ['-m32'], 'LINKFLAGS': ['-m32'] }, + 'mode:debug': { + 'CCFLAGS': ['-g', '-O0'] + } }, 'msvc': { 'all': { @@ -281,6 +292,16 @@ SIMPLE_OPTIONS = { 'values': ['arm', 'none'], 'default': 'none', 'help': 'build with simulator' + }, + 'disassembler': { + 'values': ['on', 'off'], + 'default': 'off', + 'help': 'enable the disassembler to inspect generated code' + }, + 'sourcesignatures': { + 'values': ['MD5', 'timestamp'], + 'default': 'MD5', + 'help': 'set how the build system detects file changes' } } @@ -369,6 +390,14 @@ class BuildContext(object): else: return env.SharedObject(input, **kw) + def ApplyEnvOverrides(self, env): + if not self.env_overrides: + return + if type(env['ENV']) == DictType: + env['ENV'].update(**self.env_overrides) + else: + env['ENV'] = self.env_overrides + def PostprocessOptions(options): # Adjust architecture if the simulator option has been set @@ -427,6 +456,7 @@ def BuildSpecific(env, mode, env_overrides): ) # Link the object files into a library. + context.ApplyEnvOverrides(env) if context.options['library'] == 'static': library = env.StaticLibrary(library_name, object_files) else: @@ -440,7 +470,7 @@ def BuildSpecific(env, mode, env_overrides): for sample in context.samples: sample_env = Environment(LIBRARY=library_name) sample_env.Replace(**context.flags['sample']) - sample_env['ENV'].update(**context.env_overrides) + context.ApplyEnvOverrides(sample_env) sample_object = sample_env.SConscript( join('samples', 'SConscript'), build_dir=join('obj', 'sample', sample, target_id), @@ -470,6 +500,8 @@ def Build(): VerifyOptions(env) env_overrides = ParseEnvOverrides(env['env']) + SourceSignatures(env['sourcesignatures']) + libraries = [] cctests = [] samples = [] diff --git a/benchmarks/base.js b/benchmarks/base.js index d3c9dcaec982..55e717d868c9 100644 --- a/benchmarks/base.js +++ b/benchmarks/base.js @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 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/benchmarks/deltablue.js b/benchmarks/deltablue.js index b18efa4306da..b51afd1d2dea 100644 --- a/benchmarks/deltablue.js +++ b/benchmarks/deltablue.js @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 the V8 project authors. All rights reserved. // Copyright 1996 John Maloney and Mario Wolczko. // This program is free software; you can redistribute it and/or modify diff --git a/benchmarks/richards.js b/benchmarks/richards.js index 8cced90bd097..7df363d9803e 100644 --- a/benchmarks/richards.js +++ b/benchmarks/richards.js @@ -1,4 +1,4 @@ -// Copyright 2007 Google Inc. All rights reserved. +// Copyright 2006-2008 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/benchmarks/run.js b/benchmarks/run.js index 8302535d411b..7a1c89584a20 100644 --- a/benchmarks/run.js +++ b/benchmarks/run.js @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 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/codereview.settings b/codereview.settings new file mode 100644 index 000000000000..e83396c25d5f --- /dev/null +++ b/codereview.settings @@ -0,0 +1,4 @@ +# This file is used by gcl to get repository specific information. +CODE_REVIEW_SERVER: codereview.chromium.org +VIEW_VC: http://code.google.com/p/v8/source/detail?r= +CC_LIST: v8-dev@googlegroups.com diff --git a/include/v8-debug.h b/include/v8-debug.h index 8881e4a2965c..f537d7dc891f 100644 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 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,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 -#define _V8_DEBUG +#ifndef V8_DEBUG_H_ +#define V8_DEBUG_H_ #include "v8.h" @@ -140,4 +140,4 @@ class EXPORT Debug { #undef EXPORT -#endif // _V8_DEBUG +#endif // V8_DEBUG_H_ diff --git a/include/v8.h b/include/v8.h index ddd423e0e4a9..fd6d9ab2783e 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1,4 +1,4 @@ -// Copyright 2007-2008 Google Inc. All Rights Reserved. +// Copyright 2007-2008 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: @@ -26,8 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** \mainpage V8 API Reference Guide - * - * V8 is Google's open source JavaScript engine. + * + * V8 is Google's open source JavaScript engine. * * This set of documents provides reference material generated from the * V8 header file, include/v8.h. @@ -35,8 +35,8 @@ * For other documentation see http://code.google.com/apis/v8/ */ -#ifndef _V8 -#define _V8 +#ifndef V8_H_ +#define V8_H_ #include @@ -461,10 +461,8 @@ class EXPORT HandleScope { /** Deallocates any extensions used by the current scope.*/ static void DeleteExtensions(); -#ifdef DEBUG // Zaps the handles in the half-open interval [start, end). static void ZapRange(void** start, void** end); -#endif friend class ImplementationUtilities; }; @@ -485,7 +483,7 @@ class EXPORT Data { /** * Pre-compilation data that can be associated with a script. This * data can be calculated for a script in advance of actually - * compiling it, and can bestored between compilations. When script + * compiling it, and can be stored between compilations. When script * data is given to the compile method compilation will be faster. */ class EXPORT ScriptData { // NOLINT @@ -555,7 +553,7 @@ class EXPORT Script { class EXPORT Message { public: Local Get(); - Local GetSourceLine(); + Local GetSourceLine(); // TODO(1241256): Rewrite (or remove) this method. We don't want to // deal with ownership of the returned string and we want to use @@ -568,8 +566,35 @@ class EXPORT Message { // bindings. Handle GetSourceData(); + /** + * Returns the number, 1-based, of the line where the error occurred. + */ int GetLineNumber(); + /** + * Returns the index within the script of the first character where + * the error occurred. + */ + int GetStartPosition(); + + /** + * Returns the index within the script of the last character where + * the error occurred. + */ + int GetEndPosition(); + + /** + * Returns the index within the line of the first character where + * the error occurred. + */ + int GetStartColumn(); + + /** + * Returns the index within the line of the last character where + * the error occurred. + */ + int GetEndColumn(); + // TODO(1245381): Print to a string instead of on a FILE. static void PrintCurrentStackTrace(FILE* out); }; @@ -631,7 +656,7 @@ class EXPORT Value : public Data { * Returns true if this value is boolean. */ bool IsBoolean(); - + /** * Returns true if this value is a number. */ @@ -696,8 +721,18 @@ class EXPORT Boolean : public Primitive { */ class EXPORT String : public Primitive { public: + + /** + * Returns the number of characters in this string. + */ int Length(); + /** + * Returns the number of bytes in the UTF-8 encoded + * representation of this string. + */ + int Utf8Length(); + /** * Write the contents of the string to an external buffer. * If no arguments are given, expects the buffer to be large @@ -716,9 +751,8 @@ class EXPORT String : public Primitive { * excluding the NULL terminator. */ int Write(uint16_t* buffer, int start = 0, int length = -1); // UTF-16 - int WriteAscii(char* buffer, - int start = 0, - int length = -1); // literally ascii + int WriteAscii(char* buffer, int start = 0, int length = -1); // ASCII + int WriteUtf8(char* buffer, int length = -1); // UTF-8 /** * Returns true if the string is external @@ -733,7 +767,7 @@ class EXPORT String : public Primitive { * An ExternalStringResource is a wrapper around a two-byte string * buffer that resides outside V8's heap. Implement an * ExternalStringResource to manage the life cycle of the underlying - * buffer. + * buffer. Note that the string data must be immutable. */ class EXPORT ExternalStringResource { // NOLINT public: @@ -757,7 +791,11 @@ class EXPORT String : public Primitive { * An ExternalAsciiStringResource is a wrapper around an ascii * string buffer that resides outside V8's heap. Implement an * ExternalAsciiStringResource to manage the life cycle of the - * underlying buffer. + * underlying buffer. Note that the string data must be immutable + * and that the data must be strict 7-bit ASCII, not Latin1 or + * UTF-8, which would require special treatment internally in the + * engine and, in the case of UTF-8, do not allow efficient indexing. + * Use String::New or convert to 16 bit data for non-ASCII. */ class EXPORT ExternalAsciiStringResource { // NOLINT @@ -835,6 +873,21 @@ class EXPORT String : public Primitive { /** Creates an undetectable string from the supplied utf-16 data.*/ static Local NewUndetectable(const uint16_t* data, int length = -1); + /** + * Converts an object to a utf8-encoded character array. Useful if + * you want to print the object. + */ + class EXPORT Utf8Value { + public: + explicit Utf8Value(Handle obj); + ~Utf8Value(); + char* operator*() { return str_; } + int length() { return length_; } + private: + char* str_; + int length_; + }; + /** * Converts an object to an ascii string. * Useful if you want to print the object. @@ -844,8 +897,10 @@ class EXPORT String : public Primitive { explicit AsciiValue(Handle obj); ~AsciiValue(); char* operator*() { return str_; } + int length() { return length_; } private: char* str_; + int length_; }; /** @@ -856,8 +911,10 @@ class EXPORT String : public Primitive { explicit Value(Handle obj); ~Value(); uint16_t* operator*() { return str_; } + int length() { return length_; } private: uint16_t* str_; + int length_; }; }; @@ -1755,7 +1812,7 @@ class EXPORT V8 { static void IgnoreOutOfMemoryException(); /** - * Check if V8 is dead and therefore unusable. This is the case after + * Check if V8 is dead and therefore unusable. This is the case after * fatal errors such as out-of-memory situations. */ static bool IsDead(); @@ -1900,6 +1957,15 @@ class EXPORT TryCatch { */ Local Exception(); + /** + * Returns the message associated with this exception. If there is + * no message associated an empty handle is returned. + * + * The returned handle is valid until this TryCatch block has been + * destroyed. + */ + Local Message(); + /** * Clears any exceptions that may have been caught by this try/catch block. * After this method has been called, HasCaught() will return false. @@ -1921,10 +1987,19 @@ class EXPORT TryCatch { */ void SetVerbose(bool value); + /** + * Set whether or not this TryCatch should capture a Message object + * which holds source information about where the exception + * occurred. True by default. + */ + void SetCaptureMessage(bool value); + public: TryCatch* next_; void* exception_; + void* message_; bool is_verbose_; + bool capture_message_; }; @@ -2116,11 +2191,11 @@ class EXPORT Locker { */ static void StopPreemption(); -#ifdef DEBUG - static void AssertIsLocked(); -#else - static inline void AssertIsLocked() { } -#endif + /** + * Returns whether or not the locker is locked by the current thread. + */ + static bool IsLocked(); + private: bool has_lock_; bool top_level_; @@ -2302,4 +2377,4 @@ void Template::Set(const char* name, v8::Handle value) { #undef TYPE_CHECK -#endif // _V8 +#endif // V8_H_ diff --git a/samples/SConscript b/samples/SConscript index bab66418fcc4..31990b681be3 100644 --- a/samples/SConscript +++ b/samples/SConscript @@ -1,4 +1,4 @@ -# Copyright 2008 Google Inc. All rights reserved. +# Copyright 2008 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: @@ -31,6 +31,7 @@ Import('sample context') def ConfigureObjectFiles(): env = Environment() env.Replace(**context.flags['sample']) + context.ApplyEnvOverrides(env) return env.Object(sample + '.cc') sample_object = ConfigureObjectFiles() diff --git a/samples/count-hosts.js b/samples/count-hosts.js index 5c714c3e03bd..bea6553d27bb 100644 --- a/samples/count-hosts.js +++ b/samples/count-hosts.js @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 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/samples/process.cc b/samples/process.cc index c0710f323a27..6567f080b86a 100644 --- a/samples/process.cc +++ b/samples/process.cc @@ -1,4 +1,4 @@ -// Copyright 2008 Google Inc. All Rights Reserved. +// Copyright 2008 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: @@ -137,7 +137,7 @@ static Handle LogCallback(const Arguments& args) { if (args.Length() < 1) return v8::Undefined(); HandleScope scope; Handle arg = args[0]; - String::AsciiValue value(arg); + String::Utf8Value value(arg); HttpRequestProcessor::Log(*value); return v8::Undefined(); } @@ -206,7 +206,7 @@ bool JsHttpRequestProcessor::ExecuteScript(Handle script) { // Compile the script and check for errors. Handle