diff options
Diffstat (limited to 'chromium/v8/src/code-stub-assembler.cc')
-rw-r--r-- | chromium/v8/src/code-stub-assembler.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/chromium/v8/src/code-stub-assembler.cc b/chromium/v8/src/code-stub-assembler.cc index 2027d208abc..5f73c515b2f 100644 --- a/chromium/v8/src/code-stub-assembler.cc +++ b/chromium/v8/src/code-stub-assembler.cc @@ -509,6 +509,18 @@ TNode<Smi> CodeStubAssembler::SmiFromWord32(SloppyTNode<Int32T> value) { WordShl(value_intptr, SmiShiftBitsConstant())); } +TNode<BoolT> CodeStubAssembler::IsValidPositiveSmi(TNode<IntPtrT> value) { + intptr_t constant_value; + if (ToIntPtrConstant(value, constant_value)) { + return (static_cast<uintptr_t>(constant_value) <= + static_cast<uintptr_t>(Smi::kMaxValue)) + ? ReinterpretCast<BoolT>(Int32Constant(1)) + : ReinterpretCast<BoolT>(Int32Constant(0)); + } + + return UintPtrLessThanOrEqual(value, IntPtrConstant(Smi::kMaxValue)); +} + TNode<Smi> CodeStubAssembler::SmiTag(SloppyTNode<IntPtrT> value) { int32_t constant_value; if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { @@ -911,6 +923,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<IntPtrT>(size_in_bytes))); + } + } + Node* top = Load(MachineType::Pointer(), top_address); Node* limit = Load(MachineType::Pointer(), limit_address); |