Index: src/code-stub-assembler.cc |
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
index b14031b4c715dfb804c6e5230630de5e2d838fec..e06506a7aaa93559505c944085db41750cba25e4 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::MatchesParameterMode(Node* value, ParameterMode mode) { |
+ return (mode == SMI_PARAMETERS) ? TaggedIsSmi(value) : Int32Constant(1); |
+} |
+ |
Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { |
// value && !(value & (value - 1)) |
return WordEqual( |
@@ -437,15 +441,18 @@ 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)); |
} |
@@ -458,6 +465,8 @@ Node* CodeStubAssembler::SmiMin(Node* a, Node* 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,6 +526,7 @@ 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(); |
} |
@@ -578,11 +588,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 +674,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 +992,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 +1075,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 +1136,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 +1220,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) { |
@@ -1260,6 +1281,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 +1356,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, MatchesParameterMode(index_node, parameter_mode)); |
int32_t header_size = |
FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
#if V8_TARGET_LITTLE_ENDIAN |
@@ -1353,6 +1377,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, IsFixedDoubleArray(object)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode)); |
CSA_ASSERT(this, IsFixedDoubleArray(object)); |
int32_t header_size = |
FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; |
@@ -1387,11 +1413,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 +1428,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)); |
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 +1445,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 +1484,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 +1509,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 +1526,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 +1538,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 +1559,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, MatchesParameterMode(index_node, parameter_mode)); |
DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
barrier_mode == UPDATE_WRITE_BARRIER); |
int header_size = |
@@ -1537,6 +1578,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, MatchesParameterMode(index_node, parameter_mode)); |
Node* offset = |
ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
FixedArray::kHeaderSize - kHeapObjectTag); |
@@ -1594,6 +1636,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 +1707,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 +1767,8 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, |
ParameterMode mode, |
AllocationFlags flags) { |
Comment("AllocateSeqOneByteString"); |
+ CSA_SLOW_ASSERT(this, IsFixedArray(context)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(length, mode)); |
VARIABLE(var_result, MachineRepresentation::kTagged); |
// Compute the SeqOneByteString size and check if it fits into new space. |
@@ -1793,6 +1839,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, MatchesParameterMode(length, mode)); |
Comment("AllocateSeqTwoByteString"); |
VARIABLE(var_result, MachineRepresentation::kTagged); |
@@ -1848,7 +1896,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 +1931,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 +1972,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 +2030,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 +2132,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, IsDictionary(dictionary)); |
Label done(this); |
Node* length = SmiUntag(LoadFixedArrayBaseLength(dictionary)); |
GotoIf( |
@@ -2098,6 +2160,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 +2168,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 +2176,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 +2184,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 +2214,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, TaggedIsPositiveSmi(length)); |
+ CSA_SLOW_ASSERT(this, IsMap(array_map)); |
int base_size = JSArray::kSize; |
if (allocation_site != nullptr) { |
base_size += AllocationMemento::kSize; |
@@ -2164,6 +2232,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, TaggedIsPositiveSmi(length)); |
+ CSA_SLOW_ASSERT(this, IsMap(array_map)); |
int base_size = JSArray::kSize; |
if (allocation_site != nullptr) { |
@@ -2190,13 +2260,15 @@ Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind, |
Node* length, |
Node* allocation_site, |
Node* size_in_bytes) { |
+ CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); |
+ 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); |
Comment("write JSArray headers"); |
StoreMapNoWriteBarrier(array, array_map); |
- CSA_ASSERT(this, TaggedIsSmi(length)); |
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length); |
StoreObjectFieldRoot(array, JSArray::kPropertiesOffset, |
@@ -2212,6 +2284,10 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
Node* capacity, Node* length, |
Node* allocation_site, |
ParameterMode capacity_mode) { |
+ CSA_SLOW_ASSERT(this, IsMap(array_map)); |
+ CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(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 +2321,7 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
Node* capacity_node, |
ParameterMode mode, |
AllocationFlags flags) { |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity_node, mode)); |
CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, |
IntPtrOrSmiConstant(0, mode), mode)); |
Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); |
@@ -2264,6 +2341,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, MatchesParameterMode(from_node, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode)); |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind)); |
bool is_double = IsFastDoubleElementsKind(kind); |
DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || |
value_root_index == Heap::kUndefinedValueRootIndex); |
@@ -2307,6 +2387,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, MatchesParameterMode(element_count, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(from_array, from_kind)); |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(to_array, to_kind)); |
STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); |
const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; |
Comment("[ CopyFixedArrayElements"); |
@@ -2443,6 +2527,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, MatchesParameterMode(character_count, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(from_index, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(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 +2590,7 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, |
ElementsKind from_kind, |
ElementsKind to_kind, |
Label* if_hole) { |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, from_kind)); |
if (IsFastDoubleElementsKind(from_kind)) { |
Node* value = |
LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64()); |
@@ -2527,6 +2617,7 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, |
Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, |
ParameterMode mode) { |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(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 +2627,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, IsFixedArrayWithKind(elements, kind)); |
+ CSA_SLOW_ASSERT(this, TaggedIsSmi(key)); |
Node* capacity = LoadFixedArrayBaseLength(elements); |
ParameterMode mode = OptimalParameterMode(); |
@@ -2552,6 +2646,10 @@ Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
ParameterMode mode, |
Label* bailout) { |
Comment("TryGrowElementsCapacity"); |
+ CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(elements, kind)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(key, mode)); |
// If the gap growth is too big, fall back to the runtime. |
Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); |
@@ -2569,6 +2667,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, IsFixedArrayWithKind(elements, from_kind)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(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 +2880,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 +2908,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 +2945,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 +3010,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 +3030,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 +3168,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; |
@@ -3177,7 +3286,7 @@ Node* CodeStubAssembler::IsJSGlobalProxy(Node* object) { |
} |
Node* CodeStubAssembler::IsMap(Node* map) { |
- return HasInstanceType(map, MAP_TYPE); |
+ return WordEqual(LoadMap(map), MetaMapConstant()); |
Igor Sheludko
2017/05/03 14:03:05
return IsMetaMap(LoadMap(map));
jgruber
2017/05/18 14:33:35
Done.
|
} |
Node* CodeStubAssembler::IsJSValueInstanceType(Node* instance_type) { |
@@ -3204,6 +3313,19 @@ Node* CodeStubAssembler::IsJSArrayMap(Node* map) { |
return IsJSArrayInstanceType(LoadMapInstanceType(map)); |
} |
+Node* CodeStubAssembler::IsFixedArray(Node* object) { |
+ return HasInstanceType(object, FIXED_ARRAY_TYPE); |
+} |
+ |
+Node* CodeStubAssembler::IsFixedArrayWithKind(Node* object, ElementsKind kind) { |
+ if (IsFastDoubleElementsKind(kind)) { |
+ return IsFixedDoubleArray(object); |
+ } else { |
+ DCHECK(IsFastSmiOrObjectElementsKind(kind)); |
+ return IsFixedArray(object); |
+ } |
+} |
+ |
Node* CodeStubAssembler::IsWeakCell(Node* object) { |
return IsWeakCellMap(LoadMap(object)); |
} |
@@ -3339,7 +3461,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, MatchesParameterMode(index, parameter_mode)); |
CSA_ASSERT(this, IsString(string)); |
// Translate the {index} into a Word. |
@@ -3451,6 +3573,7 @@ Node* CodeStubAssembler::StringFromCharCode(Node* code) { |
} |
BIND(&if_done); |
+ CSA_ASSERT(this, IsString(var_result.value())); |
return var_result.value(); |
} |
@@ -3648,6 +3771,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 +3914,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 +4119,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 +4224,7 @@ Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) { |
} |
BIND(&done); |
+ CSA_ASSERT(this, IsString(result.value())); |
return result.value(); |
} |
@@ -4164,6 +4271,7 @@ Node* CodeStubAssembler::ToName(Node* context, Node* value) { |
} |
BIND(&end); |
+ CSA_ASSERT(this, IsName(var_result.value())); |
return var_result.value(); |
} |
@@ -4252,6 +4360,7 @@ Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) { |
} |
BIND(&end); |
+ CSA_ASSERT(this, IsNumber(var_result.value())); |
return var_result.value(); |
} |
@@ -4281,6 +4390,7 @@ Node* CodeStubAssembler::ToNumber(Node* context, Node* input) { |
} |
BIND(&end); |
+ CSA_ASSERT(this, IsNumber(var_result.value())); |
return var_result.value(); |
} |
@@ -4383,6 +4493,7 @@ Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { |
} |
BIND(&out); |
+ CSA_ASSERT(this, IsNumber(var_result.value())); |
return var_result.value(); |
} |
@@ -4422,6 +4533,7 @@ Node* CodeStubAssembler::ToString(Node* context, Node* input) { |
} |
BIND(&done); |
+ CSA_ASSERT(this, IsString(result.value())); |
return result.value(); |
} |
@@ -4475,6 +4587,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 +4612,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 +4673,7 @@ Node* CodeStubAssembler::ToInteger(Node* context, Node* input, |
} |
BIND(&out); |
+ CSA_SLOW_ASSERT(this, IsNumber(var_arg.value())); |
return var_arg.value(); |
} |
@@ -4675,6 +4790,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 +5038,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 +5081,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)); |
@@ -6601,6 +6720,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, MatchesParameterMode(start_index, parameter_mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(end_index, parameter_mode)); |
MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS) |
? MachineType::PointerRepresentation() |
: MachineRepresentation::kTaggedSigned; |
@@ -6638,6 +6759,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, MatchesParameterMode(first_element_inclusive, mode)); |
+ CSA_SLOW_ASSERT(this, MatchesParameterMode(last_element_exclusive, mode)); |
+ CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(fixed_array, kind)); |
int32_t first_val; |
bool constant_first = ToInt32Constant(first_element_inclusive, first_val); |
int32_t last_val; |
@@ -6698,6 +6822,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); |
@@ -6713,6 +6838,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); |
@@ -6824,6 +6952,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); |
@@ -8325,6 +8456,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); |
@@ -8377,6 +8510,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); |
@@ -8803,6 +8938,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 = |