From bb2b2792d437a1aa095f80d465a646fa28de7bf0 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Mon, 11 Jun 2018 13:12:02 -0400 Subject: [PATCH] deps: patch V8 to 6.7.288.46 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/21260 Refs: https://github.com/v8/v8/compare/6.7.288.45...6.7.288.46 Reviewed-By: Michaƫl Zasso Reviewed-By: Michael Dawson Reviewed-By: Minwoo Jung Reviewed-By: Colin Ihrig Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Tiancheng "Timothy" Gu --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/code-stub-assembler.cc | 25 +++++++++++ deps/v8/src/code-stub-assembler.h | 3 ++ .../test/cctest/test-code-stub-assembler.cc | 43 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 649deb515aa395..440a6068699ef0 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 6 #define V8_MINOR_VERSION 7 #define V8_BUILD_NUMBER 288 -#define V8_PATCH_LEVEL 45 +#define V8_PATCH_LEVEL 46 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/code-stub-assembler.cc b/deps/v8/src/code-stub-assembler.cc index 556efe7d0af8ef..b85609d9560ef7 100644 --- a/deps/v8/src/code-stub-assembler.cc +++ b/deps/v8/src/code-stub-assembler.cc @@ -534,6 +534,18 @@ TNode CodeStubAssembler::SmiFromInt32(SloppyTNode value) { WordShl(value_intptr, SmiShiftBitsConstant())); } +TNode CodeStubAssembler::IsValidPositiveSmi(TNode value) { + intptr_t constant_value; + if (ToIntPtrConstant(value, constant_value)) { + return (static_cast(constant_value) <= + static_cast(Smi::kMaxValue)) + ? Int32TrueConstant() + : Int32FalseConstant(); + } + + return UintPtrLessThanOrEqual(value, IntPtrConstant(Smi::kMaxValue)); +} + TNode CodeStubAssembler::SmiTag(SloppyTNode value) { int32_t constant_value; if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { @@ -1002,6 +1014,19 @@ void CodeStubAssembler::GotoIfForceSlowPath(Label* if_true) { Node* CodeStubAssembler::AllocateRaw(Node* size_in_bytes, AllocationFlags flags, Node* top_address, Node* limit_address) { + // TODO(jgruber, chromium:848672): TNodeify AllocateRaw. + // TODO(jgruber, chromium:848672): Call FatalProcessOutOfMemory if this fails. + { + intptr_t constant_value; + if (ToIntPtrConstant(size_in_bytes, constant_value)) { + CHECK(Internals::IsValidSmi(constant_value)); + CHECK_GT(constant_value, 0); + } else { + CSA_CHECK(this, + IsValidPositiveSmi(UncheckedCast(size_in_bytes))); + } + } + Node* top = Load(MachineType::Pointer(), top_address); Node* limit = Load(MachineType::Pointer(), limit_address); diff --git a/deps/v8/src/code-stub-assembler.h b/deps/v8/src/code-stub-assembler.h index 6c027f4a92e81b..633b1d8dce6f51 100644 --- a/deps/v8/src/code-stub-assembler.h +++ b/deps/v8/src/code-stub-assembler.h @@ -252,6 +252,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { TNode index, TNode length); + // Returns true iff the given value fits into smi range and is >= 0. + TNode IsValidPositiveSmi(TNode value); + // Tag an IntPtr as a Smi value. TNode SmiTag(SloppyTNode value); // Untag a Smi value as an IntPtr. diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index 65f07a64af8859..12e9fe4bea114f 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -206,6 +206,49 @@ TEST(ToUint32) { ft.CheckThrows(factory->match_symbol()); } +namespace { +void IsValidPositiveSmiCase(Isolate* isolate, intptr_t value, bool expected) { + const int kNumParams = 0; + CodeAssemblerTester asm_tester(isolate, kNumParams); + + CodeStubAssembler m(asm_tester.state()); + m.Return( + m.SelectBooleanConstant(m.IsValidPositiveSmi(m.IntPtrConstant(value)))); + + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + MaybeHandle maybe_handle = ft.Call(); + + if (expected) { + CHECK(maybe_handle.ToHandleChecked()->IsTrue(isolate)); + } else { + CHECK(maybe_handle.ToHandleChecked()->IsFalse(isolate)); + } +} +} // namespace + +TEST(IsValidPositiveSmi) { + Isolate* isolate(CcTest::InitIsolateOnce()); + + IsValidPositiveSmiCase(isolate, -1, false); + IsValidPositiveSmiCase(isolate, 0, true); + IsValidPositiveSmiCase(isolate, 1, true); + +#ifdef V8_TARGET_ARCH_32_BIT + IsValidPositiveSmiCase(isolate, 0x3FFFFFFFU, true); + IsValidPositiveSmiCase(isolate, 0xC0000000U, false); + IsValidPositiveSmiCase(isolate, 0x40000000U, false); + IsValidPositiveSmiCase(isolate, 0xBFFFFFFFU, false); +#else + typedef std::numeric_limits int32_limits; + IsValidPositiveSmiCase(isolate, int32_limits::max(), true); + IsValidPositiveSmiCase(isolate, int32_limits::min(), false); + IsValidPositiveSmiCase(isolate, + static_cast(int32_limits::max()) + 1, false); + IsValidPositiveSmiCase(isolate, + static_cast(int32_limits::min()) - 1, false); +#endif +} + TEST(FixedArrayAccessSmiIndex) { Isolate* isolate(CcTest::InitIsolateOnce()); CodeAssemblerTester asm_tester(isolate);