Commit 4aa00d14 authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Add new CSA routines needed by Torque

Currently these new functions are unused and untested, but will be used once
Torque is checked in. They are split off into this separate CL to ease rollback
of Torque if required.

Change-Id: If2b96f342011592ae7cd88a4f6d9a4f2acc3643e
Reviewed-on: https://chromium-review.googlesource.com/998171
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52460}
parent 9c9e4583
......@@ -90,8 +90,8 @@ TNode<FixedArray> GrowableFixedArray::ResizeFixedArray(
CodeStubAssembler::ExtractFixedArrayFlags flags;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kFixedArrays;
TNode<FixedArray> to_array = CAST(ExtractFixedArray(
from_array, nullptr, element_count, new_capacity, flags));
TNode<FixedArray> to_array = ExtractFixedArray(
from_array, nullptr, element_count, new_capacity, flags);
return to_array;
}
......
......@@ -2175,6 +2175,16 @@ Node* CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset,
}
}
Node* CodeStubAssembler::StoreJSArrayLength(TNode<JSArray> array,
TNode<Smi> length) {
return StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
}
Node* CodeStubAssembler::StoreElements(TNode<Object> object,
TNode<FixedArrayBase> elements) {
return StoreObjectField(object, JSObject::kElementsOffset, elements);
}
Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node,
Node* value,
WriteBarrierMode barrier_mode,
......@@ -3200,10 +3210,9 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
return array;
}
Node* CodeStubAssembler::ExtractFixedArray(Node* fixed_array, Node* first,
Node* count, Node* capacity,
ExtractFixedArrayFlags extract_flags,
ParameterMode parameter_mode) {
TNode<FixedArray> CodeStubAssembler::ExtractFixedArray(
Node* fixed_array, Node* first, Node* count, Node* capacity,
ExtractFixedArrayFlags extract_flags, ParameterMode parameter_mode) {
VARIABLE(var_result, MachineRepresentation::kTagged);
VARIABLE(var_fixed_array_map, MachineRepresentation::kTagged);
const AllocationFlags flags =
......@@ -3344,7 +3353,7 @@ Node* CodeStubAssembler::ExtractFixedArray(Node* fixed_array, Node* first,
}
BIND(&done);
return var_result.value();
return UncheckedCast<FixedArray>(var_result.value());
}
void CodeStubAssembler::InitializePropertyArrayLength(Node* property_array,
......@@ -3574,6 +3583,18 @@ void CodeStubAssembler::CopyFixedArrayElements(
Comment("] CopyFixedArrayElements");
}
TNode<FixedArray> CodeStubAssembler::ConvertFixedArrayBaseToFixedArray(
TNode<FixedArrayBase> base, Label* cast_fail) {
Label fixed_array(this);
TNode<Map> map = LoadMap(base);
GotoIf(WordEqual(map, LoadRoot(Heap::kFixedArrayMapRootIndex)), &fixed_array);
GotoIf(WordNotEqual(map, LoadRoot(Heap::kFixedCOWArrayMapRootIndex)),
cast_fail);
Goto(&fixed_array);
BIND(&fixed_array);
return UncheckedCast<FixedArray>(base);
}
void CodeStubAssembler::CopyPropertyArrayValues(Node* from_array,
Node* to_array,
Node* property_count,
......@@ -5334,6 +5355,16 @@ void CodeStubAssembler::BranchIfCanDerefIndirectString(Node* string,
Goto(cannot_deref);
}
Node* CodeStubAssembler::DerefIndirectString(TNode<String> string,
TNode<Int32T> instance_type,
Label* cannot_deref) {
Label deref(this);
BranchIfCanDerefIndirectString(string, instance_type, &deref, cannot_deref);
BIND(&deref);
STATIC_ASSERT(ThinString::kActualOffset == ConsString::kFirstOffset);
return LoadObjectField(string, ThinString::kActualOffset);
}
void CodeStubAssembler::DerefIndirectString(Variable* var_string,
Node* instance_type) {
#ifdef DEBUG
......@@ -10755,6 +10786,15 @@ Node* CodeStubAssembler::AllocateJSIteratorResultForEntry(Node* context,
return result;
}
Node* CodeStubAssembler::ArraySpeciesCreate(TNode<Context> context,
TNode<Object> o,
TNode<Number> len) {
Node* constructor =
CallRuntime(Runtime::kArraySpeciesConstructor, context, o);
return ConstructJS(CodeFactory::Construct(isolate()), context, constructor,
len);
}
Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) {
CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE));
......@@ -10811,7 +10851,7 @@ TNode<Object> CodeStubArguments::AtIndex(int index) const {
}
TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
int index, SloppyTNode<Object> default_value) {
int index, TNode<Object> default_value) {
CodeStubAssembler::TVariable<Object> result(assembler_);
CodeStubAssembler::Label argument_missing(assembler_),
argument_done(assembler_, &result);
......@@ -10831,6 +10871,27 @@ TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
return result.value();
}
TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
TNode<IntPtrT> index, TNode<Object> default_value) {
CodeStubAssembler::TVariable<Object> result(assembler_);
CodeStubAssembler::Label argument_missing(assembler_),
argument_done(assembler_, &result);
assembler_->GotoIf(
assembler_->UintPtrOrSmiGreaterThanOrEqual(
assembler_->IntPtrToParameter(index, argc_mode_), argc_, argc_mode_),
&argument_missing);
result = AtIndex(index);
assembler_->Goto(&argument_done);
assembler_->BIND(&argument_missing);
result = default_value;
assembler_->Goto(&argument_done);
assembler_->BIND(&argument_done);
return result.value();
}
void CodeStubArguments::ForEach(
const CodeStubAssembler::VariableList& vars,
const CodeStubArguments::ForEachBodyFunction& body, Node* first, Node* last,
......@@ -10882,6 +10943,11 @@ Node* CodeStubAssembler::IsFastSmiOrTaggedElementsKind(Node* elements_kind) {
Int32Constant(TERMINAL_FAST_ELEMENTS_KIND));
}
Node* CodeStubAssembler::IsFastSmiElementsKind(Node* elements_kind) {
return Uint32LessThanOrEqual(elements_kind,
Int32Constant(HOLEY_SMI_ELEMENTS));
}
Node* CodeStubAssembler::IsHoleyFastElementsKind(Node* elements_kind) {
CSA_ASSERT(this, IsFastElementsKind(elements_kind));
......@@ -11117,6 +11183,20 @@ Node* CodeStubAssembler::CheckEnumCache(Node* receiver, Label* if_empty,
return receiver_map;
}
TNode<IntPtrT> CodeStubAssembler::GetArgumentsLength(CodeStubArguments* args) {
return args->GetLength();
}
TNode<Object> CodeStubAssembler::GetArgumentValue(CodeStubArguments* args,
TNode<IntPtrT> index) {
return args->GetOptionalArgumentValue(index);
}
TNode<Object> CodeStubAssembler::GetArgumentValue(CodeStubArguments* args,
TNode<Smi> index) {
return args->GetOptionalArgumentValue(SmiUntag(index));
}
void CodeStubAssembler::Print(const char* s) {
std::string formatted(s);
formatted += "\n";
......
This diff is collapsed.
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