Chromium Code Reviews| Index: src/code-stub-assembler.cc |
| diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
| index 480be44f8bac83e570adcedc706a287f90e6e591..12707064c008b784d04f893bd7a19e7837ec8eb8 100644 |
| --- a/src/code-stub-assembler.cc |
| +++ b/src/code-stub-assembler.cc |
| @@ -194,6 +194,10 @@ Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) { |
| return IntPtrAdd(value, IntPtrConstant(1)); |
| } |
| +Node* CodeStubAssembler::IsParameterMode(Node* value, ParameterMode mode) { |
| + return (mode == SMI_PARAMETERS) ? TaggedIsSmi(value) : Int32Constant(1); |
| +} |
| + |
| Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { |
| // value && !(value & (value - 1)) |
| return WordEqual( |
| @@ -437,27 +441,36 @@ Node* CodeStubAssembler::SmiTag(Node* value) { |
| } |
| Node* CodeStubAssembler::SmiUntag(Node* value) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); |
| return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); |
| } |
| Node* CodeStubAssembler::SmiToWord32(Node* value) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); |
| Node* result = SmiUntag(value); |
| return TruncateWordToWord32(result); |
| } |
| Node* CodeStubAssembler::SmiToFloat64(Node* value) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); |
| return ChangeInt32ToFloat64(SmiToWord32(value)); |
| } |
| Node* CodeStubAssembler::SmiMax(Node* a, Node* b) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(a)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(b)); |
| return SelectTaggedConstant(SmiLessThan(a, b), b, a); |
| } |
| Node* CodeStubAssembler::SmiMin(Node* a, Node* b) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(a)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(b)); |
| return SelectTaggedConstant(SmiLessThan(a, b), a, b); |
| } |
| Node* CodeStubAssembler::SmiMod(Node* a, Node* b) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(a)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(b)); |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| Label return_result(this, &var_result), |
| return_minuszero(this, Label::kDeferred), |
| @@ -517,10 +530,13 @@ Node* CodeStubAssembler::SmiMod(Node* a, Node* b) { |
| Goto(&return_result); |
| BIND(&return_result); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(a)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(b)); |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| VARIABLE(var_lhs_float64, MachineRepresentation::kFloat64); |
| VARIABLE(var_rhs_float64, MachineRepresentation::kFloat64); |
| @@ -578,11 +594,15 @@ Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { |
| } |
| BIND(&return_result); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| Node* CodeStubAssembler::TrySmiDiv(Node* dividend, Node* divisor, |
| Label* bailout) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(dividend)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(divisor)); |
| + |
| // Both {a} and {b} are Smis. Bailout to floating point division if {divisor} |
| // is zero. |
| GotoIf(WordEqual(divisor, SmiConstant(0)), bailout); |
| @@ -660,6 +680,7 @@ Node* CodeStubAssembler::WordIsWordAligned(Node* word) { |
| void CodeStubAssembler::BranchIfPrototypesHaveNoElements( |
| Node* receiver_map, Label* definitely_no_elements, |
| Label* possibly_elements) { |
| + CSA_SLOW_ASSERT(this, IsMap(receiver_map)); |
| VARIABLE(var_map, MachineRepresentation::kTagged, receiver_map); |
| Label loop_body(this, &var_map); |
| Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex); |
| @@ -977,11 +998,13 @@ Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset, |
| Node* CodeStubAssembler::LoadObjectField(Node* object, int offset, |
| MachineType rep) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag)); |
| } |
| Node* CodeStubAssembler::LoadObjectField(Node* object, Node* offset, |
| MachineType rep) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))); |
| } |
| @@ -1058,11 +1081,13 @@ Node* CodeStubAssembler::StoreAndTagSmi(Node* base, int offset, Node* value) { |
| } |
| Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) { |
| + CSA_SLOW_ASSERT(this, IsHeapNumber(object)); |
| return LoadObjectField(object, HeapNumber::kValueOffset, |
| MachineType::Float64()); |
| } |
| Node* CodeStubAssembler::LoadMap(Node* object) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| return LoadObjectField(object, HeapObject::kMapOffset); |
| } |
| @@ -1117,6 +1142,7 @@ Node* CodeStubAssembler::LoadMapBitField3(Node* map) { |
| } |
| Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { |
| + CSA_SLOW_ASSERT(this, IsMap(map)); |
| return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); |
| } |
| @@ -1200,6 +1226,7 @@ Node* CodeStubAssembler::LoadMapConstructor(Node* map) { |
| Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField( |
| Node* shared, int offset, ParameterMode mode) { |
| + CSA_SLOW_ASSERT(this, HasInstanceType(shared, SHARED_FUNCTION_INFO_TYPE)); |
| if (Is64()) { |
| Node* result = LoadObjectField(shared, offset, MachineType::Int32()); |
| if (mode == SMI_PARAMETERS) { |
| @@ -1245,6 +1272,7 @@ Node* CodeStubAssembler::LoadJSValueValue(Node* object) { |
| Node* CodeStubAssembler::LoadWeakCellValueUnchecked(Node* weak_cell) { |
| // TODO(ishell): fix callers. |
| + CSA_SLOW_ASSERT(this, IsWeakCell(weak_cell)); |
| return LoadObjectField(weak_cell, WeakCell::kValueOffset); |
| } |
| @@ -1260,6 +1288,7 @@ Node* CodeStubAssembler::LoadWeakCellValue(Node* weak_cell, Label* if_cleared) { |
| Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, |
| int additional_offset, |
| ParameterMode parameter_mode) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(object)); |
| int32_t header_size = |
| FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
| @@ -1334,6 +1363,8 @@ Node* CodeStubAssembler::LoadFixedTypedArrayElementAsTagged( |
| Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement( |
| Node* object, Node* index_node, int additional_offset, |
| ParameterMode parameter_mode) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(object)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode)); |
| int32_t header_size = |
| FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| #if V8_TARGET_LITTLE_ENDIAN |
| @@ -1353,6 +1384,8 @@ Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement( |
| Node* CodeStubAssembler::LoadFixedDoubleArrayElement( |
| Node* object, Node* index_node, MachineType machine_type, |
| int additional_offset, ParameterMode parameter_mode, Label* if_hole) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(object)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode)); |
| CSA_ASSERT(this, IsFixedDoubleArray(object)); |
| int32_t header_size = |
| FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| @@ -1387,11 +1420,13 @@ Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, |
| } |
| Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| int offset = Context::SlotOffset(slot_index); |
| return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset)); |
| } |
| Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| Node* offset = |
| IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| @@ -1400,12 +1435,14 @@ Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { |
| Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, |
| Node* value) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
|
Camillo Bruni
2017/04/28 15:57:44
I've prepared an IsContext which will call HeapObj
jgruber
2017/05/03 11:11:50
Acknowledged.
|
| int offset = Context::SlotOffset(slot_index); |
| return Store(context, IntPtrConstant(offset), value); |
| } |
| Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, |
| Node* value) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| Node* offset = |
| IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| @@ -1415,12 +1452,14 @@ Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, |
| Node* CodeStubAssembler::StoreContextElementNoWriteBarrier(Node* context, |
| int slot_index, |
| Node* value) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| int offset = Context::SlotOffset(slot_index); |
| return StoreNoWriteBarrier(MachineRepresentation::kTagged, context, |
| IntPtrConstant(offset), value); |
| } |
| Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
| } |
| @@ -1452,18 +1491,21 @@ Node* CodeStubAssembler::LoadJSFunctionPrototype(Node* function, |
| } |
| Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
| + CSA_SLOW_ASSERT(this, IsHeapNumber(object)); |
| return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
| MachineRepresentation::kFloat64); |
| } |
| Node* CodeStubAssembler::StoreObjectField( |
| Node* object, int offset, Node* value) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead. |
| return Store(object, IntPtrConstant(offset - kHeapObjectTag), value); |
| } |
| Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, |
| Node* value) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| int const_offset; |
| if (ToInt32Constant(offset, const_offset)) { |
| return StoreObjectField(object, const_offset, value); |
| @@ -1474,12 +1516,14 @@ Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, |
| Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| Node* object, int offset, Node* value, MachineRepresentation rep) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| return StoreNoWriteBarrier(rep, object, |
| IntPtrConstant(offset - kHeapObjectTag), value); |
| } |
| Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| Node* object, Node* offset, Node* value, MachineRepresentation rep) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| int const_offset; |
| if (ToInt32Constant(offset, const_offset)) { |
| return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep); |
| @@ -1489,6 +1533,7 @@ Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| } |
| Node* CodeStubAssembler::StoreMap(Node* object, Node* map) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| CSA_SLOW_ASSERT(this, IsMap(map)); |
| return StoreWithMapWriteBarrier( |
| object, IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); |
| @@ -1500,6 +1545,7 @@ Node* CodeStubAssembler::StoreMapNoWriteBarrier( |
| } |
| Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| CSA_SLOW_ASSERT(this, IsMap(map)); |
| return StoreNoWriteBarrier( |
| MachineRepresentation::kTagged, object, |
| @@ -1520,6 +1566,8 @@ Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, |
| WriteBarrierMode barrier_mode, |
| int additional_offset, |
| ParameterMode parameter_mode) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(object)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode)); |
| DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
| barrier_mode == UPDATE_WRITE_BARRIER); |
| int header_size = |
| @@ -1537,6 +1585,7 @@ Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, |
| Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
| Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
| CSA_ASSERT(this, IsFixedDoubleArray(object)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode)); |
| Node* offset = |
| ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
| FixedArray::kHeaderSize - kHeapObjectTag); |
| @@ -1594,6 +1643,7 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, |
| CodeStubArguments& args, |
| Variable& arg_index, |
| Label* bailout) { |
| + CSA_SLOW_ASSERT(this, IsJSArray(array)); |
| Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); |
| Label pre_bailout(this); |
| Label success(this); |
| @@ -1664,6 +1714,7 @@ void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind, |
| void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, |
| Node* value, Label* bailout) { |
| + CSA_SLOW_ASSERT(this, IsJSArray(array)); |
| Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); |
| ParameterMode mode = OptimalParameterMode(); |
| VARIABLE(var_length, OptimalParameterRepresentation(), |
| @@ -1723,6 +1774,8 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, |
| ParameterMode mode, |
| AllocationFlags flags) { |
| Comment("AllocateSeqOneByteString"); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(length, mode)); |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| // Compute the SeqOneByteString size and check if it fits into new space. |
| @@ -1793,6 +1846,8 @@ Node* CodeStubAssembler::AllocateSeqTwoByteString(int length, |
| Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length, |
| ParameterMode mode, |
| AllocationFlags flags) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(length, mode)); |
| Comment("AllocateSeqTwoByteString"); |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| @@ -1848,7 +1903,9 @@ Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length, |
| Node* CodeStubAssembler::AllocateSlicedString( |
| Heap::RootListIndex map_root_index, Node* length, Node* parent, |
| Node* offset) { |
| + CSA_ASSERT(this, IsString(parent)); |
| CSA_ASSERT(this, TaggedIsSmi(length)); |
| + CSA_ASSERT(this, TaggedIsSmi(offset)); |
| Node* result = Allocate(SlicedString::kSize); |
| DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); |
| StoreMapNoWriteBarrier(result, map_root_index); |
| @@ -1881,6 +1938,8 @@ Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index, |
| Node* length, Node* first, |
| Node* second, |
| AllocationFlags flags) { |
| + CSA_ASSERT(this, IsString(first)); |
| + CSA_ASSERT(this, IsString(second)); |
| CSA_ASSERT(this, TaggedIsSmi(length)); |
| Node* result = Allocate(ConsString::kSize, flags); |
| DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); |
| @@ -1920,6 +1979,9 @@ Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, |
| Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, |
| Node* right, AllocationFlags flags) { |
| + CSA_ASSERT(this, IsFixedArray(context)); |
| + CSA_ASSERT(this, IsString(left)); |
| + CSA_ASSERT(this, IsString(right)); |
| CSA_ASSERT(this, TaggedIsSmi(length)); |
| // Added string can be a cons string. |
| Comment("Allocating ConsString"); |
| @@ -1975,10 +2037,16 @@ Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, |
| Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, |
| Node* index, Node* input) { |
| + CSA_ASSERT(this, IsFixedArray(context)); |
| + CSA_ASSERT(this, TaggedIsSmi(index)); |
| + CSA_ASSERT(this, TaggedIsSmi(length)); |
| + CSA_ASSERT(this, IsString(input)); |
| + |
| +#ifdef DEBUG |
| Node* const max_length = |
| SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray)); |
| CSA_ASSERT(this, SmiLessThanOrEqual(length, max_length)); |
| - USE(max_length); |
| +#endif // DEBUG |
| // Allocate the JSRegExpResult. |
| // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove |
| @@ -2071,6 +2139,7 @@ Node* CodeStubAssembler::AllocateNameDictionary(Node* at_least_space_for) { |
| Node* CodeStubAssembler::CopyNameDictionary(Node* dictionary, |
| Label* large_object_fallback) { |
| Comment("Copy boilerplate property dict"); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(dictionary)); |
| Label done(this); |
| Node* length = SmiUntag(LoadFixedArrayBaseLength(dictionary)); |
| GotoIf( |
| @@ -2098,6 +2167,7 @@ Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, |
| void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
| Node* size, Node* properties, |
| Node* elements) { |
| + CSA_SLOW_ASSERT(this, IsMap(map)); |
| // This helper assumes that the object is in new-space, as guarded by the |
| // check in AllocatedJSObjectFromMap. |
| if (properties == nullptr) { |
| @@ -2105,6 +2175,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
| StoreObjectFieldRoot(object, JSObject::kPropertiesOffset, |
| Heap::kEmptyFixedArrayRootIndex); |
| } else { |
| + CSA_ASSERT(this, IsFixedArray(properties)); |
| StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOffset, |
| properties); |
| } |
| @@ -2112,6 +2183,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
| StoreObjectFieldRoot(object, JSObject::kElementsOffset, |
| Heap::kEmptyFixedArrayRootIndex); |
| } else { |
| + CSA_ASSERT(this, IsFixedArray(elements)); |
| StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements); |
| } |
| InitializeJSObjectBody(object, map, size, JSObject::kHeaderSize); |
| @@ -2119,6 +2191,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
| void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map, |
| Node* size, int start_offset) { |
| + CSA_SLOW_ASSERT(this, IsMap(map)); |
| // TODO(cbruni): activate in-object slack tracking machinery. |
| Comment("InitializeJSObjectBody"); |
| Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); |
| @@ -2148,6 +2221,8 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address, |
| Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( |
| ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { |
| Comment("begin allocation of JSArray without elements"); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(length)); |
|
Camillo Bruni
2017/04/28 15:57:44
TaggedIsPositiveSmi(length)
jgruber
2017/05/03 11:11:50
Done.
|
| + CSA_SLOW_ASSERT(this, IsMap(array_map)); |
| int base_size = JSArray::kSize; |
| if (allocation_site != nullptr) { |
| base_size += AllocationMemento::kSize; |
| @@ -2164,6 +2239,8 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( |
| ElementsKind kind, Node* array_map, Node* length, Node* allocation_site, |
| Node* capacity, ParameterMode capacity_mode) { |
| Comment("begin allocation of JSArray with elements"); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(length)); |
|
Camillo Bruni
2017/04/28 15:57:44
TaggedIsPositiveSmi(length)
jgruber
2017/05/03 11:11:50
Done.
|
| + CSA_SLOW_ASSERT(this, IsMap(array_map)); |
| int base_size = JSArray::kSize; |
| if (allocation_site != nullptr) { |
| @@ -2190,6 +2267,9 @@ Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind, |
| Node* length, |
| Node* allocation_site, |
| Node* size_in_bytes) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(length)); |
|
Camillo Bruni
2017/04/28 15:57:44
TaggedIsPositiveSmi(length)
jgruber
2017/05/03 11:11:50
Done.
|
| + CSA_SLOW_ASSERT(this, IsMap(array_map)); |
| + |
| // Allocate space for the JSArray and the elements FixedArray in one go. |
| Node* array = AllocateInNewSpace(size_in_bytes); |
| @@ -2212,6 +2292,10 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
| Node* capacity, Node* length, |
| Node* allocation_site, |
| ParameterMode capacity_mode) { |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(length)); |
|
Camillo Bruni
2017/04/28 15:57:44
TaggedIsPositiveSmi(length)
jgruber
2017/05/03 11:11:50
Done.
|
| + CSA_SLOW_ASSERT(this, IsMap(array_map)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(capacity, capacity_mode)); |
| + |
| Node *array = nullptr, *elements = nullptr; |
| if (IsIntPtrOrSmiConstantZero(capacity)) { |
| // Array is empty. Use the shared empty fixed array instead of allocating a |
| @@ -2245,6 +2329,7 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
| Node* capacity_node, |
| ParameterMode mode, |
| AllocationFlags flags) { |
| + CSA_SLOW_ASSERT(this, IsParameterMode(capacity_node, mode)); |
| CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, |
| IntPtrOrSmiConstant(0, mode), mode)); |
| Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); |
| @@ -2264,6 +2349,9 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
| void CodeStubAssembler::FillFixedArrayWithValue( |
| ElementsKind kind, Node* array, Node* from_node, Node* to_node, |
| Heap::RootListIndex value_root_index, ParameterMode mode) { |
| + CSA_SLOW_ASSERT(this, IsParameterMode(from_node, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(to_node, mode)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(array)); |
| bool is_double = IsFastDoubleElementsKind(kind); |
| DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || |
| value_root_index == Heap::kUndefinedValueRootIndex); |
| @@ -2307,6 +2395,10 @@ void CodeStubAssembler::CopyFixedArrayElements( |
| ElementsKind from_kind, Node* from_array, ElementsKind to_kind, |
| Node* to_array, Node* element_count, Node* capacity, |
| WriteBarrierMode barrier_mode, ParameterMode mode) { |
| + CSA_SLOW_ASSERT(this, IsParameterMode(element_count, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(from_array)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(to_array)); |
| STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); |
| const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| Comment("[ CopyFixedArrayElements"); |
| @@ -2443,6 +2535,11 @@ void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string, |
| String::Encoding from_encoding, |
| String::Encoding to_encoding, |
| ParameterMode mode) { |
| + CSA_SLOW_ASSERT(this, IsString(from_string)); |
| + CSA_SLOW_ASSERT(this, IsString(to_string)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(character_count, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(from_index, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(to_index, mode)); |
| bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING; |
| bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING; |
| DCHECK_IMPLIES(to_one_byte, from_one_byte); |
| @@ -2501,6 +2598,7 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, |
| ElementsKind from_kind, |
| ElementsKind to_kind, |
| Label* if_hole) { |
| + CSA_SLOW_ASSERT(this, IsFixedArray(array)); |
| if (IsFastDoubleElementsKind(from_kind)) { |
| Node* value = |
| LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64()); |
| @@ -2527,6 +2625,7 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, |
| Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, |
| ParameterMode mode) { |
| + CSA_SLOW_ASSERT(this, IsParameterMode(old_capacity, mode)); |
| Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); |
| Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); |
| Node* padding = IntPtrOrSmiConstant(16, mode); |
| @@ -2536,6 +2635,9 @@ Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, |
| Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
| ElementsKind kind, Node* key, |
| Label* bailout) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(elements)); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(key)); |
| Node* capacity = LoadFixedArrayBaseLength(elements); |
| ParameterMode mode = OptimalParameterMode(); |
| @@ -2552,6 +2654,10 @@ Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
| ParameterMode mode, |
| Label* bailout) { |
| Comment("TryGrowElementsCapacity"); |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(elements)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(key, mode)); |
| // If the gap growth is too big, fall back to the runtime. |
| Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); |
| @@ -2569,6 +2675,11 @@ Node* CodeStubAssembler::GrowElementsCapacity( |
| Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind, |
| Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) { |
| Comment("[ GrowElementsCapacity"); |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(elements)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(new_capacity, mode)); |
| + |
| // If size of the allocation for the new capacity doesn't fit in a page |
| // that we can bump-pointer allocate from, fall back to the runtime. |
| int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); |
| @@ -2777,6 +2888,7 @@ Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value) { |
| Goto(&if_join); |
| } |
| BIND(&if_join); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -2804,6 +2916,7 @@ Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { |
| } |
| Goto(&if_join); |
| BIND(&if_join); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -2840,6 +2953,7 @@ Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { |
| Goto(&if_join); |
| BIND(&if_join); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -2904,6 +3018,7 @@ Node* CodeStubAssembler::ToThisString(Node* context, Node* value, |
| } |
| Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) { |
| + CSA_SLOW_ASSERT(this, IsNumber(value)); |
| VARIABLE(result, MachineRepresentation::kFloat64); |
| Label smi(this); |
| Label done(this, &result); |
| @@ -2923,6 +3038,7 @@ Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) { |
| } |
| Node* CodeStubAssembler::ChangeNumberToIntPtr(Node* value) { |
| + CSA_SLOW_ASSERT(this, IsNumber(value)); |
| VARIABLE(result, MachineType::PointerRepresentation()); |
| Label smi(this), done(this, &result); |
| GotoIf(TaggedIsSmi(value), &smi); |
| @@ -3060,6 +3176,7 @@ Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { |
| } |
| Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { |
| + CSA_SLOW_ASSERT(this, IsMap(map)); |
| Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); |
| uint32_t mask = |
| 1 << Map::kHasNamedInterceptor | 1 << Map::kIsAccessCheckNeeded; |
| @@ -3204,6 +3321,10 @@ Node* CodeStubAssembler::IsJSArrayMap(Node* map) { |
| return IsJSArrayInstanceType(LoadMapInstanceType(map)); |
| } |
| +Node* CodeStubAssembler::IsFixedArray(Node* object) { |
| + return HasInstanceType(object, FIXED_ARRAY_TYPE); |
| +} |
| + |
| Node* CodeStubAssembler::IsWeakCell(Node* object) { |
| return IsWeakCellMap(LoadMap(object)); |
| } |
| @@ -3339,7 +3460,7 @@ Node* CodeStubAssembler::IsNumberNormalized(Node* number) { |
| Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index, |
| ParameterMode parameter_mode) { |
| - if (parameter_mode == SMI_PARAMETERS) CSA_ASSERT(this, TaggedIsSmi(index)); |
| + CSA_ASSERT(this, IsParameterMode(index, parameter_mode)); |
| CSA_ASSERT(this, IsString(string)); |
| // Translate the {index} into a Word. |
| @@ -3451,6 +3572,7 @@ Node* CodeStubAssembler::StringFromCharCode(Node* code) { |
| } |
| BIND(&if_done); |
| + CSA_ASSERT(this, IsString(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -3648,6 +3770,7 @@ Node* CodeStubAssembler::SubString(Node* context, Node* string, Node* from, |
| } |
| BIND(&end); |
| + CSA_ASSERT(this, IsString(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -3790,26 +3913,6 @@ Node* ToDirectStringAssembler::TryToSequential(StringPointerKind ptr_kind, |
| return var_result.value(); |
| } |
| -Node* CodeStubAssembler::TryDerefExternalString(Node* const string, |
| - Node* const instance_type, |
| - Label* if_bailout) { |
| - Label out(this); |
| - |
| - CSA_ASSERT(this, IsExternalStringInstanceType(instance_type)); |
| - GotoIf(IsShortExternalStringInstanceType(instance_type), if_bailout); |
| - |
| - // Move the pointer so that offset-wise, it looks like a sequential string. |
| - STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| - |
| - Node* resource_data = LoadObjectField( |
| - string, ExternalString::kResourceDataOffset, MachineType::Pointer()); |
| - Node* const fake_sequential_string = |
| - IntPtrSub(resource_data, |
| - IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| - |
| - return fake_sequential_string; |
| -} |
| - |
| void CodeStubAssembler::MaybeDerefIndirectString(Variable* var_string, |
| Node* instance_type, |
| Variable* var_did_something) { |
| @@ -4015,10 +4118,12 @@ Node* CodeStubAssembler::StringFromCodePoint(Node* codepoint, |
| } |
| BIND(&return_result); |
| + CSA_ASSERT(this, IsString(var_result.value())); |
| return var_result.value(); |
| } |
| Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { |
| + CSA_SLOW_ASSERT(this, IsString(input)); |
| Label runtime(this, Label::kDeferred); |
| Label end(this); |
| @@ -4118,6 +4223,7 @@ Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) { |
| } |
| BIND(&done); |
| + CSA_ASSERT(this, IsString(result.value())); |
| return result.value(); |
| } |
| @@ -4164,6 +4270,7 @@ Node* CodeStubAssembler::ToName(Node* context, Node* value) { |
| } |
| BIND(&end); |
| + CSA_ASSERT(this, IsName(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -4252,6 +4359,7 @@ Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) { |
| } |
| BIND(&end); |
| + CSA_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -4281,6 +4389,7 @@ Node* CodeStubAssembler::ToNumber(Node* context, Node* input) { |
| } |
| BIND(&end); |
| + CSA_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -4383,6 +4492,7 @@ Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { |
| } |
| BIND(&out); |
| + CSA_ASSERT(this, IsNumber(var_result.value())); |
| return var_result.value(); |
| } |
| @@ -4422,6 +4532,7 @@ Node* CodeStubAssembler::ToString(Node* context, Node* input) { |
| } |
| BIND(&done); |
| + CSA_ASSERT(this, IsString(result.value())); |
| return result.value(); |
| } |
| @@ -4475,6 +4586,7 @@ Node* CodeStubAssembler::ToSmiIndex(Node* const input, Node* const context, |
| Goto(&done); |
| BIND(&done); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value())); |
| return result.value(); |
| } |
| @@ -4499,6 +4611,7 @@ Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context, |
| Goto(&done); |
| BIND(&done); |
| + CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value())); |
| return result.value(); |
| } |
| @@ -4559,6 +4672,7 @@ Node* CodeStubAssembler::ToInteger(Node* context, Node* input, |
| } |
| BIND(&out); |
| + CSA_SLOW_ASSERT(this, IsNumber(var_arg.value())); |
| return var_arg.value(); |
| } |
| @@ -4675,6 +4789,7 @@ void CodeStubAssembler::TryInternalizeString( |
| Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) { |
| DCHECK(var_index->rep() == MachineType::PointerRepresentation()); |
| DCHECK(var_internalized->rep() == MachineRepresentation::kTagged); |
| + CSA_SLOW_ASSERT(this, IsString(string)); |
| Node* function = ExternalConstant( |
| ExternalReference::try_internalize_string_function(isolate())); |
| Node* result = CallCFunction1(MachineType::AnyTagged(), |
| @@ -4922,6 +5037,8 @@ void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, |
| Node* name, Node* value, |
| Node* index, |
| Node* enum_index) { |
| + CSA_SLOW_ASSERT(this, IsDictionary(dictionary)); |
| + |
| // Store name and value. |
| StoreFixedArrayElement(dictionary, index, name); |
| StoreValueByKeyIndex<NameDictionary>(dictionary, index, value); |
| @@ -4963,6 +5080,7 @@ void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, |
| template <class Dictionary> |
| void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value, |
| Label* bailout) { |
| + CSA_SLOW_ASSERT(this, IsDictionary(dictionary)); |
| Node* capacity = GetCapacity<Dictionary>(dictionary); |
| Node* nof = GetNumberOfElements<Dictionary>(dictionary); |
| Node* new_nof = SmiAdd(nof, SmiConstant(1)); |
| @@ -6600,6 +6718,8 @@ Node* CodeStubAssembler::BuildFastLoop( |
| const CodeStubAssembler::VariableList& vars, Node* start_index, |
| Node* end_index, const FastLoopBody& body, int increment, |
| ParameterMode parameter_mode, IndexAdvanceMode advance_mode) { |
| + CSA_SLOW_ASSERT(this, IsParameterMode(start_index, parameter_mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(end_index, parameter_mode)); |
| MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS) |
| ? MachineType::PointerRepresentation() |
| : MachineRepresentation::kTaggedSigned; |
| @@ -6637,6 +6757,9 @@ void CodeStubAssembler::BuildFastFixedArrayForEach( |
| Node* last_element_exclusive, const FastFixedArrayForEachBody& body, |
| ParameterMode mode, ForEachDirection direction) { |
| STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(first_element_inclusive, mode)); |
| + CSA_SLOW_ASSERT(this, IsParameterMode(last_element_exclusive, mode)); |
| + CSA_SLOW_ASSERT(this, IsFixedArray(fixed_array)); |
| int32_t first_val; |
| bool constant_first = ToInt32Constant(first_element_inclusive, first_val); |
| int32_t last_val; |
| @@ -6697,6 +6820,7 @@ void CodeStubAssembler::GotoIfFixedArraySizeDoesntFitInNewSpace( |
| void CodeStubAssembler::InitializeFieldsWithRoot( |
| Node* object, Node* start_offset, Node* end_offset, |
| Heap::RootListIndex root_index) { |
| + CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
| start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag)); |
| end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag)); |
| Node* root_value = LoadRoot(root_index); |
| @@ -6712,6 +6836,9 @@ void CodeStubAssembler::InitializeFieldsWithRoot( |
| void CodeStubAssembler::BranchIfNumericRelationalComparison( |
| RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true, |
| Label* if_false) { |
| + CSA_SLOW_ASSERT(this, IsNumber(lhs)); |
| + CSA_SLOW_ASSERT(this, IsNumber(rhs)); |
| + |
| Label end(this); |
| VARIABLE(result, MachineRepresentation::kTagged); |
| @@ -6823,6 +6950,9 @@ void CodeStubAssembler::GotoUnlessNumberLessThan(Node* lhs, Node* rhs, |
| Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode, |
| Node* lhs, Node* rhs, |
| Node* context) { |
| + CSA_SLOW_ASSERT(this, IsNumber(lhs)); |
| + CSA_SLOW_ASSERT(this, IsNumber(rhs)); |
| + |
| Label return_true(this), return_false(this), end(this); |
| VARIABLE(result, MachineRepresentation::kTagged); |
| @@ -8324,6 +8454,8 @@ Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, |
| } |
| Node* CodeStubAssembler::NumberInc(Node* value) { |
| + CSA_SLOW_ASSERT(this, IsNumber(value)); |
| + |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| VARIABLE(var_finc_value, MachineRepresentation::kFloat64); |
| Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); |
| @@ -8376,6 +8508,8 @@ Node* CodeStubAssembler::NumberInc(Node* value) { |
| } |
| Node* CodeStubAssembler::NumberDec(Node* value) { |
| + CSA_SLOW_ASSERT(this, IsNumber(value)); |
| + |
| VARIABLE(var_result, MachineRepresentation::kTagged); |
| VARIABLE(var_fdec_value, MachineRepresentation::kFloat64); |
| Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this); |
| @@ -8780,6 +8914,8 @@ Node* CodeStubAssembler::IsPromiseHookEnabledOrDebugIsActive() { |
| Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map, |
| Node* shared_info, |
| Node* context) { |
| + CSA_SLOW_ASSERT(this, IsMap(map)); |
| + |
| Node* const code = BitcastTaggedToWord( |
| LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset)); |
| Node* const code_entry = |