From 1b2f6f9e29bf7137e177b8d9b600fe558d36f512 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 18 Oct 2010 17:13:30 -0700 Subject: [PATCH] Upgrade V8 to 2.5.0 --- deps/v8/AUTHORS | 1 + deps/v8/ChangeLog | 22 + deps/v8/SConstruct | 6 +- deps/v8/benchmarks/base.js | 2 +- deps/v8/include/v8-profiler.h | 4 +- deps/v8/include/v8.h | 65 +- deps/v8/src/SConscript | 2 + deps/v8/src/api.cc | 75 + deps/v8/src/api.h | 6 + deps/v8/src/arm/code-stubs-arm.cc | 2 +- deps/v8/src/arm/codegen-arm.cc | 10 +- deps/v8/src/arm/codegen-arm.h | 7 +- deps/v8/src/arm/full-codegen-arm.cc | 7 + deps/v8/src/arm/simulator-arm.cc | 4 +- deps/v8/src/arm/simulator-arm.h | 6 +- deps/v8/src/ast.h | 5 + deps/v8/src/atomic.h | 197 -- deps/v8/src/cached-powers.cc | 152 + deps/v8/src/cached-powers.h | 84 +- deps/v8/src/codegen.cc | 43 +- deps/v8/src/codegen.h | 1 - deps/v8/src/compiler.cc | 442 ++- deps/v8/src/compiler.h | 212 +- deps/v8/src/conversions.cc | 68 +- deps/v8/src/d8.js | 4 +- deps/v8/src/data-flow.cc | 9 +- deps/v8/src/data-flow.h | 6 +- deps/v8/src/date.js | 2 +- deps/v8/src/debug-debugger.js | 6 +- deps/v8/src/execution.cc | 13 + deps/v8/src/execution.h | 5 + deps/v8/src/fast-dtoa.cc | 18 +- deps/v8/src/full-codegen.cc | 34 +- deps/v8/src/full-codegen.h | 11 +- deps/v8/src/handles.cc | 26 +- deps/v8/src/ia32/codegen-ia32.cc | 31 +- deps/v8/src/ia32/codegen-ia32.h | 7 +- deps/v8/src/ia32/full-codegen-ia32.cc | 7 + deps/v8/src/liveedit-debugger.js | 223 +- deps/v8/src/liveedit.cc | 48 +- deps/v8/src/messages.js | 6 +- deps/v8/src/mips/simulator-mips.cc | 4 +- deps/v8/src/mips/simulator-mips.h | 6 +- deps/v8/src/mirror-debugger.js | 2 +- deps/v8/src/objects.cc | 37 +- deps/v8/src/objects.h | 5 +- deps/v8/src/parser.cc | 67 +- deps/v8/src/parser.h | 16 +- deps/v8/src/powers-ten.h | 2461 ----------------- deps/v8/src/profile-generator.cc | 115 +- deps/v8/src/profile-generator.h | 19 +- deps/v8/src/regexp.js | 150 +- deps/v8/src/rewriter.cc | 40 +- deps/v8/src/rewriter.h | 31 +- deps/v8/src/scopes.cc | 26 +- deps/v8/src/scopes.h | 10 +- deps/v8/src/string.js | 5 +- deps/v8/src/strtod.cc | 181 ++ deps/v8/src/strtod.h | 40 + deps/v8/src/top.cc | 26 +- deps/v8/src/v8-counters.h | 11 +- deps/v8/src/v8.cc | 2 +- deps/v8/src/v8natives.js | 18 +- deps/v8/src/version.cc | 4 +- deps/v8/src/x64/code-stubs-x64.cc | 14 +- deps/v8/src/x64/codegen-x64.cc | 32 +- deps/v8/src/x64/codegen-x64.h | 7 +- deps/v8/src/x64/full-codegen-x64.cc | 6 + deps/v8/test/cctest/SConscript | 1 + deps/v8/test/cctest/test-api.cc | 148 +- deps/v8/test/cctest/test-conversions.cc | 32 + deps/v8/test/cctest/test-heap-profiler.cc | 80 +- deps/v8/test/cctest/test-strtod.cc | 201 ++ deps/v8/test/mjsunit/regexp.js | 87 + deps/v8/test/mjsunit/regress/regress-58740.js | 35 + .../regress/regress-create-exception.js | 58 + deps/v8/test/mjsunit/smi-negative-zero.js | 13 + deps/v8/tools/gyp/v8.gyp | 4 +- 78 files changed, 2217 insertions(+), 3656 deletions(-) delete mode 100644 deps/v8/src/atomic.h create mode 100644 deps/v8/src/cached-powers.cc delete mode 100644 deps/v8/src/powers-ten.h create mode 100644 deps/v8/src/strtod.cc create mode 100644 deps/v8/src/strtod.h create mode 100644 deps/v8/test/cctest/test-strtod.cc create mode 100644 deps/v8/test/mjsunit/regress/regress-58740.js create mode 100644 deps/v8/test/mjsunit/regress/regress-create-exception.js diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 2403fbb956..3749cebcd1 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -6,6 +6,7 @@ Google Inc. Sigma Designs Inc. ARM Ltd. +Hewlett-Packard Development Company, LP Alexander Botero-Lowry Alexandre Vassalotti diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 42de286502..d58efc514c 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,25 @@ +2010-10-18: Version 2.5.0 + + Fixed bug in cache handling of lastIndex on global regexps + (issue http://crbug.com/58740). + + Added USE_SIMULATOR macro that explicitly indicates that we wish to use + the simulator as the execution engine (by Mark Lam + from Hewlett-Packard Development Company, LP). + + Fixed compilation error on ARM with gcc 4.4 (issue 894). + + +2010-10-13: Version 2.4.9 + + Fixed a bug in the handling of conditional expressions in test + contexts in compiler for top-level code. + + Added "//@ sourceURL" information to the StackTrace API. + + Exposed RegExp construction through the API. + + 2010-10-04: Version 2.4.8 Fixed a bug in ResumeProfilerEx causing it to not always write out the diff --git a/deps/v8/SConstruct b/deps/v8/SConstruct index 9328699b16..5a0cc0e9eb 100644 --- a/deps/v8/SConstruct +++ b/deps/v8/SConstruct @@ -206,7 +206,8 @@ LIBRARY_FLAGS = { }, 'simulator:arm': { 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + 'LINKFLAGS': ['-m32'], + 'CPPDEFINES': ['USE_SIMULATOR'] }, 'arch:mips': { 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], @@ -217,7 +218,8 @@ LIBRARY_FLAGS = { }, 'simulator:mips': { 'CCFLAGS': ['-m32'], - 'LINKFLAGS': ['-m32'] + 'LINKFLAGS': ['-m32'], + 'CPPDEFINES': ['USE_SIMULATOR'] }, 'arch:x64': { 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], diff --git a/deps/v8/benchmarks/base.js b/deps/v8/benchmarks/base.js index 0388da6844..ffabf24dda 100644 --- a/deps/v8/benchmarks/base.js +++ b/deps/v8/benchmarks/base.js @@ -78,7 +78,7 @@ BenchmarkSuite.suites = []; // Scores are not comparable across versions. Bump the version if // you're making changes that will affect that scores, e.g. if you add // a new benchmark or change an existing one. -BenchmarkSuite.version = '6 (candidate)'; +BenchmarkSuite.version = '6'; // To make the benchmark results predictable, we replace Math.random diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index 27da41822b..fb492d955c 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -245,7 +245,9 @@ class V8EXPORT HeapGraphNode { kString = 2, // A string. kObject = 3, // A JS object (except for arrays and strings). kCode = 4, // Compiled code. - kClosure = 5 // Function closure. + kClosure = 5, // Function closure. + kRegExp = 6, // RegExp. + kHeapNumber = 7 // Number stored in the heap. }; /** Returns node type (see HeapGraphNode::Type). */ diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 0613d5861c..ef9a41168c 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -758,8 +758,9 @@ class V8EXPORT StackTrace { kFunctionName = 1 << 3, kIsEval = 1 << 4, kIsConstructor = 1 << 5, + kScriptNameOrSourceURL = 1 << 6, kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName, - kDetailed = kOverview | kIsEval | kIsConstructor + kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL }; /** @@ -818,6 +819,13 @@ class V8EXPORT StackFrame { */ Local GetScriptName() const; + /** + * Returns the name of the resource that contains the script for the + * function for this StackFrame or sourceURL value if the script name + * is undefined and its source ends with //@ sourceURL=... string. + */ + Local GetScriptNameOrSourceURL() const; + /** * Returns the name of the function associated with this stack frame. */ @@ -1359,6 +1367,53 @@ class Date : public Value { }; +/** + * An instance of the built-in RegExp constructor (ECMA-262, 15.10). + */ +class RegExp : public Value { + public: + /** + * Regular expression flag bits. They can be or'ed to enable a set + * of flags. + */ + enum Flags { + kNone = 0, + kGlobal = 1, + kIgnoreCase = 2, + kMultiline = 4 + }; + + /** + * Creates a regular expression from the given pattern string and + * the flags bit field. May throw a JavaScript exception as + * described in ECMA-262, 15.10.4.1. + * + * For example, + * RegExp::New(v8::String::New("foo"), + * static_cast(kGlobal | kMultiline)) + * is equivalent to evaluating "/foo/gm". + */ + V8EXPORT static Local New(Handle pattern, + Flags flags); + + /** + * Returns the value of the source property: a string representing + * the regular expression. + */ + V8EXPORT Local GetSource() const; + + /** + * Returns the flags bit field. + */ + V8EXPORT Flags GetFlags() const; + + static inline RegExp* Cast(v8::Value* obj); + + private: + V8EXPORT static void CheckCast(v8::Value* obj); +}; + + enum PropertyAttribute { None = 0, ReadOnly = 1 << 0, @@ -3617,6 +3672,14 @@ Date* Date::Cast(v8::Value* value) { } +RegExp* RegExp::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast(value); +} + + Object* Object::Cast(v8::Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/deps/v8/src/SConscript b/deps/v8/src/SConscript index 05ccae4a98..4bb982d8a0 100755 --- a/deps/v8/src/SConscript +++ b/deps/v8/src/SConscript @@ -42,6 +42,7 @@ SOURCES = { ast.cc bootstrapper.cc builtins.cc + cached-powers.cc checks.cc circular-queue.cc code-stubs.cc @@ -102,6 +103,7 @@ SOURCES = { spaces.cc string-search.cc string-stream.cc + strtod.cc stub-cache.cc token.cc top.cc diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 350410a3cc..962723d4e8 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -1679,6 +1679,21 @@ Local StackFrame::GetScriptName() const { } +Local StackFrame::GetScriptNameOrSourceURL() const { + if (IsDeadCheck("v8::StackFrame::GetScriptNameOrSourceURL()")) { + return Local(); + } + ENTER_V8; + HandleScope scope; + i::Handle self = Utils::OpenHandle(this); + i::Handle name = GetProperty(self, "scriptNameOrSourceURL"); + if (!name->IsString()) { + return Local(); + } + return scope.Close(Local::Cast(Utils::ToLocal(name))); +} + + Local StackFrame::GetFunctionName() const { if (IsDeadCheck("v8::StackFrame::GetFunctionName()")) return Local(); ENTER_V8; @@ -1991,6 +2006,15 @@ void v8::Date::CheckCast(v8::Value* that) { } +void v8::RegExp::CheckCast(v8::Value* that) { + if (IsDeadCheck("v8::RegExp::Cast()")) return; + i::Handle obj = Utils::OpenHandle(that); + ApiCheck(obj->IsJSRegExp(), + "v8::RegExp::Cast()", + "Could not convert to regular expression"); +} + + bool Value::BooleanValue() const { if (IsDeadCheck("v8::Value::BooleanValue()")) return false; LOG_API("BooleanValue"); @@ -3712,6 +3736,57 @@ double v8::Date::NumberValue() const { } +static i::Handle RegExpFlagsToString(RegExp::Flags flags) { + char flags_buf[3]; + int num_flags = 0; + if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; + if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; + if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; + ASSERT(num_flags <= static_cast(ARRAY_SIZE(flags_buf))); + return i::Factory::LookupSymbol( + i::Vector(flags_buf, num_flags)); +} + + +Local v8::RegExp::New(Handle pattern, + Flags flags) { + EnsureInitialized("v8::RegExp::New()"); + LOG_API("RegExp::New"); + ENTER_V8; + EXCEPTION_PREAMBLE(); + i::Handle obj = i::Execution::NewJSRegExp( + Utils::OpenHandle(*pattern), + RegExpFlagsToString(flags), + &has_pending_exception); + EXCEPTION_BAILOUT_CHECK(Local()); + return Utils::ToLocal(i::Handle::cast(obj)); +} + + +Local v8::RegExp::GetSource() const { + if (IsDeadCheck("v8::RegExp::GetSource()")) return Local(); + i::Handle obj = Utils::OpenHandle(this); + return Utils::ToLocal(i::Handle(obj->Pattern())); +} + + +// Assert that the static flags cast in GetFlags is valid. +#define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ + STATIC_ASSERT(static_cast(v8::RegExp::api_flag) == \ + static_cast(i::JSRegExp::internal_flag)) +REGEXP_FLAG_ASSERT_EQ(kNone, NONE); +REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); +REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); +REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); +#undef REGEXP_FLAG_ASSERT_EQ + +v8::RegExp::Flags v8::RegExp::GetFlags() const { + if (IsDeadCheck("v8::RegExp::GetFlags()")) return v8::RegExp::kNone; + i::Handle obj = Utils::OpenHandle(this); + return static_cast(obj->GetFlags().value()); +} + + Local v8::Array::New(int length) { EnsureInitialized("v8::Array::New()"); LOG_API("Array::New"); diff --git a/deps/v8/src/api.h b/deps/v8/src/api.h index 5c671369de..e179e35672 100644 --- a/deps/v8/src/api.h +++ b/deps/v8/src/api.h @@ -174,6 +174,8 @@ class Utils { v8::internal::Handle obj); static inline Local ToLocal( v8::internal::Handle obj); + static inline Local ToLocal( + v8::internal::Handle obj); static inline Local ToLocal( v8::internal::Handle obj); static inline Local ToLocal( @@ -209,6 +211,8 @@ class Utils { OpenHandle(const ObjectTemplate* that); static inline v8::internal::Handle OpenHandle(const Data* data); + static inline v8::internal::Handle + OpenHandle(const RegExp* data); static inline v8::internal::Handle OpenHandle(const v8::Object* data); static inline v8::internal::Handle @@ -265,6 +269,7 @@ MAKE_TO_LOCAL(ToLocal, Context, Context) MAKE_TO_LOCAL(ToLocal, Object, Value) MAKE_TO_LOCAL(ToLocal, JSFunction, Function) MAKE_TO_LOCAL(ToLocal, String, String) +MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) MAKE_TO_LOCAL(ToLocal, JSObject, Object) MAKE_TO_LOCAL(ToLocal, JSArray, Array) MAKE_TO_LOCAL(ToLocal, Proxy, External) @@ -297,6 +302,7 @@ MAKE_OPEN_HANDLE(ObjectTemplate, ObjectTemplateInfo) MAKE_OPEN_HANDLE(Signature, SignatureInfo) MAKE_OPEN_HANDLE(TypeSwitch, TypeSwitchInfo) MAKE_OPEN_HANDLE(Data, Object) +MAKE_OPEN_HANDLE(RegExp, JSRegExp) MAKE_OPEN_HANDLE(Object, JSObject) MAKE_OPEN_HANDLE(Array, JSArray) MAKE_OPEN_HANDLE(String, String) diff --git a/deps/v8/src/arm/code-stubs-arm.cc b/deps/v8/src/arm/code-stubs-arm.cc index 8f801cf934..c9ef29ac46 100644 --- a/deps/v8/src/arm/code-stubs-arm.cc +++ b/deps/v8/src/arm/code-stubs-arm.cc @@ -935,7 +935,7 @@ void CompareStub::Generate(MacroAssembler* masm) { __ orr(r2, r1, r0); __ tst(r2, Operand(kSmiTagMask)); __ b(ne, ¬_two_smis); - __ sub(r0, r1, r0); + __ sub(r0, r1, r0, SetCC); __ b(vc, &smi_done); // Correct the sign in case of overflow. __ rsb(r0, r0, Operand(0, RelocInfo::NONE)); diff --git a/deps/v8/src/arm/codegen-arm.cc b/deps/v8/src/arm/codegen-arm.cc index d273e75988..684106c339 100644 --- a/deps/v8/src/arm/codegen-arm.cc +++ b/deps/v8/src/arm/codegen-arm.cc @@ -175,7 +175,7 @@ void CodeGenerator::Generate(CompilationInfo* info) { // Adjust for function-level loop nesting. ASSERT_EQ(0, loop_nesting_); - loop_nesting_ = info->loop_nesting(); + loop_nesting_ = info->is_in_loop() ? 1 : 0; { CodeGenState state(this); @@ -339,7 +339,7 @@ void CodeGenerator::Generate(CompilationInfo* info) { } // Adjust for function-level loop nesting. - ASSERT(loop_nesting_ == info->loop_nesting()); + ASSERT(loop_nesting_ == info->is_in_loop()? 1 : 0); loop_nesting_ = 0; // Code generation state must be reset. @@ -3132,9 +3132,9 @@ void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { // Build the function info and instantiate it. Handle function_info = - Compiler::BuildFunctionInfo(node, script(), this); - // Check for stack-overflow exception. - if (HasStackOverflow()) { + Compiler::BuildFunctionInfo(node, script()); + if (function_info.is_null()) { + SetStackOverflow(); ASSERT(frame_->height() == original_height); return; } diff --git a/deps/v8/src/arm/codegen-arm.h b/deps/v8/src/arm/codegen-arm.h index 1483c0b545..e6fd6071e1 100644 --- a/deps/v8/src/arm/codegen-arm.h +++ b/deps/v8/src/arm/codegen-arm.h @@ -207,9 +207,7 @@ enum NopMarkerTypes { class CodeGenerator: public AstVisitor { public: - // Takes a function literal, generates code for it. This function should only - // be called by compiler.cc. - static Handle MakeCode(CompilationInfo* info); + static bool MakeCode(CompilationInfo* info); // Printing of AST, etc. as requested by flags. static void MakeCodePrologue(CompilationInfo* info); @@ -449,9 +447,6 @@ class CodeGenerator: public AstVisitor { void Branch(bool if_true, JumpTarget* target); void CheckStack(); - static InlineFunctionGenerator FindInlineFunctionGenerator( - Runtime::FunctionId function_id); - bool CheckForInlineRuntimeCall(CallRuntime* node); static Handle ComputeLazyCompile(int argc); diff --git a/deps/v8/src/arm/full-codegen-arm.cc b/deps/v8/src/arm/full-codegen-arm.cc index 9fc0c096bb..2855ca4f3b 100644 --- a/deps/v8/src/arm/full-codegen-arm.cc +++ b/deps/v8/src/arm/full-codegen-arm.cc @@ -62,6 +62,13 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { SetFunctionPosition(function()); Comment cmnt(masm_, "[ function compiled by full code generator"); +#ifdef DEBUG + if (strlen(FLAG_stop_at) > 0 && + info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { + __ stop("stop-at"); + } +#endif + int locals_count = scope()->num_stack_slots(); __ Push(lr, fp, cp, r1); diff --git a/deps/v8/src/arm/simulator-arm.cc b/deps/v8/src/arm/simulator-arm.cc index 40be9bb818..84d9d01d08 100644 --- a/deps/v8/src/arm/simulator-arm.cc +++ b/deps/v8/src/arm/simulator-arm.cc @@ -37,7 +37,7 @@ #include "arm/constants-arm.h" #include "arm/simulator-arm.h" -#if !defined(__arm__) +#if !defined(__arm__) || defined(USE_SIMULATOR) // Only build the simulator if not compiling for real ARM hardware. namespace assembler { @@ -2840,6 +2840,6 @@ uintptr_t Simulator::PopAddress() { } } // namespace assembler::arm -#endif // __arm__ +#endif // !__arm__ || USE_SIMULATOR #endif // V8_TARGET_ARCH_ARM diff --git a/deps/v8/src/arm/simulator-arm.h b/deps/v8/src/arm/simulator-arm.h index fee296e40e..d4c8250b33 100644 --- a/deps/v8/src/arm/simulator-arm.h +++ b/deps/v8/src/arm/simulator-arm.h @@ -38,7 +38,7 @@ #include "allocation.h" -#if defined(__arm__) +#if defined(__arm__) && !defined(USE_SIMULATOR) // When running without a simulator we call the entry directly. #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ @@ -70,7 +70,7 @@ class SimulatorStack : public v8::internal::AllStatic { reinterpret_cast(try_catch_address) -#else // defined(__arm__) +#else // !defined(__arm__) || defined(USE_SIMULATOR) // When running with the simulator transition into simulated execution at this // point. @@ -356,6 +356,6 @@ class SimulatorStack : public v8::internal::AllStatic { }; -#endif // defined(__arm__) +#endif // !defined(__arm__) || defined(USE_SIMULATOR) #endif // V8_ARM_SIMULATOR_ARM_H_ diff --git a/deps/v8/src/ast.h b/deps/v8/src/ast.h index fc34fd4614..e8d54e4689 100644 --- a/deps/v8/src/ast.h +++ b/deps/v8/src/ast.h @@ -1436,6 +1436,11 @@ class FunctionLiteral: public Expression { bool AllowsLazyCompilation(); + Handle debug_name() const { + if (name_->length() > 0) return name_; + return inferred_name(); + } + Handle inferred_name() const { return inferred_name_; } void set_inferred_name(Handle inferred_name) { inferred_name_ = inferred_name; diff --git a/deps/v8/src/atomic.h b/deps/v8/src/atomic.h deleted file mode 100644 index e5c14e086d..0000000000 --- a/deps/v8/src/atomic.h +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This module wraps compiler specific syncronisation related intrinsics. - -#ifndef V8_ATOMIC_H_ -#define V8_ATOMIC_H_ - -// Avoid warning when compiled with /Wp64. -#ifndef _MSC_VER -#define __w64 -#endif -typedef __w64 int32_t Atomic32; -#ifdef V8_TARGET_ARCH_X64 -// We need to be able to go between Atomic64 and AtomicWord implicitly. This -// means Atomic64 and AtomicWord should be the same type on 64-bit. -typedef intptr_t Atomic64; -#endif - -// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or -// Atomic64 routines below, depending on your architecture. -typedef intptr_t AtomicWord; - -inline void AtomicAdd(volatile Atomic32* ptr, Atomic32 value); -inline void AtomicOr(volatile Atomic32* ptr, Atomic32 value); -inline void AtomicAnd(volatile Atomic32* ptr, Atomic32 value); -inline bool AtomicCompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value); - -#if defined(V8_TARGET_ARCH_X64) -inline bool AtomicCompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value); -#endif - - -#if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) - -// Microsoft Visual C++ specific stuff. -#ifdef _MSC_VER -#if (_MSC_VER >= 1500) -#include -#else -// For older versions we have to provide intrisic signatures. -long _InterlockedExchangeAdd (long volatile* Addend, long Value); -long _InterlockedOr (long volatile* Value, long Mask); -long _InterlockedAnd (long volatile *Value, long Mask); -long _InterlockedCompareExchange (long volatile* Destination, - long Exchange, - long Comperand); - -#pragma intrinsic(_InterlockedExchangeAdd) -#pragma intrinsic(_InterlockedOr) -#pragma intrinsic(_InterlockedAnd) -#pragma intrinsic(_InterlockedCompareExchange) -#endif - -inline void AtomicAdd(volatile Atomic32* ptr, Atomic32 value) { - _InterlockedExchangeAdd(reinterpret_cast(ptr), - static_cast(value)); -} - -inline void AtomicOr(volatile Atomic32* ptr, Atomic32 value) { - _InterlockedOr(reinterpret_cast(ptr), - static_cast(value)); -} - -inline void AtomicAnd(volatile Atomic32* ptr, Atomic32 value) { - _InterlockedAnd(reinterpret_cast(ptr), - static_cast(value)); -} - -inline bool AtomicCompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - long result = _InterlockedCompareExchange( - reinterpret_cast(ptr), - static_cast(new_value), - static_cast(old_value)); - return result == static_cast(old_value); -} - -#if defined(V8_TARGET_ARCH_X64) -inline bool AtomicCompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - - __int64 result = _InterlockedCompareExchange_64( - reinterpret_cast<__int64 volatile*>(ptr), - static_cast<__int64>(new_value), - static_cast<__int64>(old_value)); - return result == static_cast<__int64>(old_value); -} -#endif - -#define ATOMIC_SUPPORTED 1 - -#endif // _MSC_VER - -// GCC specific stuff -#ifdef __GNUC__ -inline void AtomicAdd(volatile Atomic32* ptr, Atomic32 value) { - __sync_fetch_and_add(ptr, value); -} - -inline void AtomicOr(volatile Atomic32* ptr, Atomic32 value) { - __sync_fetch_and_or(ptr, value); -} - -inline void AtomicAnd(volatile Atomic32* ptr, Atomic32 value) { - __sync_fetch_and_and(ptr, value); -} - -inline bool AtomicCompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return __sync_bool_compare_and_swap(ptr, old_value, new_value); -} - -#if defined(V8_TARGET_ARCH_X64) -inline bool AtomicCompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - return __sync_bool_compare_and_swap(ptr, old_value, new_value); -} -#endif - -#define ATOMIC_SUPPORTED 1 -#endif - -#endif // defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) - -#ifndef ATOMIC_SUPPORTED -inline void AtomicAdd(volatile Atomic32* ptr, Atomic32 value) { - *ptr += value; -} - -inline void AtomicOr(volatile Atomic32* ptr, Atomic32 value) { - *ptr |= value; -} - -inline void AtomicAnd(volatile Atomic32* ptr, Atomic32 value) { - *ptr &= value; -} - -inline bool AtomicCompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - if (*ptr == old_value) { - *ptr = new_value; - return true; - } - return false; -} - -#if defined(V8_TARGET_ARCH_X64) -inline bool AtomicCompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - if (*ptr == old_value) { - *ptr = new_value; - return true; - } - return false; -} -#endif - -#define ATOMIC_SUPPORTED 0 -#endif - - -#endif diff --git a/deps/v8/src/cached-powers.cc b/deps/v8/src/cached-powers.cc new file mode 100644 index 0000000000..8f822862bd --- /dev/null +++ b/deps/v8/src/cached-powers.cc @@ -0,0 +1,152 @@ +// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +#include "v8.h" + +#include "cached-powers.h" + +namespace v8 { +namespace internal { + +struct CachedPower { + uint64_t significand; + int16_t binary_exponent; + int16_t decimal_exponent; +}; + +static const CachedPower kCachedPowers[] = { + {V8_2PART_UINT64_C(0xe61acf03, 3d1a45df), -1087, -308}, + {V8_2PART_UINT64_C(0xab70fe17, c79ac6ca), -1060, -300}, + {V8_2PART_UINT64_C(0xff77b1fc, bebcdc4f), -1034, -292}, + {V8_2PART_UINT64_C(0xbe5691ef, 416bd60c), -1007, -284}, + {V8_2PART_UINT64_C(0x8dd01fad, 907ffc3c), -980, -276}, + {V8_2PART_UINT64_C(0xd3515c28, 31559a83), -954, -268}, + {V8_2PART_UINT64_C(0x9d71ac8f, ada6c9b5), -927, -260}, + {V8_2PART_UINT64_C(0xea9c2277, 23ee8bcb), -901, -252}, + {V8_2PART_UINT64_C(0xaecc4991, 4078536d), -874, -244}, + {V8_2PART_UINT64_C(0x823c1279, 5db6ce57), -847, -236}, + {V8_2PART_UINT64_C(0xc2109436, 4dfb5637), -821, -228}, + {V8_2PART_UINT64_C(0x9096ea6f, 3848984f), -794, -220}, + {V8_2PART_UINT64_C(0xd77485cb, 25823ac7), -768, -212}, + {V8_2PART_UINT64_C(0xa086cfcd, 97bf97f4), -741, -204}, + {V8_2PART_UINT64_C(0xef340a98, 172aace5), -715, -196}, + {V8_2PART_UINT64_C(0xb23867fb, 2a35b28e), -688, -188}, + {V8_2PART_UINT64_C(0x84c8d4df, d2c63f3b), -661, -180}, + {V8_2PART_UINT64_C(0xc5dd4427, 1ad3cdba), -635, -172}, + {V8_2PART_UINT64_C(0x936b9fce, bb25c996), -608, -164}, + {V8_2PART_UINT64_C(0xdbac6c24, 7d62a584), -582, -156}, + {V8_2PART_UINT64_C(0xa3ab6658, 0d5fdaf6), -555, -148}, + {V8_2PART_UINT64_C(0xf3e2f893, dec3f126), -529, -140}, + {V8_2PART_UINT64_C(0xb5b5ada8, aaff80b8), -502, -132}, + {V8_2PART_UINT64_C(0x87625f05, 6c7c4a8b), -475, -124}, + {V8_2PART_UINT64_C(0xc9bcff60, 34c13053), -449, -116}, + {V8_2PART_UINT64_C(0x964e858c, 91ba2655), -422, -108}, + {V8_2PART_UINT64_C(0xdff97724, 70297ebd), -396, -100}, + {V8_2PART_UINT64_C(0xa6dfbd9f, b8e5b88f), -369, -92}, + {V8_2PART_UINT64_C(0xf8a95fcf, 88747d94), -343, -84}, + {V8_2PART_UINT64_C(0xb9447093, 8fa89bcf), -316, -76}, + {V8_2PART_UINT64_C(0x8a08f0f8, bf0f156b), -289, -68}, + {V8_2PART_UINT64_C(0xcdb02555, 653131b6), -263, -60}, + {V8_2PART_UINT64_C(0x993fe2c6, d07b7fac), -236, -52}, + {V8_2PART_UINT64_C(0xe45c10c4, 2a2b3b06), -210, -44}, + {V8_2PART_UINT64_C(0xaa242499, 697392d3), -183, -36}, + {V8_2PART_UINT64_C(0xfd87b5f2, 8300ca0e), -157, -28}, + {V8_2PART_UINT64_C(0xbce50864, 92111aeb), -130, -20}, + {V8_2PART_UINT64_C(0x8cbccc09, 6f5088cc), -103, -12}, + {V8_2PART_UINT64_C(0xd1b71758, e219652c), -77, -4}, + {V8_2PART_UINT64_C(0x9c400000, 00000000), -50, 4}, + {V8_2PART_UINT64_C(0xe8d4a510, 00000000), -24, 12}, + {V8_2PART_UINT64_C(0xad78ebc5, ac620000), 3, 20}, + {V8_2PART_UINT64_C(0x813f3978, f8940984), 30, 28}, + {V8_2PART_UINT64_C(0xc097ce7b, c90715b3), 56, 36}, + {V8_2PART_UINT64_C(0x8f7e32ce, 7bea5c70), 83, 44}, + {V8_2PART_UINT64_C(0xd5d238a4, abe98068), 109, 52}, + {V8_2PART_UINT64_C(0x9f4f2726, 179a2245), 136, 60}, + {V8_2PART_UINT64_C(0xed63a231, d4c4fb27), 162, 68}, + {V8_2PART_UINT64_C(0xb0de6538, 8cc8ada8), 189, 76}, + {V8_2PART_UINT64_C(0x83c7088e, 1aab65db), 216, 84}, + {V8_2PART_UINT64_C(0xc45d1df9, 42711d9a), 242, 92}, + {V8_2PART_UINT64_C(0x924d692c, a61be758), 269, 100}, + {V8_2PART_UINT64_C(0xda01ee64, 1a708dea), 295, 108}, + {V8_2PART_UINT64_C(0xa26da399, 9aef774a), 322, 116}, + {V8_2PART_UINT64_C(0xf209787b, b47d6b85), 348, 124}, + {V8_2PART_UINT64_C(0xb454e4a1, 79dd1877), 375, 132}, + {V8_2PART_UINT64_C(0x865b8692, 5b9bc5c2), 402, 140}, + {V8_2PART_UINT64_C(0xc83553c5, c8965d3d), 428, 148}, + {V8_2PART_UINT64_C(0x952ab45c, fa97a0b3), 455, 156}, + {V8_2PART_UINT64_C(0xde469fbd, 99a05fe3), 481, 164}, + {V8_2PART_UINT64_C(0xa59bc234, db398c25), 508, 172}, + {V8_2PART_UINT64_C(0xf6c69a72, a3989f5c), 534, 180}, + {V8_2PART_UINT64_C(0xb7dcbf53, 54e9bece), 561, 188}, + {V8_2PART_UINT64_C(0x88fcf317, f22241e2), 588, 196}, + {V8_2PART_UINT64_C(0xcc20ce9b, d35c78a5), 614, 204}, + {V8_2PART_UINT64_C(0x98165af3, 7b2153df), 641, 212}, + {V8_2PART_UINT64_C(0xe2a0b5dc, 971f303a), 667, 220}, + {V8_2PART_UINT64_C(0xa8d9d153, 5ce3b396), 694, 228}, + {V8_2PART_UINT64_C(0xfb9b7cd9, a4a7443c), 720, 236}, + {V8_2PART_UINT64_C(0xbb764c4c, a7a44410), 747, 244}, + {V8_2PART_UINT64_C(0x8bab8eef, b6409c1a), 774, 252}, + {V8_2PART_UINT64_C(0xd01fef10, a657842c), 800, 260}, + {V8_2PART_UINT64_C(0x9b10a4e5, e9913129), 827, 268}, + {V8_2PART_UINT64_C(0xe7109bfb, a19c0c9d), 853, 276}, + {V8_2PART_UINT64_C(0xac2820d9, 623bf429), 880, 284}, + {V8_2PART_UINT64_C(0x80444b5e, 7aa7cf85), 907, 292}, + {V8_2PART_UINT64_C(0xbf21e440, 03acdd2d), 933, 300}, + {V8_2PART_UINT64_C(0x8e679c2f, 5e44ff8f), 960, 308}, + {V8_2PART_UINT64_C(0xd433179d, 9c8cb841), 986, 316}, + {V8_2PART_UINT64_C(0x9e19db92, b4e31ba9), 1013, 324}, + {V8_2PART_UINT64_C(0xeb96bf6e, badf77d9), 1039, 332}, + {V8_2PART_UINT64_C(0xaf87023b, 9bf0ee6b), 1066, 340}, +}; + +static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers); +static const int kCachedPowersOffset = -kCachedPowers[0].decimal_exponent; +static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) +static const int kCachedPowersDecimalDistance = + kCachedPowers[1].decimal_exponent - kCachedPowers[0].decimal_exponent; + +void GetCachedPowerForBinaryExponentRange(int min_exponent, + int max_exponent, + DiyFp* power, + int* decimal_exponent) { + int kQ = DiyFp::kSignificandSize; + double k = ceiling((min_exponent + kQ - 1) * kD_1_LOG2_10); + int foo = kCachedPowersOffset; + int index = + (foo + static_cast(k) - 1) / kCachedPowersDecimalDistance + 1; + ASSERT(0 <= index && index < kCachedPowersLength); + CachedPower cached_power = kCachedPowers[index]; + ASSERT(min_exponent <= cached_power.binary_exponent); + ASSERT(cached_power.binary_exponent <= max_exponent); + *decimal_exponent = cached_power.decimal_exponent; + *power = DiyFp(cached_power.significand, cached_power.binary_exponent); +} + +} } // namespace v8::internal diff --git a/deps/v8/src/cached-powers.h b/deps/v8/src/cached-powers.h index 314ccca3c4..0c78343170 100644 --- a/deps/v8/src/cached-powers.h +++ b/deps/v8/src/cached-powers.h @@ -33,86 +33,10 @@ namespace v8 { namespace internal { -struct CachedPower { - uint64_t significand; - int16_t binary_exponent; - int16_t decimal_exponent; -}; - -// The following defines implement the interface between this file and the -// generated 'powers_ten.h'. -// GRISU_CACHE_NAME(1) contains all possible cached powers. -// GRISU_CACHE_NAME(i) contains GRISU_CACHE_NAME(1) where only every 'i'th -// element is kept. More formally GRISU_CACHE_NAME(i) contains the elements j*i -// with 0 <= j < k with k such that j*k < the size of GRISU_CACHE_NAME(1). -// The higher 'i' is the fewer elements we use. -// Given that there are less elements, the exponent-distance between two -// elements in the cache grows. The variable GRISU_CACHE_MAX_DISTANCE(i) stores -// the maximum distance between two elements. -#define GRISU_CACHE_STRUCT CachedPower -#define GRISU_CACHE_NAME(i) kCachedPowers##i -#define GRISU_CACHE_MAX_DISTANCE(i) kCachedPowersMaxDistance##i -#define GRISU_CACHE_OFFSET kCachedPowerOffset -#define GRISU_UINT64_C V8_2PART_UINT64_C -// The following include imports the precompiled cached powers. -#include "powers-ten.h" // NOLINT - -static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) - -// We can't use a function since we reference variables depending on the 'i'. -// This way the compiler is able to see at compile time that only one -// cache-array variable is used and thus can remove all the others. -#define COMPUTE_FOR_CACHE(i) \ - if (!found && (gamma - alpha + 1 >= GRISU_CACHE_MAX_DISTANCE(i))) { \ - int kQ = DiyFp::kSignificandSize; \ - double k = ceiling((alpha - e + kQ - 1) * kD_1_LOG2_10); \ - int index = (GRISU_CACHE_OFFSET + static_cast(k) - 1) / i + 1; \ - cached_power = GRISU_CACHE_NAME(i)[index]; \ - found = true; \ - } \ - -static void GetCachedPower(int e, int alpha, int gamma, int* mk, DiyFp* c_mk) { - // The following if statement should be optimized by the compiler so that only - // one array is referenced and the others are not included in the object file. - bool found = false; - CachedPower cached_power; - COMPUTE_FOR_CACHE(20); - COMPUTE_FOR_CACHE(19); - COMPUTE_FOR_CACHE(18); - COMPUTE_FOR_CACHE(17); - COMPUTE_FOR_CACHE(16); - COMPUTE_FOR_CACHE(15); - COMPUTE_FOR_CACHE(14); - COMPUTE_FOR_CACHE(13); - COMPUTE_FOR_CACHE(12); - COMPUTE_FOR_CACHE(11); - COMPUTE_FOR_CACHE(10); - COMPUTE_FOR_CACHE(9); - COMPUTE_FOR_CACHE(8); - COMPUTE_FOR_CACHE(7); - COMPUTE_FOR_CACHE(6); - COMPUTE_FOR_CACHE(5); - COMPUTE_FOR_CACHE(4); - COMPUTE_FOR_CACHE(3); - COMPUTE_FOR_CACHE(2); - COMPUTE_FOR_CACHE(1); - if (!found) { - UNIMPLEMENTED(); - // Silence compiler warnings. - cached_power.significand = 0; - cached_power.binary_exponent = 0; - cached_power.decimal_exponent = 0; - } - *c_mk = DiyFp(cached_power.significand, cached_power.binary_exponent); - *mk = cached_power.decimal_exponent; - ASSERT((alpha <= c_mk->e() + e) && (c_mk->e() + e <= gamma)); -} -#undef GRISU_REDUCTION -#undef GRISU_CACHE_STRUCT -#undef GRISU_CACHE_NAME -#undef GRISU_CACHE_MAX_DISTANCE -#undef GRISU_CACHE_OFFSET -#undef GRISU_UINT64_C +void GetCachedPowerForBinaryExponentRange(int min_exponent, + int max_exponent, + DiyFp* power, + int* decimal_exponent); } } // namespace v8::internal diff --git a/deps/v8/src/codegen.cc b/deps/v8/src/codegen.cc index 92241d1c51..bda697abaf 100644 --- a/deps/v8/src/codegen.cc +++ b/deps/v8/src/codegen.cc @@ -206,10 +206,9 @@ Handle CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, } -// Generate the code. Takes a function literal, generates code for it, assemble -// all the pieces into a Code object. This function is only to be called by -// the compiler.cc code. -Handle CodeGenerator::MakeCode(CompilationInfo* info) { +// Generate the code. Compile the AST and assemble all the pieces into a +// Code object. +bool CodeGenerator::MakeCode(CompilationInfo* info) { Handle