Commit b1a5a18d authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

TNodeify Allocate and friends

Tbr: ishell@chromium.org
Bug: v8:8238
Change-Id: I3fe3b821105d2ce58df717970085098f6336f937
Reviewed-on: https://chromium-review.googlesource.com/c/1301512Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57039}
parent 6f08b647
......@@ -82,11 +82,11 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map,
}
bool empty = IsIntPtrOrSmiConstantZero(arguments_count, mode);
DCHECK_IMPLIES(empty, parameter_map_count == nullptr);
Node* size =
TNode<IntPtrT> size =
empty ? IntPtrConstant(base_size)
: ElementOffsetFromIndex(element_count, PACKED_ELEMENTS, mode,
base_size + FixedArray::kHeaderSize);
Node* result = Allocate(size);
TNode<Object> result = Allocate(size);
Comment("Initialize arguments object");
StoreMapNoWriteBarrier(result, map);
Node* empty_fixed_array = LoadRoot(RootIndex::kEmptyFixedArray);
......@@ -104,9 +104,9 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map,
}
Node* parameter_map = nullptr;
if (parameter_map_count != nullptr) {
Node* parameter_map_offset = ElementOffsetFromIndex(
TNode<IntPtrT> parameter_map_offset = ElementOffsetFromIndex(
arguments_count, PACKED_ELEMENTS, mode, FixedArray::kHeaderSize);
parameter_map = InnerAllocate(arguments, parameter_map_offset);
parameter_map = InnerAllocate(CAST(arguments), parameter_map_offset);
StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset,
parameter_map);
Node* sloppy_elements_map =
......
......@@ -860,8 +860,8 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
TNode<Map> array_map =
LoadJSArrayElementsMap(elements_kind, native_context);
TNode<JSArray> array =
CAST(AllocateJSArray(GetInitialFastElementsKind(), array_map, len, len,
nullptr, CodeStubAssembler::SMI_PARAMETERS));
AllocateJSArray(GetInitialFastElementsKind(), array_map, len, len,
nullptr, CodeStubAssembler::SMI_PARAMETERS);
a_.Bind(array);
Goto(&done);
......@@ -909,8 +909,8 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
TNode<Context> native_context = LoadNativeContext(context());
TNode<Map> array_map =
LoadJSArrayElementsMap(elements_kind, native_context);
a_.Bind(AllocateJSArray(PACKED_SMI_ELEMENTS, array_map, len, len, nullptr,
CodeStubAssembler::SMI_PARAMETERS));
a_.Bind(AllocateJSArray(PACKED_SMI_ELEMENTS, array_map, len, CAST(len),
nullptr, CodeStubAssembler::SMI_PARAMETERS));
Goto(&done);
......@@ -1213,8 +1213,9 @@ class ArrayPrototypeSliceCodeStubAssembler : public CodeStubAssembler {
GotoIf(SmiAbove(end, unmapped_elements_length), slow);
Node* array_map = LoadJSArrayElementsMap(HOLEY_ELEMENTS, native_context);
result.Bind(AllocateJSArray(HOLEY_ELEMENTS, array_map, count, count,
TNode<Map> array_map =
LoadJSArrayElementsMap(HOLEY_ELEMENTS, native_context);
result.Bind(AllocateJSArray(HOLEY_ELEMENTS, array_map, count, CAST(count),
nullptr, SMI_PARAMETERS));
index_out.Bind(IntPtrConstant(0));
......@@ -1871,9 +1872,9 @@ class ArrayPopulatorAssembler : public CodeStubAssembler {
TNode<Map> array_map = CAST(LoadContextElement(
context, Context::JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX));
array = CAST(AllocateJSArray(PACKED_SMI_ELEMENTS, array_map,
SmiConstant(0), SmiConstant(0), nullptr,
ParameterMode::SMI_PARAMETERS));
array = AllocateJSArray(PACKED_SMI_ELEMENTS, array_map, SmiConstant(0),
SmiConstant(0), nullptr,
ParameterMode::SMI_PARAMETERS);
Goto(&done);
}
......@@ -4111,8 +4112,8 @@ void ArrayBuiltinsAssembler::GenerateConstructor(
BIND(&small_smi_size);
{
Node* array = AllocateJSArray(
elements_kind, array_map, array_size, array_size,
TNode<JSArray> array = AllocateJSArray(
elements_kind, CAST(array_map), array_size, CAST(array_size),
mode == DONT_TRACK_ALLOCATION_SITE ? nullptr : allocation_site,
CodeStubAssembler::SMI_PARAMETERS);
Return(array);
......@@ -4134,8 +4135,8 @@ void ArrayBuiltinsAssembler::GenerateArrayNoArgumentConstructor(
AllocationSite::ShouldTrack(kind) && mode != DISABLE_ALLOCATION_SITES;
Node* allocation_site =
track_allocation_site ? Parameter(Descriptor::kAllocationSite) : nullptr;
Node* array_map = LoadJSArrayElementsMap(kind, native_context);
Node* array = AllocateJSArray(
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<JSArray> array = AllocateJSArray(
kind, array_map, IntPtrConstant(JSArray::kPreallocatedArrayElements),
SmiConstant(0), allocation_site);
Return(array);
......@@ -4194,9 +4195,10 @@ TF_BUILTIN(ArrayNArgumentsConstructor, ArrayBuiltinsAssembler) {
void ArrayBuiltinsAssembler::GenerateInternalArrayNoArgumentConstructor(
ElementsKind kind) {
typedef ArrayNoArgumentConstructorDescriptor Descriptor;
Node* array_map = LoadObjectField(Parameter(Descriptor::kFunction),
JSFunction::kPrototypeOrInitialMapOffset);
Node* array = AllocateJSArray(
TNode<Map> array_map =
CAST(LoadObjectField(Parameter(Descriptor::kFunction),
JSFunction::kPrototypeOrInitialMapOffset));
TNode<JSArray> array = AllocateJSArray(
kind, array_map, IntPtrConstant(JSArray::kPreallocatedArrayElements),
SmiConstant(0));
Return(array);
......
......@@ -82,12 +82,12 @@ TF_BUILTIN(AsyncFunctionEnter, AsyncFunctionBuiltinsAssembler) {
// Allocate space for the promise, the async function object
// and the register file.
TNode<WordT> size = IntPtrAdd(
TNode<IntPtrT> size = IntPtrAdd(
IntPtrConstant(JSPromise::kSizeWithEmbedderFields +
JSAsyncFunctionObject::kSize + FixedArray::kHeaderSize),
WordShl(parameters_and_register_length,
IntPtrConstant(kPointerSizeLog2)));
Node* base = AllocateInNewSpace(size);
Signed(WordShl(parameters_and_register_length,
IntPtrConstant(kPointerSizeLog2))));
TNode<Object> base = AllocateInNewSpace(size);
// Initialize the register file.
TNode<FixedArray> parameters_and_registers = UncheckedCast<FixedArray>(
......
......@@ -39,8 +39,8 @@ Node* AsyncBuiltinsAssembler::AwaitOld(Node* context, Node* generator,
static const int kTotalSize =
kRejectClosureOffset + JSFunction::kSizeWithoutPrototype;
Node* const base = AllocateInNewSpace(kTotalSize);
Node* const closure_context = base;
TNode<Object> base = AllocateInNewSpace(kTotalSize);
TNode<Context> closure_context = UncheckedCast<Context>(base);
{
// Initialize the await context, storing the {generator} as extension.
StoreMapNoWriteBarrier(closure_context, RootIndex::kAwaitContextMap);
......@@ -69,7 +69,7 @@ Node* AsyncBuiltinsAssembler::AwaitOld(Node* context, Node* generator,
CSA_ASSERT(this, WordEqual(LoadMapInstanceSizeInWords(promise_map),
IntPtrConstant(JSPromise::kSizeWithEmbedderFields /
kPointerSize)));
Node* const wrapped_value = InnerAllocate(base, kWrappedPromiseOffset);
TNode<Object> wrapped_value = InnerAllocate(base, kWrappedPromiseOffset);
{
// Initialize Promise
StoreMapNoWriteBarrier(wrapped_value, promise_map);
......@@ -81,12 +81,12 @@ Node* AsyncBuiltinsAssembler::AwaitOld(Node* context, Node* generator,
}
// Initialize resolve handler
Node* const on_resolve = InnerAllocate(base, kResolveClosureOffset);
TNode<Object> on_resolve = InnerAllocate(base, kResolveClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_resolve,
on_resolve_context_index);
// Initialize reject handler
Node* const on_reject = InnerAllocate(base, kRejectClosureOffset);
TNode<Object> on_reject = InnerAllocate(base, kRejectClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index);
......@@ -132,8 +132,8 @@ Node* AsyncBuiltinsAssembler::AwaitOptimized(Node* context, Node* generator,
// Node* const promise =
// CallBuiltin(Builtins::kPromiseResolve, context, promise_fun, value);
Node* const base = AllocateInNewSpace(kTotalSize);
Node* const closure_context = base;
TNode<Object> base = AllocateInNewSpace(kTotalSize);
TNode<Context> closure_context = UncheckedCast<Context>(base);
{
// Initialize the await context, storing the {generator} as extension.
StoreMapNoWriteBarrier(closure_context, RootIndex::kAwaitContextMap);
......@@ -152,12 +152,12 @@ Node* AsyncBuiltinsAssembler::AwaitOptimized(Node* context, Node* generator,
}
// Initialize resolve handler
Node* const on_resolve = InnerAllocate(base, kResolveClosureOffset);
TNode<Object> on_resolve = InnerAllocate(base, kResolveClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_resolve,
on_resolve_context_index);
// Initialize reject handler
Node* const on_reject = InnerAllocate(base, kRejectClosureOffset);
TNode<Object> on_reject = InnerAllocate(base, kRejectClosureOffset);
InitializeNativeClosure(closure_context, native_context, on_reject,
on_reject_context_index);
......
......@@ -1095,9 +1095,9 @@ TNode<JSArray> CollectionsBuiltinsAssembler::MapIteratorToList(
LoadAndUntagObjectField(table, OrderedHashMap::kNumberOfElementsOffset);
const ElementsKind kind = PACKED_ELEMENTS;
Node* const array_map =
TNode<Map> array_map =
LoadJSArrayElementsMap(kind, LoadNativeContext(context));
Node* const array = AllocateJSArray(kind, array_map, size, SmiTag(size));
TNode<JSArray> array = AllocateJSArray(kind, array_map, size, SmiTag(size));
TNode<FixedArray> elements = CAST(LoadElements(array));
const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
......@@ -1206,9 +1206,9 @@ TNode<JSArray> CollectionsBuiltinsAssembler::SetOrSetIteratorToList(
LoadAndUntagObjectField(table, OrderedHashMap::kNumberOfElementsOffset);
const ElementsKind kind = PACKED_ELEMENTS;
Node* const array_map =
TNode<Map> array_map =
LoadJSArrayElementsMap(kind, LoadNativeContext(context));
Node* const array = AllocateJSArray(kind, array_map, size, SmiTag(size));
TNode<JSArray> array = AllocateJSArray(kind, array_map, size, SmiTag(size));
TNode<FixedArray> elements = CAST(LoadElements(array));
const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
......
......@@ -106,9 +106,9 @@ TF_BUILTIN(FastNewClosure, ConstructorBuiltinsAssembler) {
LoadContextElement(native_context, function_map_index);
// Create a new closure from the given function info in new space
Node* instance_size_in_bytes =
TNode<IntPtrT> instance_size_in_bytes =
TimesPointerSize(LoadMapInstanceSizeInWords(function_map));
Node* const result = Allocate(instance_size_in_bytes);
TNode<Object> result = Allocate(instance_size_in_bytes);
StoreMapNoWriteBarrier(result, function_map);
InitializeJSObjectBodyNoSlackTracking(result, function_map,
instance_size_in_bytes,
......@@ -230,7 +230,8 @@ Node* ConstructorBuiltinsAssembler::EmitFastNewFunctionContext(
ParameterMode mode = INTPTR_PARAMETERS;
Node* min_context_slots = IntPtrConstant(Context::MIN_CONTEXT_SLOTS);
Node* length = IntPtrAdd(slots, min_context_slots);
Node* size = GetFixedArrayAllocationSize(length, PACKED_ELEMENTS, mode);
TNode<IntPtrT> size =
GetFixedArrayAllocationSize(length, PACKED_ELEMENTS, mode);
// Create a new closure from the given function info in new space
TNode<Context> function_context =
......@@ -406,10 +407,10 @@ Node* ConstructorBuiltinsAssembler::EmitCreateEmptyArrayLiteral(
TNode<Int32T> kind = LoadElementsKind(allocation_site.value());
TNode<Context> native_context = LoadNativeContext(context);
Comment("LoadJSArrayElementsMap");
Node* array_map = LoadJSArrayElementsMap(kind, native_context);
Node* zero = SmiConstant(0);
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<Smi> zero = SmiConstant(0);
Comment("Allocate JSArray");
Node* result =
TNode<JSArray> result =
AllocateJSArray(GetInitialFastElementsKind(), array_map, zero, zero,
allocation_site.value(), ParameterMode::SMI_PARAMETERS);
......@@ -492,9 +493,9 @@ Node* ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
// Ensure new-space allocation for a fresh JSObject so we can skip write
// barriers when copying all object fields.
STATIC_ASSERT(JSObject::kMaxInstanceSize < kMaxRegularHeapObjectSize);
Node* instance_size =
TNode<IntPtrT> instance_size =
TimesPointerSize(LoadMapInstanceSizeInWords(boilerplate_map));
Node* allocation_size = instance_size;
TNode<IntPtrT> allocation_size = instance_size;
bool needs_allocation_memento = FLAG_allocation_site_pretenuring;
if (needs_allocation_memento) {
// Prepare for inner-allocating the AllocationMemento.
......@@ -502,7 +503,8 @@ Node* ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
IntPtrAdd(instance_size, IntPtrConstant(AllocationMemento::kSize));
}
Node* copy = AllocateInNewSpace(allocation_size);
TNode<HeapObject> copy =
UncheckedCast<HeapObject>(AllocateInNewSpace(allocation_size));
{
Comment("Initialize Literal Copy");
// Initialize Object fields.
......
......@@ -188,10 +188,10 @@ void IntlBuiltinsAssembler::ListFormatCommon(TNode<Context> context,
TNode<JSArray> IntlBuiltinsAssembler::AllocateEmptyJSArray(
TNode<Context> context) {
return CAST(CodeStubAssembler::AllocateJSArray(
return CodeStubAssembler::AllocateJSArray(
PACKED_ELEMENTS,
LoadJSArrayElementsMap(PACKED_ELEMENTS, LoadNativeContext(context)),
SmiConstant(0), SmiConstant(0)));
SmiConstant(0), SmiConstant(0));
}
TF_BUILTIN(ListFormatPrototypeFormat, IntlBuiltinsAssembler) {
......
......@@ -218,9 +218,10 @@ void ObjectEntriesValuesBuiltinsAssembler::GetOwnValuesOrEntries(
BIND(&if_no_properties);
{
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* empty_array = AllocateJSArray(PACKED_ELEMENTS, array_map,
IntPtrConstant(0), SmiConstant(0));
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<JSArray> empty_array = AllocateJSArray(
PACKED_ELEMENTS, array_map, IntPtrConstant(0), SmiConstant(0));
Return(empty_array);
}
......@@ -609,8 +610,9 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) {
Node* array = nullptr;
Node* elements = nullptr;
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* array_length = SmiTag(object_enum_length);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<Smi> array_length = SmiTag(object_enum_length);
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
PACKED_ELEMENTS, array_map, array_length, nullptr, object_enum_length,
INTPTR_PARAMETERS);
......@@ -640,9 +642,10 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) {
{
// Wrap the elements into a proper JSArray and return that.
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* array = AllocateUninitializedJSArrayWithoutElements(
array_map, var_length.value(), nullptr);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<JSArray> array = AllocateUninitializedJSArrayWithoutElements(
array_map, CAST(var_length.value()), nullptr);
StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset,
var_elements.value());
Return(array);
......@@ -700,8 +703,9 @@ TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) {
Node* array = nullptr;
Node* elements = nullptr;
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* array_length = SmiTag(object_enum_length);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<Smi> array_length = SmiTag(object_enum_length);
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
PACKED_ELEMENTS, array_map, array_length, nullptr, object_enum_length,
INTPTR_PARAMETERS);
......@@ -742,9 +746,10 @@ TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) {
{
// Wrap the elements into a proper JSArray and return that.
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* array = AllocateUninitializedJSArrayWithoutElements(
array_map, var_length.value(), nullptr);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<JSArray> array = AllocateUninitializedJSArrayWithoutElements(
array_map, CAST(var_length.value()), nullptr);
StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset,
var_elements.value());
Return(array);
......
......@@ -203,10 +203,10 @@ Node* PromiseBuiltinsAssembler::CreatePromiseAllResolveElementContext(
CSA_ASSERT(this, IsNativeContext(native_context));
// TODO(bmeurer): Manually fold this into a single allocation.
Node* const array_map = LoadContextElement(
native_context, Context::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX);
Node* const values_array = AllocateJSArray(PACKED_ELEMENTS, array_map,
IntPtrConstant(0), SmiConstant(0));
TNode<Map> array_map = CAST(LoadContextElement(
native_context, Context::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX));
TNode<JSArray> values_array = AllocateJSArray(
PACKED_ELEMENTS, array_map, IntPtrConstant(0), SmiConstant(0));
Node* const context =
CreatePromiseContext(native_context, kPromiseAllResolveElementLength);
......
......@@ -113,8 +113,10 @@ Node* ProxiesCodeStubAssembler::AllocateJSArrayForCodeStubArguments(
BIND(&allocate_js_array);
// Allocate the result JSArray.
Node* native_context = LoadNativeContext(context);
Node* array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
Node* array = AllocateUninitializedJSArrayWithoutElements(array_map, length);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<JSArray> array =
AllocateUninitializedJSArrayWithoutElements(array_map, length);
StoreObjectFieldNoWriteBarrier(array, JSObject::kElementsOffset,
elements.value());
......
......@@ -58,8 +58,8 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::AllocateRegExpResult(
// The folded allocation.
Node* result = Allocate(total_size);
Node* elements = InnerAllocate(result, kElementsOffset);
TNode<Object> result = Allocate(total_size);
TNode<Object> elements = InnerAllocate(result, kElementsOffset);
// Initialize the JSRegExpResult.
......@@ -2132,7 +2132,7 @@ TNode<Object> RegExpBuiltinsAssembler::MatchAllIterator(
// 4. Let iterator be ObjectCreate(%RegExpStringIteratorPrototype%, «
// [[IteratingRegExp]], [[IteratedString]], [[Global]], [[Unicode]],
// [[Done]] »).
TNode<Object> iterator = CAST(Allocate(JSRegExpStringIterator::kSize));
TNode<Object> iterator = Allocate(JSRegExpStringIterator::kSize);
StoreMapNoWriteBarrier(iterator, map);
StoreObjectFieldRoot(iterator,
JSRegExpStringIterator::kPropertiesOrHashOffset,
......@@ -2366,7 +2366,7 @@ void RegExpBuiltinsAssembler::RegExpPrototypeSplitBody(Node* const context,
Node* const allocation_site = nullptr;
Node* const native_context = LoadNativeContext(context);
Node* const array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
Label return_empty_array(this, Label::kDeferred);
......@@ -2400,12 +2400,12 @@ void RegExpBuiltinsAssembler::RegExpPrototypeSplitBody(Node* const context,
BIND(&return_singleton_array);
{
Node* const length = SmiConstant(1);
Node* const capacity = IntPtrConstant(1);
Node* const result = AllocateJSArray(kind, array_map, capacity, length,
allocation_site, mode);
TNode<Smi> length = SmiConstant(1);
TNode<IntPtrT> capacity = IntPtrConstant(1);
TNode<JSArray> result = AllocateJSArray(kind, array_map, capacity,
length, allocation_site, mode);
TNode<FixedArray> const fixed_array = CAST(LoadElements(result));
TNode<FixedArray> fixed_array = CAST(LoadElements(result));
StoreFixedArrayElement(fixed_array, 0, string);
Return(result);
......@@ -2577,10 +2577,10 @@ void RegExpBuiltinsAssembler::RegExpPrototypeSplitBody(Node* const context,
BIND(&return_empty_array);
{
Node* const length = SmiZero();
Node* const capacity = IntPtrZero();
Node* const result = AllocateJSArray(kind, array_map, capacity, length,
allocation_site, mode);
TNode<Smi> length = SmiZero();
TNode<IntPtrT> capacity = IntPtrZero();
TNode<JSArray> result = AllocateJSArray(kind, array_map, capacity, length,
allocation_site, mode);
Return(result);
}
}
......@@ -2702,7 +2702,7 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
Node* result_array;
{
ElementsKind kind = PACKED_ELEMENTS;
Node* const array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<IntPtrT> capacity = IntPtrConstant(16);
TNode<Smi> length = SmiZero();
Node* const allocation_site = nullptr;
......
......@@ -1800,8 +1800,8 @@ TNode<JSArray> StringBuiltinsAssembler::StringToArray(
1, ParameterMode::INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
TNode<Map> array_map = LoadJSArrayElementsMap(PACKED_ELEMENTS, context);
result_array = CAST(
AllocateUninitializedJSArrayWithoutElements(array_map, length_smi));
result_array =
AllocateUninitializedJSArrayWithoutElements(array_map, length_smi);
StoreObjectField(result_array.value(), JSObject::kElementsOffset, elements);
Goto(&done);
......@@ -1878,13 +1878,13 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
const ElementsKind kind = PACKED_ELEMENTS;
Node* const native_context = LoadNativeContext(context);
Node* const array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
Node* const length = SmiConstant(1);
Node* const capacity = IntPtrConstant(1);
Node* const result = AllocateJSArray(kind, array_map, capacity, length);
TNode<Smi> length = SmiConstant(1);
TNode<IntPtrT> capacity = IntPtrConstant(1);
TNode<JSArray> result = AllocateJSArray(kind, array_map, capacity, length);
TNode<FixedArray> const fixed_array = CAST(LoadElements(result));
TNode<FixedArray> fixed_array = CAST(LoadElements(result));
StoreFixedArrayElement(fixed_array, 0, subject_string);
args.PopAndReturn(result);
......@@ -1916,11 +1916,11 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
{
const ElementsKind kind = PACKED_ELEMENTS;
Node* const native_context = LoadNativeContext(context);
Node* const array_map = LoadJSArrayElementsMap(kind, native_context);
TNode<Map> array_map = LoadJSArrayElementsMap(kind, native_context);
Node* const length = smi_zero;
Node* const capacity = IntPtrConstant(0);
Node* const result = AllocateJSArray(kind, array_map, capacity, length);
TNode<Smi> length = smi_zero;
TNode<IntPtrT> capacity = IntPtrConstant(0);
TNode<JSArray> result = AllocateJSArray(kind, array_map, capacity, length);
args.PopAndReturn(result);
}
......@@ -2498,11 +2498,12 @@ TNode<JSArray> StringBuiltinsAssembler::StringToList(TNode<Context> context,
const ElementsKind kind = PACKED_ELEMENTS;
const TNode<IntPtrT> length = LoadStringLengthAsWord(string);
Node* const array_map =
TNode<Map> array_map =
LoadJSArrayElementsMap(kind, LoadNativeContext(context));
// Allocate the array to new space, assuming that the new array will fit in.
Node* const array = AllocateJSArray(kind, array_map, length, SmiTag(length));
Node* const elements = LoadElements(array);
TNode<JSArray> array =
AllocateJSArray(kind, array_map, length, SmiTag(length));
TNode<FixedArrayBase> elements = LoadElements(array);
const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
TNode<IntPtrT> first_to_element_offset =
......
......@@ -56,9 +56,8 @@ TNode<JSArray> GrowableFixedArray::ToJSArray(TNode<Context> const context) {
}
TNode<Smi> const result_length = SmiTag(length());
TNode<JSArray> const result =
CAST(AllocateUninitializedJSArrayWithoutElements(array_map, result_length,
nullptr));
TNode<JSArray> const result = AllocateUninitializedJSArrayWithoutElements(
array_map, result_length, nullptr);
StoreObjectField(result, JSObject::kElementsOffset, var_array_.value());
......
This diff is collapsed.
......@@ -647,13 +647,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Number> BitwiseOp(Node* left32, Node* right32, Operation bitwise_op);
// Allocate an object of the given size.
Node* AllocateInNewSpace(Node* size, AllocationFlags flags = kNone);
Node* AllocateInNewSpace(int size, AllocationFlags flags = kNone);
Node* Allocate(Node* size, AllocationFlags flags = kNone);
Node* Allocate(int size, AllocationFlags flags = kNone);
Node* InnerAllocate(Node* previous, int offset);
Node* InnerAllocate(Node* previous, Node* offset);
Node* IsRegularHeapObjectSize(Node* size);
TNode<Object> AllocateInNewSpace(TNode<IntPtrT> size,
AllocationFlags flags = kNone);
TNode<Object> AllocateInNewSpace(int size, AllocationFlags flags = kNone);
TNode<Object> Allocate(TNode<IntPtrT> size, AllocationFlags flags = kNone);
TNode<Object> Allocate(int size, AllocationFlags flags = kNone);
TNode<Object> InnerAllocate(TNode<Object> previous, int offset);
TNode<Object> InnerAllocate(TNode<Object> previous, TNode<IntPtrT> offset);
TNode<BoolT> IsRegularHeapObjectSize(TNode<IntPtrT> size);
typedef std::function<void(Label*, Label*)> BranchGenerator;
typedef std::function<Node*()> NodeGenerator;
......@@ -1460,28 +1462,33 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
int start_offset = JSObject::kHeaderSize);
// Allocate a JSArray without elements and initialize the header fields.
Node* AllocateUninitializedJSArrayWithoutElements(
Node* array_map, Node* length, Node* allocation_site = nullptr);
TNode<JSArray> AllocateUninitializedJSArrayWithoutElements(
TNode<Map> array_map, TNode<Smi> length, Node* allocation_site = nullptr);
//
// Allocate and return a JSArray with initialized header fields and its
// uninitialized elements.
// The ParameterMode argument is only used for the capacity parameter.
std::pair<Node*, Node*> AllocateUninitializedJSArrayWithElements(
ElementsKind kind, Node* array_map, Node* length, Node* allocation_site,
Node* capacity, ParameterMode capacity_mode = INTPTR_PARAMETERS);
std::pair<TNode<JSArray>, TNode<FixedArrayBase>>
AllocateUninitializedJSArrayWithElements(
ElementsKind kind, TNode<Map> array_map, TNode<Smi> length,
Node* allocation_site, Node* capacity,
ParameterMode capacity_mode = INTPTR_PARAMETERS);
// Allocate a JSArray and fill elements with the hole.
// The ParameterMode argument is only used for the capacity parameter.
Node* AllocateJSArray(ElementsKind kind, Node* array_map, Node* capacity,
Node* length, Node* allocation_site = nullptr,
ParameterMode capacity_mode = INTPTR_PARAMETERS);
TNode<JSArray> AllocateJSArray(
ElementsKind kind, TNode<Map> array_map, Node* capacity,
TNode<Smi> length, Node* allocation_site = nullptr,
ParameterMode capacity_mode = INTPTR_PARAMETERS);
Node* AllocateJSArray(ElementsKind kind, TNode<Map> array_map,
TNode<Smi> capacity, TNode<Smi> length) {
TNode<JSArray> AllocateJSArray(ElementsKind kind, TNode<Map> array_map,
TNode<Smi> capacity, TNode<Smi> length) {
return AllocateJSArray(kind, array_map, capacity, length, nullptr,
SMI_PARAMETERS);
}
Node* AllocateJSArray(ElementsKind kind, TNode<Map> array_map,
TNode<IntPtrT> capacity, TNode<Smi> length) {
TNode<JSArray> AllocateJSArray(ElementsKind kind, TNode<Map> array_map,
TNode<IntPtrT> capacity, TNode<Smi> length) {
return AllocateJSArray(kind, array_map, capacity, length, nullptr,
INTPTR_PARAMETERS);
}
......@@ -3192,17 +3199,24 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
void HandleBreakOnNode();
Node* AllocateRawDoubleAligned(Node* size_in_bytes, AllocationFlags flags,
Node* top_address, Node* limit_address);
Node* AllocateRawUnaligned(Node* size_in_bytes, AllocationFlags flags,
Node* top_adddress, Node* limit_address);
Node* AllocateRaw(Node* size_in_bytes, AllocationFlags flags,
Node* top_address, Node* limit_address);
TNode<Object> AllocateRawDoubleAligned(TNode<IntPtrT> size_in_bytes,
AllocationFlags flags,
TNode<RawPtrT> top_address,
TNode<RawPtrT> limit_address);
TNode<Object> AllocateRawUnaligned(TNode<IntPtrT> size_in_bytes,
AllocationFlags flags,
TNode<RawPtrT> top_address,
TNode<RawPtrT> limit_address);
TNode<Object> AllocateRaw(TNode<IntPtrT> size_in_bytes, AllocationFlags flags,
TNode<RawPtrT> top_address,
TNode<RawPtrT> limit_address);
// Allocate and return a JSArray of given total size in bytes with header
// fields initialized.
Node* AllocateUninitializedJSArray(Node* array_map, Node* length,
Node* allocation_site,
Node* size_in_bytes);
TNode<JSArray> AllocateUninitializedJSArray(TNode<Map> array_map,
TNode<Smi> length,
Node* allocation_site,
TNode<IntPtrT> size_in_bytes);
TNode<BoolT> IsValidSmi(TNode<Smi> smi);
Node* SmiShiftBitsConstant();
......
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