| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fb71337 commit ffc29c1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | #define V8_MAJOR_VERSION 6 | |
| 12 | 12 | #define V8_MINOR_VERSION 7 | |
| 13 | 13 | #define V8_BUILD_NUMBER 288 | |
| 14 | - #define V8_PATCH_LEVEL 45 | ||
| 14 | + #define V8_PATCH_LEVEL 46 | ||
| 15 | 15 | ||
| 16 | 16 | // Use 1 for candidates and 0 otherwise. | |
| 17 | 17 | // (Boolean macro values are not supported by all preprocessors.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -534,6 +534,18 @@ TNode<Smi> CodeStubAssembler::SmiFromInt32(SloppyTNode<Int32T> value) { | |||
| 534 | 534 | WordShl(value_intptr, SmiShiftBitsConstant())); | |
| 535 | 535 | } | |
| 536 | 536 | ||
| 537 | + TNode<BoolT> CodeStubAssembler::IsValidPositiveSmi(TNode<IntPtrT> value) { | ||
| 538 | + intptr_t constant_value; | ||
| 539 | + if (ToIntPtrConstant(value, constant_value)) { | ||
| 540 | + return (static_cast<uintptr_t>(constant_value) <= | ||
| 541 | + static_cast<uintptr_t>(Smi::kMaxValue)) | ||
| 542 | + ? Int32TrueConstant() | ||
| 543 | + : Int32FalseConstant(); | ||
| 544 | + } | ||
| 545 | + | ||
| 546 | + return UintPtrLessThanOrEqual(value, IntPtrConstant(Smi::kMaxValue)); | ||
| 547 | + } | ||
| 548 | + | ||
| 537 | 549 | TNode<Smi> CodeStubAssembler::SmiTag(SloppyTNode<IntPtrT> value) { | |
| 538 | 550 | int32_t constant_value; | |
| 539 | 551 | if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { | |
@@ -1002,6 +1014,19 @@ void CodeStubAssembler::GotoIfForceSlowPath(Label* if_true) { | |||
| 1002 | 1014 | ||
| 1003 | 1015 | Node* CodeStubAssembler::AllocateRaw(Node* size_in_bytes, AllocationFlags flags, | |
| 1004 | 1016 | Node* top_address, Node* limit_address) { | |
| 1017 | + // TODO(jgruber, chromium:848672): TNodeify AllocateRaw. | ||
| 1018 | + // TODO(jgruber, chromium:848672): Call FatalProcessOutOfMemory if this fails. | ||
| 1019 | + { | ||
| 1020 | + intptr_t constant_value; | ||
| 1021 | + if (ToIntPtrConstant(size_in_bytes, constant_value)) { | ||
| 1022 | + CHECK(Internals::IsValidSmi(constant_value)); | ||
| 1023 | + CHECK_GT(constant_value, 0); | ||
| 1024 | + } else { | ||
| 1025 | + CSA_CHECK(this, | ||
| 1026 | + IsValidPositiveSmi(UncheckedCast<IntPtrT>(size_in_bytes))); | ||
| 1027 | + } | ||
| 1028 | + } | ||
| 1029 | + | ||
| 1005 | 1030 | Node* top = Load(MachineType::Pointer(), top_address); | |
| 1006 | 1031 | Node* limit = Load(MachineType::Pointer(), limit_address); | |
| 1007 | 1032 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -252,6 +252,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { | |||
| 252 | 252 | TNode<Object> index, | |
| 253 | 253 | TNode<IntPtrT> length); | |
| 254 | 254 | ||
| 255 | + // Returns true iff the given value fits into smi range and is >= 0. | ||
| 256 | + TNode<BoolT> IsValidPositiveSmi(TNode<IntPtrT> value); | ||
| 257 | + | ||
| 255 | 258 | // Tag an IntPtr as a Smi value. | |
| 256 | 259 | TNode<Smi> SmiTag(SloppyTNode<IntPtrT> value); | |
| 257 | 260 | // Untag a Smi value as an IntPtr. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -206,6 +206,49 @@ TEST(ToUint32) { | |||
| 206 | 206 | ft.CheckThrows(factory->match_symbol()); | |
| 207 | 207 | } | |
| 208 | 208 | ||
| 209 | + namespace { | ||
| 210 | + void IsValidPositiveSmiCase(Isolate* isolate, intptr_t value, bool expected) { | ||
| 211 | + const int kNumParams = 0; | ||
| 212 | + CodeAssemblerTester asm_tester(isolate, kNumParams); | ||
| 213 | + | ||
| 214 | + CodeStubAssembler m(asm_tester.state()); | ||
| 215 | + m.Return( | ||
| 216 | + m.SelectBooleanConstant(m.IsValidPositiveSmi(m.IntPtrConstant(value)))); | ||
| 217 | + | ||
| 218 | + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); | ||
| 219 | + MaybeHandle<Object> maybe_handle = ft.Call(); | ||
| 220 | + | ||
| 221 | + if (expected) { | ||
| 222 | + CHECK(maybe_handle.ToHandleChecked()->IsTrue(isolate)); | ||
| 223 | + } else { | ||
| 224 | + CHECK(maybe_handle.ToHandleChecked()->IsFalse(isolate)); | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + } // namespace | ||
| 228 | + | ||
| 229 | + TEST(IsValidPositiveSmi) { | ||
| 230 | + Isolate* isolate(CcTest::InitIsolateOnce()); | ||
| 231 | + | ||
| 232 | + IsValidPositiveSmiCase(isolate, -1, false); | ||
| 233 | + IsValidPositiveSmiCase(isolate, 0, true); | ||
| 234 | + IsValidPositiveSmiCase(isolate, 1, true); | ||
| 235 | + | ||
| 236 | + #ifdef V8_TARGET_ARCH_32_BIT | ||
| 237 | + IsValidPositiveSmiCase(isolate, 0x3FFFFFFFU, true); | ||
| 238 | + IsValidPositiveSmiCase(isolate, 0xC0000000U, false); | ||
| 239 | + IsValidPositiveSmiCase(isolate, 0x40000000U, false); | ||
| 240 | + IsValidPositiveSmiCase(isolate, 0xBFFFFFFFU, false); | ||
| 241 | + #else | ||
| 242 | + typedef std::numeric_limits<int32_t> int32_limits; | ||
| 243 | + IsValidPositiveSmiCase(isolate, int32_limits::max(), true); | ||
| 244 | + IsValidPositiveSmiCase(isolate, int32_limits::min(), false); | ||
| 245 | + IsValidPositiveSmiCase(isolate, | ||
| 246 | + static_cast<intptr_t>(int32_limits::max()) + 1, false); | ||
| 247 | + IsValidPositiveSmiCase(isolate, | ||
| 248 | + static_cast<intptr_t>(int32_limits::min()) - 1, false); | ||
| 249 | + #endif | ||
| 250 | + } | ||
| 251 | + | ||
| 209 | 252 | TEST(FixedArrayAccessSmiIndex) { | |
| 210 | 253 | Isolate* isolate(CcTest::InitIsolateOnce()); | |
| 211 | 254 | CodeAssemblerTester asm_tester(isolate); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments