Commit 8c7bfc54 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] Typify CSA::Select() and friends.

Bug: v8:6949, v8:7310
Change-Id: I8647d385355f357e8825648d6da2757efdcbc6c2
Reviewed-on: https://chromium-review.googlesource.com/980496Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52249}
parent b10f21c6
......@@ -29,13 +29,13 @@ class AsyncGeneratorBuiltinsAssembler : public AsyncBuiltinsAssembler {
: AsyncBuiltinsAssembler(state) {}
inline Node* TaggedIsAsyncGenerator(Node* tagged_object) {
Node* if_notsmi = TaggedIsNotSmi(tagged_object);
return Select(if_notsmi,
[=]() {
return HasInstanceType(tagged_object,
JS_ASYNC_GENERATOR_OBJECT_TYPE);
},
[=]() { return if_notsmi; }, MachineRepresentation::kBit);
TNode<BoolT> if_notsmi = TaggedIsNotSmi(tagged_object);
return Select<BoolT>(if_notsmi,
[=] {
return HasInstanceType(
tagged_object, JS_ASYNC_GENERATOR_OBJECT_TYPE);
},
[=] { return if_notsmi; });
}
inline Node* LoadGeneratorState(Node* const generator) {
return LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
......
......@@ -333,8 +333,7 @@ TNode<Object> BaseCollectionsAssembler::AllocateJSCollection(
[=] {
return AllocateJSCollectionSlow(context, constructor,
new_target);
},
MachineRepresentation::kTagged);
});
}
TNode<Object> BaseCollectionsAssembler::AllocateJSCollectionFast(
......@@ -456,7 +455,7 @@ TNode<IntPtrT> BaseCollectionsAssembler::EstimatedInitialSize(
return Select<IntPtrT>(
is_fast_jsarray,
[=] { return SmiUntag(LoadFastJSArrayLength(CAST(initial_entries))); },
[=] { return IntPtrConstant(0); }, MachineType::PointerRepresentation());
[=] { return IntPtrConstant(0); });
}
void BaseCollectionsAssembler::GotoIfNotJSReceiver(Node* const obj,
......@@ -494,8 +493,7 @@ TNode<Object> BaseCollectionsAssembler::LoadAndNormalizeFixedArrayElement(
TNode<Object> elements, TNode<IntPtrT> index) {
TNode<Object> element = CAST(LoadFixedArrayElement(elements, index));
return Select<Object>(IsTheHole(element), [=] { return UndefinedConstant(); },
[=] { return element; },
MachineRepresentation::kTagged);
[=] { return element; });
}
TNode<Object> BaseCollectionsAssembler::LoadAndNormalizeFixedDoubleArrayElement(
......
......@@ -126,12 +126,12 @@ TF_BUILTIN(NonNumberToNumeric, CodeStubAssembler) {
}
TF_BUILTIN(ToNumeric, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* input = Parameter(Descriptor::kArgument);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> input = CAST(Parameter(Descriptor::kArgument));
Return(Select(IsNumber(input), [=] { return input; },
[=] { return NonNumberToNumeric(context, input); },
MachineRepresentation::kTagged));
Return(Select<Numeric>(
IsNumber(input), [=] { return CAST(input); },
[=] { return NonNumberToNumeric(context, CAST(input)); }));
}
// ES6 section 7.1.3 ToNumber ( argument )
......
......@@ -75,8 +75,9 @@ TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) {
TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) {
Node* frame = Parameter(Descriptor::kFrame);
Node* length = SmiToIntPtr(Parameter(Descriptor::kLength));
Node* mapped_count = SmiToIntPtr(Parameter(Descriptor::kMappedCount));
TNode<IntPtrT> length = SmiToIntPtr(Parameter(Descriptor::kLength));
TNode<IntPtrT> mapped_count =
SmiToIntPtr(Parameter(Descriptor::kMappedCount));
// Check if we can allocate in new space.
ElementsKind kind = PACKED_ELEMENTS;
......@@ -104,9 +105,7 @@ TF_BUILTIN(NewArgumentsElements, CodeStubAssembler) {
// The elements might be used to back mapped arguments. In that case fill
// the mapped elements (i.e. the first {mapped_count}) with the hole, but
// make sure not to overshoot the {length} if some arguments are missing.
Node* number_of_holes =
SelectConstant(IntPtrLessThan(mapped_count, length), mapped_count,
length, MachineType::PointerRepresentation());
TNode<IntPtrT> number_of_holes = IntPtrMin(mapped_count, length);
Node* the_hole = TheHoleConstant();
// Fill the first elements up to {number_of_holes} with the hole.
......
......@@ -141,14 +141,15 @@ Node* ObjectBuiltinsAssembler::ConstructDataDescriptor(Node* context,
Node* ObjectBuiltinsAssembler::IsSpecialReceiverMap(SloppyTNode<Map> map) {
CSA_SLOW_ASSERT(this, IsMap(map));
Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map));
TNode<BoolT> is_special =
IsSpecialReceiverInstanceType(LoadMapInstanceType(map));
uint32_t mask =
Map::HasNamedInterceptorBit::kMask | Map::IsAccessCheckNeededBit::kMask;
USE(mask);
// Interceptors or access checks imply special receiver.
CSA_ASSERT(this,
SelectConstant(IsSetWord32(LoadMapBitField(map), mask), is_special,
Int32Constant(1), MachineRepresentation::kWord32));
SelectConstant<BoolT>(IsSetWord32(LoadMapBitField(map), mask),
is_special, Int32TrueConstant()));
return is_special;
}
......
......@@ -1185,16 +1185,14 @@ Node* RegExpBuiltinsAssembler::RegExpInitialize(Node* const context,
CSA_ASSERT(this, IsJSRegExp(regexp));
// Normalize pattern.
Node* const pattern = Select<Object>(
TNode<Object> const pattern = Select<Object>(
IsUndefined(maybe_pattern), [=] { return EmptyStringConstant(); },
[=] { return ToString_Inline(context, maybe_pattern); },
MachineRepresentation::kTagged);
[=] { return ToString_Inline(context, maybe_pattern); });
// Normalize flags.
Node* const flags = Select<Object>(
TNode<Object> const flags = Select<Object>(
IsUndefined(maybe_flags), [=] { return EmptyStringConstant(); },
[=] { return ToString_Inline(context, maybe_flags); },
MachineRepresentation::kTagged);
[=] { return ToString_Inline(context, maybe_flags); });
// Initialize.
......
......@@ -1468,10 +1468,9 @@ class StringMatchSearchAssembler : public StringBuiltinsAssembler {
RegExpBuiltinsAssembler regexp_asm(state());
Node* const receiver_string = ToString_Inline(context, receiver);
Node* const pattern = Select(
TNode<Object> const pattern = Select<Object>(
IsUndefined(maybe_regexp), [=] { return EmptyStringConstant(); },
[=] { return ToString_Inline(context, maybe_regexp); },
MachineRepresentation::kTagged);
[=] { return ToString_Inline(context, maybe_regexp); });
// Create RegExp
// TODO(pwong): This could be factored out as a helper (RegExpCreate) that
......@@ -1732,10 +1731,9 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
// String and integer conversions.
Node* const subject_string = ToString_Inline(context, receiver);
Node* const limit_number =
Select(IsUndefined(limit), [=]() { return NumberConstant(kMaxUInt32); },
[=]() { return ToUint32(context, limit); },
MachineRepresentation::kTagged);
TNode<Number> const limit_number = Select<Number>(
IsUndefined(limit), [=] { return NumberConstant(kMaxUInt32); },
[=] { return ToUint32(context, limit); });
Node* const separator_string = ToString_Inline(context, separator);
// Shortcut for {limit} == 0.
......
......@@ -1294,8 +1294,7 @@ TF_BUILTIN(TypedArrayPrototypeSlice, TypedArrayBuiltinsAssembler) {
[=] {
return SmiTag(ConvertToRelativeIndex(
context, end, SmiUntag(source_length)));
},
MachineRepresentation::kTagged);
});
// Create a result array by invoking TypedArraySpeciesCreate.
TNode<Smi> count = SmiMax(SmiSub(end_index, start_index), SmiConstant(0));
......
This diff is collapsed.
......@@ -353,47 +353,47 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* extra_node4 = nullptr, const char* extra_node4_name = "",
Node* extra_node5 = nullptr, const char* extra_node5_name = "");
Node* Select(SloppyTNode<BoolT> condition, const NodeGenerator& true_body,
const NodeGenerator& false_body, MachineRepresentation rep);
template <class A, class F, class G>
TNode<A> Select(SloppyTNode<BoolT> condition, const F& true_body,
const G& false_body, MachineRepresentation rep) {
return UncheckedCast<A>(Select(
const G& false_body) {
return UncheckedCast<A>(SelectImpl(
condition,
[&]() -> Node* { return base::implicit_cast<TNode<A>>(true_body()); },
[&]() -> Node* { return base::implicit_cast<TNode<A>>(false_body()); },
rep));
MachineRepresentationOf<A>::value));
}
Node* SelectConstant(Node* condition, Node* true_value, Node* false_value,
MachineRepresentation rep);
template <class A>
TNode<A> SelectConstant(TNode<BoolT> condition, TNode<A> true_value,
TNode<A> false_value, MachineRepresentation rep) {
return UncheckedCast<A>(
SelectConstant(condition, static_cast<Node*>(true_value),
static_cast<Node*>(false_value), rep));
TNode<A> false_value) {
return Select<A>(condition, [=] { return true_value; },
[=] { return false_value; });
}
Node* SelectInt32Constant(Node* condition, int true_value, int false_value);
Node* SelectIntPtrConstant(Node* condition, int true_value, int false_value);
Node* SelectBooleanConstant(Node* condition);
TNode<Int32T> SelectInt32Constant(SloppyTNode<BoolT> condition,
int true_value, int false_value);
TNode<IntPtrT> SelectIntPtrConstant(SloppyTNode<BoolT> condition,
int true_value, int false_value);
TNode<Oddball> SelectBooleanConstant(SloppyTNode<BoolT> condition);
template <class A>
TNode<A> SelectTaggedConstant(SloppyTNode<BoolT> condition,
TNode<A> true_value,
SloppyTNode<A> false_value) {
static_assert(std::is_base_of<Object, A>::value, "not a tagged type");
return SelectConstant(condition, true_value, false_value,
MachineRepresentation::kTagged);
return SelectConstant<A>(condition, true_value, false_value);
}
Node* SelectSmiConstant(Node* condition, Smi* true_value, Smi* false_value);
Node* SelectSmiConstant(Node* condition, int true_value, Smi* false_value) {
TNode<Smi> SelectSmiConstant(SloppyTNode<BoolT> condition, Smi* true_value,
Smi* false_value);
TNode<Smi> SelectSmiConstant(SloppyTNode<BoolT> condition, int true_value,
Smi* false_value) {
return SelectSmiConstant(condition, Smi::FromInt(true_value), false_value);
}
Node* SelectSmiConstant(Node* condition, Smi* true_value, int false_value) {
TNode<Smi> SelectSmiConstant(SloppyTNode<BoolT> condition, Smi* true_value,
int false_value) {
return SelectSmiConstant(condition, true_value, Smi::FromInt(false_value));
}
Node* SelectSmiConstant(Node* condition, int true_value, int false_value) {
TNode<Smi> SelectSmiConstant(SloppyTNode<BoolT> condition, int true_value,
int false_value) {
return SelectSmiConstant(condition, Smi::FromInt(true_value),
Smi::FromInt(false_value));
}
......@@ -564,7 +564,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// Load the EnumLength of a Map.
Node* LoadMapEnumLength(SloppyTNode<Map> map);
// Load the back-pointer of a Map.
Node* LoadMapBackPointer(SloppyTNode<Map> map);
TNode<Object> LoadMapBackPointer(SloppyTNode<Map> map);
// Load the identity hash of a JSRececiver.
TNode<IntPtrT> LoadJSReceiverIdentityHash(SloppyTNode<Object> receiver,
Label* if_no_hash = nullptr);
......@@ -1135,7 +1135,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* IsFixedTypedArray(Node* object);
Node* IsFunctionWithPrototypeSlotMap(Node* map);
Node* IsHashTable(Node* object);
Node* IsHeapNumber(Node* object);
TNode<BoolT> IsHeapNumber(Node* object);
Node* IsIndirectStringInstanceType(Node* instance_type);
Node* IsJSArrayBuffer(Node* object);
Node* IsJSArrayInstanceType(Node* instance_type);
......@@ -1172,7 +1172,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* IsNumberDictionary(Node* object);
Node* IsOneByteStringInstanceType(Node* instance_type);
Node* IsPrimitiveInstanceType(Node* instance_type);
Node* IsPrivateSymbol(Node* object);
TNode<BoolT> IsPrivateSymbol(Node* object);
Node* IsPromiseCapability(Node* object);
Node* IsPropertyArray(Node* object);
Node* IsPropertyCell(Node* object);
......@@ -1181,7 +1181,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
SloppyTNode<Map> map);
Node* IsSequentialStringInstanceType(Node* instance_type);
Node* IsShortExternalStringInstanceType(Node* instance_type);
Node* IsSpecialReceiverInstanceType(Node* instance_type);
TNode<BoolT> IsSpecialReceiverInstanceType(Node* instance_type);
Node* IsSpecialReceiverMap(Node* map);
Node* IsStringInstanceType(Node* instance_type);
Node* IsString(Node* object);
......@@ -1763,7 +1763,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// used for a property store or deletion.
void CheckForAssociatedProtector(Node* name, Label* if_protector);
Node* LoadReceiverMap(Node* receiver);
TNode<Map> LoadReceiverMap(SloppyTNode<Object> receiver);
// Emits keyed sloppy arguments load. Returns either the loaded value.
Node* LoadKeyedSloppyArguments(Node* receiver, Node* key, Label* bailout) {
......@@ -2057,6 +2057,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Smi> length, TNode<String> first,
TNode<String> second, AllocationFlags flags);
Node* SelectImpl(TNode<BoolT> condition, const NodeGenerator& true_body,
const NodeGenerator& false_body, MachineRepresentation rep);
// Implements DescriptorArray::number_of_entries.
// Returns an untagged int32.
Node* DescriptorArrayNumberOfEntries(Node* descriptors);
......
......@@ -17,14 +17,17 @@ namespace internal {
using compiler::CodeAssemblerState;
using compiler::Node;
using compiler::TNode;
using compiler::SloppyTNode;
//////////////////// Private helpers.
// Loads dataX field from the DataHandler object.
Node* AccessorAssembler::LoadHandlerDataField(Node* handler, int data_index) {
TNode<Object> AccessorAssembler::LoadHandlerDataField(
SloppyTNode<DataHandler> handler, int data_index) {
#ifdef DEBUG
Node* handler_map = LoadMap(handler);
Node* instance_type = LoadMapInstanceType(handler_map);
TNode<Map> handler_map = LoadMap(handler);
TNode<Int32T> instance_type = LoadMapInstanceType(handler_map);
#endif
CSA_ASSERT(this,
Word32Or(InstanceTypeEqual(instance_type, LOAD_HANDLER_TYPE),
......@@ -467,11 +470,10 @@ void AccessorAssembler::HandleLoadICSmiHandlerCase(
// Context is stored either in data2 or data3 field depending on whether
// the access check is enabled for this handler or not.
Node* context_cell = Select(
TNode<Object> context_cell = Select<Object>(
IsSetWord<LoadHandler::DoAccessCheckOnReceiverBits>(handler_word),
[=] { return LoadHandlerDataField(handler, 3); },
[=] { return LoadHandlerDataField(handler, 2); },
MachineRepresentation::kTagged);
[=] { return LoadHandlerDataField(handler, 2); });
Node* context = LoadWeakCellValueUnchecked(context_cell);
Node* foreign =
......@@ -1303,11 +1305,10 @@ void AccessorAssembler::HandleStoreICProtoHandler(
// Context is stored either in data2 or data3 field depending on whether
// the access check is enabled for this handler or not.
Node* context_cell = Select(
TNode<Object> context_cell = Select<Object>(
IsSetWord<LoadHandler::DoAccessCheckOnReceiverBits>(handler_word),
[=] { return LoadHandlerDataField(handler, 3); },
[=] { return LoadHandlerDataField(handler, 2); },
MachineRepresentation::kTagged);
[=] { return LoadHandlerDataField(handler, 2); });
Node* context = LoadWeakCellValueUnchecked(context_cell);
......
......@@ -18,7 +18,11 @@ class ExitPoint;
class AccessorAssembler : public CodeStubAssembler {
public:
typedef compiler::Node Node;
using Node = compiler::Node;
template <class T>
using TNode = compiler::TNode<T>;
template <class T>
using SloppyTNode = compiler::SloppyTNode<T>;
explicit AccessorAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
......@@ -85,7 +89,8 @@ class AccessorAssembler : public CodeStubAssembler {
void LoadIC_BytecodeHandler(const LoadICParameters* p, ExitPoint* exit_point);
// Loads dataX field from the DataHandler object.
Node* LoadHandlerDataField(Node* handler, int data_index);
TNode<Object> LoadHandlerDataField(SloppyTNode<DataHandler> handler,
int data_index);
protected:
struct StoreICParameters : public LoadICParameters {
......
......@@ -20,6 +20,7 @@ namespace internal {
namespace interpreter {
using compiler::Node;
using compiler::TNode;
class IntrinsicsGenerator {
public:
......@@ -132,23 +133,21 @@ Node* IntrinsicsGenerator::CompareInstanceType(Node* object, int type,
}
Node* IntrinsicsGenerator::IsInstanceType(Node* input, int type) {
Node* result =
__ Select(__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] {
return __ SelectBooleanConstant(
CompareInstanceType(input, type, kInstanceTypeEqual));
},
MachineRepresentation::kTagged);
TNode<Oddball> result = __ Select<Oddball>(
__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] {
return __ SelectBooleanConstant(
CompareInstanceType(input, type, kInstanceTypeEqual));
});
return result;
}
Node* IntrinsicsGenerator::IsJSReceiver(
const InterpreterAssembler::RegListNodePair& args, Node* context) {
Node* input = __ LoadRegisterFromRegisterList(args, 0);
Node* result = __ Select(
TNode<Oddball> result = __ Select<Oddball>(
__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] { return __ SelectBooleanConstant(__ IsJSReceiver(input)); },
MachineRepresentation::kTagged);
[=] { return __ SelectBooleanConstant(__ IsJSReceiver(input)); });
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment