[stubs] Introduce CSA::OptimalParameterMode(), TagParameter() and UntagParameter().
Delete unused CSA::AllocateUninitializedFixedArray() which also does not respect ParameterMode concept. Review-Url: https://codereview.chromium.org/2321643002 Cr-Commit-Position: refs/heads/master@{#39268}
This commit is contained in:
parent
96164b74f1
commit
7dd7d9257b
@ -64,12 +64,9 @@ void Builtins::Generate_CopyFastSmiOrObjectElements(
|
||||
// Load the {object}s elements.
|
||||
Node* source = assembler->LoadObjectField(object, JSObject::kElementsOffset);
|
||||
|
||||
CodeStubAssembler::ParameterMode mode =
|
||||
assembler->Is64() ? CodeStubAssembler::INTEGER_PARAMETERS
|
||||
: CodeStubAssembler::SMI_PARAMETERS;
|
||||
Node* length = (mode == CodeStubAssembler::INTEGER_PARAMETERS)
|
||||
? assembler->LoadAndUntagFixedArrayBaseLength(source)
|
||||
: assembler->LoadFixedArrayBaseLength(source);
|
||||
CodeStubAssembler::ParameterMode mode = assembler->OptimalParameterMode();
|
||||
Node* length = assembler->UntagParameter(
|
||||
assembler->LoadFixedArrayBaseLength(source), mode);
|
||||
|
||||
// Check if we can allocate in new space.
|
||||
ElementsKind kind = FAST_ELEMENTS;
|
||||
|
@ -86,7 +86,7 @@ Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) {
|
||||
if (mode == SMI_PARAMETERS) {
|
||||
return SmiConstant(Smi::FromInt(value));
|
||||
} else {
|
||||
DCHECK_EQ(INTEGER_PARAMETERS, mode);
|
||||
DCHECK(mode == INTEGER_PARAMETERS || mode == INTPTR_PARAMETERS);
|
||||
return IntPtrConstant(value);
|
||||
}
|
||||
}
|
||||
@ -1097,19 +1097,6 @@ Node* CodeStubAssembler::LoadWeakCellValue(Node* weak_cell, Label* if_cleared) {
|
||||
return value;
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::AllocateUninitializedFixedArray(Node* length) {
|
||||
Node* header_size = IntPtrConstant(FixedArray::kHeaderSize);
|
||||
Node* data_size = WordShl(length, IntPtrConstant(kPointerSizeLog2));
|
||||
Node* total_size = IntPtrAdd(data_size, header_size);
|
||||
|
||||
Node* result = Allocate(total_size, kNone);
|
||||
StoreMapNoWriteBarrier(result, LoadRoot(Heap::kFixedArrayMapRootIndex));
|
||||
StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset,
|
||||
SmiTag(length));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node,
|
||||
int additional_offset,
|
||||
ParameterMode parameter_mode) {
|
||||
@ -1161,9 +1148,8 @@ Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind,
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) {
|
||||
return StoreNoWriteBarrier(
|
||||
MachineRepresentation::kFloat64, object,
|
||||
IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value);
|
||||
return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value,
|
||||
MachineRepresentation::kFloat64);
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::StoreObjectField(
|
||||
@ -1360,9 +1346,8 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
|
||||
Node* empty_properties = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
|
||||
StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset,
|
||||
empty_properties);
|
||||
StoreObjectFieldNoWriteBarrier(
|
||||
array, JSArray::kLengthOffset,
|
||||
mode == SMI_PARAMETERS ? length_node : SmiTag(length_node));
|
||||
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset,
|
||||
TagParameter(length_node, mode));
|
||||
|
||||
if (allocation_site != nullptr) {
|
||||
InitializeAllocationMemento(array, JSArray::kSize, allocation_site);
|
||||
@ -1374,9 +1359,8 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
|
||||
Handle<Map> elements_map(is_double ? heap->fixed_double_array_map()
|
||||
: heap->fixed_array_map());
|
||||
StoreMapNoWriteBarrier(elements, HeapConstant(elements_map));
|
||||
StoreObjectFieldNoWriteBarrier(
|
||||
elements, FixedArray::kLengthOffset,
|
||||
mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node));
|
||||
StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset,
|
||||
TagParameter(capacity_node, mode));
|
||||
|
||||
// Fill in the elements with holes.
|
||||
FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity_node,
|
||||
@ -1402,9 +1386,8 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
|
||||
} else {
|
||||
StoreMapNoWriteBarrier(array, HeapConstant(map));
|
||||
}
|
||||
StoreObjectFieldNoWriteBarrier(
|
||||
array, FixedArray::kLengthOffset,
|
||||
mode == INTEGER_PARAMETERS ? SmiTag(capacity_node) : capacity_node);
|
||||
StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset,
|
||||
TagParameter(capacity_node, mode));
|
||||
return array;
|
||||
}
|
||||
|
||||
@ -1553,7 +1536,7 @@ Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity,
|
||||
Node* new_capacity = IntPtrAdd(half_old_capacity, old_capacity);
|
||||
Node* unconditioned_result =
|
||||
IntPtrAdd(new_capacity, IntPtrOrSmiConstant(16, mode));
|
||||
if (mode == INTEGER_PARAMETERS) {
|
||||
if (mode == INTEGER_PARAMETERS || mode == INTPTR_PARAMETERS) {
|
||||
return unconditioned_result;
|
||||
} else {
|
||||
int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
|
||||
@ -1568,17 +1551,9 @@ Node* CodeStubAssembler::CheckAndGrowElementsCapacity(Node* context,
|
||||
Node* key, Label* fail) {
|
||||
Node* capacity = LoadFixedArrayBaseLength(elements);
|
||||
|
||||
// On 32-bit platforms, there is a slight performance advantage to doing all
|
||||
// of the arithmetic for the new backing store with SMIs, since it's possible
|
||||
// to save a few tag/untag operations without paying an extra expense when
|
||||
// calculating array offset (the smi math can be folded away) and there are
|
||||
// fewer live ranges. Thus only convert |capacity| and |key| to untagged value
|
||||
// on 64-bit platforms.
|
||||
ParameterMode mode = Is64() ? INTEGER_PARAMETERS : SMI_PARAMETERS;
|
||||
if (mode == INTEGER_PARAMETERS) {
|
||||
capacity = SmiUntag(capacity);
|
||||
key = SmiUntag(key);
|
||||
}
|
||||
ParameterMode mode = OptimalParameterMode();
|
||||
capacity = UntagParameter(capacity, mode);
|
||||
key = UntagParameter(key, mode);
|
||||
|
||||
// If the gap growth is too big, fall back to the runtime.
|
||||
Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode);
|
||||
|
@ -46,8 +46,30 @@ class CodeStubAssembler : public compiler::CodeAssembler {
|
||||
|
||||
typedef base::Flags<AllocationFlag> AllocationFlags;
|
||||
|
||||
// TODO(ishell): Fix all loads/stores from arrays by int32 offsets/indices
|
||||
// and eventually remove INTEGER_PARAMETERS in favour of INTPTR_PARAMETERS.
|
||||
enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS, INTPTR_PARAMETERS };
|
||||
|
||||
// On 32-bit platforms, there is a slight performance advantage to doing all
|
||||
// of the array offset/index arithmetic with SMIs, since it's possible
|
||||
// to save a few tag/untag operations without paying an extra expense when
|
||||
// calculating array offset (the smi math can be folded away) and there are
|
||||
// fewer live ranges. Thus only convert indices to untagged value on 64-bit
|
||||
// platforms.
|
||||
ParameterMode OptimalParameterMode() const {
|
||||
return Is64() ? INTPTR_PARAMETERS : SMI_PARAMETERS;
|
||||
}
|
||||
|
||||
compiler::Node* UntagParameter(compiler::Node* value, ParameterMode mode) {
|
||||
if (mode != SMI_PARAMETERS) value = SmiUntag(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
compiler::Node* TagParameter(compiler::Node* value, ParameterMode mode) {
|
||||
if (mode != SMI_PARAMETERS) value = SmiTag(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
compiler::Node* BooleanMapConstant();
|
||||
compiler::Node* EmptyStringConstant();
|
||||
compiler::Node* HeapNumberMapConstant();
|
||||
@ -226,8 +248,6 @@ class CodeStubAssembler : public compiler::CodeAssembler {
|
||||
compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell,
|
||||
Label* if_cleared = nullptr);
|
||||
|
||||
compiler::Node* AllocateUninitializedFixedArray(compiler::Node* length);
|
||||
|
||||
// Load an array element from a FixedArray.
|
||||
compiler::Node* LoadFixedArrayElement(
|
||||
compiler::Node* object, compiler::Node* int32_index,
|
||||
|
Loading…
Reference in New Issue
Block a user