From 1b15af9dd2bf4adb7a2e73ae17a12e2e98a88f72 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 15 Sep 2011 09:41:08 -0700 Subject: [PATCH] Upgrade V8 to 3.6.4 --- deps/v8/AUTHORS | 1 + deps/v8/ChangeLog | 21 + deps/v8/build/README.txt | 4 +- deps/v8/include/v8.h | 37 +- deps/v8/samples/process.cc | 2 - deps/v8/src/accessors.cc | 1 + deps/v8/src/api.cc | 41 +- deps/v8/src/arguments.h | 1 + deps/v8/src/arm/builtins-arm.cc | 86 +- deps/v8/src/arm/code-stubs-arm.cc | 33 +- deps/v8/src/arm/full-codegen-arm.cc | 18 +- deps/v8/src/arm/ic-arm.cc | 20 +- deps/v8/src/arm/lithium-arm.cc | 33 +- deps/v8/src/arm/lithium-arm.h | 4 +- deps/v8/src/arm/lithium-codegen-arm.cc | 93 +- deps/v8/src/arm/lithium-gap-resolver-arm.h | 1 - deps/v8/src/arm/macro-assembler-arm.cc | 26 +- deps/v8/src/arm/macro-assembler-arm.h | 4 +- deps/v8/src/arm/regexp-macro-assembler-arm.h | 1 + deps/v8/src/arm/stub-cache-arm.cc | 160 +-- deps/v8/src/array.js | 18 +- deps/v8/src/ast.cc | 4 +- deps/v8/src/ast.h | 2 +- deps/v8/src/bignum.h | 1 + deps/v8/src/bootstrapper.cc | 4 +- deps/v8/src/builtins.cc | 1 - deps/v8/src/builtins.h | 2 + deps/v8/src/cached-powers.h | 1 - deps/v8/src/circular-queue-inl.h | 8 +- deps/v8/src/code-stubs.cc | 65 +- deps/v8/src/code-stubs.h | 32 +- deps/v8/src/compilation-cache.h | 1 + deps/v8/src/compiler.h | 10 +- deps/v8/src/cpu-profiler-inl.h | 5 - deps/v8/src/cpu-profiler.cc | 11 - deps/v8/src/cpu-profiler.h | 9 - deps/v8/src/d8-debug.cc | 16 +- deps/v8/src/d8-debug.h | 8 +- deps/v8/src/d8-posix.cc | 1 + deps/v8/src/d8-readline.cc | 23 +- deps/v8/src/d8.cc | 172 +-- deps/v8/src/d8.h | 74 +- deps/v8/src/dateparser.h | 4 +- deps/v8/src/debug-agent.cc | 17 +- deps/v8/src/debug-agent.h | 4 +- deps/v8/src/debug.cc | 116 +- deps/v8/src/debug.h | 6 + deps/v8/src/disassembler.cc | 5 +- deps/v8/src/elements.cc | 24 +- deps/v8/src/elements.h | 4 +- deps/v8/src/execution.cc | 65 +- deps/v8/src/execution.h | 7 +- deps/v8/src/factory.cc | 21 +- deps/v8/src/factory.h | 11 +- deps/v8/src/flags.cc | 6 +- deps/v8/src/frames.h | 1 + deps/v8/src/full-codegen.cc | 4 +- deps/v8/src/gdb-jit.cc | 4 +- deps/v8/src/handles.cc | 17 +- deps/v8/src/handles.h | 2 - deps/v8/src/heap.cc | 70 +- deps/v8/src/heap.h | 18 +- deps/v8/src/hydrogen-instructions.cc | 60 +- deps/v8/src/hydrogen-instructions.h | 29 +- deps/v8/src/hydrogen.cc | 141 +-- deps/v8/src/hydrogen.h | 3 +- deps/v8/src/ia32/assembler-ia32.h | 3 + deps/v8/src/ia32/builtins-ia32.cc | 89 +- deps/v8/src/ia32/code-stubs-ia32.cc | 35 +- deps/v8/src/ia32/full-codegen-ia32.cc | 19 +- deps/v8/src/ia32/ic-ia32.cc | 19 +- deps/v8/src/ia32/lithium-codegen-ia32.cc | 93 +- deps/v8/src/ia32/lithium-codegen-ia32.h | 2 +- deps/v8/src/ia32/lithium-ia32.cc | 35 +- deps/v8/src/ia32/lithium-ia32.h | 4 +- deps/v8/src/ia32/macro-assembler-ia32.cc | 26 +- deps/v8/src/ia32/stub-cache-ia32.cc | 86 +- deps/v8/src/ic.cc | 52 +- deps/v8/src/ic.h | 9 +- deps/v8/src/inspector.h | 2 - deps/v8/src/isolate.cc | 9 +- deps/v8/src/isolate.h | 22 +- deps/v8/src/json.js | 8 +- deps/v8/src/jsregexp.h | 8 + deps/v8/src/list-inl.h | 29 + deps/v8/src/list.h | 10 +- deps/v8/src/lithium.cc | 28 +- deps/v8/src/lithium.h | 8 +- deps/v8/src/liveedit.cc | 2 +- deps/v8/src/liveobjectlist.cc | 18 +- deps/v8/src/liveobjectlist.h | 3 - deps/v8/src/log-utils.cc | 2 +- deps/v8/src/log-utils.h | 1 - deps/v8/src/log.cc | 110 +- deps/v8/src/log.h | 2 + deps/v8/src/macros.py | 12 +- deps/v8/src/messages.cc | 7 +- deps/v8/src/messages.h | 2 +- deps/v8/src/messages.js | 3 + deps/v8/src/mips/assembler-mips-inl.h | 13 +- deps/v8/src/mips/assembler-mips.cc | 214 +++- deps/v8/src/mips/assembler-mips.h | 84 +- deps/v8/src/mips/code-stubs-mips.cc | 14 +- deps/v8/src/mips/constants-mips.cc | 9 +- deps/v8/src/mips/constants-mips.h | 50 +- deps/v8/src/mips/disasm-mips.cc | 19 +- deps/v8/src/mips/frames-mips.h | 1 - deps/v8/src/mips/full-codegen-mips.cc | 16 +- deps/v8/src/mips/ic-mips.cc | 19 +- deps/v8/src/mips/macro-assembler-mips.cc | 26 +- .../v8/src/mips/regexp-macro-assembler-mips.h | 1 + deps/v8/src/mips/simulator-mips.cc | 5 + deps/v8/src/mips/stub-cache-mips.cc | 160 +-- deps/v8/src/objects-debug.cc | 12 + deps/v8/src/objects-inl.h | 113 +- deps/v8/src/objects-printer.cc | 16 + deps/v8/src/objects-visiting.cc | 5 + deps/v8/src/objects.cc | 157 ++- deps/v8/src/objects.h | 232 ++-- deps/v8/src/parser.cc | 8 +- deps/v8/src/platform-cygwin.cc | 1 - deps/v8/src/platform-freebsd.cc | 1 - deps/v8/src/platform-macos.cc | 1 - deps/v8/src/platform-solaris.cc | 1 - deps/v8/src/platform-win32.cc | 2 +- deps/v8/src/prettyprinter.cc | 49 +- deps/v8/src/profile-generator-inl.h | 16 - deps/v8/src/profile-generator.cc | 32 + deps/v8/src/profile-generator.h | 7 +- deps/v8/src/property.cc | 6 +- deps/v8/src/property.h | 16 +- deps/v8/src/proxy.js | 51 +- deps/v8/src/regexp-macro-assembler-irregexp.h | 1 + deps/v8/src/regexp-macro-assembler-tracer.h | 1 + deps/v8/src/regexp-stack.h | 1 + deps/v8/src/runtime.cc | 240 ++-- deps/v8/src/runtime.h | 5 + deps/v8/src/runtime.js | 44 +- deps/v8/src/safepoint-table.cc | 4 +- deps/v8/src/scanner-character-streams.cc | 21 - deps/v8/src/scanner.cc | 19 + deps/v8/src/scanner.h | 2 +- deps/v8/src/scopeinfo.h | 2 +- deps/v8/src/scopes.cc | 23 +- deps/v8/src/serialize.cc | 7 +- ...{smart-pointer.h => smart-array-pointer.h} | 28 +- deps/v8/src/spaces.h | 3 +- deps/v8/src/splay-tree.h | 5 +- deps/v8/src/string-stream.cc | 4 +- deps/v8/src/string-stream.h | 3 +- deps/v8/src/string.js | 11 +- deps/v8/src/stub-cache.cc | 83 +- deps/v8/src/stub-cache.h | 25 +- deps/v8/src/type-info.cc | 1 - deps/v8/src/utils.h | 27 +- deps/v8/src/v8globals.h | 8 +- deps/v8/src/v8natives.js | 46 +- deps/v8/src/v8threads.h | 1 + deps/v8/src/variables.cc | 2 +- deps/v8/src/variables.h | 10 +- deps/v8/src/version.cc | 2 +- deps/v8/src/weakmap.js | 3 - deps/v8/src/x64/assembler-x64.h | 3 + deps/v8/src/x64/builtins-x64.cc | 77 +- deps/v8/src/x64/code-stubs-x64.cc | 33 +- deps/v8/src/x64/full-codegen-x64.cc | 15 +- deps/v8/src/x64/ic-x64.cc | 19 +- deps/v8/src/x64/lithium-codegen-x64.cc | 93 +- deps/v8/src/x64/lithium-codegen-x64.h | 2 +- deps/v8/src/x64/lithium-x64.cc | 33 +- deps/v8/src/x64/lithium-x64.h | 4 +- deps/v8/src/x64/macro-assembler-x64.cc | 24 +- deps/v8/src/x64/stub-cache-x64.cc | 92 +- deps/v8/src/zone-inl.h | 7 +- deps/v8/src/zone.cc | 15 +- deps/v8/test/cctest/cctest.h | 1 + .../cctest/log-eq-of-logging-and-traversal.js | 18 +- deps/v8/test/cctest/test-cpu-profiler.cc | 2 +- deps/v8/test/cctest/test-debug.cc | 3 +- .../test/cctest/test-func-name-inference.cc | 4 +- deps/v8/test/cctest/test-heap-profiler.cc | 2 +- deps/v8/test/cctest/test-lockers.cc | 4 + deps/v8/test/cctest/test-log.cc | 6 +- deps/v8/test/cctest/test-parsing.cc | 4 +- deps/v8/test/cctest/test-profile-generator.cc | 11 +- deps/v8/test/cctest/test-regexp.cc | 8 +- deps/v8/test/cctest/test-reloc-info.cc | 2 +- deps/v8/test/cctest/test-threads.cc | 1 + deps/v8/test/mjsunit/debug-scopes.js | 75 ++ deps/v8/test/mjsunit/debug-step-2.js | 89 ++ deps/v8/test/mjsunit/external-array.js | 13 + deps/v8/test/mjsunit/fuzz-natives.js | 3 + deps/v8/test/mjsunit/harmony/proxies.js | 1010 +++++++++++++++-- deps/v8/test/mjsunit/harmony/weakmaps.js | 4 + deps/v8/test/mjsunit/regress/regress-1639.js | 85 ++ deps/v8/test/mjsunit/regress/regress-95920.js | 58 + deps/v8/test/mjsunit/regress/regress-96523.js | 37 + .../mjsunit/regress/regress-bind-receiver.js | 44 + deps/v8/tools/codemap.js | 19 + deps/v8/tools/gyp/v8.gyp | 2 +- deps/v8/tools/push-to-trunk.sh | 11 +- 201 files changed, 4246 insertions(+), 2128 deletions(-) rename deps/v8/src/{smart-pointer.h => smart-array-pointer.h} (79%) create mode 100644 deps/v8/test/mjsunit/debug-step-2.js create mode 100644 deps/v8/test/mjsunit/regress/regress-1639.js create mode 100644 deps/v8/test/mjsunit/regress/regress-95920.js create mode 100644 deps/v8/test/mjsunit/regress/regress-96523.js create mode 100644 deps/v8/test/mjsunit/regress/regress-bind-receiver.js diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index d4e35fe8002..fcb5c205a6e 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -21,6 +21,7 @@ Daniel Andersson Daniel James Dineel D Sule Erich Ocean +Fedor Indutny Jan de Mooij Jay Freeman Joel Stanley diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 817aa3a4ee2..99495dd46b6 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,24 @@ +2011-09-15: Version 3.6.4 + + Fixed d8's broken readline history. + + Removed the need for code delete events in CPU profiler (Issue 1466). + + Fixed debugger stepping next with trycatch recursion (Issue 1639). + + Fixing parallel execution in d8 (with -p) and some memory leaks. + + Support for precise stepping in functions compiled before debugging was + started (step 1). + + +2011-09-13: Version 3.6.3 + + Implemented better support of typed arrays in the d8 shell. + + Bug fixes and performance improvements on all platforms. + + 2011-09-08: Version 3.6.2 Added "dependencies" target to top-level Makefile. diff --git a/deps/v8/build/README.txt b/deps/v8/build/README.txt index c74b52051a8..ea6287f7b72 100644 --- a/deps/v8/build/README.txt +++ b/deps/v8/build/README.txt @@ -53,11 +53,11 @@ 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 +To run GYP Python is required and it is recommended 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 +> svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26 Now generate Visual Studio solution and project files for the ia32 architecture: diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 80193c423a3..4b7f6e735fe 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -1051,18 +1051,21 @@ class String : public Primitive { NO_NULL_TERMINATION = 2 }; + // 16-bit character codes. V8EXPORT int Write(uint16_t* buffer, int start = 0, int length = -1, - int options = NO_OPTIONS) const; // UTF-16 + int options = NO_OPTIONS) const; + // ASCII characters. V8EXPORT int WriteAscii(char* buffer, int start = 0, int length = -1, - int options = NO_OPTIONS) const; // ASCII + int options = NO_OPTIONS) const; + // UTF-8 encoded characters. V8EXPORT int WriteUtf8(char* buffer, int length = -1, int* nchars_ref = NULL, - int options = NO_OPTIONS) const; // UTF-8 + int options = NO_OPTIONS) const; /** * A zero length string. @@ -1075,7 +1078,7 @@ class String : public Primitive { V8EXPORT bool IsExternal() const; /** - * Returns true if the string is both external and ascii + * Returns true if the string is both external and ASCII */ V8EXPORT bool IsExternalAscii() const; @@ -1132,11 +1135,11 @@ class String : public Primitive { }; /** - * An ExternalAsciiStringResource is a wrapper around an ascii + * 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. Note that the string data must be immutable - * and that the data must be strict 7-bit ASCII, not Latin1 or + * and that the data must be strict (7-bit) ASCII, not Latin-1 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. @@ -1152,7 +1155,7 @@ class String : public Primitive { virtual ~ExternalAsciiStringResource() {} /** The string data from the underlying buffer.*/ virtual const char* data() const = 0; - /** The number of ascii characters in the string.*/ + /** The number of ASCII characters in the string.*/ virtual size_t length() const = 0; protected: ExternalAsciiStringResource() {} @@ -1165,7 +1168,7 @@ class String : public Primitive { inline ExternalStringResource* GetExternalStringResource() const; /** - * Get the ExternalAsciiStringResource for an external ascii string. + * Get the ExternalAsciiStringResource for an external ASCII string. * Returns NULL if IsExternalAscii() doesn't return true. */ V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() const; @@ -1173,9 +1176,9 @@ class String : public Primitive { static inline String* Cast(v8::Value* obj); /** - * Allocates a new string from either utf-8 encoded or ascii data. + * Allocates a new string from either UTF-8 encoded or ASCII data. * The second parameter 'length' gives the buffer length. - * If the data is utf-8 encoded, the caller must + * If the data is UTF-8 encoded, the caller must * be careful to supply the length parameter. * If it is not given, the function calls * 'strlen' to determine the buffer length, it might be @@ -1183,7 +1186,7 @@ class String : public Primitive { */ V8EXPORT static Local New(const char* data, int length = -1); - /** Allocates a new string from utf16 data.*/ + /** Allocates a new string from 16-bit character codes.*/ V8EXPORT static Local New(const uint16_t* data, int length = -1); /** Creates a symbol. Returns one if it exists already.*/ @@ -1218,7 +1221,7 @@ class String : public Primitive { V8EXPORT bool MakeExternal(ExternalStringResource* resource); /** - * Creates a new external string using the ascii data defined in the given + * Creates a new external string using the ASCII data defined in the given * resource. When the external string is no longer live on V8's heap the * resource will be disposed by calling its Dispose method. The caller of * this function should not otherwise delete or modify the resource. Neither @@ -1244,18 +1247,18 @@ class String : public Primitive { */ V8EXPORT bool CanMakeExternal(); - /** Creates an undetectable string from the supplied ascii or utf-8 data.*/ + /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ V8EXPORT static Local NewUndetectable(const char* data, int length = -1); - /** Creates an undetectable string from the supplied utf-16 data.*/ + /** Creates an undetectable string from the supplied 16-bit character codes.*/ V8EXPORT static Local NewUndetectable(const uint16_t* data, int length = -1); /** - * Converts an object to a utf8-encoded character array. Useful if + * Converts an object to a UTF-8-encoded character array. Useful if * you want to print the object. If conversion to a string fails - * (eg. due to an exception in the toString() method of the object) + * (e.g. due to an exception in the toString() method of the object) * then the length() method returns 0 and the * operator returns * NULL. */ @@ -1276,7 +1279,7 @@ class String : public Primitive { }; /** - * Converts an object to an ascii string. + * Converts an object to an ASCII string. * Useful if you want to print the object. * If conversion to a string fails (eg. due to an exception in the toString() * method of the object) then the length() method returns 0 and the * operator diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc index 07c48057a5e..c0cee4c28e1 100644 --- a/deps/v8/samples/process.cc +++ b/deps/v8/samples/process.cc @@ -77,7 +77,6 @@ class HttpRequestProcessor { */ class JsHttpRequestProcessor : public HttpRequestProcessor { public: - // Creates a new processor that processes requests by invoking the // Process function of the JavaScript script given as an argument. explicit JsHttpRequestProcessor(Handle script) : script_(script) { } @@ -88,7 +87,6 @@ class JsHttpRequestProcessor : public HttpRequestProcessor { virtual bool Process(HttpRequest* req); private: - // Execute the script associated with this processor and extract the // Process function. Returns true if this succeeded, otherwise false. bool ExecuteScript(Handle script); diff --git a/deps/v8/src/accessors.cc b/deps/v8/src/accessors.cc index f02efa55a22..951209d964c 100644 --- a/deps/v8/src/accessors.cc +++ b/deps/v8/src/accessors.cc @@ -710,6 +710,7 @@ class FrameFunctionIterator { } while (next_function != NULL); return false; } + private: void GetFunctions() { functions_.Rewind(0); diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 26558c42924..5c8a3142aed 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -3266,6 +3266,42 @@ bool v8::Object::DeleteHiddenValue(v8::Handle key) { namespace { +static i::ElementsKind GetElementsKindFromExternalArrayType( + ExternalArrayType array_type) { + switch (array_type) { + case kExternalByteArray: + return i::EXTERNAL_BYTE_ELEMENTS; + break; + case kExternalUnsignedByteArray: + return i::EXTERNAL_UNSIGNED_BYTE_ELEMENTS; + break; + case kExternalShortArray: + return i::EXTERNAL_SHORT_ELEMENTS; + break; + case kExternalUnsignedShortArray: + return i::EXTERNAL_UNSIGNED_SHORT_ELEMENTS; + break; + case kExternalIntArray: + return i::EXTERNAL_INT_ELEMENTS; + break; + case kExternalUnsignedIntArray: + return i::EXTERNAL_UNSIGNED_INT_ELEMENTS; + break; + case kExternalFloatArray: + return i::EXTERNAL_FLOAT_ELEMENTS; + break; + case kExternalDoubleArray: + return i::EXTERNAL_DOUBLE_ELEMENTS; + break; + case kExternalPixelArray: + return i::EXTERNAL_PIXEL_ELEMENTS; + break; + } + UNREACHABLE(); + return i::DICTIONARY_ELEMENTS; +} + + void PrepareExternalArrayElements(i::Handle object, void* data, ExternalArrayType array_type, @@ -3284,9 +3320,9 @@ void PrepareExternalArrayElements(i::Handle object, elements->map() != isolate->heap()->MapForExternalArrayType(array_type); if (cant_reuse_map) { i::Handle external_array_map = - isolate->factory()->GetExternalArrayElementsMap( + isolate->factory()->GetElementsTransitionMap( i::Handle(object->map()), - array_type, + GetElementsKindFromExternalArrayType(array_type), object->HasFastProperties()); object->set_map(*external_array_map); } @@ -3348,6 +3384,7 @@ int v8::Object::GetIndexedPropertiesPixelDataLength() { } } + void v8::Object::SetIndexedPropertiesToExternalArrayData( void* data, ExternalArrayType array_type, diff --git a/deps/v8/src/arguments.h b/deps/v8/src/arguments.h index 72bbe1dd1f1..e9a32702cfe 100644 --- a/deps/v8/src/arguments.h +++ b/deps/v8/src/arguments.h @@ -75,6 +75,7 @@ class Arguments BASE_EMBEDDED { int length() const { return length_; } Object** arguments() { return arguments_; } + private: int length_; Object** arguments_; diff --git a/deps/v8/src/arm/builtins-arm.cc b/deps/v8/src/arm/builtins-arm.cc index a35380c175e..60d2081c293 100644 --- a/deps/v8/src/arm/builtins-arm.cc +++ b/deps/v8/src/arm/builtins-arm.cc @@ -1230,16 +1230,17 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // 2. Get the function to call (passed as receiver) from the stack, check // if it is a function. // r0: actual number of arguments - Label non_function; + Label slow, non_function; __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); __ JumpIfSmi(r1, &non_function); __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); - __ b(ne, &non_function); + __ b(ne, &slow); // 3a. Patch the first argument if necessary when calling a function. // r0: actual number of arguments // r1: function Label shift_arguments; + __ mov(r4, Operand(0, RelocInfo::NONE)); // indicate regular JS_FUNCTION { Label convert_to_object, use_global_receiver, patch_receiver; // Change context eagerly in case we need the global receiver. __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); @@ -1286,8 +1287,9 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ pop(r0); __ mov(r0, Operand(r0, ASR, kSmiTagSize)); __ LeaveInternalFrame(); - // Restore the function to r1. + // Restore the function to r1, and the flag to r4. __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); + __ mov(r4, Operand(0, RelocInfo::NONE)); __ jmp(&patch_receiver); // Use the global receiver object from the called function as the @@ -1307,23 +1309,30 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ jmp(&shift_arguments); } - // 3b. Patch the first argument when calling a non-function. The + // 3b. Check for function proxy. + __ bind(&slow); + __ mov(r4, Operand(1, RelocInfo::NONE)); // indicate function proxy + __ cmp(r2, Operand(JS_FUNCTION_PROXY_TYPE)); + __ b(eq, &shift_arguments); + __ bind(&non_function); + __ mov(r4, Operand(2, RelocInfo::NONE)); // indicate non-function + + // 3c. Patch the first argument when calling a non-function. The // CALL_NON_FUNCTION builtin expects the non-function callee as // receiver, so overwrite the first argument which will ultimately // become the receiver. // r0: actual number of arguments // r1: function - __ bind(&non_function); + // r4: call type (0: JS function, 1: function proxy, 2: non-function) __ add(r2, sp, Operand(r0, LSL, kPointerSizeLog2)); __ str(r1, MemOperand(r2, -kPointerSize)); - // Clear r1 to indicate a non-function being called. - __ mov(r1, Operand(0, RelocInfo::NONE)); // 4. Shift arguments and return address one slot down on the stack // (overwriting the original receiver). Adjust argument count to make // the original first argument the new receiver. // r0: actual number of arguments // r1: function + // r4: call type (0: JS function, 1: function proxy, 2: non-function) __ bind(&shift_arguments); { Label loop; // Calculate the copy start address (destination). Copy end address is sp. @@ -1341,16 +1350,28 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ pop(); } - // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. + // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, + // or a function proxy via CALL_FUNCTION_PROXY. // r0: actual number of arguments // r1: function - { Label function; - __ tst(r1, r1); - __ b(ne, &function); + // r4: call type (0: JS function, 1: function proxy, 2: non-function) + { Label function, non_proxy; + __ tst(r4, r4); + __ b(eq, &function); // Expected number of arguments is 0 for CALL_NON_FUNCTION. __ mov(r2, Operand(0, RelocInfo::NONE)); - __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); __ SetCallKind(r5, CALL_AS_METHOD); + __ cmp(r4, Operand(1)); + __ b(ne, &non_proxy); + + __ push(r1); // re-add proxy object as additional argument + __ add(r0, r0, Operand(1)); + __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY); + __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), + RelocInfo::CODE_TARGET); + + __ bind(&non_proxy); + __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), RelocInfo::CODE_TARGET); __ bind(&function); @@ -1393,7 +1414,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ push(r0); __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); - // Check the stack for overflow. We are not trying need to catch + // Check the stack for overflow. We are not trying to catch // interruptions (e.g. debug break and preemption) here, so the "real stack // limit" is checked. Label okay; @@ -1418,18 +1439,24 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ mov(r1, Operand(0, RelocInfo::NONE)); // initial index __ push(r1); + // Get the receiver. + __ ldr(r0, MemOperand(fp, kRecvOffset)); + + // Check that the function is a JS function (otherwise it must be a proxy). + Label push_receiver; + __ ldr(r1, MemOperand(fp, kFunctionOffset)); + __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); + __ b(ne, &push_receiver); + // Change context eagerly to get the right global object if necessary. - __ ldr(r0, MemOperand(fp, kFunctionOffset)); - __ ldr(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); - // Load the shared function info while the function is still in r0. - __ ldr(r1, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); + __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); + // Load the shared function info while the function is still in r1. + __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); // Compute the receiver. - Label call_to_object, use_global_receiver, push_receiver; - __ ldr(r0, MemOperand(fp, kRecvOffset)); - // Do not transform the receiver for strict mode functions. - __ ldr(r2, FieldMemOperand(r1, SharedFunctionInfo::kCompilerHintsOffset)); + Label call_to_object, use_global_receiver; + __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kCompilerHintsOffset)); __ tst(r2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize))); __ b(ne, &push_receiver); @@ -1504,9 +1531,12 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ b(ne, &loop); // Invoke the function. + Label call_proxy; ParameterCount actual(r0); __ mov(r0, Operand(r0, ASR, kSmiTagSize)); __ ldr(r1, MemOperand(fp, kFunctionOffset)); + __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); + __ b(ne, &call_proxy); __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); @@ -1514,6 +1544,20 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ LeaveInternalFrame(); __ add(sp, sp, Operand(3 * kPointerSize)); __ Jump(lr); + + // Invoke the function proxy. + __ bind(&call_proxy); + __ push(r1); // add function proxy as last argument + __ add(r0, r0, Operand(1)); + __ mov(r2, Operand(0, RelocInfo::NONE)); + __ SetCallKind(r5, CALL_AS_METHOD); + __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY); + __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), + RelocInfo::CODE_TARGET); + + __ LeaveInternalFrame(); + __ add(sp, sp, Operand(3 * kPointerSize)); + __ Jump(lr); } diff --git a/deps/v8/src/arm/code-stubs-arm.cc b/deps/v8/src/arm/code-stubs-arm.cc index c310da88bc0..e65f6d9b69c 100644 --- a/deps/v8/src/arm/code-stubs-arm.cc +++ b/deps/v8/src/arm/code-stubs-arm.cc @@ -3432,7 +3432,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, // Retrieve the pending exception and clear the variable. __ mov(ip, Operand(ExternalReference::the_hole_value_location(isolate))); __ ldr(r3, MemOperand(ip)); - __ mov(ip, Operand(ExternalReference(Isolate::k_pending_exception_address, + __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, isolate))); __ ldr(r0, MemOperand(ip)); __ str(r3, MemOperand(ip)); @@ -3567,7 +3567,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { __ mov(r7, Operand(Smi::FromInt(marker))); __ mov(r6, Operand(Smi::FromInt(marker))); __ mov(r5, - Operand(ExternalReference(Isolate::k_c_entry_fp_address, isolate))); + Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate))); __ ldr(r5, MemOperand(r5)); __ Push(r8, r7, r6, r5); @@ -3576,7 +3576,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // If this is the outermost JS call, set js_entry_sp value. Label non_outermost_js; - ExternalReference js_entry_sp(Isolate::k_js_entry_sp_address, isolate); + ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, isolate); __ mov(r5, Operand(ExternalReference(js_entry_sp))); __ ldr(r6, MemOperand(r5)); __ cmp(r6, Operand::Zero()); @@ -3597,7 +3597,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // exception field in the JSEnv and return a failure sentinel. // Coming in here the fp will be invalid because the PushTryHandler below // sets it to 0 to signal the existence of the JSEntry frame. - __ mov(ip, Operand(ExternalReference(Isolate::k_pending_exception_address, + __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, isolate))); __ str(r0, MemOperand(ip)); __ mov(r0, Operand(reinterpret_cast(Failure::Exception()))); @@ -3615,7 +3615,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // Clear any pending exceptions. __ mov(ip, Operand(ExternalReference::the_hole_value_location(isolate))); __ ldr(r5, MemOperand(ip)); - __ mov(ip, Operand(ExternalReference(Isolate::k_pending_exception_address, + __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, isolate))); __ str(r5, MemOperand(ip)); @@ -3662,7 +3662,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // Restore the top frame descriptors from the stack. __ pop(r3); __ mov(ip, - Operand(ExternalReference(Isolate::k_c_entry_fp_address, isolate))); + Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate))); __ str(r3, MemOperand(ip)); // Reset the stack to the callee saved registers. @@ -4534,7 +4534,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // TODO(592): Rerunning the RegExp to get the stack overflow exception. __ mov(r1, Operand(ExternalReference::the_hole_value_location(isolate))); __ ldr(r1, MemOperand(r1, 0)); - __ mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, + __ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, isolate))); __ ldr(r0, MemOperand(r2, 0)); __ cmp(r0, r1); @@ -4713,7 +4713,7 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { void CallFunctionStub::Generate(MacroAssembler* masm) { - Label slow; + Label slow, non_function; // The receiver might implicitly be the global object. This is // indicated by passing the hole as the receiver to the call @@ -4739,7 +4739,7 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { // Check that the function is really a JavaScript function. // r1: pushed function (to be verified) - __ JumpIfSmi(r1, &slow); + __ JumpIfSmi(r1, &non_function); // Get the map of the function object. __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); __ b(ne, &slow); @@ -4767,8 +4767,23 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { // Slow-case: Non-function called. __ bind(&slow); + // Check for function proxy. + __ cmp(r2, Operand(JS_FUNCTION_PROXY_TYPE)); + __ b(ne, &non_function); + __ push(r1); // put proxy as additional argument + __ mov(r0, Operand(argc_ + 1, RelocInfo::NONE)); + __ mov(r2, Operand(0, RelocInfo::NONE)); + __ GetBuiltinEntry(r3, Builtins::CALL_FUNCTION_PROXY); + __ SetCallKind(r5, CALL_AS_FUNCTION); + { + Handle adaptor = + masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); + __ Jump(adaptor, RelocInfo::CODE_TARGET); + } + // CALL_NON_FUNCTION expects the non-function callee as receiver (instead // of the original receiver from the call site). + __ bind(&non_function); __ str(r1, MemOperand(sp, argc_ * kPointerSize)); __ mov(r0, Operand(argc_)); // Setup the number of arguments. __ mov(r2, Operand(0, RelocInfo::NONE)); diff --git a/deps/v8/src/arm/full-codegen-arm.cc b/deps/v8/src/arm/full-codegen-arm.cc index 4d27a8d3ca4..50ed8b1da73 100644 --- a/deps/v8/src/arm/full-codegen-arm.cc +++ b/deps/v8/src/arm/full-codegen-arm.cc @@ -2028,9 +2028,8 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, // Record source position for debugger. SetSourcePosition(expr->position()); // Call the IC initialization code. - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arg_count, in_loop, mode); + isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); __ Call(ic, mode, expr->id()); RecordJSReturnSite(expr); // Restore context register. @@ -2061,9 +2060,8 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, // Record source position for debugger. SetSourcePosition(expr->position()); // Call the IC initialization code. - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; Handle ic = - isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count, in_loop); + isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); __ ldr(r2, MemOperand(sp, (arg_count + 1) * kPointerSize)); // Key. __ Call(ic, RelocInfo::CODE_TARGET, expr->id()); RecordJSReturnSite(expr); @@ -2084,8 +2082,7 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { } // Record source position for debugger. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; - CallFunctionStub stub(arg_count, in_loop, flags); + CallFunctionStub stub(arg_count, flags); __ CallStub(&stub); RecordJSReturnSite(expr); // Restore context register. @@ -2184,8 +2181,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { // Record source position for debugger. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; - CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_IMPLICIT); + CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); __ CallStub(&stub); RecordJSReturnSite(expr); // Restore context register. @@ -2514,7 +2510,7 @@ void FullCodeGenerator::EmitIsFunction(ZoneList* args) { &if_true, &if_false, &fall_through); __ JumpIfSmi(r0, if_false); - __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); + __ CompareObjectType(r0, r1, r2, JS_FUNCTION_TYPE); PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); Split(eq, if_true, if_false, fall_through); @@ -3553,9 +3549,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { __ mov(r2, Operand(expr->name())); RelocInfo::Mode mode = RelocInfo::CODE_TARGET; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arg_count, - NOT_IN_LOOP, - mode); + isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); __ Call(ic, mode, expr->id()); // Restore context register. __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); diff --git a/deps/v8/src/arm/ic-arm.cc b/deps/v8/src/arm/ic-arm.cc index 6bad5ac03e6..2e49cae9289 100644 --- a/deps/v8/src/arm/ic-arm.cc +++ b/deps/v8/src/arm/ic-arm.cc @@ -146,7 +146,7 @@ static void GenerateDictionaryLoad(MacroAssembler* masm, StringDictionary::kElementsStartIndex * kPointerSize; const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; __ ldr(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); - __ tst(scratch1, Operand(PropertyDetails::TypeField::mask() << kSmiTagSize)); + __ tst(scratch1, Operand(PropertyDetails::TypeField::kMask << kSmiTagSize)); __ b(ne, miss); // Get the value at the masked, scaled index and return. @@ -194,9 +194,9 @@ static void GenerateDictionaryStore(MacroAssembler* masm, const int kElementsStartOffset = StringDictionary::kHeaderSize + StringDictionary::kElementsStartIndex * kPointerSize; const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; - const int kTypeAndReadOnlyMask - = (PropertyDetails::TypeField::mask() | - PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize; + const int kTypeAndReadOnlyMask = + (PropertyDetails::TypeField::kMask | + PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize; __ ldr(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); __ tst(scratch1, Operand(kTypeAndReadOnlyMask)); __ b(ne, miss); @@ -393,7 +393,6 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, - NOT_IN_LOOP, MONOMORPHIC, extra_ic_state, NORMAL, @@ -734,9 +733,8 @@ void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { // ----------------------------------- // Probe the stub cache. - Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, - NOT_IN_LOOP, - MONOMORPHIC); + Code::Flags flags = + Code::ComputeFlags(Code::LOAD_IC, MONOMORPHIC); Isolate::Current()->stub_cache()->GenerateProbe( masm, flags, r0, r2, r3, r4, r5); @@ -1380,10 +1378,8 @@ void StoreIC::GenerateMegamorphic(MacroAssembler* masm, // ----------------------------------- // Get the receiver from the stack and probe the stub cache. - Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, - NOT_IN_LOOP, - MONOMORPHIC, - strict_mode); + Code::Flags flags = + Code::ComputeFlags(Code::STORE_IC, MONOMORPHIC, strict_mode); Isolate::Current()->stub_cache()->GenerateProbe( masm, flags, r1, r2, r3, r4, r5); diff --git a/deps/v8/src/arm/lithium-arm.cc b/deps/v8/src/arm/lithium-arm.cc index 30d7a1c2cd8..30ccd05beec 100644 --- a/deps/v8/src/arm/lithium-arm.cc +++ b/deps/v8/src/arm/lithium-arm.cc @@ -311,13 +311,13 @@ void LCallKeyed::PrintDataTo(StringStream* stream) { void LCallNamed::PrintDataTo(StringStream* stream) { - SmartPointer name_string = name()->ToCString(); + SmartArrayPointer name_string = name()->ToCString(); stream->Add("%s #%d / ", *name_string, arity()); } void LCallGlobal::PrintDataTo(StringStream* stream) { - SmartPointer name_string = name()->ToCString(); + SmartArrayPointer name_string = name()->ToCString(); stream->Add("%s #%d / ", *name_string, arity()); } @@ -546,7 +546,8 @@ LChunk* LChunkBuilder::Build() { void LChunkBuilder::Abort(const char* format, ...) { if (FLAG_trace_bailout) { - SmartPointer name(info()->shared_info()->DebugName()->ToCString()); + SmartArrayPointer name( + info()->shared_info()->DebugName()->ToCString()); PrintF("Aborting LChunk building in @\"%s\": ", *name); va_list arguments; va_start(arguments, format); @@ -1860,15 +1861,15 @@ LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( HLoadKeyedSpecializedArrayElement* instr) { - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); Representation representation(instr->representation()); ASSERT( (representation.IsInteger32() && - (elements_kind != JSObject::EXTERNAL_FLOAT_ELEMENTS) && - (elements_kind != JSObject::EXTERNAL_DOUBLE_ELEMENTS)) || + (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && + (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || (representation.IsDouble() && - ((elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) || - (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS)))); + ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || + (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); ASSERT(instr->key()->representation().IsInteger32()); LOperand* external_pointer = UseRegister(instr->external_pointer()); LOperand* key = UseRegisterOrConstant(instr->key()); @@ -1877,7 +1878,7 @@ LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( LInstruction* load_instr = DefineAsRegister(result); // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. - return (elements_kind == JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) ? + return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ? AssignEnvironment(load_instr) : load_instr; } @@ -1928,21 +1929,21 @@ LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( HStoreKeyedSpecializedArrayElement* instr) { Representation representation(instr->value()->representation()); - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); ASSERT( (representation.IsInteger32() && - (elements_kind != JSObject::EXTERNAL_FLOAT_ELEMENTS) && - (elements_kind != JSObject::EXTERNAL_DOUBLE_ELEMENTS)) || + (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && + (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || (representation.IsDouble() && - ((elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) || - (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS)))); + ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || + (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); ASSERT(instr->external_pointer()->representation().IsExternal()); ASSERT(instr->key()->representation().IsInteger32()); LOperand* external_pointer = UseRegister(instr->external_pointer()); bool val_is_temp_register = - elements_kind == JSObject::EXTERNAL_PIXEL_ELEMENTS || - elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS; + elements_kind == EXTERNAL_PIXEL_ELEMENTS || + elements_kind == EXTERNAL_FLOAT_ELEMENTS; LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) : UseRegister(instr->value()); diff --git a/deps/v8/src/arm/lithium-arm.h b/deps/v8/src/arm/lithium-arm.h index 3632c8cf482..8c18760fd10 100644 --- a/deps/v8/src/arm/lithium-arm.h +++ b/deps/v8/src/arm/lithium-arm.h @@ -1158,7 +1158,7 @@ class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> { LOperand* external_pointer() { return inputs_[0]; } LOperand* key() { return inputs_[1]; } - JSObject::ElementsKind elements_kind() const { + ElementsKind elements_kind() const { return hydrogen()->elements_kind(); } }; @@ -1662,7 +1662,7 @@ class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> { LOperand* external_pointer() { return inputs_[0]; } LOperand* key() { return inputs_[1]; } LOperand* value() { return inputs_[2]; } - JSObject::ElementsKind elements_kind() const { + ElementsKind elements_kind() const { return hydrogen()->elements_kind(); } }; diff --git a/deps/v8/src/arm/lithium-codegen-arm.cc b/deps/v8/src/arm/lithium-codegen-arm.cc index 24e51e0681d..f5d74491497 100644 --- a/deps/v8/src/arm/lithium-codegen-arm.cc +++ b/deps/v8/src/arm/lithium-codegen-arm.cc @@ -101,7 +101,8 @@ void LCodeGen::FinishCode(Handle code) { void LCodeGen::Abort(const char* format, ...) { if (FLAG_trace_bailout) { - SmartPointer name(info()->shared_info()->DebugName()->ToCString()); + SmartArrayPointer name( + info()->shared_info()->DebugName()->ToCString()); PrintF("Aborting LCodeGen in @\"%s\": ", *name); va_list arguments; va_start(arguments, format); @@ -2410,11 +2411,11 @@ void LCodeGen::DoLoadElements(LLoadElements* instr) { __ ldr(scratch, FieldMemOperand(scratch, Map::kBitField2Offset)); __ ubfx(scratch, scratch, Map::kElementsKindShift, Map::kElementsKindBitCount); - __ cmp(scratch, Operand(JSObject::FAST_ELEMENTS)); + __ cmp(scratch, Operand(FAST_ELEMENTS)); __ b(eq, &done); - __ cmp(scratch, Operand(JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); + __ cmp(scratch, Operand(FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); __ b(lt, &fail); - __ cmp(scratch, Operand(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); + __ cmp(scratch, Operand(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); __ b(le, &done); __ bind(&fail); __ Abort("Check for fast or external elements failed."); @@ -2478,7 +2479,7 @@ void LCodeGen::DoLoadKeyedFastDoubleElement( Register scratch = scratch0(); int shift_size = - ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); + ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS); int constant_key = 0; if (key_is_constant) { constant_key = ToInteger32(LConstantOperand::cast(instr->key())); @@ -2515,7 +2516,7 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( LLoadKeyedSpecializedArrayElement* instr) { Register external_pointer = ToRegister(instr->external_pointer()); Register key = no_reg; - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); bool key_is_constant = instr->key()->IsConstantOperand(); int constant_key = 0; if (key_is_constant) { @@ -2528,18 +2529,18 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( } int shift_size = ElementsKindToShiftSize(elements_kind); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || - elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { CpuFeatures::Scope scope(VFP3); DwVfpRegister result = ToDoubleRegister(instr->result()); Operand operand = key_is_constant ? Operand(constant_key * (1 << shift_size)) : Operand(key, LSL, shift_size); __ add(scratch0(), external_pointer, operand); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { __ vldr(result.low(), scratch0(), 0); __ vcvt_f64_f32(result, result.low()); - } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS + } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS __ vldr(result, scratch0(), 0); } } else { @@ -2548,23 +2549,23 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( ? MemOperand(external_pointer, constant_key * (1 << shift_size)) : MemOperand(external_pointer, key, LSL, shift_size)); switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: __ ldrsb(result, mem_operand); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ ldrb(result, mem_operand); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: __ ldrsh(result, mem_operand); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ ldrh(result, mem_operand); break; - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: __ ldr(result, mem_operand); break; - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ ldr(result, mem_operand); __ cmp(result, Operand(0x80000000)); // TODO(danno): we could be more clever here, perhaps having a special @@ -2572,12 +2573,12 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( // happens, and generate code that returns a double rather than int. DeoptimizeIf(cs, instr->environment()); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -3177,7 +3178,7 @@ void LCodeGen::DoCallKeyed(LCallKeyed* instr) { int arity = instr->arity(); Handle ic = - isolate()->stub_cache()->ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); + isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); CallCode(ic, RelocInfo::CODE_TARGET, instr); __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); } @@ -3189,7 +3190,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) { int arity = instr->arity(); RelocInfo::Mode mode = RelocInfo::CODE_TARGET; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_IN_LOOP, mode); + isolate()->stub_cache()->ComputeCallInitialize(arity, mode); __ mov(r2, Operand(instr->name())); CallCode(ic, mode, instr); // Restore context register. @@ -3201,7 +3202,7 @@ void LCodeGen::DoCallFunction(LCallFunction* instr) { ASSERT(ToRegister(instr->result()).is(r0)); int arity = instr->arity(); - CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_IMPLICIT); + CallFunctionStub stub(arity, RECEIVER_MIGHT_BE_IMPLICIT); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); __ Drop(1); __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); @@ -3214,7 +3215,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) { int arity = instr->arity(); RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_IN_LOOP, mode); + isolate()->stub_cache()->ComputeCallInitialize(arity, mode); __ mov(r2, Operand(instr->name())); CallCode(ic, mode, instr); __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); @@ -3340,7 +3341,7 @@ void LCodeGen::DoStoreKeyedFastDoubleElement( } else { key = ToRegister(instr->key()); } - int shift_size = ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); + int shift_size = ElementsKindToShiftSize(FAST_DOUBLE_ELEMENTS); Operand operand = key_is_constant ? Operand(constant_key * (1 << shift_size) + FixedDoubleArray::kHeaderSize - kHeapObjectTag) @@ -3367,7 +3368,7 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( Register external_pointer = ToRegister(instr->external_pointer()); Register key = no_reg; - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); bool key_is_constant = instr->key()->IsConstantOperand(); int constant_key = 0; if (key_is_constant) { @@ -3380,17 +3381,17 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( } int shift_size = ElementsKindToShiftSize(elements_kind); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || - elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { CpuFeatures::Scope scope(VFP3); DwVfpRegister value(ToDoubleRegister(instr->value())); Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) : Operand(key, LSL, shift_size)); __ add(scratch0(), external_pointer, operand); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { __ vcvt_f32_f64(double_scratch0().low(), value); __ vstr(double_scratch0().low(), scratch0(), 0); - } else { // i.e. elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS + } else { // i.e. elements_kind == EXTERNAL_DOUBLE_ELEMENTS __ vstr(value, scratch0(), 0); } } else { @@ -3399,25 +3400,25 @@ void LCodeGen::DoStoreKeyedSpecializedArrayElement( ? MemOperand(external_pointer, constant_key * (1 << shift_size)) : MemOperand(external_pointer, key, LSL, shift_size)); switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ strb(value, mem_operand); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ strh(value, mem_operand); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ str(value, mem_operand); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } diff --git a/deps/v8/src/arm/lithium-gap-resolver-arm.h b/deps/v8/src/arm/lithium-gap-resolver-arm.h index 334d2920b6e..9dd09c8d03b 100644 --- a/deps/v8/src/arm/lithium-gap-resolver-arm.h +++ b/deps/v8/src/arm/lithium-gap-resolver-arm.h @@ -40,7 +40,6 @@ class LGapResolver; class LGapResolver BASE_EMBEDDED { public: - explicit LGapResolver(LCodeGen* owner); // Resolve a set of parallel moves, emitting assembler instructions. diff --git a/deps/v8/src/arm/macro-assembler-arm.cc b/deps/v8/src/arm/macro-assembler-arm.cc index 613a1f69f13..f37f3102185 100644 --- a/deps/v8/src/arm/macro-assembler-arm.cc +++ b/deps/v8/src/arm/macro-assembler-arm.cc @@ -760,9 +760,9 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { str(ip, MemOperand(fp, ExitFrameConstants::kCodeOffset)); // Save the frame pointer and the context in top. - mov(ip, Operand(ExternalReference(Isolate::k_c_entry_fp_address, isolate()))); + mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); str(fp, MemOperand(ip)); - mov(ip, Operand(ExternalReference(Isolate::k_context_address, isolate()))); + mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); str(cp, MemOperand(ip)); // Optionally save all double registers. @@ -838,11 +838,11 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, // Clear top frame. mov(r3, Operand(0, RelocInfo::NONE)); - mov(ip, Operand(ExternalReference(Isolate::k_c_entry_fp_address, isolate()))); + mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); str(r3, MemOperand(ip)); // Restore current context from top and clear it in debug mode. - mov(ip, Operand(ExternalReference(Isolate::k_context_address, isolate()))); + mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); ldr(cp, MemOperand(ip)); #ifdef DEBUG str(r3, MemOperand(ip)); @@ -1118,7 +1118,7 @@ void MacroAssembler::PushTryHandler(CodeLocation try_location, } stm(db_w, sp, r3.bit() | cp.bit() | fp.bit() | lr.bit()); // Save the current handler as the next handler. - mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); + mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); ldr(r1, MemOperand(r3)); push(r1); // Link this handler as the new current one. @@ -1134,7 +1134,7 @@ void MacroAssembler::PushTryHandler(CodeLocation try_location, mov(r7, Operand(0, RelocInfo::NONE)); // NULL frame pointer. stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | lr.bit()); // Save the current handler as the next handler. - mov(r7, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); + mov(r7, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); ldr(r6, MemOperand(r7)); push(r6); // Link this handler as the new current one. @@ -1146,7 +1146,7 @@ void MacroAssembler::PushTryHandler(CodeLocation try_location, void MacroAssembler::PopTryHandler() { STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); pop(r1); - mov(ip, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); + mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); str(r1, MemOperand(ip)); } @@ -1166,7 +1166,7 @@ void MacroAssembler::Throw(Register value) { } // Drop the sp to the top of the handler. - mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); + mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); ldr(sp, MemOperand(r3)); // Restore the next handler. @@ -1206,7 +1206,7 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, } // Drop sp to the top stack handler. - mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); + mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); ldr(sp, MemOperand(r3)); // Unwind the handlers until the ENTRY handler is found. @@ -1230,7 +1230,7 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, if (type == OUT_OF_MEMORY) { // Set external caught exception to false. ExternalReference external_caught( - Isolate::k_external_caught_exception_address, isolate()); + Isolate::kExternalCaughtExceptionAddress, isolate()); mov(r0, Operand(false, RelocInfo::NONE)); mov(r2, Operand(external_caught)); str(r0, MemOperand(r2)); @@ -1238,7 +1238,7 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, // Set pending exception and r0 to out of memory exception. Failure* out_of_memory = Failure::OutOfMemoryException(); mov(r0, Operand(reinterpret_cast(out_of_memory))); - mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, + mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, isolate()))); str(r0, MemOperand(r2)); } @@ -1421,7 +1421,7 @@ void MacroAssembler::LoadFromNumberDictionary(Label* miss, const int kDetailsOffset = NumberDictionary::kElementsStartOffset + 2 * kPointerSize; ldr(t1, FieldMemOperand(t2, kDetailsOffset)); - tst(t1, Operand(Smi::FromInt(PropertyDetails::TypeField::mask()))); + tst(t1, Operand(Smi::FromInt(PropertyDetails::TypeField::kMask))); b(ne, miss); // Get the value at the masked, scaled index and return. @@ -1793,7 +1793,7 @@ void MacroAssembler::CompareRoot(Register obj, void MacroAssembler::CheckFastElements(Register map, Register scratch, Label* fail) { - STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); + STATIC_ASSERT(FAST_ELEMENTS == 0); ldrb(scratch, FieldMemOperand(map, Map::kBitField2Offset)); cmp(scratch, Operand(Map::kMaximumBitField2FastElementValue)); b(hi, fail); diff --git a/deps/v8/src/arm/macro-assembler-arm.h b/deps/v8/src/arm/macro-assembler-arm.h index 9d663596253..6084fde2d36 100644 --- a/deps/v8/src/arm/macro-assembler-arm.h +++ b/deps/v8/src/arm/macro-assembler-arm.h @@ -596,9 +596,7 @@ class MacroAssembler: public Assembler { // Compare instance type in a map. map contains a valid map object whose // object type should be compared with the given type. This both - // sets the flags and leaves the object type in the type_reg register. It - // leaves the heap object in the heap_object register unless the heap_object - // register is the same register as type_reg. + // sets the flags and leaves the object type in the type_reg register. void CompareInstanceType(Register map, Register type_reg, InstanceType type); diff --git a/deps/v8/src/arm/regexp-macro-assembler-arm.h b/deps/v8/src/arm/regexp-macro-assembler-arm.h index 0e653868b6b..5c8ed0693f4 100644 --- a/deps/v8/src/arm/regexp-macro-assembler-arm.h +++ b/deps/v8/src/arm/regexp-macro-assembler-arm.h @@ -116,6 +116,7 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { static int CheckStackGuardState(Address* return_address, Code* re_code, Address re_frame); + private: // Offsets from frame_pointer() of function parameters and stored registers. static const int kFramePointer = 0; diff --git a/deps/v8/src/arm/stub-cache-arm.cc b/deps/v8/src/arm/stub-cache-arm.cc index 5345892925a..f8565924b19 100644 --- a/deps/v8/src/arm/stub-cache-arm.cc +++ b/deps/v8/src/arm/stub-cache-arm.cc @@ -3099,7 +3099,7 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) { // -- r1 : receiver // ----------------------------------- Code* stub; - JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); + ElementsKind elements_kind = receiver_map->elements_kind(); MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode(); if (!maybe_stub->To(&stub)) return maybe_stub; __ DispatchMap(r1, @@ -3193,7 +3193,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { // -- r3 : scratch // ----------------------------------- Code* stub; - JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); + ElementsKind elements_kind = receiver_map->elements_kind(); bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; MaybeObject* maybe_stub = KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); @@ -3438,25 +3438,25 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( } -static bool IsElementTypeSigned(JSObject::ElementsKind elements_kind) { +static bool IsElementTypeSigned(ElementsKind elements_kind) { switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: return true; - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: return false; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); return false; } @@ -3466,7 +3466,7 @@ static bool IsElementTypeSigned(JSObject::ElementsKind elements_kind) { void KeyedLoadStubCompiler::GenerateLoadExternalArray( MacroAssembler* masm, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { // ---------- S t a t e -------------- // -- lr : return address // -- r0 : key @@ -3501,24 +3501,24 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( Register value = r2; switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: __ ldrsb(value, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ ldrb(value, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: __ ldrsh(value, MemOperand(r3, key, LSL, 0)); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ ldrh(value, MemOperand(r3, key, LSL, 0)); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ ldr(value, MemOperand(r3, key, LSL, 1)); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: if (CpuFeatures::IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); __ add(r2, r3, Operand(key, LSL, 1)); @@ -3527,7 +3527,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ ldr(value, MemOperand(r3, key, LSL, 1)); } break; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: if (CpuFeatures::IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); __ add(r2, r3, Operand(key, LSL, 2)); @@ -3539,10 +3539,10 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ ldr(r3, MemOperand(r4, Register::kSizeInBytes)); } break; - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -3556,7 +3556,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( // d0: value (if VFP3 is supported) // r2/r3: value (if VFP3 is not supported) - if (elements_kind == JSObject::EXTERNAL_INT_ELEMENTS) { + if (elements_kind == EXTERNAL_INT_ELEMENTS) { // For the Int and UnsignedInt array types, we need to see whether // the value can be represented in a Smi. If not, we need to convert // it to a HeapNumber. @@ -3600,7 +3600,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ str(dst2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); __ Ret(); } - } else if (elements_kind == JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) { + } else if (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { // The test is different for unsigned int values. Since we need // the value to be in the range of a positive smi, we can't // handle either of the top two bits being set in the value. @@ -3665,7 +3665,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ mov(r0, r4); __ Ret(); } - } else if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + } else if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { // For the floating-point array type, we need to always allocate a // HeapNumber. if (CpuFeatures::IsSupported(VFP3)) { @@ -3735,7 +3735,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ mov(r0, r3); __ Ret(); } - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { if (CpuFeatures::IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); // Allocate a HeapNumber for the result. Don't use r0 and r1 as @@ -3792,7 +3792,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( void KeyedStoreStubCompiler::GenerateStoreExternalArray( MacroAssembler* masm, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { // ---------- S t a t e -------------- // -- r0 : value // -- r1 : key @@ -3824,7 +3824,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // Handle both smis and HeapNumbers in the fast path. Go to the // runtime for all other kinds of values. // r3: external array. - if (elements_kind == JSObject::EXTERNAL_PIXEL_ELEMENTS) { + if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) { // Double to pixel conversion is only implemented in the runtime for now. __ JumpIfNotSmi(value, &slow); } else { @@ -3836,29 +3836,29 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // r3: base pointer of external storage. // r5: value (integer). switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: // Clamp the value to [0..255]. __ Usat(r5, 8, Operand(r5)); __ strb(r5, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ strb(r5, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ strh(r5, MemOperand(r3, key, LSL, 0)); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ str(r5, MemOperand(r3, key, LSL, 1)); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: // Perform int-to-float conversion and store to memory. __ SmiUntag(r4, key); StoreIntAsFloat(masm, r3, r4, r5, r6, r7, r9); break; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: __ add(r3, r3, Operand(key, LSL, 2)); // r3: effective address of the double element FloatingPointHelper::Destination destination; @@ -3879,10 +3879,10 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ str(r7, MemOperand(r3, Register::kSizeInBytes)); } break; - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -3890,7 +3890,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // Entry registers are intact, r0 holds the value which is the return value. __ Ret(); - if (elements_kind != JSObject::EXTERNAL_PIXEL_ELEMENTS) { + if (elements_kind != EXTERNAL_PIXEL_ELEMENTS) { // r3: external array. __ bind(&check_heap_number); __ CompareObjectType(value, r5, r6, HEAP_NUMBER_TYPE); @@ -3906,7 +3906,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( if (CpuFeatures::IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { // vldr requires offset to be a multiple of 4 so we can not // include -kHeapObjectTag into it. __ sub(r5, r0, Operand(kHeapObjectTag)); @@ -3914,7 +3914,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ add(r5, r3, Operand(key, LSL, 1)); __ vcvt_f32_f64(s0, d0); __ vstr(s0, r5, 0); - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { __ sub(r5, r0, Operand(kHeapObjectTag)); __ vldr(d0, r5, HeapNumber::kValueOffset); __ add(r5, r3, Operand(key, LSL, 2)); @@ -3927,25 +3927,25 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ EmitECMATruncate(r5, d0, s2, r6, r7, r9); switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ strb(r5, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ strh(r5, MemOperand(r3, key, LSL, 0)); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ str(r5, MemOperand(r3, key, LSL, 1)); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -3959,7 +3959,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ ldr(r5, FieldMemOperand(value, HeapNumber::kExponentOffset)); __ ldr(r6, FieldMemOperand(value, HeapNumber::kMantissaOffset)); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { Label done, nan_or_infinity_or_zero; static const int kMantissaInHiWordShift = kBinary32MantissaBits - HeapNumber::kMantissaBitsInTopWord; @@ -4011,7 +4011,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ orr(r9, r9, Operand(r5, LSL, kMantissaInHiWordShift)); __ orr(r5, r9, Operand(r6, LSR, kMantissaInLoWordShift)); __ b(&done); - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { __ add(r7, r3, Operand(key, LSL, 2)); // r7: effective address of destination element. __ str(r6, MemOperand(r7, 0)); @@ -4066,25 +4066,25 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ bind(&done); switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ strb(r5, MemOperand(r3, key, LSR, 1)); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ strh(r5, MemOperand(r3, key, LSL, 0)); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ str(r5, MemOperand(r3, key, LSL, 1)); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } diff --git a/deps/v8/src/array.js b/deps/v8/src/array.js index 32a370fda86..4dd23c8bb46 100644 --- a/deps/v8/src/array.js +++ b/deps/v8/src/array.js @@ -208,7 +208,7 @@ function ConvertToLocaleString(e) { // Call ToString if toLocaleString is not a function. // See issue 877615. var e_obj = ToObject(e); - if (IS_FUNCTION(e_obj.toLocaleString)) + if (IS_SPEC_FUNCTION(e_obj.toLocaleString)) return ToString(e_obj.toLocaleString()); else return ToString(e); @@ -730,7 +730,7 @@ function ArraySort(comparefn) { // In-place QuickSort algorithm. // For short (length <= 22) arrays, insertion sort is used for efficiency. - if (!IS_FUNCTION(comparefn)) { + if (!IS_SPEC_FUNCTION(comparefn)) { comparefn = function (x, y) { if (x === y) return 0; if (%_IsSmi(x) && %_IsSmi(y)) { @@ -993,7 +993,7 @@ function ArrayFilter(f, receiver) { ["Array.prototype.filter"]); } - if (!IS_FUNCTION(f)) { + if (!IS_SPEC_FUNCTION(f)) { throw MakeTypeError('called_non_callable', [ f ]); } if (IS_NULL_OR_UNDEFINED(receiver)) { @@ -1022,7 +1022,7 @@ function ArrayForEach(f, receiver) { ["Array.prototype.forEach"]); } - if (!IS_FUNCTION(f)) { + if (!IS_SPEC_FUNCTION(f)) { throw MakeTypeError('called_non_callable', [ f ]); } if (IS_NULL_OR_UNDEFINED(receiver)) { @@ -1048,7 +1048,7 @@ function ArraySome(f, receiver) { ["Array.prototype.some"]); } - if (!IS_FUNCTION(f)) { + if (!IS_SPEC_FUNCTION(f)) { throw MakeTypeError('called_non_callable', [ f ]); } if (IS_NULL_OR_UNDEFINED(receiver)) { @@ -1073,7 +1073,7 @@ function ArrayEvery(f, receiver) { ["Array.prototype.every"]); } - if (!IS_FUNCTION(f)) { + if (!IS_SPEC_FUNCTION(f)) { throw MakeTypeError('called_non_callable', [ f ]); } if (IS_NULL_OR_UNDEFINED(receiver)) { @@ -1097,7 +1097,7 @@ function ArrayMap(f, receiver) { ["Array.prototype.map"]); } - if (!IS_FUNCTION(f)) { + if (!IS_SPEC_FUNCTION(f)) { throw MakeTypeError('called_non_callable', [ f ]); } if (IS_NULL_OR_UNDEFINED(receiver)) { @@ -1245,7 +1245,7 @@ function ArrayReduce(callback, current) { ["Array.prototype.reduce"]); } - if (!IS_FUNCTION(callback)) { + if (!IS_SPEC_FUNCTION(callback)) { throw MakeTypeError('called_non_callable', [callback]); } @@ -1281,7 +1281,7 @@ function ArrayReduceRight(callback, current) { ["Array.prototype.reduceRight"]); } - if (!IS_FUNCTION(callback)) { + if (!IS_SPEC_FUNCTION(callback)) { throw MakeTypeError('called_non_callable', [callback]); } var i = ToUint32(this.length) - 1; diff --git a/deps/v8/src/ast.cc b/deps/v8/src/ast.cc index a44d9ee460e..418cc432b67 100644 --- a/deps/v8/src/ast.cc +++ b/deps/v8/src/ast.cc @@ -969,7 +969,7 @@ class RegExpUnparser: public RegExpVisitor { public: RegExpUnparser(); void VisitCharacterRange(CharacterRange that); - SmartPointer ToString() { return stream_.ToCString(); } + SmartArrayPointer ToString() { return stream_.ToCString(); } #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) #undef MAKE_CASE @@ -1124,7 +1124,7 @@ void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { } -SmartPointer RegExpTree::ToString() { +SmartArrayPointer RegExpTree::ToString() { RegExpUnparser unparser; Accept(&unparser, NULL); return unparser.ToString(); diff --git a/deps/v8/src/ast.h b/deps/v8/src/ast.h index 2b32cdfa91f..b56205f9a67 100644 --- a/deps/v8/src/ast.h +++ b/deps/v8/src/ast.h @@ -1775,7 +1775,7 @@ class RegExpTree: public ZoneObject { // expression. virtual Interval CaptureRegisters() { return Interval::Empty(); } virtual void AppendToText(RegExpText* text); - SmartPointer ToString(); + SmartArrayPointer ToString(); #define MAKE_ASTYPE(Name) \ virtual RegExp##Name* As##Name(); \ virtual bool Is##Name(); diff --git a/deps/v8/src/bignum.h b/deps/v8/src/bignum.h index 1d2bff61a5e..dcc4fa702aa 100644 --- a/deps/v8/src/bignum.h +++ b/deps/v8/src/bignum.h @@ -92,6 +92,7 @@ class Bignum { static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) { return PlusCompare(a, b, c) < 0; } + private: typedef uint32_t Chunk; typedef uint64_t DoubleChunk; diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 7abd45cac02..f07e625ec01 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -1067,7 +1067,7 @@ void Genesis::InitializeGlobal(Handle inner_global, Handle new_map = factory->CopyMapDropTransitions(old_map); new_map->set_pre_allocated_property_fields(2); Handle result = factory->NewJSObjectFromMap(new_map); - new_map->set_elements_kind(JSObject::NON_STRICT_ARGUMENTS_ELEMENTS); + new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); // Set up a well-formed parameter map to make assertions happy. Handle elements = factory->NewFixedArray(2); elements->set_map(heap->non_strict_arguments_elements_map()); @@ -2062,7 +2062,7 @@ void Genesis::TransferNamedProperties(Handle from, break; } case MAP_TRANSITION: - case EXTERNAL_ARRAY_TRANSITION: + case ELEMENTS_TRANSITION: case CONSTANT_TRANSITION: case NULL_DESCRIPTOR: // Ignore non-properties. diff --git a/deps/v8/src/builtins.cc b/deps/v8/src/builtins.cc index d403a951cfb..e6a0699f076 100644 --- a/deps/v8/src/builtins.cc +++ b/deps/v8/src/builtins.cc @@ -1583,7 +1583,6 @@ void Builtins::InitBuiltinFunctionTable() { functions->s_name = #aname; \ functions->name = k##aname; \ functions->flags = Code::ComputeFlags(Code::kind, \ - NOT_IN_LOOP, \ state, \ extra); \ functions->extra_args = NO_EXTRA_ARGUMENTS; \ diff --git a/deps/v8/src/builtins.h b/deps/v8/src/builtins.h index f9a5a13bd99..31090d3a084 100644 --- a/deps/v8/src/builtins.h +++ b/deps/v8/src/builtins.h @@ -238,6 +238,8 @@ enum BuiltinExtraArguments { V(FILTER_KEY, 1) \ V(CALL_NON_FUNCTION, 0) \ V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \ + V(CALL_FUNCTION_PROXY, 1) \ + V(CALL_FUNCTION_PROXY_AS_CONSTRUCTOR, 1) \ V(TO_OBJECT, 0) \ V(TO_NUMBER, 0) \ V(TO_STRING, 0) \ diff --git a/deps/v8/src/cached-powers.h b/deps/v8/src/cached-powers.h index 2ae56196a32..88df22260c3 100644 --- a/deps/v8/src/cached-powers.h +++ b/deps/v8/src/cached-powers.h @@ -35,7 +35,6 @@ namespace internal { class PowersOfTenCache { public: - // Not all powers of ten are cached. The decimal exponent of two neighboring // cached numbers will differ by kDecimalExponentDistance. static const int kDecimalExponentDistance; diff --git a/deps/v8/src/circular-queue-inl.h b/deps/v8/src/circular-queue-inl.h index 349f22299a4..373bf6092a9 100644 --- a/deps/v8/src/circular-queue-inl.h +++ b/deps/v8/src/circular-queue-inl.h @@ -1,4 +1,4 @@ -// Copyright 2010 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: @@ -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_CIRCULAR_BUFFER_INL_H_ -#define V8_CIRCULAR_BUFFER_INL_H_ +#ifndef V8_CIRCULAR_QUEUE_INL_H_ +#define V8_CIRCULAR_QUEUE_INL_H_ #include "circular-queue.h" @@ -50,4 +50,4 @@ void SamplingCircularQueue::WrapPositionIfNeeded( } } // namespace v8::internal -#endif // V8_CIRCULAR_BUFFER_INL_H_ +#endif // V8_CIRCULAR_QUEUE_INL_H_ diff --git a/deps/v8/src/code-stubs.cc b/deps/v8/src/code-stubs.cc index 5535d171bec..00da4cba623 100644 --- a/deps/v8/src/code-stubs.cc +++ b/deps/v8/src/code-stubs.cc @@ -61,7 +61,7 @@ void CodeStub::GenerateCode(MacroAssembler* masm) { } -SmartPointer CodeStub::GetName() { +SmartArrayPointer CodeStub::GetName() { char buffer[100]; NoAllocationStringAllocator allocator(buffer, static_cast(sizeof(buffer))); @@ -75,7 +75,7 @@ void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) { code->set_major_key(MajorKey()); Isolate* isolate = masm->isolate(); - SmartPointer name = GetName(); + SmartArrayPointer name = GetName(); PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name)); GDBJIT(AddCode(GDBJITInterface::STUB, *name, code)); Counters* counters = isolate->counters(); @@ -114,7 +114,6 @@ Handle CodeStub::GetCode() { // Copy the generated code into a heap object. Code::Flags flags = Code::ComputeFlags( static_cast(GetCodeKind()), - InLoop(), GetICState()); Handle new_object = factory->NewCode( desc, flags, masm.CodeObject(), NeedsImmovableCode()); @@ -152,7 +151,6 @@ MaybeObject* CodeStub::TryGetCode() { // Try to copy the generated code into a heap object. Code::Flags flags = Code::ComputeFlags( static_cast(GetCodeKind()), - InLoop(), GetICState()); Object* new_object; { MaybeObject* maybe_new_object = @@ -246,27 +244,27 @@ void InstanceofStub::PrintName(StringStream* stream) { void KeyedLoadElementStub::Generate(MacroAssembler* masm) { switch (elements_kind_) { - case JSObject::FAST_ELEMENTS: + case FAST_ELEMENTS: KeyedLoadStubCompiler::GenerateLoadFastElement(masm); break; - case JSObject::FAST_DOUBLE_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(masm); break; - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: KeyedLoadStubCompiler::GenerateLoadExternalArray(masm, elements_kind_); break; - case JSObject::DICTIONARY_ELEMENTS: + case DICTIONARY_ELEMENTS: KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); break; - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -275,28 +273,28 @@ void KeyedLoadElementStub::Generate(MacroAssembler* masm) { void KeyedStoreElementStub::Generate(MacroAssembler* masm) { switch (elements_kind_) { - case JSObject::FAST_ELEMENTS: + case FAST_ELEMENTS: KeyedStoreStubCompiler::GenerateStoreFastElement(masm, is_js_array_); break; - case JSObject::FAST_DOUBLE_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_js_array_); break; - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: KeyedStoreStubCompiler::GenerateStoreExternalArray(masm, elements_kind_); break; - case JSObject::DICTIONARY_ELEMENTS: + case DICTIONARY_ELEMENTS: KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); break; - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -316,17 +314,12 @@ void ArgumentsAccessStub::PrintName(StringStream* stream) { void CallFunctionStub::PrintName(StringStream* stream) { - const char* in_loop_name = NULL; // Make g++ happy. - switch (in_loop_) { - case NOT_IN_LOOP: in_loop_name = ""; break; - case IN_LOOP: in_loop_name = "_InLoop"; break; - } const char* flags_name = NULL; // Make g++ happy. switch (flags_) { case NO_CALL_FUNCTION_FLAGS: flags_name = ""; break; case RECEIVER_MIGHT_BE_IMPLICIT: flags_name = "_Implicit"; break; } - stream->Add("CallFunctionStub_Args%d%s%s", argc_, in_loop_name, flags_name); + stream->Add("CallFunctionStub_Args%d%s", argc_, flags_name); } diff --git a/deps/v8/src/code-stubs.h b/deps/v8/src/code-stubs.h index 89e99a8d085..64c89b93d13 100644 --- a/deps/v8/src/code-stubs.h +++ b/deps/v8/src/code-stubs.h @@ -168,10 +168,6 @@ class CodeStub BASE_EMBEDDED { virtual Major MajorKey() = 0; virtual int MinorKey() = 0; - // The CallFunctionStub needs to override this so it can encode whether a - // lazily generated function should be fully optimized or not. - virtual InLoopFlag InLoop() { return NOT_IN_LOOP; } - // BinaryOpStub needs to override this. virtual int GetCodeKind(); @@ -181,7 +177,7 @@ class CodeStub BASE_EMBEDDED { } // Returns a name for logging/debugging purposes. - SmartPointer GetName(); + SmartArrayPointer GetName(); virtual void PrintName(StringStream* stream) { stream->Add("%s", MajorName(MajorKey(), false)); } @@ -646,8 +642,8 @@ class RegExpConstructResultStub: public CodeStub { class CallFunctionStub: public CodeStub { public: - CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags) - : argc_(argc), in_loop_(in_loop), flags_(flags) { } + CallFunctionStub(int argc, CallFunctionFlags flags) + : argc_(argc), flags_(flags) { } void Generate(MacroAssembler* masm); @@ -657,26 +653,20 @@ class CallFunctionStub: public CodeStub { private: int argc_; - InLoopFlag in_loop_; CallFunctionFlags flags_; virtual void PrintName(StringStream* stream); // Minor key encoding in 32 bits with Bitfield . - class InLoopBits: public BitField {}; - class FlagBits: public BitField {}; - class ArgcBits: public BitField {}; + class FlagBits: public BitField {}; + class ArgcBits: public BitField {}; Major MajorKey() { return CallFunction; } int MinorKey() { // Encode the parameters in a unique 32 bit value. - return InLoopBits::encode(in_loop_) - | FlagBits::encode(flags_) - | ArgcBits::encode(argc_); + return FlagBits::encode(flags_) | ArgcBits::encode(argc_); } - InLoopFlag InLoop() { return in_loop_; } - bool ReceiverMightBeImplicit() { return (flags_ & RECEIVER_MIGHT_BE_IMPLICIT) != 0; } @@ -860,7 +850,7 @@ class AllowStubCallsScope { class KeyedLoadElementStub : public CodeStub { public: - explicit KeyedLoadElementStub(JSObject::ElementsKind elements_kind) + explicit KeyedLoadElementStub(ElementsKind elements_kind) : elements_kind_(elements_kind) { } @@ -870,7 +860,7 @@ class KeyedLoadElementStub : public CodeStub { void Generate(MacroAssembler* masm); private: - JSObject::ElementsKind elements_kind_; + ElementsKind elements_kind_; DISALLOW_COPY_AND_ASSIGN(KeyedLoadElementStub); }; @@ -879,20 +869,20 @@ class KeyedLoadElementStub : public CodeStub { class KeyedStoreElementStub : public CodeStub { public: KeyedStoreElementStub(bool is_js_array, - JSObject::ElementsKind elements_kind) + ElementsKind elements_kind) : is_js_array_(is_js_array), elements_kind_(elements_kind) { } Major MajorKey() { return KeyedStoreElement; } int MinorKey() { - return (is_js_array_ ? 0 : JSObject::kElementsKindCount) + elements_kind_; + return (is_js_array_ ? 0 : kElementsKindCount) + elements_kind_; } void Generate(MacroAssembler* masm); private: bool is_js_array_; - JSObject::ElementsKind elements_kind_; + ElementsKind elements_kind_; DISALLOW_COPY_AND_ASSIGN(KeyedStoreElementStub); }; diff --git a/deps/v8/src/compilation-cache.h b/deps/v8/src/compilation-cache.h index 1fcf75313ec..4339d22641d 100644 --- a/deps/v8/src/compilation-cache.h +++ b/deps/v8/src/compilation-cache.h @@ -242,6 +242,7 @@ class CompilationCache { // cache during debugging to make sure new scripts are always compiled. void Enable(); void Disable(); + private: explicit CompilationCache(Isolate* isolate); ~CompilationCache(); diff --git a/deps/v8/src/compiler.h b/deps/v8/src/compiler.h index 8e92cf5a177..09aa23dec98 100644 --- a/deps/v8/src/compiler.h +++ b/deps/v8/src/compiler.h @@ -49,11 +49,11 @@ class CompilationInfo BASE_EMBEDDED { ASSERT(Isolate::Current() == isolate_); return isolate_; } - bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } - bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } - bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } - bool is_strict_mode() const { return (flags_ & IsStrictMode::mask()) != 0; } - bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } + bool is_lazy() const { return IsLazy::decode(flags_); } + bool is_eval() const { return IsEval::decode(flags_); } + bool is_global() const { return IsGlobal::decode(flags_); } + bool is_strict_mode() const { return IsStrictMode::decode(flags_); } + bool is_in_loop() const { return IsInLoop::decode(flags_); } FunctionLiteral* function() const { return function_; } Scope* scope() const { return scope_; } Handle code() const { return code_; } diff --git a/deps/v8/src/cpu-profiler-inl.h b/deps/v8/src/cpu-profiler-inl.h index 938b632214e..4982197caba 100644 --- a/deps/v8/src/cpu-profiler-inl.h +++ b/deps/v8/src/cpu-profiler-inl.h @@ -51,11 +51,6 @@ void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) { } -void CodeDeleteEventRecord::UpdateCodeMap(CodeMap* code_map) { - code_map->DeleteCode(start); -} - - void SharedFunctionInfoMoveEventRecord::UpdateCodeMap(CodeMap* code_map) { code_map->MoveCode(from, to); } diff --git a/deps/v8/src/cpu-profiler.cc b/deps/v8/src/cpu-profiler.cc index bb480fc345b..65490285e75 100644 --- a/deps/v8/src/cpu-profiler.cc +++ b/deps/v8/src/cpu-profiler.cc @@ -137,16 +137,6 @@ void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) { } -void ProfilerEventsProcessor::CodeDeleteEvent(Address from) { - CodeEventsContainer evt_rec; - CodeDeleteEventRecord* rec = &evt_rec.CodeDeleteEventRecord_; - rec->type = CodeEventRecord::CODE_DELETE; - rec->order = ++enqueue_order_; - rec->start = from; - events_buffer_.Enqueue(evt_rec); -} - - void ProfilerEventsProcessor::SharedFunctionInfoMoveEvent(Address from, Address to) { CodeEventsContainer evt_rec; @@ -425,7 +415,6 @@ void CpuProfiler::CodeMoveEvent(Address from, Address to) { void CpuProfiler::CodeDeleteEvent(Address from) { - Isolate::Current()->cpu_profiler()->processor_->CodeDeleteEvent(from); } diff --git a/deps/v8/src/cpu-profiler.h b/deps/v8/src/cpu-profiler.h index 4175e8f6805..a71c0e0ab4e 100644 --- a/deps/v8/src/cpu-profiler.h +++ b/deps/v8/src/cpu-profiler.h @@ -48,7 +48,6 @@ class TokenEnumerator; #define CODE_EVENTS_TYPE_LIST(V) \ V(CODE_CREATION, CodeCreateEventRecord) \ V(CODE_MOVE, CodeMoveEventRecord) \ - V(CODE_DELETE, CodeDeleteEventRecord) \ V(SHARED_FUNC_MOVE, SharedFunctionInfoMoveEventRecord) @@ -87,14 +86,6 @@ class CodeMoveEventRecord : public CodeEventRecord { }; -class CodeDeleteEventRecord : public CodeEventRecord { - public: - Address start; - - INLINE(void UpdateCodeMap(CodeMap* code_map)); -}; - - class SharedFunctionInfoMoveEventRecord : public CodeEventRecord { public: Address from; diff --git a/deps/v8/src/d8-debug.cc b/deps/v8/src/d8-debug.cc index 06622057b4a..adefba73227 100644 --- a/deps/v8/src/d8-debug.cc +++ b/deps/v8/src/d8-debug.cc @@ -221,14 +221,14 @@ void RemoteDebugger::Run() { } -void RemoteDebugger::MessageReceived(i::SmartPointer message) { +void RemoteDebugger::MessageReceived(i::SmartArrayPointer message) { RemoteDebuggerEvent* event = new RemoteDebuggerEvent(RemoteDebuggerEvent::kMessage, message); AddEvent(event); } -void RemoteDebugger::KeyboardCommand(i::SmartPointer command) { +void RemoteDebugger::KeyboardCommand(i::SmartArrayPointer command) { RemoteDebuggerEvent* event = new RemoteDebuggerEvent(RemoteDebuggerEvent::kKeyboard, command); AddEvent(event); @@ -238,7 +238,7 @@ void RemoteDebugger::KeyboardCommand(i::SmartPointer command) { void RemoteDebugger::ConnectionClosed() { RemoteDebuggerEvent* event = new RemoteDebuggerEvent(RemoteDebuggerEvent::kDisconnect, - i::SmartPointer()); + i::SmartArrayPointer()); AddEvent(event); } @@ -330,14 +330,14 @@ void RemoteDebugger::HandleKeyboardCommand(char* command) { void ReceiverThread::Run() { // Receive the connect message (with empty body). - i::SmartPointer message = - i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); + i::SmartArrayPointer message = + i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); ASSERT(*message == NULL); while (true) { // Receive a message. - i::SmartPointer message = - i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); + i::SmartArrayPointer message = + i::DebuggerAgentUtil::ReceiveMessage(remote_debugger_->conn()); if (*message == NULL) { remote_debugger_->ConnectionClosed(); return; @@ -361,7 +361,7 @@ void KeyboardThread::Run() { // Pass the keyboard command to the main thread. remote_debugger_->KeyboardCommand( - i::SmartPointer(i::StrDup(command))); + i::SmartArrayPointer(i::StrDup(command))); } } diff --git a/deps/v8/src/d8-debug.h b/deps/v8/src/d8-debug.h index 4e33e6f4c45..aeff3c121c1 100644 --- a/deps/v8/src/d8-debug.h +++ b/deps/v8/src/d8-debug.h @@ -61,8 +61,8 @@ class RemoteDebugger { void Run(); // Handle events from the subordinate threads. - void MessageReceived(i::SmartPointer message); - void KeyboardCommand(i::SmartPointer command); + void MessageReceived(i::SmartArrayPointer message); + void KeyboardCommand(i::SmartArrayPointer command); void ConnectionClosed(); private: @@ -127,7 +127,7 @@ class KeyboardThread: public i::Thread { // Events processed by the main deubgger thread. class RemoteDebuggerEvent { public: - RemoteDebuggerEvent(int type, i::SmartPointer data) + RemoteDebuggerEvent(int type, i::SmartArrayPointer data) : type_(type), data_(data), next_(NULL) { ASSERT(type == kMessage || type == kKeyboard || type == kDisconnect); } @@ -144,7 +144,7 @@ class RemoteDebuggerEvent { RemoteDebuggerEvent* next() { return next_; } int type_; - i::SmartPointer data_; + i::SmartArrayPointer data_; RemoteDebuggerEvent* next_; friend class RemoteDebugger; diff --git a/deps/v8/src/d8-posix.cc b/deps/v8/src/d8-posix.cc index 658fd4ff072..289c3b0ae8f 100644 --- a/deps/v8/src/d8-posix.cc +++ b/deps/v8/src/d8-posix.cc @@ -231,6 +231,7 @@ class ExecArgs { static const unsigned kMaxArgs = 1000; char** arg_array() { return exec_args_; } char* arg0() { return exec_args_[0]; } + private: char* exec_args_[kMaxArgs + 1]; }; diff --git a/deps/v8/src/d8-readline.cc b/deps/v8/src/d8-readline.cc index 08395e53de1..71be933109b 100644 --- a/deps/v8/src/d8-readline.cc +++ b/deps/v8/src/d8-readline.cc @@ -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: @@ -49,7 +49,7 @@ namespace v8 { class ReadLineEditor: public LineEditor { public: ReadLineEditor() : LineEditor(LineEditor::READLINE, "readline") { } - virtual i::SmartPointer Prompt(const char* prompt); + virtual i::SmartArrayPointer Prompt(const char* prompt); virtual bool Open(); virtual bool Close(); virtual void AddHistory(const char* str); @@ -72,6 +72,7 @@ bool ReadLineEditor::Open() { rl_completer_word_break_characters = kWordBreakCharacters; rl_bind_key('\t', rl_complete); using_history(); + stifle_history(Shell::kMaxHistoryEntries); return read_history(Shell::kHistoryFileName) == 0; } @@ -81,13 +82,25 @@ bool ReadLineEditor::Close() { } -i::SmartPointer ReadLineEditor::Prompt(const char* prompt) { +i::SmartArrayPointer ReadLineEditor::Prompt(const char* prompt) { char* result = readline(prompt); - return i::SmartPointer(result); + return i::SmartArrayPointer(result); } void ReadLineEditor::AddHistory(const char* str) { + // Do not record empty input. + if (strlen(str) == 0) return; + // Remove duplicate history entry. + history_set_pos(history_length-1); + if (current_history()) { + do { + if (strcmp(current_history()->line, str) == 0) { + remove_history(where_history()); + break; + } + } while (previous_history()); + } add_history(str); } @@ -105,7 +118,7 @@ char* ReadLineEditor::CompletionGenerator(const char* text, int state) { static unsigned current_index; static Persistent current_completions; if (state == 0) { - i::SmartPointer full_text(i::StrNDup(rl_line_buffer, rl_point)); + i::SmartArrayPointer full_text(i::StrNDup(rl_line_buffer, rl_point)); HandleScope scope; Handle completions = Shell::GetCompletions(String::New(text), String::New(*full_text)); diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc index 93b383d9acd..55f0d4c2ab5 100644 --- a/deps/v8/src/d8.cc +++ b/deps/v8/src/d8.cc @@ -70,6 +70,7 @@ namespace v8 { #ifndef V8_SHARED LineEditor *LineEditor::first_ = NULL; const char* Shell::kHistoryFileName = ".d8_history"; +const int Shell::kMaxHistoryEntries = 1000; LineEditor::LineEditor(Type type, const char* name) @@ -95,19 +96,19 @@ LineEditor* LineEditor::Get() { class DumbLineEditor: public LineEditor { public: DumbLineEditor() : LineEditor(LineEditor::DUMB, "dumb") { } - virtual i::SmartPointer Prompt(const char* prompt); + virtual i::SmartArrayPointer Prompt(const char* prompt); }; static DumbLineEditor dumb_line_editor; -i::SmartPointer DumbLineEditor::Prompt(const char* prompt) { +i::SmartArrayPointer DumbLineEditor::Prompt(const char* prompt) { static const int kBufferSize = 256; char buffer[kBufferSize]; printf("%s", prompt); char* str = fgets(buffer, kBufferSize, stdin); - return i::SmartPointer(str ? i::StrDup(str) : str); + return i::SmartArrayPointer(str ? i::StrDup(str) : str); } @@ -117,6 +118,7 @@ CounterCollection Shell::local_counters_; CounterCollection* Shell::counters_ = &local_counters_; i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); Persistent Shell::utility_context_; +LineEditor* Shell::console = NULL; #endif // V8_SHARED Persistent Shell::evaluation_context_; @@ -203,7 +205,7 @@ Handle Shell::Write(const Arguments& args) { int n = static_cast(fwrite(*str, sizeof(**str), str.length(), stdout)); if (n != str.length()) { printf("Error in fwrite\n"); - exit(1); + Exit(1); } } return Undefined(); @@ -271,7 +273,7 @@ Handle Shell::Load(const Arguments& args) { if (source.IsEmpty()) { return ThrowException(String::New("Error loading file")); } - if (!ExecuteString(source, String::New(*file), false, false)) { + if (!ExecuteString(source, String::New(*file), false, true)) { return ThrowException(String::New("Error executing file")); } } @@ -295,18 +297,20 @@ Handle Shell::CreateExternalArray(const Arguments& args, size_t length = 0; if (args[0]->IsUint32()) { length = args[0]->Uint32Value(); - } else if (args[0]->IsNumber()) { - double raw_length = args[0]->NumberValue(); + } else { + Local number = args[0]->ToNumber(); + if (number.IsEmpty() || !number->IsNumber()) { + return ThrowException(String::New("Array length must be a number.")); + } + int32_t raw_length = number->ToInt32()->Int32Value(); if (raw_length < 0) { return ThrowException(String::New("Array length must not be negative.")); } - if (raw_length > kMaxLength) { + if (raw_length > static_cast(kMaxLength)) { return ThrowException( String::New("Array length exceeds maximum length.")); } length = static_cast(raw_length); - } else { - return ThrowException(String::New("Array length must be a number.")); } if (length > static_cast(kMaxLength)) { return ThrowException(String::New("Array length exceeds maximum length.")); @@ -439,6 +443,7 @@ void Shell::ReportException(v8::TryCatch* try_catch) { printf("%s\n", stack_trace_string); } } + printf("\n"); } @@ -518,7 +523,7 @@ void Shell::MapCounters(const char* name) { NULL : counters_file_->memory(); if (memory == NULL) { printf("Could not map counters file %s\n", name); - exit(1); + Exit(1); } counters_ = static_cast(memory); V8::SetCounterFunction(LookupCounter); @@ -715,7 +720,7 @@ void Shell::Initialize() { int bz2_result = startup_data_decompressor.Decompress(); if (bz2_result != BZ_OK) { fprintf(stderr, "bzip error code: %d\n", bz2_result); - exit(1); + Exit(1); } #endif @@ -777,8 +782,18 @@ Persistent Shell::CreateEvaluationContext() { } +void Shell::Exit(int exit_code) { + // Use _exit instead of exit to avoid races between isolate + // threads and static destructors. + fflush(stdout); + fflush(stderr); + _exit(exit_code); +} + + #ifndef V8_SHARED void Shell::OnExit() { + if (console != NULL) console->Close(); if (i::FLAG_dump_counters) { printf("+----------------------------------------+-------------+\n"); printf("| Name | Value |\n"); @@ -883,20 +898,19 @@ void Shell::RunShell() { HandleScope outer_scope; Handle name = String::New("(d8)"); #ifndef V8_SHARED - LineEditor* editor = LineEditor::Get(); - printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); + console = LineEditor::Get(); + printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name()); if (i::FLAG_debugger) { printf("JavaScript debugger enabled\n"); } - editor->Open(); + console->Open(); while (true) { - i::SmartPointer input = editor->Prompt(Shell::kPrompt); + i::SmartArrayPointer input = console->Prompt(Shell::kPrompt); if (input.is_empty()) break; - editor->AddHistory(*input); + console->AddHistory(*input); HandleScope inner_scope; ExecuteString(String::New(*input), name, true, true); } - editor->Close(); #else printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); static const int kBufferSize = 256; @@ -915,18 +929,24 @@ void Shell::RunShell() { #ifndef V8_SHARED class ShellThread : public i::Thread { public: - ShellThread(int no, i::Vector files) + // Takes ownership of the underlying char array of |files|. + ShellThread(int no, char* files) : Thread("d8:ShellThread"), no_(no), files_(files) { } + + ~ShellThread() { + delete[] files_; + } + virtual void Run(); private: int no_; - i::Vector files_; + char* files_; }; void ShellThread::Run() { - char* ptr = const_cast(files_.start()); + char* ptr = files_; while ((ptr != NULL) && (*ptr != '\0')) { // For each newline-separated line. char* next_line = ReadLine(ptr); @@ -939,23 +959,24 @@ void ShellThread::Run() { // Prepare the context for this thread. Locker locker; - HandleScope scope; + HandleScope outer_scope; Persistent thread_context = Shell::CreateEvaluationContext(); Context::Scope context_scope(thread_context); while ((ptr != NULL) && (*ptr != '\0')) { + HandleScope inner_scope; char* filename = ptr; ptr = ReadWord(ptr); // Skip empty strings. if (strlen(filename) == 0) { - break; + continue; } Handle str = Shell::ReadFile(filename); if (str.IsEmpty()) { - printf("WARNING: %s not found\n", filename); - break; + printf("File '%s' not found\n", filename); + Shell::Exit(1); } Shell::ExecuteString(str, String::New(filename), false, false); @@ -968,12 +989,15 @@ void ShellThread::Run() { #endif // V8_SHARED -void SourceGroup::ExitShell(int exit_code) { - // Use _exit instead of exit to avoid races between isolate - // threads and static destructors. - fflush(stdout); - fflush(stderr); - _exit(exit_code); +SourceGroup::~SourceGroup() { +#ifndef V8_SHARED + delete next_semaphore_; + next_semaphore_ = NULL; + delete done_semaphore_; + done_semaphore_ = NULL; + delete thread_; + thread_ = NULL; +#endif // V8_SHARED } @@ -986,8 +1010,7 @@ void SourceGroup::Execute() { Handle file_name = String::New("unnamed"); Handle source = String::New(argv_[i + 1]); if (!Shell::ExecuteString(source, file_name, false, true)) { - ExitShell(1); - return; + Shell::Exit(1); } ++i; } else if (arg[0] == '-') { @@ -999,12 +1022,10 @@ void SourceGroup::Execute() { Handle source = ReadFile(arg); if (source.IsEmpty()) { printf("Error reading '%s'\n", arg); - ExitShell(1); - return; + Shell::Exit(1); } if (!Shell::ExecuteString(source, file_name, false, true)) { - ExitShell(1); - return; + Shell::Exit(1); } } } @@ -1037,7 +1058,7 @@ i::Thread::Options SourceGroup::GetThreadOptions() { void SourceGroup::ExecuteInThread() { Isolate* isolate = Isolate::New(); do { - if (!next_semaphore_.is_empty()) next_semaphore_->Wait(); + if (next_semaphore_ != NULL) next_semaphore_->Wait(); { Isolate::Scope iscope(isolate); Locker lock(isolate); @@ -1049,15 +1070,15 @@ void SourceGroup::ExecuteInThread() { } context.Dispose(); } - if (!done_semaphore_.is_empty()) done_semaphore_->Signal(); + if (done_semaphore_ != NULL) done_semaphore_->Signal(); } while (!Shell::options.last_run); isolate->Dispose(); } void SourceGroup::StartExecuteInThread() { - if (thread_.is_empty()) { - thread_ = i::SmartPointer(new IsolateThread(this)); + if (thread_ == NULL) { + thread_ = new IsolateThread(this); thread_->Start(); } next_semaphore_->Signal(); @@ -1065,7 +1086,7 @@ void SourceGroup::StartExecuteInThread() { void SourceGroup::WaitForThread() { - if (thread_.is_empty()) return; + if (thread_ == NULL) return; if (Shell::options.last_run) { thread_->Join(); } else { @@ -1140,14 +1161,18 @@ bool Shell::SetOptions(int argc, char* argv[]) { return false; #endif // V8_SHARED options.num_isolates++; + } else if (strcmp(argv[i], "-p") == 0) { +#ifdef V8_SHARED + printf("D8 with shared library does not support multi-threading\n"); + return false; +#else + options.num_parallel_files++; +#endif // V8_SHARED } #ifdef V8_SHARED else if (strcmp(argv[i], "--dump-counters") == 0) { printf("D8 with shared library does not include counters\n"); return false; - } else if (strcmp(argv[i], "-p") == 0) { - printf("D8 with shared library does not support multi-threading\n"); - return false; } else if (strcmp(argv[i], "--debugger") == 0) { printf("Javascript debugger not included\n"); return false; @@ -1157,6 +1182,8 @@ bool Shell::SetOptions(int argc, char* argv[]) { #ifndef V8_SHARED // Run parallel threads if we are not using --isolate + options.parallel_files = new char*[options.num_parallel_files]; + int parallel_files_set = 0; for (int i = 1; i < argc; i++) { if (argv[i] == NULL) continue; if (strcmp(argv[i], "-p") == 0 && i + 1 < argc) { @@ -1165,25 +1192,21 @@ bool Shell::SetOptions(int argc, char* argv[]) { return false; } argv[i] = NULL; - if (options.parallel_files == NULL) { - options.parallel_files = new i::List >(); - } - int size = 0; - const char* files = ReadChars(argv[++i], &size); - if (files == NULL) { - printf("-p option incomplete\n"); - return false; - } + i++; + options.parallel_files[parallel_files_set] = argv[i]; + parallel_files_set++; argv[i] = NULL; - options.parallel_files->Add(i::Vector(files, size)); - delete[] files; } } + if (parallel_files_set != options.num_parallel_files) { + printf("-p requires a file containing a list of files as parameter\n"); + return false; + } #endif // V8_SHARED v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - // set up isolated source groups + // Set up isolated source groups. options.isolate_sources = new SourceGroup[options.num_isolates]; SourceGroup* current = options.isolate_sources; current->Begin(argv, 1); @@ -1206,14 +1229,22 @@ bool Shell::SetOptions(int argc, char* argv[]) { int Shell::RunMain(int argc, char* argv[]) { #ifndef V8_SHARED i::List threads(1); - if (options.parallel_files != NULL) - for (int i = 0; i < options.parallel_files->length(); i++) { - i::Vector files = options.parallel_files->at(i); + if (options.parallel_files != NULL) { + for (int i = 0; i < options.num_parallel_files; i++) { + char* files = NULL; + { Locker lock(Isolate::GetCurrent()); + int size = 0; + files = ReadChars(options.parallel_files[i], &size); + } + if (files == NULL) { + printf("File list '%s' not found\n", options.parallel_files[i]); + Exit(1); + } ShellThread* thread = new ShellThread(threads.length(), files); thread->Start(); threads.Add(thread); } - + } for (int i = 1; i < options.num_isolates; ++i) { options.isolate_sources[i].StartExecuteInThread(); } @@ -1235,8 +1266,7 @@ int Shell::RunMain(int argc, char* argv[]) { #ifndef V8_SHARED // Start preemption if threads have been created and preemption is enabled. - if (options.parallel_files != NULL - && threads.length() > 0 + if (threads.length() > 0 && options.use_preemption) { Locker::StartPreemption(options.preemption_interval); } @@ -1248,12 +1278,16 @@ int Shell::RunMain(int argc, char* argv[]) { options.isolate_sources[i].WaitForThread(); } - if (options.parallel_files != NULL) - for (int i = 0; i < threads.length(); i++) { - i::Thread* thread = threads[i]; - thread->Join(); - delete thread; - } + for (int i = 0; i < threads.length(); i++) { + i::Thread* thread = threads[i]; + thread->Join(); + delete thread; + } + + if (threads.length() > 0 && options.use_preemption) { + Locker lock; + Locker::StopPreemption(); + } #endif // V8_SHARED return 0; } diff --git a/deps/v8/src/d8.h b/deps/v8/src/d8.h index 3ec03907ed1..15d8d5d50fc 100644 --- a/deps/v8/src/d8.h +++ b/deps/v8/src/d8.h @@ -1,4 +1,4 @@ -// Copyright 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: @@ -31,7 +31,7 @@ #ifndef V8_SHARED #include "allocation.h" #include "hashmap.h" -#include "smart-pointer.h" +#include "smart-array-pointer.h" #include "v8.h" #else #include "../include/v8.h" @@ -116,17 +116,43 @@ class CounterMap { #endif // V8_SHARED +#ifndef V8_SHARED +class LineEditor { + public: + enum Type { DUMB = 0, READLINE = 1 }; + LineEditor(Type type, const char* name); + virtual ~LineEditor() { } + + virtual i::SmartArrayPointer Prompt(const char* prompt) = 0; + virtual bool Open() { return true; } + virtual bool Close() { return true; } + virtual void AddHistory(const char* str) { } + + const char* name() { return name_; } + static LineEditor* Get(); + private: + Type type_; + const char* name_; + LineEditor* next_; + static LineEditor* first_; +}; +#endif // V8_SHARED + + class SourceGroup { public: SourceGroup() : #ifndef V8_SHARED next_semaphore_(v8::internal::OS::CreateSemaphore(0)), done_semaphore_(v8::internal::OS::CreateSemaphore(0)), + thread_(NULL), #endif // V8_SHARED argv_(NULL), begin_offset_(0), end_offset_(0) {} + ~SourceGroup(); + void Begin(char** argv, int offset) { argv_ = const_cast(argv); begin_offset_ = offset; @@ -157,9 +183,9 @@ class SourceGroup { static i::Thread::Options GetThreadOptions(); void ExecuteInThread(); - i::SmartPointer next_semaphore_; - i::SmartPointer done_semaphore_; - i::SmartPointer thread_; + i::Semaphore* next_semaphore_; + i::Semaphore* done_semaphore_; + i::Thread* thread_; #endif // V8_SHARED void ExitShell(int exit_code); @@ -177,6 +203,7 @@ class ShellOptions { #ifndef V8_SHARED use_preemption(true), preemption_interval(10), + num_parallel_files(0), parallel_files(NULL), #endif // V8_SHARED script_executed(false), @@ -188,10 +215,18 @@ class ShellOptions { num_isolates(1), isolate_sources(NULL) { } + ~ShellOptions() { +#ifndef V8_SHARED + delete[] parallel_files; +#endif // V8_SHARED + delete[] isolate_sources; + } + #ifndef V8_SHARED bool use_preemption; int preemption_interval; - i::List< i::Vector >* parallel_files; + int num_parallel_files; + char** parallel_files; #endif // V8_SHARED bool script_executed; bool last_run; @@ -208,6 +243,7 @@ class Shell { #else class Shell : public i::AllStatic { #endif // V8_SHARED + public: static bool ExecuteString(Handle source, Handle name, @@ -219,6 +255,7 @@ class Shell : public i::AllStatic { static Persistent CreateEvaluationContext(); static int RunMain(int argc, char* argv[]); static int Main(int argc, char* argv[]); + static void Exit(int exit_code); #ifndef V8_SHARED static Handle GetCompletions(Handle text, @@ -299,6 +336,8 @@ class Shell : public i::AllStatic { static void AddOSMethods(Handle os_template); #ifndef V8_SHARED static const char* kHistoryFileName; + static const int kMaxHistoryEntries; + static LineEditor* console; #endif // V8_SHARED static const char* kPrompt; static ShellOptions options; @@ -329,29 +368,6 @@ class Shell : public i::AllStatic { }; -#ifndef V8_SHARED -class LineEditor { - public: - enum Type { DUMB = 0, READLINE = 1 }; - LineEditor(Type type, const char* name); - virtual ~LineEditor() { } - - virtual i::SmartPointer Prompt(const char* prompt) = 0; - virtual bool Open() { return true; } - virtual bool Close() { return true; } - virtual void AddHistory(const char* str) { } - - const char* name() { return name_; } - static LineEditor* Get(); - private: - Type type_; - const char* name_; - LineEditor* next_; - static LineEditor* first_; -}; -#endif // V8_SHARED - - } // namespace v8 diff --git a/deps/v8/src/dateparser.h b/deps/v8/src/dateparser.h index 4777e35f66c..27584ce39ef 100644 --- a/deps/v8/src/dateparser.h +++ b/deps/v8/src/dateparser.h @@ -36,7 +36,6 @@ namespace internal { class DateParser : public AllStatic { public: - // Parse the string as a date. If parsing succeeds, return true after // filling out the output array as follows (all integers are Smis): // [0]: year @@ -234,6 +233,7 @@ class DateParser : public AllStatic { static DateToken Invalid() { return DateToken(kInvalidTokenTag, 0, -1); } + private: enum TagType { kInvalidTokenTag = -6, @@ -275,6 +275,7 @@ class DateParser : public AllStatic { } return false; } + private: DateToken Scan(); @@ -351,6 +352,7 @@ class DateParser : public AllStatic { static bool IsMinute(int x) { return Between(x, 0, 59); } static bool IsHour(int x) { return Between(x, 0, 23); } static bool IsSecond(int x) { return Between(x, 0, 59); } + private: static bool IsHour12(int x) { return Between(x, 0, 12); } static bool IsMillisecond(int x) { return Between(x, 0, 999); } diff --git a/deps/v8/src/debug-agent.cc b/deps/v8/src/debug-agent.cc index 520bc629262..591d0b3e464 100644 --- a/deps/v8/src/debug-agent.cc +++ b/deps/v8/src/debug-agent.cc @@ -169,7 +169,8 @@ void DebuggerAgentSession::Run() { while (true) { // Read data from the debugger front end. - SmartPointer message = DebuggerAgentUtil::ReceiveMessage(client_); + SmartArrayPointer message = + DebuggerAgentUtil::ReceiveMessage(client_); const char* msg = *message; bool is_closing_session = (msg == NULL); @@ -232,7 +233,7 @@ const int DebuggerAgentUtil::kContentLengthSize = StrLength(kContentLength); -SmartPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { +SmartArrayPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { int received; // Read header. @@ -250,7 +251,7 @@ SmartPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { received = conn->Receive(&c, 1); if (received <= 0) { PrintF("Error %d\n", Socket::LastError()); - return SmartPointer(); + return SmartArrayPointer(); } // Add character to header buffer. @@ -287,12 +288,12 @@ SmartPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { if (strcmp(key, kContentLength) == 0) { // Get the content length value if present and within a sensible range. if (value == NULL || strlen(value) > 7) { - return SmartPointer(); + return SmartArrayPointer(); } for (int i = 0; value[i] != '\0'; i++) { // Bail out if illegal data. if (value[i] < '0' || value[i] > '9') { - return SmartPointer(); + return SmartArrayPointer(); } content_length = 10 * content_length + (value[i] - '0'); } @@ -304,7 +305,7 @@ SmartPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { // Return now if no body. if (content_length == 0) { - return SmartPointer(); + return SmartArrayPointer(); } // Read body. @@ -312,11 +313,11 @@ SmartPointer DebuggerAgentUtil::ReceiveMessage(const Socket* conn) { received = ReceiveAll(conn, buffer, content_length); if (received < content_length) { PrintF("Error %d\n", Socket::LastError()); - return SmartPointer(); + return SmartArrayPointer(); } buffer[content_length] = '\0'; - return SmartPointer(buffer); + return SmartArrayPointer(buffer); } diff --git a/deps/v8/src/debug-agent.h b/deps/v8/src/debug-agent.h index e1678719775..a07fb0f49c7 100644 --- a/deps/v8/src/debug-agent.h +++ b/deps/v8/src/debug-agent.h @@ -72,7 +72,7 @@ class DebuggerAgent: public Thread { void OnSessionClosed(DebuggerAgentSession* session); Isolate* isolate_; - SmartPointer name_; // Name of the embedding application. + SmartArrayPointer name_; // Name of the embedding application. int port_; // Port to use for the agent. Socket* server_; // Server socket for listen/accept. bool terminate_; // Termination flag. @@ -117,7 +117,7 @@ class DebuggerAgentUtil { static const char* const kContentLength; static const int kContentLengthSize; - static SmartPointer ReceiveMessage(const Socket* conn); + static SmartArrayPointer ReceiveMessage(const Socket* conn); static bool SendConnectMessage(const Socket* conn, const char* embedding_host); static bool SendMessage(const Socket* conn, const Vector message); diff --git a/deps/v8/src/debug.cc b/deps/v8/src/debug.cc index 2d58ce1f54a..a229d39c3ed 100644 --- a/deps/v8/src/debug.cc +++ b/deps/v8/src/debug.cc @@ -40,6 +40,7 @@ #include "global-handles.h" #include "ic.h" #include "ic-inl.h" +#include "list.h" #include "messages.h" #include "natives.h" #include "stub-cache.h" @@ -542,6 +543,7 @@ void Debug::ThreadInit() { thread_local_.last_statement_position_ = RelocInfo::kNoPosition; thread_local_.step_count_ = 0; thread_local_.last_fp_ = 0; + thread_local_.queued_step_count_ = 0; thread_local_.step_into_fp_ = 0; thread_local_.step_out_fp_ = 0; thread_local_.after_break_target_ = 0; @@ -957,14 +959,49 @@ Object* Debug::Break(Arguments args) { // Clear all current stepping setup. ClearStepping(); - // Notify the debug event listeners. - isolate_->debugger()->OnDebugBreak(break_points_hit, false); + if (thread_local_.queued_step_count_ > 0) { + // Perform queued steps + int step_count = thread_local_.queued_step_count_; + + // Clear queue + thread_local_.queued_step_count_ = 0; + + PrepareStep(StepNext, step_count); + } else { + // Notify the debug event listeners. + isolate_->debugger()->OnDebugBreak(break_points_hit, false); + } } else if (thread_local_.last_step_action_ != StepNone) { // Hold on to last step action as it is cleared by the call to // ClearStepping. StepAction step_action = thread_local_.last_step_action_; int step_count = thread_local_.step_count_; + // If StepNext goes deeper in code, StepOut until original frame + // and keep step count queued up in the meantime. + if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) { + // Count frames until target frame + int count = 0; + JavaScriptFrameIterator it(isolate_); + while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) { + count++; + it.Advance(); + } + + // If we found original frame + if (it.frame()->fp() == thread_local_.last_fp_) { + if (step_count > 1) { + // Save old count and action to continue stepping after + // StepOut + thread_local_.queued_step_count_ = step_count - 1; + } + + // Set up for StepOut to reach target frame + step_action = StepOut; + step_count = count; + } + } + // Clear all current stepping setup. ClearStepping(); @@ -1105,6 +1142,8 @@ void Debug::SetBreakPoint(Handle shared, int* source_position) { HandleScope scope(isolate_); + PrepareForBreakPoints(); + if (!EnsureDebugInfo(shared)) { // Return if retrieving debug info failed. return; @@ -1178,6 +1217,7 @@ void Debug::ClearAllBreakPoints() { void Debug::FloodWithOneShot(Handle shared) { + PrepareForBreakPoints(); // Make sure the function has setup the debug info. if (!EnsureDebugInfo(shared)) { // Return if we failed to retrieve the debug info. @@ -1234,6 +1274,9 @@ bool Debug::IsBreakOnException(ExceptionBreakType type) { void Debug::PrepareStep(StepAction step_action, int step_count) { HandleScope scope(isolate_); + + PrepareForBreakPoints(); + ASSERT(Debug::InDebugger()); // Remember this step action and count. @@ -1448,6 +1491,13 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { // steps before reporting break back to the debugger. bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator, JavaScriptFrame* frame) { + // StepNext and StepOut shouldn't bring us deeper in code, so last frame + // shouldn't be a parent of current frame. + if (thread_local_.last_step_action_ == StepNext || + thread_local_.last_step_action_ == StepOut) { + if (frame->fp() < thread_local_.last_fp_) return true; + } + // If the step last action was step next or step in make sure that a new // statement is hit. if (thread_local_.last_step_action_ == StepNext || @@ -1676,20 +1726,64 @@ void Debug::ClearStepNext() { } +void Debug::PrepareForBreakPoints() { + // If preparing for the first break point make sure to deoptimize all + // functions as debugging does not work with optimized code. + if (!has_break_points_) { + Deoptimizer::DeoptimizeAll(); + + AssertNoAllocation no_allocation; + Builtins* builtins = isolate_->builtins(); + Code* lazy_compile = builtins->builtin(Builtins::kLazyCompile); + + // Find all non-optimized code functions with activation frames on + // the stack. + List active_functions(100); + for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { + JavaScriptFrame* frame = it.frame(); + if (frame->function()->IsJSFunction()) { + JSFunction* function = JSFunction::cast(frame->function()); + if (function->code()->kind() == Code::FUNCTION) + active_functions.Add(function); + } + } + active_functions.Sort(); + + // Scan the heap for all non-optimized functions which has no + // debug break slots. + HeapIterator iterator; + HeapObject* obj = NULL; + while (((obj = iterator.next()) != NULL)) { + if (obj->IsJSFunction()) { + JSFunction* function = JSFunction::cast(obj); + if (function->shared()->allows_lazy_compilation() && + function->shared()->script()->IsScript() && + function->code()->kind() == Code::FUNCTION && + !function->code()->has_debug_break_slots()) { + bool has_activation = + SortedListBSearch(active_functions, function) != -1; + if (!has_activation) { + function->set_code(lazy_compile); + function->shared()->set_code(lazy_compile); + } + } + } + } + } +} + + // Ensures the debug information is present for shared. bool Debug::EnsureDebugInfo(Handle shared) { // Return if we already have the debug info for shared. - if (HasDebugInfo(shared)) return true; + if (HasDebugInfo(shared)) { + ASSERT(shared->is_compiled()); + return true; + } // Ensure shared in compiled. Return false if this failed. if (!EnsureCompiled(shared, CLEAR_EXCEPTION)) return false; - // If preparing for the first break point make sure to deoptimize all - // functions as debugging does not work with optimized code. - if (!has_break_points_) { - Deoptimizer::DeoptimizeAll(); - } - // Create the debug info object. Handle debug_info = FACTORY->NewDebugInfo(shared); @@ -1739,6 +1833,8 @@ void Debug::RemoveDebugInfo(Handle debug_info) { void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { HandleScope scope(isolate_); + PrepareForBreakPoints(); + // Get the executing function in which the debug break occurred. Handle shared = Handle(JSFunction::cast(frame->function())->shared()); @@ -1829,6 +1925,8 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { return false; } + PrepareForBreakPoints(); + // Get the executing function in which the debug break occurred. Handle shared = Handle(JSFunction::cast(frame->function())->shared()); diff --git a/deps/v8/src/debug.h b/deps/v8/src/debug.h index c614844ab56..a098040c0df 100644 --- a/deps/v8/src/debug.h +++ b/deps/v8/src/debug.h @@ -247,6 +247,8 @@ class Debug { static Handle GetDebugInfo(Handle shared); static bool HasDebugInfo(Handle shared); + void PrepareForBreakPoints(); + // Returns whether the operation succeeded. bool EnsureDebugInfo(Handle shared); @@ -506,6 +508,9 @@ class Debug { // Frame pointer from last step next action. Address last_fp_; + // Number of queued steps left to perform before debug event. + int queued_step_count_; + // Frame pointer for frame from which step in was performed. Address step_into_fp_; @@ -1026,6 +1031,7 @@ class Debug_Address { return NULL; } } + private: Debug::AddressId id_; }; diff --git a/deps/v8/src/disassembler.cc b/deps/v8/src/disassembler.cc index 79076d6abc2..1e67b4cb66d 100644 --- a/deps/v8/src/disassembler.cc +++ b/deps/v8/src/disassembler.cc @@ -223,7 +223,7 @@ static int DecodeIt(FILE* f, HeapStringAllocator allocator; StringStream accumulator(&allocator); relocinfo.target_object()->ShortPrint(&accumulator); - SmartPointer obj_name = accumulator.ToCString(); + SmartArrayPointer obj_name = accumulator.ToCString(); out.AddFormatted(" ;; object: %s", *obj_name); } else if (rmode == RelocInfo::EXTERNAL_REFERENCE) { const char* reference_name = @@ -247,9 +247,6 @@ static int DecodeIt(FILE* f, PropertyType type = code->type(); out.AddFormatted(", %s", Code::PropertyType2String(type)); } - if (code->ic_in_loop() == IN_LOOP) { - out.AddFormatted(", in_loop"); - } if (kind == Code::CALL_IC || kind == Code::KEYED_CALL_IC) { out.AddFormatted(", argc = %d", code->arguments_count()); } diff --git a/deps/v8/src/elements.cc b/deps/v8/src/elements.cc index 1afc5dad5e0..e4ecfe8dd63 100644 --- a/deps/v8/src/elements.cc +++ b/deps/v8/src/elements.cc @@ -401,7 +401,7 @@ class DictionaryElementsAccessor Heap* heap = isolate->heap(); FixedArray* backing_store = FixedArray::cast(obj->elements()); bool is_arguments = - (obj->GetElementsKind() == JSObject::NON_STRICT_ARGUMENTS_ELEMENTS); + (obj->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS); if (is_arguments) { backing_store = FixedArray::cast(backing_store->get(1)); } @@ -565,28 +565,28 @@ ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) { switch (array->map()->instance_type()) { case FIXED_ARRAY_TYPE: if (array->IsDictionary()) { - return elements_accessors_[JSObject::DICTIONARY_ELEMENTS]; + return elements_accessors_[DICTIONARY_ELEMENTS]; } else { - return elements_accessors_[JSObject::FAST_ELEMENTS]; + return elements_accessors_[FAST_ELEMENTS]; } case EXTERNAL_BYTE_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_BYTE_ELEMENTS]; + return elements_accessors_[EXTERNAL_BYTE_ELEMENTS]; case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS]; + return elements_accessors_[EXTERNAL_UNSIGNED_BYTE_ELEMENTS]; case EXTERNAL_SHORT_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_SHORT_ELEMENTS]; + return elements_accessors_[EXTERNAL_SHORT_ELEMENTS]; case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS]; + return elements_accessors_[EXTERNAL_UNSIGNED_SHORT_ELEMENTS]; case EXTERNAL_INT_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_INT_ELEMENTS]; + return elements_accessors_[EXTERNAL_INT_ELEMENTS]; case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS]; + return elements_accessors_[EXTERNAL_UNSIGNED_INT_ELEMENTS]; case EXTERNAL_FLOAT_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_FLOAT_ELEMENTS]; + return elements_accessors_[EXTERNAL_FLOAT_ELEMENTS]; case EXTERNAL_DOUBLE_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_DOUBLE_ELEMENTS]; + return elements_accessors_[EXTERNAL_DOUBLE_ELEMENTS]; case EXTERNAL_PIXEL_ARRAY_TYPE: - return elements_accessors_[JSObject::EXTERNAL_PIXEL_ELEMENTS]; + return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS]; default: UNREACHABLE(); return NULL; diff --git a/deps/v8/src/elements.h b/deps/v8/src/elements.h index 3eae303ed13..851c8c3d97f 100644 --- a/deps/v8/src/elements.h +++ b/deps/v8/src/elements.h @@ -54,8 +54,8 @@ class ElementsAccessor { Object* receiver) = 0; // Returns a shared ElementsAccessor for the specified ElementsKind. - static ElementsAccessor* ForKind(JSObject::ElementsKind elements_kind) { - ASSERT(elements_kind < JSObject::kElementsKindCount); + static ElementsAccessor* ForKind(ElementsKind elements_kind) { + ASSERT(elements_kind < kElementsKindCount); return elements_accessors_[elements_kind]; } diff --git a/deps/v8/src/execution.cc b/deps/v8/src/execution.cc index bdbdca81bb7..f36d4e4911f 100644 --- a/deps/v8/src/execution.cc +++ b/deps/v8/src/execution.cc @@ -149,12 +149,29 @@ Handle Execution::Call(Handle callable, Handle receiver, int argc, Object*** args, - bool* pending_exception) { + bool* pending_exception, + bool convert_receiver) { if (!callable->IsJSFunction()) { callable = TryGetFunctionDelegate(callable, pending_exception); if (*pending_exception) return callable; } Handle func = Handle::cast(callable); + + // In non-strict mode, convert receiver. + if (convert_receiver && !receiver->IsJSReceiver() && + !func->shared()->native() && !func->shared()->strict_mode()) { + if (receiver->IsUndefined() || receiver->IsNull()) { + Object* global = func->context()->global()->global_receiver(); + // Under some circumstances, 'global' can be the JSBuiltinsObject + // In that case, don't rewrite. + // (FWIW, the same holds for GetIsolate()->global()->global_receiver().) + if (!global->IsJSBuiltinsObject()) receiver = Handle(global); + } else { + receiver = ToObject(receiver, pending_exception); + } + if (*pending_exception) return callable; + } + return Invoke(false, func, receiver, argc, args, pending_exception); } @@ -210,10 +227,17 @@ Handle Execution::GetFunctionDelegate(Handle object) { // If you return a function from here, it will be called when an // attempt is made to call the given object as a function. + // If object is a function proxy, get its handler. Iterate if necessary. + Object* fun = *object; + while (fun->IsJSFunctionProxy()) { + fun = JSFunctionProxy::cast(fun)->call_trap(); + } + if (fun->IsJSFunction()) return Handle(fun); + // Objects created through the API can have an instance-call handler // that should be used when calling the object as a function. - if (object->IsHeapObject() && - HeapObject::cast(*object)->map()->has_instance_call_handler()) { + if (fun->IsHeapObject() && + HeapObject::cast(fun)->map()->has_instance_call_handler()) { return Handle( isolate->global_context()->call_as_function_delegate()); } @@ -227,10 +251,17 @@ Handle Execution::TryGetFunctionDelegate(Handle object, ASSERT(!object->IsJSFunction()); Isolate* isolate = Isolate::Current(); + // If object is a function proxy, get its handler. Iterate if necessary. + Object* fun = *object; + while (fun->IsJSFunctionProxy()) { + fun = JSFunctionProxy::cast(fun)->call_trap(); + } + if (fun->IsJSFunction()) return Handle(fun); + // Objects created through the API can have an instance-call handler // that should be used when calling the object as a function. - if (object->IsHeapObject() && - HeapObject::cast(*object)->map()->has_instance_call_handler()) { + if (fun->IsHeapObject() && + HeapObject::cast(fun)->map()->has_instance_call_handler()) { return Handle( isolate->global_context()->call_as_function_delegate()); } @@ -253,10 +284,17 @@ Handle Execution::GetConstructorDelegate(Handle object) { // If you return a function from here, it will be called when an // attempt is made to call the given object as a constructor. + // If object is a function proxies, get its handler. Iterate if necessary. + Object* fun = *object; + while (fun->IsJSFunctionProxy()) { + fun = JSFunctionProxy::cast(fun)->call_trap(); + } + if (fun->IsJSFunction()) return Handle(fun); + // Objects created through the API can have an instance-call handler // that should be used when calling the object as a function. - if (object->IsHeapObject() && - HeapObject::cast(*object)->map()->has_instance_call_handler()) { + if (fun->IsHeapObject() && + HeapObject::cast(fun)->map()->has_instance_call_handler()) { return Handle( isolate->global_context()->call_as_constructor_delegate()); } @@ -274,10 +312,17 @@ Handle Execution::TryGetConstructorDelegate( // If you return a function from here, it will be called when an // attempt is made to call the given object as a constructor. + // If object is a function proxies, get its handler. Iterate if necessary. + Object* fun = *object; + while (fun->IsJSFunctionProxy()) { + fun = JSFunctionProxy::cast(fun)->call_trap(); + } + if (fun->IsJSFunction()) return Handle(fun); + // Objects created through the API can have an instance-call handler // that should be used when calling the object as a function. - if (object->IsHeapObject() && - HeapObject::cast(*object)->map()->has_instance_call_handler()) { + if (fun->IsHeapObject() && + HeapObject::cast(fun)->map()->has_instance_call_handler()) { return Handle( isolate->global_context()->call_as_constructor_delegate()); } @@ -553,7 +598,7 @@ Handle Execution::ToDetailString(Handle obj, bool* exc) { Handle Execution::ToObject(Handle obj, bool* exc) { - if (obj->IsJSObject()) return obj; + if (obj->IsSpecObject()) return obj; RETURN_NATIVE_CALL(to_object, 1, { obj.location() }, exc); } diff --git a/deps/v8/src/execution.h b/deps/v8/src/execution.h index bb5f8045068..5cd7141fc26 100644 --- a/deps/v8/src/execution.h +++ b/deps/v8/src/execution.h @@ -53,11 +53,16 @@ class Execution : public AllStatic { // *pending_exception tells whether the invoke resulted in // a pending exception. // + // When convert_receiver is set, and the receiver is not an object, + // and the function called is not in strict mode, receiver is converted to + // an object. + // static Handle Call(Handle callable, Handle receiver, int argc, Object*** args, - bool* pending_exception); + bool* pending_exception, + bool convert_receiver = false); // Construct object from function, the caller supplies an array of // arguments. Arguments are Object* type. After function returns, diff --git a/deps/v8/src/factory.cc b/deps/v8/src/factory.cc index ee5c37bf081..97289266e37 100644 --- a/deps/v8/src/factory.cc +++ b/deps/v8/src/factory.cc @@ -465,13 +465,13 @@ Handle Factory::GetSlowElementsMap(Handle src) { } -Handle Factory::GetExternalArrayElementsMap( +Handle Factory::GetElementsTransitionMap( Handle src, - ExternalArrayType array_type, + ElementsKind elements_kind, bool safe_to_add_transition) { CALL_HEAP_FUNCTION(isolate(), - src->GetExternalArrayElementsMap(array_type, - safe_to_add_transition), + src->GetElementsTransitionMap(elements_kind, + safe_to_add_transition), Map); } @@ -922,10 +922,19 @@ Handle Factory::NewJSProxy(Handle handler, } -void Factory::BecomeJSObject(Handle object) { +void Factory::BecomeJSObject(Handle object) { CALL_HEAP_FUNCTION_VOID( isolate(), - isolate()->heap()->ReinitializeJSProxyAsJSObject(*object)); + isolate()->heap()->ReinitializeJSReceiver( + *object, JS_OBJECT_TYPE, JSObject::kHeaderSize)); +} + + +void Factory::BecomeJSFunction(Handle object) { + CALL_HEAP_FUNCTION_VOID( + isolate(), + isolate()->heap()->ReinitializeJSReceiver( + *object, JS_FUNCTION_TYPE, JSFunction::kSize)); } diff --git a/deps/v8/src/factory.h b/deps/v8/src/factory.h index a69b05b38f0..71ae750b38b 100644 --- a/deps/v8/src/factory.h +++ b/deps/v8/src/factory.h @@ -219,9 +219,9 @@ class Factory { Handle GetSlowElementsMap(Handle map); - Handle GetExternalArrayElementsMap(Handle map, - ExternalArrayType array_type, - bool safe_to_add_transition); + Handle GetElementsTransitionMap(Handle map, + ElementsKind elements_kind, + bool safe_to_add_transition); Handle CopyFixedArray(Handle array); @@ -260,8 +260,9 @@ class Factory { Handle NewJSProxy(Handle handler, Handle prototype); - // Change the type of the argument into a regular JS object and reinitialize. - void BecomeJSObject(Handle object); + // Change the type of the argument into a JS object/function and reinitialize. + void BecomeJSObject(Handle object); + void BecomeJSFunction(Handle object); Handle NewFunction(Handle name, Handle prototype); diff --git a/deps/v8/src/flags.cc b/deps/v8/src/flags.cc index c20f5ee05d8..ab5b57cedc1 100644 --- a/deps/v8/src/flags.cc +++ b/deps/v8/src/flags.cc @@ -31,7 +31,7 @@ #include "v8.h" #include "platform.h" -#include "smart-pointer.h" +#include "smart-array-pointer.h" #include "string-stream.h" @@ -193,7 +193,7 @@ static const char* Type2String(Flag::FlagType type) { } -static SmartPointer ToString(Flag* flag) { +static SmartArrayPointer ToString(Flag* flag) { HeapStringAllocator string_allocator; StringStream buffer(&string_allocator); switch (flag->type()) { @@ -528,7 +528,7 @@ void FlagList::PrintHelp() { printf("Options:\n"); for (size_t i = 0; i < num_flags; ++i) { Flag* f = &flags[i]; - SmartPointer value = ToString(f); + SmartArrayPointer value = ToString(f); printf(" --%s (%s)\n type: %s default: %s\n", f->name(), f->comment(), Type2String(f->type()), *value); } diff --git a/deps/v8/src/frames.h b/deps/v8/src/frames.h index 4f94ebc7d1d..fed11c4faf5 100644 --- a/deps/v8/src/frames.h +++ b/deps/v8/src/frames.h @@ -579,6 +579,7 @@ class ArgumentsAdaptorFrame: public JavaScriptFrame { virtual void Print(StringStream* accumulator, PrintMode mode, int index) const; + protected: explicit ArgumentsAdaptorFrame(StackFrameIterator* iterator) : JavaScriptFrame(iterator) { } diff --git a/deps/v8/src/full-codegen.cc b/deps/v8/src/full-codegen.cc index 53ace82fe7a..80738741329 100644 --- a/deps/v8/src/full-codegen.cc +++ b/deps/v8/src/full-codegen.cc @@ -286,11 +286,13 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { } unsigned table_offset = cgen.EmitStackCheckTable(); - Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); + Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); Handle code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); code->set_optimizable(info->IsOptimizable()); cgen.PopulateDeoptimizationData(code); code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); + code->set_has_debug_break_slots( + info->isolate()->debugger()->IsDebuggerActive()); code->set_allow_osr_at_loop_nesting_level(0); code->set_stack_check_table_offset(table_offset); CodeGenerator::PrintCode(code, info); diff --git a/deps/v8/src/gdb-jit.cc b/deps/v8/src/gdb-jit.cc index 4d57e254609..68cb0533b8e 100644 --- a/deps/v8/src/gdb-jit.cc +++ b/deps/v8/src/gdb-jit.cc @@ -993,7 +993,7 @@ class CodeDescription BASE_EMBEDDED { } #endif - SmartPointer GetFilename() { + SmartArrayPointer GetFilename() { return String::cast(script_->name())->ToCString(); } @@ -1991,7 +1991,7 @@ void GDBJITInterface::AddCode(Handle name, GetScriptLineNumber(script, 0); if (!name.is_null()) { - SmartPointer name_cstring = name->ToCString(DISALLOW_NULLS); + SmartArrayPointer name_cstring = name->ToCString(DISALLOW_NULLS); AddCode(*name_cstring, *code, GDBJITInterface::FUNCTION, *script, info); } else { AddCode("", *code, GDBJITInterface::FUNCTION, *script, info); diff --git a/deps/v8/src/handles.cc b/deps/v8/src/handles.cc index 8c6439b227a..35c363c10c9 100644 --- a/deps/v8/src/handles.cc +++ b/deps/v8/src/handles.cc @@ -921,16 +921,13 @@ bool CompileLazyShared(Handle shared, } -static bool CompileLazyFunction(Handle function, - ClearExceptionFlag flag, - InLoopFlag in_loop_flag) { +bool CompileLazy(Handle function, ClearExceptionFlag flag) { bool result = true; if (function->shared()->is_compiled()) { function->ReplaceCode(function->shared()->code()); function->shared()->set_code_age(0); } else { CompilationInfo info(function); - if (in_loop_flag == IN_LOOP) info.MarkAsInLoop(); result = CompileLazyHelper(&info, flag); ASSERT(!result || function->is_compiled()); } @@ -938,18 +935,6 @@ static bool CompileLazyFunction(Handle function, } -bool CompileLazy(Handle function, - ClearExceptionFlag flag) { - return CompileLazyFunction(function, flag, NOT_IN_LOOP); -} - - -bool CompileLazyInLoop(Handle function, - ClearExceptionFlag flag) { - return CompileLazyFunction(function, flag, IN_LOOP); -} - - bool CompileOptimized(Handle function, int osr_ast_id, ClearExceptionFlag flag) { diff --git a/deps/v8/src/handles.h b/deps/v8/src/handles.h index 9bb3b1f1d5c..7eaf4de9273 100644 --- a/deps/v8/src/handles.h +++ b/deps/v8/src/handles.h @@ -363,8 +363,6 @@ bool CompileLazyShared(Handle shared, bool CompileLazy(Handle function, ClearExceptionFlag flag); -bool CompileLazyInLoop(Handle function, ClearExceptionFlag flag); - bool CompileOptimized(Handle function, int osr_ast_id, ClearExceptionFlag flag); diff --git a/deps/v8/src/heap.cc b/deps/v8/src/heap.cc index 0ca138f337f..d0185930b7f 100644 --- a/deps/v8/src/heap.cc +++ b/deps/v8/src/heap.cc @@ -1627,7 +1627,7 @@ MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size) { map->set_unused_property_fields(0); map->set_bit_field(0); map->set_bit_field2(1 << Map::kIsExtensible); - map->set_elements_kind(JSObject::FAST_ELEMENTS); + map->set_elements_kind(FAST_ELEMENTS); // If the map object is aligned fill the padding area with Smi 0 objects. if (Map::kPadStart < Map::kSize) { @@ -3415,11 +3415,36 @@ MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { map->set_prototype(prototype); // Allocate the proxy object. - Object* result; + JSProxy* result; MaybeObject* maybe_result = Allocate(map, NEW_SPACE); - if (!maybe_result->ToObject(&result)) return maybe_result; - JSProxy::cast(result)->set_handler(handler); - JSProxy::cast(result)->set_padding(Smi::FromInt(0)); + if (!maybe_result->To(&result)) return maybe_result; + result->InitializeBody(map->instance_size(), Smi::FromInt(0)); + result->set_handler(handler); + return result; +} + + +MaybeObject* Heap::AllocateJSFunctionProxy(Object* handler, + Object* call_trap, + Object* construct_trap, + Object* prototype) { + // Allocate map. + // TODO(rossberg): Once we optimize proxies, think about a scheme to share + // maps. Will probably depend on the identity of the handler object, too. + Map* map; + MaybeObject* maybe_map_obj = + AllocateMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); + if (!maybe_map_obj->To(&map)) return maybe_map_obj; + map->set_prototype(prototype); + + // Allocate the proxy object. + JSFunctionProxy* result; + MaybeObject* maybe_result = Allocate(map, NEW_SPACE); + if (!maybe_result->To(&result)) return maybe_result; + result->InitializeBody(map->instance_size(), Smi::FromInt(0)); + result->set_handler(handler); + result->set_call_trap(call_trap); + result->set_construct_trap(construct_trap); return result; } @@ -3564,16 +3589,19 @@ MaybeObject* Heap::CopyJSObject(JSObject* source) { } -MaybeObject* Heap::ReinitializeJSProxyAsJSObject(JSProxy* object) { +MaybeObject* Heap::ReinitializeJSReceiver( + JSReceiver* object, InstanceType type, int size) { + ASSERT(type >= FIRST_JS_RECEIVER_TYPE); + // Allocate fresh map. // TODO(rossberg): Once we optimize proxies, cache these maps. Map* map; - MaybeObject* maybe_map_obj = - AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + MaybeObject* maybe_map_obj = AllocateMap(type, size); if (!maybe_map_obj->To(&map)) return maybe_map_obj; - // Check that the receiver has the same size as a fresh object. - ASSERT(map->instance_size() == object->map()->instance_size()); + // Check that the receiver has at least the size of the fresh object. + int size_difference = object->map()->instance_size() - map->instance_size(); + ASSERT(size_difference >= 0); map->set_prototype(object->map()->prototype()); @@ -3590,6 +3618,28 @@ MaybeObject* Heap::ReinitializeJSProxyAsJSObject(JSProxy* object) { // Reinitialize the object from the constructor map. InitializeJSObjectFromMap(JSObject::cast(object), FixedArray::cast(properties), map); + + // Functions require some minimal initialization. + if (type == JS_FUNCTION_TYPE) { + String* name; + MaybeObject* maybe_name = LookupAsciiSymbol(""); + if (!maybe_name->To(&name)) return maybe_name; + SharedFunctionInfo* shared; + MaybeObject* maybe_shared = AllocateSharedFunctionInfo(name); + if (!maybe_shared->To(&shared)) return maybe_shared; + JSFunction* func; + MaybeObject* maybe_func = + InitializeFunction(JSFunction::cast(object), shared, the_hole_value()); + if (!maybe_func->To(&func)) return maybe_func; + func->set_context(isolate()->context()->global_context()); + } + + // Put in filler if the new object is smaller than the old. + if (size_difference > 0) { + CreateFillerObjectAt( + object->address() + map->instance_size(), size_difference); + } + return object; } diff --git a/deps/v8/src/heap.h b/deps/v8/src/heap.h index cc689df17bd..d81ff6cad5d 100644 --- a/deps/v8/src/heap.h +++ b/deps/v8/src/heap.h @@ -440,17 +440,25 @@ class Heap { // Please note this does not perform a garbage collection. MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function); - // Allocates a Harmony Proxy. + // Allocates a Harmony proxy or function proxy. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. MUST_USE_RESULT MaybeObject* AllocateJSProxy(Object* handler, Object* prototype); - // Reinitialize a JSProxy into an (empty) JSObject. The receiver - // must have the same size as an empty object. The object is reinitialized - // and behaves as an object that has been freshly allocated. - MUST_USE_RESULT MaybeObject* ReinitializeJSProxyAsJSObject(JSProxy* object); + MUST_USE_RESULT MaybeObject* AllocateJSFunctionProxy(Object* handler, + Object* call_trap, + Object* construct_trap, + Object* prototype); + + // Reinitialize a JSReceiver into an (empty) JS object of respective type and + // size, but keeping the original prototype. The receiver must have at least + // the size of the new object. The object is reinitialized and behaves as an + // object that has been freshly allocated. + MUST_USE_RESULT MaybeObject* ReinitializeJSReceiver(JSReceiver* object, + InstanceType type, + int size); // Reinitialize an JSGlobalProxy based on a constructor. The object // must have the same size as objects allocated using the diff --git a/deps/v8/src/hydrogen-instructions.cc b/deps/v8/src/hydrogen-instructions.cc index 14e1bc8a46e..5630ce3913f 100644 --- a/deps/v8/src/hydrogen-instructions.cc +++ b/deps/v8/src/hydrogen-instructions.cc @@ -1133,7 +1133,7 @@ void HDeoptimize::PrintDataTo(StringStream* stream) { void HEnterInlined::PrintDataTo(StringStream* stream) { - SmartPointer name = function()->debug_name()->ToCString(); + SmartArrayPointer name = function()->debug_name()->ToCString(); stream->Add("%s, id=%d", *name, function()->id()); } @@ -1307,6 +1307,12 @@ void HCompareIDAndBranch::PrintDataTo(StringStream* stream) { left()->PrintNameTo(stream); stream->Add(" "); right()->PrintNameTo(stream); + HControlInstruction::PrintDataTo(stream); +} + + +void HGoto::PrintDataTo(StringStream* stream) { + stream->Add("B%d", SuccessorAt(0)->block_id()); } @@ -1454,37 +1460,37 @@ void HLoadKeyedSpecializedArrayElement::PrintDataTo( external_pointer()->PrintNameTo(stream); stream->Add("."); switch (elements_kind()) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: stream->Add("byte"); break; - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: stream->Add("u_byte"); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: stream->Add("short"); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: stream->Add("u_short"); break; - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: stream->Add("int"); break; - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: stream->Add("u_int"); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: stream->Add("float"); break; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: stream->Add("double"); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: stream->Add("pixel"); break; - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -1549,37 +1555,37 @@ void HStoreKeyedSpecializedArrayElement::PrintDataTo( external_pointer()->PrintNameTo(stream); stream->Add("."); switch (elements_kind()) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: stream->Add("byte"); break; - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: stream->Add("u_byte"); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: stream->Add("short"); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: stream->Add("u_short"); break; - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: stream->Add("int"); break; - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: stream->Add("u_int"); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: stream->Add("float"); break; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: stream->Add("double"); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: stream->Add("pixel"); break; - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } diff --git a/deps/v8/src/hydrogen-instructions.h b/deps/v8/src/hydrogen-instructions.h index 3ccf302e40f..1bc28ba82dd 100644 --- a/deps/v8/src/hydrogen-instructions.h +++ b/deps/v8/src/hydrogen-instructions.h @@ -915,6 +915,8 @@ class HGoto: public HTemplateControlInstruction<1, 0> { return Representation::None(); } + virtual void PrintDataTo(StringStream* stream); + DECLARE_CONCRETE_INSTRUCTION(Goto) }; @@ -2209,6 +2211,13 @@ class HPhi: public HValue { is_convertible_to_integer_ = b; } + bool AllOperandsConvertibleToInteger() { + for (int i = 0; i < OperandCount(); ++i) { + if (!OperandAt(i)->IsConvertibleToInteger()) return false; + } + return true; + } + protected: virtual void DeleteFromGraph(); virtual void InternalSetOperandAt(int index, HValue* value) { @@ -3555,12 +3564,12 @@ class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> { public: HLoadKeyedSpecializedArrayElement(HValue* external_elements, HValue* key, - JSObject::ElementsKind elements_kind) + ElementsKind elements_kind) : elements_kind_(elements_kind) { SetOperandAt(0, external_elements); SetOperandAt(1, key); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || - elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { set_representation(Representation::Double()); } else { set_representation(Representation::Integer32()); @@ -3583,7 +3592,7 @@ class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> { HValue* external_pointer() { return OperandAt(0); } HValue* key() { return OperandAt(1); } - JSObject::ElementsKind elements_kind() const { return elements_kind_; } + ElementsKind elements_kind() const { return elements_kind_; } DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) @@ -3596,7 +3605,7 @@ class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> { } private: - JSObject::ElementsKind elements_kind_; + ElementsKind elements_kind_; }; @@ -3776,7 +3785,7 @@ class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> { HStoreKeyedSpecializedArrayElement(HValue* external_elements, HValue* key, HValue* val, - JSObject::ElementsKind elements_kind) + ElementsKind elements_kind) : elements_kind_(elements_kind) { SetFlag(kChangesSpecializedArrayElements); SetOperandAt(0, external_elements); @@ -3791,8 +3800,8 @@ class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> { return Representation::External(); } else { bool float_or_double_elements = - elements_kind() == JSObject::EXTERNAL_FLOAT_ELEMENTS || - elements_kind() == JSObject::EXTERNAL_DOUBLE_ELEMENTS; + elements_kind() == EXTERNAL_FLOAT_ELEMENTS || + elements_kind() == EXTERNAL_DOUBLE_ELEMENTS; if (index == 2 && float_or_double_elements) { return Representation::Double(); } else { @@ -3804,12 +3813,12 @@ class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> { HValue* external_pointer() { return OperandAt(0); } HValue* key() { return OperandAt(1); } HValue* value() { return OperandAt(2); } - JSObject::ElementsKind elements_kind() const { return elements_kind_; } + ElementsKind elements_kind() const { return elements_kind_; } DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement) private: - JSObject::ElementsKind elements_kind_; + ElementsKind elements_kind_; }; diff --git a/deps/v8/src/hydrogen.cc b/deps/v8/src/hydrogen.cc index ab25299b78c..cca168a96b4 100644 --- a/deps/v8/src/hydrogen.cc +++ b/deps/v8/src/hydrogen.cc @@ -220,6 +220,17 @@ bool HBasicBlock::Dominates(HBasicBlock* other) const { } +int HBasicBlock::LoopNestingDepth() const { + const HBasicBlock* current = this; + int result = (current->IsLoopHeader()) ? 1 : 0; + while (current->parent_loop_header() != NULL) { + current = current->parent_loop_header(); + result++; + } + return result; +} + + void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { ASSERT(IsLoopHeader()); @@ -638,8 +649,7 @@ Handle HGraph::Compile(CompilationInfo* info) { PrintF("Crankshaft Compiler - "); } CodeGenerator::MakeCodePrologue(info); - Code::Flags flags = - Code::ComputeFlags(Code::OPTIMIZED_FUNCTION, NOT_IN_LOOP); + Code::Flags flags = Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); Handle code = CodeGenerator::MakeCodeEpilogue(&assembler, flags, info); generator.FinishCode(code); @@ -1638,18 +1648,20 @@ Representation HInferRepresentation::TryChange(HValue* value) { int non_tagged_count = double_count + int32_count; // If a non-loop phi has tagged uses, don't convert it to untagged. - if (value->IsPhi() && !value->block()->IsLoopHeader()) { - if (tagged_count > 0) return Representation::None(); + if (value->IsPhi() && !value->block()->IsLoopHeader() && tagged_count > 0) { + return Representation::None(); } - if (non_tagged_count >= tagged_count) { - if (int32_count > 0) { - if (!value->IsPhi() || value->IsConvertibleToInteger()) { - return Representation::Integer32(); - } - } - if (double_count > 0) return Representation::Double(); + // Prefer unboxing over boxing, the latter is more expensive. + if (tagged_count > non_tagged_count) Representation::None(); + + // Prefer Integer32 over Double, if possible. + if (int32_count > 0 && value->IsConvertibleToInteger()) { + return Representation::Integer32(); } + + if (double_count > 0) return Representation::Double(); + return Representation::None(); } @@ -1690,40 +1702,25 @@ void HInferRepresentation::Analyze() { } } - // (3) Sum up the non-phi use counts of all connected phis. Don't include - // the non-phi uses of the phi itself. + // (3) Use the phi reachability information from step 2 to + // (a) sum up the non-phi use counts of all connected phis. + // (b) push information about values which can't be converted to integer + // without deoptimization through the phi use-def chains, avoiding + // unnecessary deoptimizations later. for (int i = 0; i < phi_count; ++i) { HPhi* phi = phi_list->at(i); + bool cti = phi->AllOperandsConvertibleToInteger(); for (BitVector::Iterator it(connected_phis.at(i)); !it.Done(); it.Advance()) { int index = it.Current(); - if (index != i) { - HPhi* it_use = phi_list->at(it.Current()); - phi->AddNonPhiUsesFrom(it_use); - } - } - } - - // (4) Compute phis that definitely can't be converted to integer - // without deoptimization and mark them to avoid unnecessary deoptimization. - change = true; - while (change) { - change = false; - for (int i = 0; i < phi_count; ++i) { - HPhi* phi = phi_list->at(i); - for (int j = 0; j < phi->OperandCount(); ++j) { - if (phi->IsConvertibleToInteger() && - !phi->OperandAt(j)->IsConvertibleToInteger()) { - phi->set_is_convertible_to_integer(false); - change = true; - break; - } - } + HPhi* it_use = phi_list->at(it.Current()); + if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice! + if (!cti) it_use->set_is_convertible_to_integer(false); } } - + // Initialize work list for (int i = 0; i < graph_->blocks()->length(); ++i) { HBasicBlock* block = graph_->blocks()->at(i); const ZoneList* phis = block->phis(); @@ -1738,6 +1735,7 @@ void HInferRepresentation::Analyze() { } } + // Do a fixed point iteration, trying to improve representations while (!worklist_.is_empty()) { HValue* current = worklist_.RemoveLast(); in_worklist_.Remove(current->id()); @@ -2203,7 +2201,8 @@ void TestContext::BuildBranch(HValue* value) { void HGraphBuilder::Bailout(const char* reason) { if (FLAG_trace_bailout) { - SmartPointer name(info()->shared_info()->DebugName()->ToCString()); + SmartArrayPointer name( + info()->shared_info()->DebugName()->ToCString()); PrintF("Bailout in HGraphBuilder: @\"%s\": %s\n", *name, reason); } SetStackOverflow(); @@ -3904,35 +3903,35 @@ HInstruction* HGraphBuilder::BuildExternalArrayElementAccess( HValue* external_elements, HValue* checked_key, HValue* val, - JSObject::ElementsKind elements_kind, + ElementsKind elements_kind, bool is_store) { if (is_store) { ASSERT(val != NULL); switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: { + case EXTERNAL_PIXEL_ELEMENTS: { HClampToUint8* clamp = new(zone()) HClampToUint8(val); AddInstruction(clamp); val = clamp; break; } - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: { + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: { HToInt32* floor_val = new(zone()) HToInt32(val); AddInstruction(floor_val); val = floor_val; break; } - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: break; - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -4016,7 +4015,7 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, SmallMapList* maps = prop->GetReceiverTypes(); bool todo_external_array = false; - static const int kNumElementTypes = JSObject::kElementsKindCount; + static const int kNumElementTypes = kElementsKindCount; bool type_todo[kNumElementTypes]; for (int i = 0; i < kNumElementTypes; ++i) { type_todo[i] = false; @@ -4026,7 +4025,7 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, ASSERT(maps->at(i)->IsMap()); type_todo[maps->at(i)->elements_kind()] = true; if (maps->at(i)->elements_kind() - >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { + >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { todo_external_array = true; } } @@ -4041,16 +4040,16 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, HInstruction* checked_key = NULL; // FAST_ELEMENTS is assumed to be the first case. - STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); + STATIC_ASSERT(FAST_ELEMENTS == 0); - for (JSObject::ElementsKind elements_kind = JSObject::FAST_ELEMENTS; - elements_kind <= JSObject::LAST_ELEMENTS_KIND; - elements_kind = JSObject::ElementsKind(elements_kind + 1)) { + for (ElementsKind elements_kind = FAST_ELEMENTS; + elements_kind <= LAST_ELEMENTS_KIND; + elements_kind = ElementsKind(elements_kind + 1)) { // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we // need to add some code that's executed for all external array cases. - STATIC_ASSERT(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == - JSObject::LAST_ELEMENTS_KIND); - if (elements_kind == JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND + STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == + LAST_ELEMENTS_KIND); + if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && todo_external_array) { HInstruction* length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); @@ -4069,11 +4068,11 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, set_current_block(if_true); HInstruction* access; - if (elements_kind == JSObject::FAST_ELEMENTS || - elements_kind == JSObject::FAST_DOUBLE_ELEMENTS) { + if (elements_kind == FAST_ELEMENTS || + elements_kind == FAST_DOUBLE_ELEMENTS) { bool fast_double_elements = - elements_kind == JSObject::FAST_DOUBLE_ELEMENTS; - if (is_store && elements_kind == JSObject::FAST_ELEMENTS) { + elements_kind == FAST_DOUBLE_ELEMENTS; + if (is_store && elements_kind == FAST_ELEMENTS) { AddInstruction(new(zone()) HCheckMap( elements, isolate()->factory()->fixed_array_map(), elements_kind_branch)); @@ -4138,7 +4137,7 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, new(zone()) HLoadKeyedFastElement(elements, checked_key)); } } - } else if (elements_kind == JSObject::DICTIONARY_ELEMENTS) { + } else if (elements_kind == DICTIONARY_ELEMENTS) { if (is_store) { access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); } else { @@ -4433,8 +4432,10 @@ void HGraphBuilder::TraceInline(Handle target, Handle caller, const char* reason) { if (FLAG_trace_inlining) { - SmartPointer target_name = target->shared()->DebugName()->ToCString(); - SmartPointer caller_name = caller->shared()->DebugName()->ToCString(); + SmartArrayPointer target_name = + target->shared()->DebugName()->ToCString(); + SmartArrayPointer caller_name = + caller->shared()->DebugName()->ToCString(); if (reason == NULL) { PrintF("Inlined %s called from %s.\n", *target_name, *caller_name); } else { @@ -5913,7 +5914,9 @@ void HGraphBuilder::GenerateIsFunction(CallRuntime* call) { CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasInstanceTypeAndBranch* result = - new(zone()) HHasInstanceTypeAndBranch(value, JS_FUNCTION_TYPE); + new(zone()) HHasInstanceTypeAndBranch(value, + JS_FUNCTION_TYPE, + JS_FUNCTION_PROXY_TYPE); return ast_context()->ReturnControl(result, call->id()); } @@ -6567,6 +6570,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { PrintBlockProperty("dominator", current->dominator()->block_id()); } + PrintIntProperty("loop_depth", current->LoopNestingDepth()); + if (chunk != NULL) { int first_index = current->first_instruction_index(); int last_index = current->last_instruction_index(); diff --git a/deps/v8/src/hydrogen.h b/deps/v8/src/hydrogen.h index 614991f7c2a..03fbc732201 100644 --- a/deps/v8/src/hydrogen.h +++ b/deps/v8/src/hydrogen.h @@ -102,6 +102,7 @@ class HBasicBlock: public ZoneObject { void RemovePhi(HPhi* phi); void AddInstruction(HInstruction* instr); bool Dominates(HBasicBlock* other) const; + int LoopNestingDepth() const; void SetInitialEnvironment(HEnvironment* env); void ClearEnvironment() { last_environment_ = NULL; } @@ -935,7 +936,7 @@ class HGraphBuilder: public AstVisitor { HValue* external_elements, HValue* checked_key, HValue* val, - JSObject::ElementsKind elements_kind, + ElementsKind elements_kind, bool is_store); HInstruction* BuildMonomorphicElementAccess(HValue* object, diff --git a/deps/v8/src/ia32/assembler-ia32.h b/deps/v8/src/ia32/assembler-ia32.h index c186094b397..4698e3ed1b0 100644 --- a/deps/v8/src/ia32/assembler-ia32.h +++ b/deps/v8/src/ia32/assembler-ia32.h @@ -465,6 +465,7 @@ class CpuFeatures : public AllStatic { // Enable a specified feature within a scope. class Scope BASE_EMBEDDED { #ifdef DEBUG + public: explicit Scope(CpuFeature f) { uint64_t mask = static_cast(1) << f; @@ -484,10 +485,12 @@ class CpuFeatures : public AllStatic { isolate_->set_enabled_cpu_features(old_enabled_); } } + private: Isolate* isolate_; uint64_t old_enabled_; #else + public: explicit Scope(CpuFeature f) {} #endif diff --git a/deps/v8/src/ia32/builtins-ia32.cc b/deps/v8/src/ia32/builtins-ia32.cc index 845a073c409..310ea3d1234 100644 --- a/deps/v8/src/ia32/builtins-ia32.cc +++ b/deps/v8/src/ia32/builtins-ia32.cc @@ -590,16 +590,17 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // 2. Get the function to call (passed as receiver) from the stack, check // if it is a function. - Label non_function; + Label slow, non_function; // 1 ~ return address. __ mov(edi, Operand(esp, eax, times_4, 1 * kPointerSize)); __ JumpIfSmi(edi, &non_function); __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); - __ j(not_equal, &non_function); + __ j(not_equal, &slow); // 3a. Patch the first argument if necessary when calling a function. Label shift_arguments; + __ Set(edx, Immediate(0)); // indicate regular JS_FUNCTION { Label convert_to_object, use_global_receiver, patch_receiver; // Change context eagerly in case we need the global receiver. __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); @@ -637,6 +638,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ push(ebx); __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); __ mov(ebx, eax); + __ Set(edx, Immediate(0)); // restore __ pop(eax); __ SmiUntag(eax); @@ -661,14 +663,19 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ jmp(&shift_arguments); } - // 3b. Patch the first argument when calling a non-function. The + // 3b. Check for function proxy. + __ bind(&slow); + __ Set(edx, Immediate(1)); // indicate function proxy + __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); + __ j(equal, &shift_arguments); + __ bind(&non_function); + __ Set(edx, Immediate(2)); // indicate non-function + + // 3c. Patch the first argument when calling a non-function. The // CALL_NON_FUNCTION builtin expects the non-function callee as // receiver, so overwrite the first argument which will ultimately // become the receiver. - __ bind(&non_function); __ mov(Operand(esp, eax, times_4, 0), edi); - // Clear edi to indicate a non-function being called. - __ Set(edi, Immediate(0)); // 4. Shift arguments and return address one slot down on the stack // (overwriting the original receiver). Adjust argument count to make @@ -685,13 +692,26 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ dec(eax); // One fewer argument (first argument is new receiver). } - // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. - { Label function; - __ test(edi, Operand(edi)); - __ j(not_zero, &function); + // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, + // or a function proxy via CALL_FUNCTION_PROXY. + { Label function, non_proxy; + __ test(edx, Operand(edx)); + __ j(zero, &function); __ Set(ebx, Immediate(0)); - __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); __ SetCallKind(ecx, CALL_AS_METHOD); + __ cmp(Operand(edx), Immediate(1)); + __ j(not_equal, &non_proxy); + + __ pop(edx); // return address + __ push(edi); // re-add proxy object as additional argument + __ push(edx); + __ inc(eax); + __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); + __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), + RelocInfo::CODE_TARGET); + + __ bind(&non_proxy); + __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), RelocInfo::CODE_TARGET); __ bind(&function); @@ -717,13 +737,17 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { void Builtins::Generate_FunctionApply(MacroAssembler* masm) { + static const int kArgumentsOffset = 2 * kPointerSize; + static const int kReceiverOffset = 3 * kPointerSize; + static const int kFunctionOffset = 4 * kPointerSize; + __ EnterInternalFrame(); - __ push(Operand(ebp, 4 * kPointerSize)); // push this - __ push(Operand(ebp, 2 * kPointerSize)); // push arguments + __ push(Operand(ebp, kFunctionOffset)); // push this + __ push(Operand(ebp, kArgumentsOffset)); // push arguments __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); - // Check the stack for overflow. We are not trying need to catch + // Check the stack for overflow. We are not trying to catch // interruptions (e.g. debug break and preemption) here, so the "real stack // limit" is checked. Label okay; @@ -756,16 +780,21 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ push(eax); // limit __ push(Immediate(0)); // index - // Change context eagerly to get the right global object if - // necessary. - __ mov(edi, Operand(ebp, 4 * kPointerSize)); + // Get the receiver. + __ mov(ebx, Operand(ebp, kReceiverOffset)); + + // Check that the function is a JS function (otherwise it must be a proxy). + Label push_receiver; + __ mov(edi, Operand(ebp, kFunctionOffset)); + __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); + __ j(not_equal, &push_receiver); + + // Change context eagerly to get the right global object if necessary. __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); // Compute the receiver. - Label call_to_object, use_global_receiver, push_receiver; - __ mov(ebx, Operand(ebp, 3 * kPointerSize)); - // Do not transform the receiver for strict mode functions. + Label call_to_object, use_global_receiver; __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), 1 << SharedFunctionInfo::kStrictModeBitWithinByte); @@ -814,7 +843,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ mov(eax, Operand(ebp, kIndexOffset)); __ jmp(&entry); __ bind(&loop); - __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments + __ mov(edx, Operand(ebp, kArgumentsOffset)); // load arguments // Use inline caching to speed up access to arguments. Handle ic = masm->isolate()->builtins()->KeyedLoadIC_Initialize(); @@ -837,14 +866,30 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ j(not_equal, &loop); // Invoke the function. + Label call_proxy; ParameterCount actual(eax); __ SmiUntag(eax); - __ mov(edi, Operand(ebp, 4 * kPointerSize)); + __ mov(edi, Operand(ebp, kFunctionOffset)); + __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); + __ j(not_equal, &call_proxy); __ InvokeFunction(edi, actual, CALL_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); __ LeaveInternalFrame(); __ ret(3 * kPointerSize); // remove this, receiver, and arguments + + // Invoke the function proxy. + __ bind(&call_proxy); + __ push(edi); // add function proxy as last argument + __ inc(eax); + __ Set(ebx, Immediate(0)); + __ SetCallKind(ecx, CALL_AS_METHOD); + __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); + __ call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), + RelocInfo::CODE_TARGET); + + __ LeaveInternalFrame(); + __ ret(3 * kPointerSize); // remove this, receiver, and arguments } diff --git a/deps/v8/src/ia32/code-stubs-ia32.cc b/deps/v8/src/ia32/code-stubs-ia32.cc index f3eb09fa515..1009aaf5731 100644 --- a/deps/v8/src/ia32/code-stubs-ia32.cc +++ b/deps/v8/src/ia32/code-stubs-ia32.cc @@ -3551,7 +3551,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // stack overflow (on the backtrack stack) was detected in RegExp code but // haven't created the exception yet. Handle that in the runtime system. // TODO(592): Rerunning the RegExp to get the stack overflow exception. - ExternalReference pending_exception(Isolate::k_pending_exception_address, + ExternalReference pending_exception(Isolate::kPendingExceptionAddress, masm->isolate()); __ mov(edx, Operand::StaticVariable(ExternalReference::the_hole_value_location( @@ -4199,7 +4199,7 @@ void StackCheckStub::Generate(MacroAssembler* masm) { void CallFunctionStub::Generate(MacroAssembler* masm) { - Label slow; + Label slow, non_function; // The receiver might implicitly be the global object. This is // indicated by passing the hole as the receiver to the call @@ -4224,7 +4224,7 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { __ mov(edi, Operand(esp, (argc_ + 2) * kPointerSize)); // Check that the function really is a JavaScript function. - __ JumpIfSmi(edi, &slow); + __ JumpIfSmi(edi, &non_function); // Goto slow case if we do not have a function. __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); __ j(not_equal, &slow); @@ -4251,15 +4251,32 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { // Slow-case: Non-function called. __ bind(&slow); + // Check for function proxy. + __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); + __ j(not_equal, &non_function); + __ pop(ecx); + __ push(edi); // put proxy as additional argument under return address + __ push(ecx); + __ Set(eax, Immediate(argc_ + 1)); + __ Set(ebx, Immediate(0)); + __ SetCallKind(ecx, CALL_AS_FUNCTION); + __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); + { + Handle adaptor = + masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); + __ jmp(adaptor, RelocInfo::CODE_TARGET); + } + // CALL_NON_FUNCTION expects the non-function callee as receiver (instead // of the original receiver from the call site). + __ bind(&non_function); __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); __ Set(eax, Immediate(argc_)); __ Set(ebx, Immediate(0)); + __ SetCallKind(ecx, CALL_AS_METHOD); __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); Handle adaptor = masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); - __ SetCallKind(ecx, CALL_AS_METHOD); __ jmp(adaptor, RelocInfo::CODE_TARGET); } @@ -4341,7 +4358,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm, __ j(zero, &failure_returned); ExternalReference pending_exception_address( - Isolate::k_pending_exception_address, masm->isolate()); + Isolate::kPendingExceptionAddress, masm->isolate()); // Check that there is no pending exception, otherwise we // should have returned some failure value. @@ -4482,11 +4499,11 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { __ push(ebx); // Save copies of the top frame descriptor on the stack. - ExternalReference c_entry_fp(Isolate::k_c_entry_fp_address, masm->isolate()); + ExternalReference c_entry_fp(Isolate::kCEntryFPAddress, masm->isolate()); __ push(Operand::StaticVariable(c_entry_fp)); // If this is the outermost JS call, set js_entry_sp value. - ExternalReference js_entry_sp(Isolate::k_js_entry_sp_address, + ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, masm->isolate()); __ cmp(Operand::StaticVariable(js_entry_sp), Immediate(0)); __ j(not_equal, ¬_outermost_js, Label::kNear); @@ -4503,7 +4520,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // Caught exception: Store result (exception) in the pending // exception field in the JSEnv and return a failure sentinel. - ExternalReference pending_exception(Isolate::k_pending_exception_address, + ExternalReference pending_exception(Isolate::kPendingExceptionAddress, masm->isolate()); __ mov(Operand::StaticVariable(pending_exception), eax); __ mov(eax, reinterpret_cast(Failure::Exception())); @@ -4554,7 +4571,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // Restore the top frame descriptor from the stack. __ pop(Operand::StaticVariable(ExternalReference( - Isolate::k_c_entry_fp_address, + Isolate::kCEntryFPAddress, masm->isolate()))); // Restore callee-saved registers (C calling conventions). diff --git a/deps/v8/src/ia32/full-codegen-ia32.cc b/deps/v8/src/ia32/full-codegen-ia32.cc index 59f7b9c7b39..81c9ccb1280 100644 --- a/deps/v8/src/ia32/full-codegen-ia32.cc +++ b/deps/v8/src/ia32/full-codegen-ia32.cc @@ -2013,9 +2013,8 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr, } // Record source position of the IC call. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arg_count, in_loop, mode); + isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); __ call(ic, mode, expr->id()); RecordJSReturnSite(expr); // Restore context register. @@ -2047,9 +2046,8 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, } // Record source position of the IC call. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; - Handle ic = isolate()->stub_cache()->ComputeKeyedCallInitialize( - arg_count, in_loop); + Handle ic = + isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. __ call(ic, RelocInfo::CODE_TARGET, expr->id()); RecordJSReturnSite(expr); @@ -2071,8 +2069,7 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { } // Record source position for debugger. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; - CallFunctionStub stub(arg_count, in_loop, flags); + CallFunctionStub stub(arg_count, flags); __ CallStub(&stub); RecordJSReturnSite(expr); // Restore context register. @@ -2166,8 +2163,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { } // Record source position for debugger. SetSourcePosition(expr->position()); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; - CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_IMPLICIT); + CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); __ CallStub(&stub); RecordJSReturnSite(expr); // Restore context register. @@ -3582,10 +3578,9 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { if (expr->is_jsruntime()) { // Call the JS runtime function via a call IC. __ Set(ecx, Immediate(expr->name())); - InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; RelocInfo::Mode mode = RelocInfo::CODE_TARGET; - Handle ic = isolate()->stub_cache()->ComputeCallInitialize( - arg_count, in_loop, mode); + Handle ic = + isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); __ call(ic, mode, expr->id()); // Restore context register. __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); diff --git a/deps/v8/src/ia32/ic-ia32.cc b/deps/v8/src/ia32/ic-ia32.cc index 7d3ead2eac1..9b5cc564010 100644 --- a/deps/v8/src/ia32/ic-ia32.cc +++ b/deps/v8/src/ia32/ic-ia32.cc @@ -144,7 +144,7 @@ static void GenerateDictionaryLoad(MacroAssembler* masm, StringDictionary::kElementsStartIndex * kPointerSize; const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; __ test(Operand(elements, r0, times_4, kDetailsOffset - kHeapObjectTag), - Immediate(PropertyDetails::TypeField::mask() << kSmiTagSize)); + Immediate(PropertyDetails::TypeField::kMask << kSmiTagSize)); __ j(not_zero, miss_label); // Get the value at the masked, scaled index. @@ -198,9 +198,9 @@ static void GenerateDictionaryStore(MacroAssembler* masm, StringDictionary::kHeaderSize + StringDictionary::kElementsStartIndex * kPointerSize; const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; - const int kTypeAndReadOnlyMask - = (PropertyDetails::TypeField::mask() | - PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize; + const int kTypeAndReadOnlyMask = + (PropertyDetails::TypeField::kMask | + PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize; __ test(Operand(elements, r0, times_4, kDetailsOffset - kHeapObjectTag), Immediate(kTypeAndReadOnlyMask)); __ j(not_zero, miss_label); @@ -832,7 +832,6 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, - NOT_IN_LOOP, MONOMORPHIC, extra_ic_state, NORMAL, @@ -1237,9 +1236,7 @@ void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { // ----------------------------------- // Probe the stub cache. - Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, - NOT_IN_LOOP, - MONOMORPHIC); + Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, MONOMORPHIC); Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, eax, ecx, ebx, edx); @@ -1339,10 +1336,8 @@ void StoreIC::GenerateMegamorphic(MacroAssembler* masm, // -- esp[0] : return address // ----------------------------------- - Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, - NOT_IN_LOOP, - MONOMORPHIC, - strict_mode); + Code::Flags flags = + Code::ComputeFlags(Code::STORE_IC, MONOMORPHIC, strict_mode); Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, no_reg); diff --git a/deps/v8/src/ia32/lithium-codegen-ia32.cc b/deps/v8/src/ia32/lithium-codegen-ia32.cc index 31e9dd82e2d..4e3ea98161d 100644 --- a/deps/v8/src/ia32/lithium-codegen-ia32.cc +++ b/deps/v8/src/ia32/lithium-codegen-ia32.cc @@ -88,7 +88,8 @@ void LCodeGen::FinishCode(Handle code) { void LCodeGen::Abort(const char* format, ...) { if (FLAG_trace_bailout) { - SmartPointer name(info()->shared_info()->DebugName()->ToCString()); + SmartArrayPointer name( + info()->shared_info()->DebugName()->ToCString()); PrintF("Aborting LCodeGen in @\"%s\": ", *name); va_list arguments; va_start(arguments, format); @@ -2219,11 +2220,11 @@ void LCodeGen::DoLoadElements(LLoadElements* instr) { __ movzx_b(temp, FieldOperand(temp, Map::kBitField2Offset)); __ and_(temp, Map::kElementsKindMask); __ shr(temp, Map::kElementsKindShift); - __ cmp(temp, JSObject::FAST_ELEMENTS); + __ cmp(temp, FAST_ELEMENTS); __ j(equal, &ok, Label::kNear); - __ cmp(temp, JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); + __ cmp(temp, FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); __ j(less, &fail, Label::kNear); - __ cmp(temp, JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); + __ cmp(temp, LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); __ j(less_equal, &ok, Label::kNear); __ bind(&fail); __ Abort("Check for fast or external elements failed."); @@ -2264,7 +2265,7 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { // Load the result. __ mov(result, BuildFastArrayOperand(instr->elements(), instr->key(), - JSObject::FAST_ELEMENTS, + FAST_ELEMENTS, FixedArray::kHeaderSize - kHeapObjectTag)); // Check for the hole value. @@ -2284,14 +2285,14 @@ void LCodeGen::DoLoadKeyedFastDoubleElement( sizeof(kHoleNanLower32); Operand hole_check_operand = BuildFastArrayOperand( instr->elements(), instr->key(), - JSObject::FAST_DOUBLE_ELEMENTS, + FAST_DOUBLE_ELEMENTS, offset); __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); DeoptimizeIf(equal, instr->environment()); } Operand double_load_operand = BuildFastArrayOperand( - instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, + instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, FixedDoubleArray::kHeaderSize - kHeapObjectTag); __ movdbl(result, double_load_operand); } @@ -2300,7 +2301,7 @@ void LCodeGen::DoLoadKeyedFastDoubleElement( Operand LCodeGen::BuildFastArrayOperand( LOperand* elements_pointer, LOperand* key, - JSObject::ElementsKind elements_kind, + ElementsKind elements_kind, uint32_t offset) { Register elements_pointer_reg = ToRegister(elements_pointer); int shift_size = ElementsKindToShiftSize(elements_kind); @@ -2320,35 +2321,35 @@ Operand LCodeGen::BuildFastArrayOperand( void LCodeGen::DoLoadKeyedSpecializedArrayElement( LLoadKeyedSpecializedArrayElement* instr) { - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); Operand operand(BuildFastArrayOperand(instr->external_pointer(), instr->key(), elements_kind, 0)); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { XMMRegister result(ToDoubleRegister(instr->result())); __ movss(result, operand); __ cvtss2sd(result, result); - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { __ movdbl(ToDoubleRegister(instr->result()), operand); } else { Register result(ToRegister(instr->result())); switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: __ movsx_b(result, operand); break; - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ movzx_b(result, operand); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: __ movsx_w(result, operand); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ movzx_w(result, operand); break; - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: __ mov(result, operand); break; - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ mov(result, operand); __ test(result, Operand(result)); // TODO(danno): we could be more clever here, perhaps having a special @@ -2356,12 +2357,12 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( // happens, and generate code that returns a double rather than int. DeoptimizeIf(negative, instr->environment()); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -2980,8 +2981,8 @@ void LCodeGen::DoCallKeyed(LCallKeyed* instr) { ASSERT(ToRegister(instr->result()).is(eax)); int arity = instr->arity(); - Handle ic = isolate()->stub_cache()-> - ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); + Handle ic = + isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); CallCode(ic, RelocInfo::CODE_TARGET, instr); } @@ -2993,7 +2994,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) { int arity = instr->arity(); RelocInfo::Mode mode = RelocInfo::CODE_TARGET; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_IN_LOOP, mode); + isolate()->stub_cache()->ComputeCallInitialize(arity, mode); __ mov(ecx, instr->name()); CallCode(ic, mode, instr); } @@ -3004,7 +3005,7 @@ void LCodeGen::DoCallFunction(LCallFunction* instr) { ASSERT(ToRegister(instr->result()).is(eax)); int arity = instr->arity(); - CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_IMPLICIT); + CallFunctionStub stub(arity, RECEIVER_MIGHT_BE_IMPLICIT); CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); __ Drop(1); } @@ -3017,7 +3018,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) { int arity = instr->arity(); RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; Handle ic = - isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_IN_LOOP, mode); + isolate()->stub_cache()->ComputeCallInitialize(arity, mode); __ mov(ecx, instr->name()); CallCode(ic, mode, instr); } @@ -3103,36 +3104,36 @@ void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { void LCodeGen::DoStoreKeyedSpecializedArrayElement( LStoreKeyedSpecializedArrayElement* instr) { - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); Operand operand(BuildFastArrayOperand(instr->external_pointer(), instr->key(), elements_kind, 0)); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value())); __ movss(operand, xmm0); - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { __ movdbl(operand, ToDoubleRegister(instr->value())); } else { Register value = ToRegister(instr->value()); switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: __ mov_b(operand, value); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ mov_w(operand, value); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ mov(operand, value); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -3186,7 +3187,7 @@ void LCodeGen::DoStoreKeyedFastDoubleElement( __ bind(&have_value); Operand double_store_operand = BuildFastArrayOperand( - instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, + instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, FixedDoubleArray::kHeaderSize - kHeapObjectTag); __ movdbl(double_store_operand, value); } diff --git a/deps/v8/src/ia32/lithium-codegen-ia32.h b/deps/v8/src/ia32/lithium-codegen-ia32.h index d26f245553d..61563274201 100644 --- a/deps/v8/src/ia32/lithium-codegen-ia32.h +++ b/deps/v8/src/ia32/lithium-codegen-ia32.h @@ -224,7 +224,7 @@ class LCodeGen BASE_EMBEDDED { int ToInteger32(LConstantOperand* op) const; Operand BuildFastArrayOperand(LOperand* elements_pointer, LOperand* key, - JSObject::ElementsKind elements_kind, + ElementsKind elements_kind, uint32_t offset); // Specific math operations - used from DoUnaryMathOperation. diff --git a/deps/v8/src/ia32/lithium-ia32.cc b/deps/v8/src/ia32/lithium-ia32.cc index 34c5beb38d8..3dc220d3d9b 100644 --- a/deps/v8/src/ia32/lithium-ia32.cc +++ b/deps/v8/src/ia32/lithium-ia32.cc @@ -315,13 +315,13 @@ void LCallKeyed::PrintDataTo(StringStream* stream) { void LCallNamed::PrintDataTo(StringStream* stream) { - SmartPointer name_string = name()->ToCString(); + SmartArrayPointer name_string = name()->ToCString(); stream->Add("%s #%d / ", *name_string, arity()); } void LCallGlobal::PrintDataTo(StringStream* stream) { - SmartPointer name_string = name()->ToCString(); + SmartArrayPointer name_string = name()->ToCString(); stream->Add("%s #%d / ", *name_string, arity()); } @@ -540,7 +540,8 @@ LChunk* LChunkBuilder::Build() { void LChunkBuilder::Abort(const char* format, ...) { if (FLAG_trace_bailout) { - SmartPointer name(info()->shared_info()->DebugName()->ToCString()); + SmartArrayPointer name( + info()->shared_info()->DebugName()->ToCString()); PrintF("Aborting LChunk building in @\"%s\": ", *name); va_list arguments; va_start(arguments, format); @@ -1902,15 +1903,15 @@ LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( HLoadKeyedSpecializedArrayElement* instr) { - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); Representation representation(instr->representation()); ASSERT( (representation.IsInteger32() && - (elements_kind != JSObject::EXTERNAL_FLOAT_ELEMENTS) && - (elements_kind != JSObject::EXTERNAL_DOUBLE_ELEMENTS)) || + (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && + (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || (representation.IsDouble() && - ((elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) || - (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS)))); + ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || + (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); ASSERT(instr->key()->representation().IsInteger32()); LOperand* external_pointer = UseRegister(instr->external_pointer()); LOperand* key = UseRegisterOrConstant(instr->key()); @@ -1920,7 +1921,7 @@ LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( LInstruction* load_instr = DefineAsRegister(result); // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. - return (elements_kind == JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) + return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ? AssignEnvironment(load_instr) : load_instr; } @@ -1972,23 +1973,23 @@ LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( HStoreKeyedSpecializedArrayElement* instr) { Representation representation(instr->value()->representation()); - JSObject::ElementsKind elements_kind = instr->elements_kind(); + ElementsKind elements_kind = instr->elements_kind(); ASSERT( (representation.IsInteger32() && - (elements_kind != JSObject::EXTERNAL_FLOAT_ELEMENTS) && - (elements_kind != JSObject::EXTERNAL_DOUBLE_ELEMENTS)) || + (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && + (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || (representation.IsDouble() && - ((elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) || - (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS)))); + ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || + (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); ASSERT(instr->external_pointer()->representation().IsExternal()); ASSERT(instr->key()->representation().IsInteger32()); LOperand* external_pointer = UseRegister(instr->external_pointer()); LOperand* key = UseRegisterOrConstant(instr->key()); LOperand* val = NULL; - if (elements_kind == JSObject::EXTERNAL_BYTE_ELEMENTS || - elements_kind == JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS || - elements_kind == JSObject::EXTERNAL_PIXEL_ELEMENTS) { + if (elements_kind == EXTERNAL_BYTE_ELEMENTS || + elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || + elements_kind == EXTERNAL_PIXEL_ELEMENTS) { // We need a byte register in this case for the value. val = UseFixed(instr->value(), eax); } else { diff --git a/deps/v8/src/ia32/lithium-ia32.h b/deps/v8/src/ia32/lithium-ia32.h index e752b714e4a..038049ca068 100644 --- a/deps/v8/src/ia32/lithium-ia32.h +++ b/deps/v8/src/ia32/lithium-ia32.h @@ -1184,7 +1184,7 @@ class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> { LOperand* external_pointer() { return inputs_[0]; } LOperand* key() { return inputs_[1]; } - JSObject::ElementsKind elements_kind() const { + ElementsKind elements_kind() const { return hydrogen()->elements_kind(); } }; @@ -1699,7 +1699,7 @@ class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> { LOperand* external_pointer() { return inputs_[0]; } LOperand* key() { return inputs_[1]; } LOperand* value() { return inputs_[2]; } - JSObject::ElementsKind elements_kind() const { + ElementsKind elements_kind() const { return hydrogen()->elements_kind(); } }; diff --git a/deps/v8/src/ia32/macro-assembler-ia32.cc b/deps/v8/src/ia32/macro-assembler-ia32.cc index 6d3ce2bcd95..837112a55c8 100644 --- a/deps/v8/src/ia32/macro-assembler-ia32.cc +++ b/deps/v8/src/ia32/macro-assembler-ia32.cc @@ -287,7 +287,7 @@ void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { void MacroAssembler::CheckFastElements(Register map, Label* fail, Label::Distance distance) { - STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); + STATIC_ASSERT(FAST_ELEMENTS == 0); cmpb(FieldOperand(map, Map::kBitField2Offset), Map::kMaximumBitField2FastElementValue); j(above, fail, distance); @@ -437,9 +437,9 @@ void MacroAssembler::EnterExitFramePrologue() { push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. // Save the frame pointer and the context in top. - ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address, + ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); - ExternalReference context_address(Isolate::k_context_address, + ExternalReference context_address(Isolate::kContextAddress, isolate()); mov(Operand::StaticVariable(c_entry_fp_address), ebp); mov(Operand::StaticVariable(context_address), esi); @@ -518,14 +518,14 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles) { void MacroAssembler::LeaveExitFrameEpilogue() { // Restore current context from top and clear it in debug mode. - ExternalReference context_address(Isolate::k_context_address, isolate()); + ExternalReference context_address(Isolate::kContextAddress, isolate()); mov(esi, Operand::StaticVariable(context_address)); #ifdef DEBUG mov(Operand::StaticVariable(context_address), Immediate(0)); #endif // Clear the top frame. - ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address, + ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); } @@ -567,10 +567,10 @@ void MacroAssembler::PushTryHandler(CodeLocation try_location, push(Immediate(Smi::FromInt(0))); // No context. } // Save the current handler as the next handler. - push(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, + push(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, isolate()))); // Link this handler as the new current one. - mov(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, + mov(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, isolate())), esp); } @@ -578,7 +578,7 @@ void MacroAssembler::PushTryHandler(CodeLocation try_location, void MacroAssembler::PopTryHandler() { STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); - pop(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address, + pop(Operand::StaticVariable(ExternalReference(Isolate::kHandlerAddress, isolate()))); add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize)); } @@ -598,7 +598,7 @@ void MacroAssembler::Throw(Register value) { } // Drop the sp to the top of the handler. - ExternalReference handler_address(Isolate::k_handler_address, + ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); mov(esp, Operand::StaticVariable(handler_address)); @@ -637,7 +637,7 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, } // Drop sp to the top stack handler. - ExternalReference handler_address(Isolate::k_handler_address, + ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); mov(esp, Operand::StaticVariable(handler_address)); @@ -660,13 +660,13 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, if (type == OUT_OF_MEMORY) { // Set external caught exception to false. ExternalReference external_caught( - Isolate::k_external_caught_exception_address, + Isolate::kExternalCaughtExceptionAddress, isolate()); mov(eax, false); mov(Operand::StaticVariable(external_caught), eax); // Set pending exception and eax to out of memory exception. - ExternalReference pending_exception(Isolate::k_pending_exception_address, + ExternalReference pending_exception(Isolate::kPendingExceptionAddress, isolate()); mov(eax, reinterpret_cast(Failure::OutOfMemoryException())); mov(Operand::StaticVariable(pending_exception), eax); @@ -840,7 +840,7 @@ void MacroAssembler::LoadFromNumberDictionary(Label* miss, NumberDictionary::kElementsStartOffset + 2 * kPointerSize; ASSERT_EQ(NORMAL, 0); test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), - Immediate(PropertyDetails::TypeField::mask() << kSmiTagSize)); + Immediate(PropertyDetails::TypeField::kMask << kSmiTagSize)); j(not_zero, miss); // Get the value at the masked, scaled index. diff --git a/deps/v8/src/ia32/stub-cache-ia32.cc b/deps/v8/src/ia32/stub-cache-ia32.cc index 621a9bbfa21..ab62764e640 100644 --- a/deps/v8/src/ia32/stub-cache-ia32.cc +++ b/deps/v8/src/ia32/stub-cache-ia32.cc @@ -2679,7 +2679,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { // -- esp[0] : return address // ----------------------------------- Code* stub; - JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); + ElementsKind elements_kind = receiver_map->elements_kind(); bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; MaybeObject* maybe_stub = KeyedStoreElementStub(is_jsarray, elements_kind).TryGetCode(); @@ -3140,7 +3140,7 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) { // -- esp[0] : return address // ----------------------------------- Code* stub; - JSObject::ElementsKind elements_kind = receiver_map->elements_kind(); + ElementsKind elements_kind = receiver_map->elements_kind(); MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode(); if (!maybe_stub->To(&stub)) return maybe_stub; __ DispatchMap(edx, @@ -3385,7 +3385,7 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( void KeyedLoadStubCompiler::GenerateLoadExternalArray( MacroAssembler* masm, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { // ----------- S t a t e ------------- // -- eax : key // -- edx : receiver @@ -3407,29 +3407,29 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ mov(ebx, FieldOperand(ebx, ExternalArray::kExternalPointerOffset)); // ebx: base pointer of external storage switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: __ SmiUntag(eax); // Untag the index. __ movsx_b(eax, Operand(ebx, eax, times_1, 0)); break; - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: __ SmiUntag(eax); // Untag the index. __ movzx_b(eax, Operand(ebx, eax, times_1, 0)); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: __ movsx_w(eax, Operand(ebx, eax, times_1, 0)); break; - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ movzx_w(eax, Operand(ebx, eax, times_1, 0)); break; - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: - case JSObject::EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: __ mov(ecx, Operand(ebx, eax, times_2, 0)); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: __ fld_s(Operand(ebx, eax, times_2, 0)); break; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: __ fld_d(Operand(ebx, eax, times_4, 0)); break; default: @@ -3442,17 +3442,17 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( // For floating-point array type: // FP(0): value - if (elements_kind == JSObject::EXTERNAL_INT_ELEMENTS || - elements_kind == JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) { + if (elements_kind == EXTERNAL_INT_ELEMENTS || + elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { // For the Int and UnsignedInt array types, we need to see whether // the value can be represented in a Smi. If not, we need to convert // it to a HeapNumber. Label box_int; - if (elements_kind == JSObject::EXTERNAL_INT_ELEMENTS) { + if (elements_kind == EXTERNAL_INT_ELEMENTS) { __ cmp(ecx, 0xC0000000); __ j(sign, &box_int); } else { - ASSERT_EQ(JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind); + ASSERT_EQ(EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind); // The test is different for unsigned int values. Since we need // the value to be in the range of a positive smi, we can't // handle either of the top two bits being set in the value. @@ -3468,12 +3468,12 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( // Allocate a HeapNumber for the int and perform int-to-double // conversion. - if (elements_kind == JSObject::EXTERNAL_INT_ELEMENTS) { + if (elements_kind == EXTERNAL_INT_ELEMENTS) { __ push(ecx); __ fild_s(Operand(esp, 0)); __ pop(ecx); } else { - ASSERT_EQ(JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind); + ASSERT_EQ(EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind); // Need to zero-extend the value. // There's no fild variant for unsigned values, so zero-extend // to a 64-bit int manually. @@ -3489,8 +3489,8 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( __ mov(eax, ecx); __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); __ ret(0); - } else if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || - elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { // For the floating-point array type, we need to always allocate a // HeapNumber. __ AllocateHeapNumber(ecx, ebx, edi, &failed_allocation); @@ -3540,7 +3540,7 @@ void KeyedLoadStubCompiler::GenerateLoadExternalArray( void KeyedStoreStubCompiler::GenerateStoreExternalArray( MacroAssembler* masm, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { // ----------- S t a t e ------------- // -- eax : key // -- edx : receiver @@ -3566,7 +3566,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // edx: receiver // ecx: key // edi: elements array - if (elements_kind == JSObject::EXTERNAL_PIXEL_ELEMENTS) { + if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) { __ JumpIfNotSmi(eax, &slow); } else { __ JumpIfNotSmi(eax, &check_heap_number); @@ -3578,33 +3578,33 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ mov(edi, FieldOperand(edi, ExternalArray::kExternalPointerOffset)); // edi: base pointer of external storage switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: __ ClampUint8(ebx); __ SmiUntag(ecx); __ mov_b(Operand(edi, ecx, times_1, 0), ebx); break; - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ SmiUntag(ecx); __ mov_b(Operand(edi, ecx, times_1, 0), ebx); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ mov_w(Operand(edi, ecx, times_1, 0), ebx); break; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: __ mov(Operand(edi, ecx, times_2, 0), ebx); break; - case JSObject::EXTERNAL_FLOAT_ELEMENTS: - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: // Need to perform int-to-float conversion. __ push(ebx); __ fild_s(Operand(esp, 0)); __ pop(ebx); - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { __ fstp_s(Operand(edi, ecx, times_2, 0)); - } else { // elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS. + } else { // elements_kind == EXTERNAL_DOUBLE_ELEMENTS. __ fstp_d(Operand(edi, ecx, times_4, 0)); } break; @@ -3615,7 +3615,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( __ ret(0); // Return the original value. // TODO(danno): handle heap number -> pixel array conversion - if (elements_kind != JSObject::EXTERNAL_PIXEL_ELEMENTS) { + if (elements_kind != EXTERNAL_PIXEL_ELEMENTS) { __ bind(&check_heap_number); // eax: value // edx: receiver @@ -3630,11 +3630,11 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // reproducible behavior, convert these to zero. __ mov(edi, FieldOperand(edi, ExternalArray::kExternalPointerOffset)); // edi: base pointer of external storage - if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { + if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); __ fstp_s(Operand(edi, ecx, times_2, 0)); __ ret(0); - } else if (elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { + } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); __ fstp_d(Operand(edi, ecx, times_4, 0)); __ ret(0); @@ -3647,23 +3647,23 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray( // (code-stubs-ia32.cc) is roughly what is needed here though the // conversion failure case does not need to be handled. if (CpuFeatures::IsSupported(SSE2)) { - if (elements_kind != JSObject::EXTERNAL_INT_ELEMENTS && - elements_kind != JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS) { + if (elements_kind != EXTERNAL_INT_ELEMENTS && + elements_kind != EXTERNAL_UNSIGNED_INT_ELEMENTS) { ASSERT(CpuFeatures::IsSupported(SSE2)); CpuFeatures::Scope scope(SSE2); __ cvttsd2si(ebx, FieldOperand(eax, HeapNumber::kValueOffset)); // ecx: untagged integer value switch (elements_kind) { - case JSObject::EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: __ ClampUint8(ebx); // Fall through. - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: __ SmiUntag(ecx); __ mov_b(Operand(edi, ecx, times_1, 0), ebx); break; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: __ mov_w(Operand(edi, ecx, times_1, 0), ebx); break; default: diff --git a/deps/v8/src/ic.cc b/deps/v8/src/ic.cc index 0d0b93570bc..0f76a9a06cb 100644 --- a/deps/v8/src/ic.cc +++ b/deps/v8/src/ic.cc @@ -61,8 +61,7 @@ static char TransitionMarkFromState(IC::State state) { void IC::TraceIC(const char* type, Handle name, State old_state, - Code* new_target, - const char* extra_info) { + Code* new_target) { if (FLAG_trace_ic) { State new_state = StateFrom(new_target, HEAP->undefined_value(), @@ -94,10 +93,9 @@ void IC::TraceIC(const char* type, } else { PrintF(""); } - PrintF(" (%c->%c)%s", + PrintF(" (%c->%c)", TransitionMarkFromState(old_state), - TransitionMarkFromState(new_state), - extra_info); + TransitionMarkFromState(new_state)); name->Print(); PrintF("]\n"); } @@ -326,7 +324,6 @@ void CallICBase::Clear(Address address, Code* target) { Code* code = Isolate::Current()->stub_cache()->FindCallInitialize( target->arguments_count(), - target->ic_in_loop(), contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, target->kind()); SetTargetAtAddress(address, code); @@ -604,13 +601,11 @@ MaybeObject* CallICBase::ComputeMonomorphicStub( Handle object, Handle name) { int argc = target()->arguments_count(); - InLoopFlag in_loop = target()->ic_in_loop(); MaybeObject* maybe_code = NULL; switch (lookup->type()) { case FIELD: { int index = lookup->GetFieldIndex(); maybe_code = isolate()->stub_cache()->ComputeCallField(argc, - in_loop, kind_, extra_ic_state, *name, @@ -626,7 +621,6 @@ MaybeObject* CallICBase::ComputeMonomorphicStub( JSFunction* function = lookup->GetConstantFunction(); maybe_code = isolate()->stub_cache()->ComputeCallConstant(argc, - in_loop, kind_, extra_ic_state, *name, @@ -646,7 +640,6 @@ MaybeObject* CallICBase::ComputeMonomorphicStub( if (!cell->value()->IsJSFunction()) return NULL; JSFunction* function = JSFunction::cast(cell->value()); maybe_code = isolate()->stub_cache()->ComputeCallGlobal(argc, - in_loop, kind_, extra_ic_state, *name, @@ -661,7 +654,6 @@ MaybeObject* CallICBase::ComputeMonomorphicStub( // applicable. if (lookup->holder() != *receiver) return NULL; maybe_code = isolate()->stub_cache()->ComputeCallNormal(argc, - in_loop, kind_, extra_ic_state, *name, @@ -706,7 +698,6 @@ void CallICBase::UpdateCaches(LookupResult* lookup, // Compute the number of arguments. int argc = target()->arguments_count(); - InLoopFlag in_loop = target()->ic_in_loop(); MaybeObject* maybe_code = NULL; bool had_proto_failure = false; if (state == UNINITIALIZED) { @@ -715,7 +706,6 @@ void CallICBase::UpdateCaches(LookupResult* lookup, // setting the monomorphic state. maybe_code = isolate()->stub_cache()->ComputeCallPreMonomorphic(argc, - in_loop, kind_, extra_ic_state); } else if (state == MONOMORPHIC) { @@ -739,7 +729,6 @@ void CallICBase::UpdateCaches(LookupResult* lookup, } else { maybe_code = isolate()->stub_cache()->ComputeCallMegamorphic(argc, - in_loop, kind_, extra_ic_state); } @@ -776,7 +765,7 @@ void CallICBase::UpdateCaches(LookupResult* lookup, #ifdef DEBUG if (had_proto_failure) state = MONOMORPHIC_PROTOTYPE_FAILURE; TraceIC(kind_ == Code::CALL_IC ? "CallIC" : "KeyedCallIC", - name, state, target(), in_loop ? " (in-loop)" : ""); + name, state, target()); #endif } @@ -797,31 +786,28 @@ MaybeObject* KeyedCallIC::LoadFunction(State state, if (FLAG_use_ic && state != MEGAMORPHIC && object->IsHeapObject()) { int argc = target()->arguments_count(); - InLoopFlag in_loop = target()->ic_in_loop(); Heap* heap = Handle::cast(object)->GetHeap(); Map* map = heap->non_strict_arguments_elements_map(); if (object->IsJSObject() && Handle::cast(object)->elements()->map() == map) { MaybeObject* maybe_code = isolate()->stub_cache()->ComputeCallArguments( - argc, in_loop, Code::KEYED_CALL_IC); + argc, Code::KEYED_CALL_IC); Object* code; if (maybe_code->ToObject(&code)) { set_target(Code::cast(code)); #ifdef DEBUG - TraceIC( - "KeyedCallIC", key, state, target(), in_loop ? " (in-loop)" : ""); + TraceIC("KeyedCallIC", key, state, target()); #endif } } else if (FLAG_use_ic && state != MEGAMORPHIC && !object->IsAccessCheckNeeded()) { MaybeObject* maybe_code = isolate()->stub_cache()->ComputeCallMegamorphic( - argc, in_loop, Code::KEYED_CALL_IC, Code::kNoExtraICState); + argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); Object* code; if (maybe_code->ToObject(&code)) { set_target(Code::cast(code)); #ifdef DEBUG - TraceIC( - "KeyedCallIC", key, state, target(), in_loop ? " (in-loop)" : ""); + TraceIC("KeyedCallIC", key, state, target()); #endif } } @@ -1093,7 +1079,7 @@ void LoadIC::UpdateCaches(LookupResult* lookup, MaybeObject* KeyedLoadIC::GetElementStubWithoutMapCheck( bool is_js_array, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { return KeyedLoadElementStub(elements_kind).TryGetCode(); } @@ -1650,7 +1636,6 @@ MaybeObject* KeyedIC::ComputeStub(JSObject* receiver, PolymorphicCodeCache* cache = isolate()->heap()->polymorphic_code_cache(); Code::Flags flags = Code::ComputeFlags(this->kind(), - NOT_IN_LOOP, MEGAMORPHIC, strict_mode); Object* maybe_cached_stub = cache->Lookup(&target_receiver_maps, flags); @@ -1721,7 +1706,7 @@ MaybeObject* KeyedIC::ComputeMonomorphicStub(JSObject* receiver, MaybeObject* KeyedStoreIC::GetElementStubWithoutMapCheck( bool is_js_array, - JSObject::ElementsKind elements_kind) { + ElementsKind elements_kind) { return KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); } @@ -1905,16 +1890,11 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup, // static JSFunction* CompileFunction(Isolate* isolate, - JSFunction* function, - InLoopFlag in_loop) { + JSFunction* function) { // Compile now with optimization. HandleScope scope(isolate); Handle function_handle(function, isolate); - if (in_loop == IN_LOOP) { - CompileLazyInLoop(function_handle, CLEAR_EXCEPTION); - } else { - CompileLazy(function_handle, CLEAR_EXCEPTION); - } + CompileLazy(function_handle, CLEAR_EXCEPTION); return *function_handle; } @@ -1943,9 +1923,7 @@ RUNTIME_FUNCTION(MaybeObject*, CallIC_Miss) { if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { return result; } - return CompileFunction(isolate, - JSFunction::cast(result), - ic.target()->ic_in_loop()); + return CompileFunction(isolate, JSFunction::cast(result)); } @@ -1964,9 +1942,7 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_Miss) { if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { return result; } - return CompileFunction(isolate, - JSFunction::cast(result), - ic.target()->ic_in_loop()); + return CompileFunction(isolate, JSFunction::cast(result)); } diff --git a/deps/v8/src/ic.h b/deps/v8/src/ic.h index 2236ba37b67..ece5be9f050 100644 --- a/deps/v8/src/ic.h +++ b/deps/v8/src/ic.h @@ -149,8 +149,7 @@ class IC { void TraceIC(const char* type, Handle name, State old_state, - Code* new_target, - const char* extra_info = ""); + Code* new_target); #endif Failure* TypeError(const char* type, @@ -348,7 +347,7 @@ class KeyedIC: public IC { virtual MaybeObject* GetElementStubWithoutMapCheck( bool is_js_array, - JSObject::ElementsKind elements_kind) = 0; + ElementsKind elements_kind) = 0; protected: virtual Code* string_stub() { @@ -415,7 +414,7 @@ class KeyedLoadIC: public KeyedIC { virtual MaybeObject* GetElementStubWithoutMapCheck( bool is_js_array, - JSObject::ElementsKind elements_kind); + ElementsKind elements_kind); protected: virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } @@ -566,7 +565,7 @@ class KeyedStoreIC: public KeyedIC { virtual MaybeObject* GetElementStubWithoutMapCheck( bool is_js_array, - JSObject::ElementsKind elements_kind); + ElementsKind elements_kind); protected: virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } diff --git a/deps/v8/src/inspector.h b/deps/v8/src/inspector.h index f8b30428615..e328bcdfa5e 100644 --- a/deps/v8/src/inspector.h +++ b/deps/v8/src/inspector.h @@ -41,7 +41,6 @@ namespace internal { class Inspector { public: - static void DumpObjectType(FILE* out, Object *obj, bool print_more); static void DumpObjectType(FILE* out, Object *obj) { DumpObjectType(out, obj, false); @@ -59,4 +58,3 @@ class Inspector { #endif // INSPECTOR #endif // V8_INSPECTOR_H_ - diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index afb9624875c..fd0f673e7ec 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -1414,7 +1414,7 @@ Isolate::Isolate() TRACE_ISOLATE(constructor); memset(isolate_addresses_, 0, - sizeof(isolate_addresses_[0]) * (k_isolate_address_count + 1)); + sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); heap_.isolate_ = this; zone_.isolate_ = this; @@ -1686,9 +1686,10 @@ bool Isolate::Init(Deserializer* des) { // ensuring that Isolate::Current() == this. heap_.SetStackLimits(); -#define C(name) isolate_addresses_[Isolate::k_##name] = \ - reinterpret_cast
(name()); - ISOLATE_ADDRESS_LIST(C) +#define ASSIGN_ELEMENT(CamelName, hacker_name) \ + isolate_addresses_[Isolate::k##CamelName##Address] = \ + reinterpret_cast
(hacker_name##_address()); + FOR_EACH_ISOLATE_ADDRESS_NAME(ASSIGN_ELEMENT) #undef C string_tracker_ = new StringTracker(); diff --git a/deps/v8/src/isolate.h b/deps/v8/src/isolate.h index 7c690d26ba8..2582da644a7 100644 --- a/deps/v8/src/isolate.h +++ b/deps/v8/src/isolate.h @@ -119,13 +119,13 @@ typedef ZoneList > ZoneObjectList; #define RETURN_IF_EMPTY_HANDLE(isolate, call) \ RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception()) -#define ISOLATE_ADDRESS_LIST(C) \ - C(handler_address) \ - C(c_entry_fp_address) \ - C(context_address) \ - C(pending_exception_address) \ - C(external_caught_exception_address) \ - C(js_entry_sp_address) +#define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \ + C(Handler, handler) \ + C(CEntryFP, c_entry_fp) \ + C(Context, context) \ + C(PendingException, pending_exception) \ + C(ExternalCaughtException, external_caught_exception) \ + C(JSEntrySP, js_entry_sp) // Platform-independent, reliable thread identifier. @@ -423,10 +423,10 @@ class Isolate { enum AddressId { -#define C(name) k_##name, - ISOLATE_ADDRESS_LIST(C) +#define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, + FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM) #undef C - k_isolate_address_count + kIsolateAddressCount }; // Returns the PerIsolateThreadData for the current thread (or NULL if one is @@ -1097,7 +1097,7 @@ class Isolate { StringStream* incomplete_message_; // The preallocated memory thread singleton. PreallocatedMemoryThread* preallocated_memory_thread_; - Address isolate_addresses_[k_isolate_address_count + 1]; // NOLINT + Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT NoAllocationStringAllocator* preallocated_message_space_; Bootstrapper* bootstrapper_; diff --git a/deps/v8/src/json.js b/deps/v8/src/json.js index a491bcc1517..deba1262122 100644 --- a/deps/v8/src/json.js +++ b/deps/v8/src/json.js @@ -54,7 +54,7 @@ function Revive(holder, name, reviver) { function JSONParse(text, reviver) { var unfiltered = %ParseJson(TO_STRING_INLINE(text)); - if (IS_FUNCTION(reviver)) { + if (IS_SPEC_FUNCTION(reviver)) { return Revive({'': unfiltered}, '', reviver); } else { return unfiltered; @@ -143,11 +143,11 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) { var value = holder[key]; if (IS_SPEC_OBJECT(value)) { var toJSON = value.toJSON; - if (IS_FUNCTION(toJSON)) { + if (IS_SPEC_FUNCTION(toJSON)) { value = %_CallFunction(value, key, toJSON); } } - if (IS_FUNCTION(replacer)) { + if (IS_SPEC_FUNCTION(replacer)) { value = %_CallFunction(holder, key, value, replacer); } if (IS_STRING(value)) { @@ -273,7 +273,7 @@ function BasicSerializeObject(value, stack, builder) { function BasicJSONSerialize(key, value, stack, builder) { if (IS_SPEC_OBJECT(value)) { var toJSON = value.toJSON; - if (IS_FUNCTION(toJSON)) { + if (IS_SPEC_FUNCTION(toJSON)) { value = %_CallFunction(value, ToString(key), toJSON); } } diff --git a/deps/v8/src/jsregexp.h b/deps/v8/src/jsregexp.h index 3bd5e008939..54297a49abc 100644 --- a/deps/v8/src/jsregexp.h +++ b/deps/v8/src/jsregexp.h @@ -255,6 +255,7 @@ class SetRelation BASE_EMBEDDED { return (bits_ == (kInFirst | kInSecond | kInBoth)); } int value() { return bits_; } + private: int bits_; }; @@ -404,6 +405,7 @@ class DispatchTable : public ZoneObject { template void ForEach(Callback* callback) { return tree()->ForEach(callback); } + private: // There can't be a static empty set since it allocates its // successors in a zone and caches them. @@ -793,6 +795,7 @@ class ActionNode: public SeqRegExpNode { virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } virtual ActionNode* Clone() { return new ActionNode(*this); } virtual int ComputeFirstCharacterSet(int budget); + private: union { struct { @@ -861,6 +864,7 @@ class TextNode: public SeqRegExpNode { } void CalculateOffsets(); virtual int ComputeFirstCharacterSet(int budget); + private: enum TextEmitPassType { NON_ASCII_MATCH, // Check for characters that can't match. @@ -925,6 +929,7 @@ class AssertionNode: public SeqRegExpNode { virtual AssertionNode* Clone() { return new AssertionNode(*this); } AssertionNodeType type() { return type_; } void set_type(AssertionNodeType type) { type_ = type; } + private: AssertionNode(AssertionNodeType t, RegExpNode* on_success) : SeqRegExpNode(on_success), type_(t) { } @@ -955,6 +960,7 @@ class BackReferenceNode: public SeqRegExpNode { } virtual BackReferenceNode* Clone() { return new BackReferenceNode(*this); } virtual int ComputeFirstCharacterSet(int budget); + private: int start_reg_; int end_reg_; @@ -1301,6 +1307,7 @@ class Trace { } void InvalidateCurrentCharacter(); void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler); + private: int FindAffectedRegisters(OutSet* affected_registers); void PerformDeferredActions(RegExpMacroAssembler* macro, @@ -1402,6 +1409,7 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT) void fail(const char* error_message) { error_message_ = error_message; } + private: bool ignore_case_; bool is_ascii_; diff --git a/deps/v8/src/list-inl.h b/deps/v8/src/list-inl.h index 8ef7514f4f6..80bccc9bc32 100644 --- a/deps/v8/src/list-inl.h +++ b/deps/v8/src/list-inl.h @@ -207,6 +207,35 @@ void List::Initialize(int capacity) { } +template +int SortedListBSearch( + const List& list, T elem, int (*cmp)(const T* x, const T* y)) { + int low = 0; + int high = list.length() - 1; + while (low <= high) { + int mid = (low + high) / 2; + T mid_elem = list[mid]; + + if (mid_elem > elem) { + high = mid - 1; + continue; + } + if (mid_elem < elem) { + low = mid + 1; + continue; + } + // Found the elememt. + return mid; + } + return -1; +} + + +template +int SortedListBSearch(const List& list, T elem) { + return SortedListBSearch(list, elem, PointerValueCompare); +} + } } // namespace v8::internal #endif // V8_LIST_INL_H_ diff --git a/deps/v8/src/list.h b/deps/v8/src/list.h index ca2b7bce227..055870904e0 100644 --- a/deps/v8/src/list.h +++ b/deps/v8/src/list.h @@ -49,7 +49,6 @@ namespace internal { template class List { public: - List() { Initialize(0); } INLINE(explicit List(int capacity)) { Initialize(capacity); } INLINE(~List()) { DeleteData(data_); } @@ -169,6 +168,15 @@ class Code; typedef List MapList; typedef List CodeList; +// Perform binary search for an element in an already sorted +// list. Returns the index of the element of -1 if it was not found. +template +int SortedListBSearch( + const List& list, T elem, int (*cmp)(const T* x, const T* y)); +template +int SortedListBSearch(const List& list, T elem); + } } // namespace v8::internal + #endif // V8_LIST_H_ diff --git a/deps/v8/src/lithium.cc b/deps/v8/src/lithium.cc index 64ef469b33a..5410f6f0586 100644 --- a/deps/v8/src/lithium.cc +++ b/deps/v8/src/lithium.cc @@ -166,25 +166,25 @@ void LPointerMap::PrintTo(StringStream* stream) { } -int ElementsKindToShiftSize(JSObject::ElementsKind elements_kind) { +int ElementsKindToShiftSize(ElementsKind elements_kind) { switch (elements_kind) { - case JSObject::EXTERNAL_BYTE_ELEMENTS: - case JSObject::EXTERNAL_PIXEL_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: return 0; - case JSObject::EXTERNAL_SHORT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: return 1; - case JSObject::EXTERNAL_INT_ELEMENTS: - case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: - case JSObject::EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_FLOAT_ELEMENTS: return 2; - case JSObject::EXTERNAL_DOUBLE_ELEMENTS: - case JSObject::FAST_DOUBLE_ELEMENTS: + case EXTERNAL_DOUBLE_ELEMENTS: + case FAST_DOUBLE_ELEMENTS: return 3; - case JSObject::FAST_ELEMENTS: - case JSObject::DICTIONARY_ELEMENTS: - case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: + case FAST_ELEMENTS: + case DICTIONARY_ELEMENTS: + case NON_STRICT_ARGUMENTS_ELEMENTS: return kPointerSizeLog2; } UNREACHABLE(); diff --git a/deps/v8/src/lithium.h b/deps/v8/src/lithium.h index 6010b777ed1..20da21a63ce 100644 --- a/deps/v8/src/lithium.h +++ b/deps/v8/src/lithium.h @@ -165,8 +165,7 @@ class LUnallocated: public LOperand { } Policy policy() const { return PolicyField::decode(value_); } void set_policy(Policy policy) { - value_ &= ~PolicyField::mask(); - value_ |= PolicyField::encode(policy); + value_ = PolicyField::update(value_, policy); } int fixed_index() const { return static_cast(value_) >> kFixedIndexShift; @@ -177,8 +176,7 @@ class LUnallocated: public LOperand { } void set_virtual_register(unsigned id) { - value_ &= ~VirtualRegisterField::mask(); - value_ |= VirtualRegisterField::encode(id); + value_ = VirtualRegisterField::update(value_, id); } LUnallocated* CopyUnconstrained() { @@ -586,7 +584,7 @@ class DeepIterator BASE_EMBEDDED { }; -int ElementsKindToShiftSize(JSObject::ElementsKind elements_kind); +int ElementsKindToShiftSize(ElementsKind elements_kind); } } // namespace v8::internal diff --git a/deps/v8/src/liveedit.cc b/deps/v8/src/liveedit.cc index 07c9fdde053..d44c2fc1cd1 100644 --- a/deps/v8/src/liveedit.cc +++ b/deps/v8/src/liveedit.cc @@ -1450,7 +1450,7 @@ static bool FixTryCatchHandler(StackFrame* top_frame, StackFrame* bottom_frame) { Address* pointer_address = &Memory::Address_at(Isolate::Current()->get_address_from_id( - Isolate::k_handler_address)); + Isolate::kHandlerAddress)); while (*pointer_address < top_frame->sp()) { pointer_address = &Memory::Address_at(*pointer_address); diff --git a/deps/v8/src/liveobjectlist.cc b/deps/v8/src/liveobjectlist.cc index 451a28ab70f..957c0515d6d 100644 --- a/deps/v8/src/liveobjectlist.cc +++ b/deps/v8/src/liveobjectlist.cc @@ -184,7 +184,7 @@ bool IsOfType(LiveObjectType type, HeapObject *obj) { const AllocationSpace kInvalidSpace = static_cast(-1); static AllocationSpace FindSpaceFor(String* space_str) { - SmartPointer s = + SmartArrayPointer s = space_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); const char* key_str = *s; @@ -236,7 +236,7 @@ static bool InSpace(AllocationSpace space, HeapObject *heap_obj) { static LiveObjectType FindTypeFor(String* type_str) { - SmartPointer s = + SmartArrayPointer s = type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); #define CHECK_OBJECT_TYPE(type_, name) { \ @@ -503,10 +503,10 @@ static void GenerateObjectDesc(HeapObject* obj, // We'll only dump 80 of them after we compact them. const int kMaxCharToDump = 80; const int kMaxBufferSize = kMaxCharToDump * 2; - SmartPointer str_sp = str->ToCString(DISALLOW_NULLS, - ROBUST_STRING_TRAVERSAL, - 0, - kMaxBufferSize); + SmartArrayPointer str_sp = str->ToCString(DISALLOW_NULLS, + ROBUST_STRING_TRAVERSAL, + 0, + kMaxBufferSize); char* str_cstr = *str_sp; int length = CompactString(str_cstr); OS::SNPrintF(buffer_v, @@ -526,14 +526,14 @@ static void GenerateObjectDesc(HeapObject* obj, } String* name = sinfo->DebugName(); - SmartPointer name_sp = + SmartArrayPointer name_sp = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); char* name_cstr = *name_sp; HeapStringAllocator string_allocator; StringStream stream(&string_allocator); sinfo->SourceCodePrint(&stream, 50); - SmartPointer source_sp = stream.ToCString(); + SmartArrayPointer source_sp = stream.ToCString(); const char* source_cstr = *source_sp; OS::SNPrintF(buffer_v, @@ -1656,7 +1656,7 @@ int LiveObjectList::GetObjId(Object* obj) { // Gets the obj id for the specified address if valid. Object* LiveObjectList::GetObjId(Handle address) { - SmartPointer addr_str = + SmartArrayPointer addr_str = address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); Isolate* isolate = Isolate::Current(); diff --git a/deps/v8/src/liveobjectlist.h b/deps/v8/src/liveobjectlist.h index 542482d9c58..65470d7ad9b 100644 --- a/deps/v8/src/liveobjectlist.h +++ b/deps/v8/src/liveobjectlist.h @@ -114,7 +114,6 @@ class LiveObjectList { static Object* PrintObj(int obj_id); private: - struct Element { int id_; HeapObject* obj_; @@ -224,7 +223,6 @@ class LiveObjectList { // Helper class for updating the LiveObjectList HeapObject pointers. class UpdateLiveObjectListVisitor: public ObjectVisitor { public: - void VisitPointer(Object** p) { UpdatePointer(p); } void VisitPointers(Object** start, Object** end) { @@ -319,4 +317,3 @@ class LiveObjectList { } } // namespace v8::internal #endif // V8_LIVEOBJECTLIST_H_ - diff --git a/deps/v8/src/log-utils.cc b/deps/v8/src/log-utils.cc index 27e654d5e8a..7bd7baa2d83 100644 --- a/deps/v8/src/log-utils.cc +++ b/deps/v8/src/log-utils.cc @@ -125,7 +125,7 @@ void Log::Initialize() { stream.Put(*p); } } - SmartPointer expanded = stream.ToCString(); + SmartArrayPointer expanded = stream.ToCString(); OpenFile(*expanded); } else { OpenFile(FLAG_logfile); diff --git a/deps/v8/src/log-utils.h b/deps/v8/src/log-utils.h index 2b20a01bbc6..d0cb8289831 100644 --- a/deps/v8/src/log-utils.h +++ b/deps/v8/src/log-utils.h @@ -141,7 +141,6 @@ class LogMessageBuilder BASE_EMBEDDED { void WriteToLogFile(); private: - Log* log_; ScopedLock sl; int pos_; diff --git a/deps/v8/src/log.cc b/deps/v8/src/log.cc index dedf7e90c5c..3d66b5fb101 100644 --- a/deps/v8/src/log.cc +++ b/deps/v8/src/log.cc @@ -617,7 +617,7 @@ void Logger::ApiEvent(const char* format, ...) { void Logger::ApiNamedSecurityCheck(Object* key) { if (!log_->IsEnabled() || !FLAG_log_api) return; if (key->IsString()) { - SmartPointer str = + SmartArrayPointer str = String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); ApiEvent("api,check-security,\"%s\"\n", *str); } else if (key->IsUndefined()) { @@ -762,9 +762,9 @@ void Logger::ApiNamedPropertyAccess(const char* tag, ASSERT(name->IsString()); if (!log_->IsEnabled() || !FLAG_log_api) return; String* class_name_obj = holder->class_name(); - SmartPointer class_name = + SmartArrayPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); - SmartPointer property_name = + SmartArrayPointer property_name = String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name); } @@ -774,7 +774,7 @@ void Logger::ApiIndexedPropertyAccess(const char* tag, uint32_t index) { if (!log_->IsEnabled() || !FLAG_log_api) return; String* class_name_obj = holder->class_name(); - SmartPointer class_name = + SmartArrayPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index); } @@ -782,7 +782,7 @@ void Logger::ApiIndexedPropertyAccess(const char* tag, void Logger::ApiObjectAccess(const char* tag, JSObject* object) { if (!log_->IsEnabled() || !FLAG_log_api) return; String* class_name_obj = object->class_name(); - SmartPointer class_name = + SmartArrayPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); ApiEvent("api,%s,\"%s\"\n", tag, *class_name); } @@ -836,7 +836,7 @@ void Logger::CallbackEventInternal(const char* prefix, const char* name, void Logger::CallbackEvent(String* name, Address entry_point) { if (!log_->IsEnabled() || !FLAG_log_code) return; - SmartPointer str = + SmartArrayPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); CallbackEventInternal("", *str, entry_point); } @@ -844,7 +844,7 @@ void Logger::CallbackEvent(String* name, Address entry_point) { void Logger::GetterCallbackEvent(String* name, Address entry_point) { if (!log_->IsEnabled() || !FLAG_log_code) return; - SmartPointer str = + SmartArrayPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); CallbackEventInternal("get ", *str, entry_point); } @@ -852,7 +852,7 @@ void Logger::GetterCallbackEvent(String* name, Address entry_point) { void Logger::SetterCallbackEvent(String* name, Address entry_point) { if (!log_->IsEnabled() || !FLAG_log_code) return; - SmartPointer str = + SmartArrayPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); CallbackEventInternal("set ", *str, entry_point); } @@ -957,7 +957,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, return; LogMessageBuilder msg(this); - SmartPointer str = + SmartArrayPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); msg.Append("%s,%s,", kLogEventsNames[CODE_CREATION_EVENT], @@ -998,9 +998,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, } if (!FLAG_log_code) return; LogMessageBuilder msg(this); - SmartPointer name = + SmartArrayPointer name = shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); - SmartPointer sourcestr = + SmartArrayPointer sourcestr = source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); msg.Append("%s,%s,", kLogEventsNames[CODE_CREATION_EVENT], @@ -1527,6 +1527,51 @@ void Logger::LogCodeObjects() { } +void Logger::LogExistingFunction(Handle shared, + Handle code) { + Handle func_name(shared->DebugName()); + if (shared->script()->IsScript()) { + Handle