Commit 4ef7e3e7 authored by ishell's avatar ishell Committed by Commit bot

[stubs] Fixing loads/stores from arrays by int32 offsets/indices. Step 3.

Review-Url: https://codereview.chromium.org/2319243002
Cr-Commit-Position: refs/heads/master@{#39276}
parent eea147fc
This diff is collapsed.
......@@ -1033,7 +1033,8 @@ Node* CodeStubAssembler::LoadMapPrototype(Node* map) {
}
Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) {
return LoadObjectField(map, Map::kInstanceSizeOffset, MachineType::Uint8());
return ChangeUint32ToWord(
LoadObjectField(map, Map::kInstanceSizeOffset, MachineType::Uint8()));
}
Node* CodeStubAssembler::LoadMapInobjectProperties(Node* map) {
......@@ -1041,9 +1042,19 @@ Node* CodeStubAssembler::LoadMapInobjectProperties(Node* map) {
STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
Assert(Int32GreaterThanOrEqual(LoadMapInstanceType(map),
Int32Constant(FIRST_JS_OBJECT_TYPE)));
return LoadObjectField(
return ChangeUint32ToWord(LoadObjectField(
map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset,
MachineType::Uint8());
MachineType::Uint8()));
}
Node* CodeStubAssembler::LoadMapConstructorFunctionIndex(Node* map) {
// See Map::GetConstructorFunctionIndex() for details.
STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
Assert(Int32LessThanOrEqual(LoadMapInstanceType(map),
Int32Constant(LAST_PRIMITIVE_TYPE)));
return ChangeUint32ToWord(LoadObjectField(
map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset,
MachineType::Uint8()));
}
Node* CodeStubAssembler::LoadMapConstructor(Node* map) {
......@@ -1138,13 +1149,13 @@ Node* CodeStubAssembler::LoadFixedDoubleArrayElement(
Node* CodeStubAssembler::LoadNativeContext(Node* context) {
return LoadFixedArrayElement(context,
Int32Constant(Context::NATIVE_CONTEXT_INDEX));
IntPtrConstant(Context::NATIVE_CONTEXT_INDEX));
}
Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind,
Node* native_context) {
return LoadFixedArrayElement(native_context,
Int32Constant(Context::ArrayMapIndex(kind)));
IntPtrConstant(Context::ArrayMapIndex(kind)));
}
Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) {
......@@ -1411,8 +1422,9 @@ void CodeStubAssembler::FillFixedArrayWithValue(
if (constant_to && constant_from &&
(to - from) <= kElementLoopUnrollThreshold) {
for (int i = from; i < to; ++i) {
Node* index = IntPtrConstant(i);
if (is_double) {
Node* offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode,
Node* offset = ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS,
first_element_offset);
// Don't use doubles to store the hole double, since manipulating the
// signaling NaN used for the hole in C++, e.g. with bit_cast, will
......@@ -1428,14 +1440,14 @@ void CodeStubAssembler::FillFixedArrayWithValue(
} else {
StoreNoWriteBarrier(MachineRepresentation::kWord32, array, offset,
double_hole);
offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode,
offset = ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS,
first_element_offset + kPointerSize);
StoreNoWriteBarrier(MachineRepresentation::kWord32, array, offset,
double_hole);
}
} else {
StoreFixedArrayElement(array, Int32Constant(i), value,
SKIP_WRITE_BARRIER);
StoreFixedArrayElement(array, index, value, SKIP_WRITE_BARRIER,
INTPTR_PARAMETERS);
}
}
} else {
......@@ -1452,8 +1464,8 @@ void CodeStubAssembler::FillFixedArrayWithValue(
Bind(&decrement);
current.Bind(IntPtrSub(
current.value(),
Int32Constant(IsFastDoubleElementsKind(kind) ? kDoubleSize
: kPointerSize)));
IntPtrConstant(IsFastDoubleElementsKind(kind) ? kDoubleSize
: kPointerSize)));
if (is_double) {
// Don't use doubles to store the hole double, since manipulating the
// signaling NaN used for the hole in C++, e.g. with bit_cast, will
......@@ -1495,8 +1507,9 @@ void CodeStubAssembler::CopyFixedArrayElements(ElementsKind kind,
bool double_elements = IsFastDoubleElementsKind(kind);
bool needs_write_barrier =
barrier_mode == UPDATE_WRITE_BARRIER && !IsFastObjectElementsKind(kind);
Node* limit_offset = ElementOffsetFromIndex(
IntPtrConstant(0), kind, mode, FixedArray::kHeaderSize - kHeapObjectTag);
Node* limit_offset =
ElementOffsetFromIndex(IntPtrOrSmiConstant(0, mode), kind, mode,
FixedArray::kHeaderSize - kHeapObjectTag);
Variable current_offset(this, MachineType::PointerRepresentation());
current_offset.Bind(ElementOffsetFromIndex(
element_count, kind, mode, FixedArray::kHeaderSize - kHeapObjectTag));
......@@ -2603,7 +2616,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
Bind(&if_in_field);
{
Node* field_index =
BitFieldDecode<PropertyDetails::FieldIndexField>(details);
BitFieldDecodeWord<PropertyDetails::FieldIndexField>(details);
Node* representation =
BitFieldDecode<PropertyDetails::RepresentationField>(details);
......@@ -2612,15 +2625,15 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
Label if_inobject(this), if_backing_store(this);
Variable var_double_value(this, MachineRepresentation::kFloat64);
Label rebox_double(this, &var_double_value);
BranchIfInt32LessThan(field_index, inobject_properties, &if_inobject,
&if_backing_store);
BranchIfUintPtrLessThan(field_index, inobject_properties, &if_inobject,
&if_backing_store);
Bind(&if_inobject);
{
Comment("if_inobject");
Node* field_offset = ChangeInt32ToIntPtr(
Int32Mul(Int32Sub(LoadMapInstanceSize(map),
Int32Sub(inobject_properties, field_index)),
Int32Constant(kPointerSize)));
Node* field_offset =
IntPtrMul(IntPtrSub(LoadMapInstanceSize(map),
IntPtrSub(inobject_properties, field_index)),
IntPtrConstant(kPointerSize));
Label if_double(this), if_tagged(this);
BranchIfWord32NotEqual(representation,
......@@ -2647,7 +2660,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
{
Comment("if_backing_store");
Node* properties = LoadProperties(object);
field_index = Int32Sub(field_index, inobject_properties);
field_index = IntPtrSub(field_index, inobject_properties);
Node* value = LoadFixedArrayElement(properties, field_index);
Label if_double(this), if_tagged(this);
......@@ -4101,7 +4114,8 @@ void CodeStubAssembler::LoadGlobalIC(const LoadICParameters* p) {
LoadWithVectorDescriptor descriptor(isolate());
Node* native_context = LoadNativeContext(p->context);
Node* receiver = LoadFixedArrayElement(
native_context, Int32Constant(Context::EXTENSION_INDEX));
native_context, IntPtrConstant(Context::EXTENSION_INDEX), 0,
INTPTR_PARAMETERS);
Node* fake_name = IntPtrConstant(0);
TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot,
p->vector);
......
......@@ -230,6 +230,8 @@ class CodeStubAssembler : public compiler::CodeAssembler {
compiler::Node* LoadMapInstanceSize(compiler::Node* map);
// Load the inobject properties count of a Map (valid only for JSObjects).
compiler::Node* LoadMapInobjectProperties(compiler::Node* map);
// Load the constructor function index of a Map (only for primitive maps).
compiler::Node* LoadMapConstructorFunctionIndex(compiler::Node* map);
// Load the constructor of a Map (equivalent to Map::GetConstructor()).
compiler::Node* LoadMapConstructor(compiler::Node* map);
......@@ -251,18 +253,16 @@ class CodeStubAssembler : public compiler::CodeAssembler {
// Load an array element from a FixedArray.
compiler::Node* LoadFixedArrayElement(
compiler::Node* object, compiler::Node* int32_index,
int additional_offset = 0,
compiler::Node* object, compiler::Node* index, int additional_offset = 0,
ParameterMode parameter_mode = INTEGER_PARAMETERS);
// Load an array element from a FixedArray, untag it and return it as Word32.
compiler::Node* LoadAndUntagToWord32FixedArrayElement(
compiler::Node* object, compiler::Node* int32_index,
int additional_offset = 0,
compiler::Node* object, compiler::Node* index, int additional_offset = 0,
ParameterMode parameter_mode = INTEGER_PARAMETERS);
// Load an array element from a FixedDoubleArray.
compiler::Node* LoadFixedDoubleArrayElement(
compiler::Node* object, compiler::Node* int32_index,
MachineType machine_type, int additional_offset = 0,
compiler::Node* object, compiler::Node* index, MachineType machine_type,
int additional_offset = 0,
ParameterMode parameter_mode = INTEGER_PARAMETERS);
// Context manipulation
......
......@@ -2601,7 +2601,7 @@ void ToObjectStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* context = assembler->Parameter(Descriptor::kContext);
Variable constructor_function_index_var(assembler,
MachineRepresentation::kWord32);
MachineType::PointerRepresentation());
assembler->Branch(assembler->WordIsSmi(object), &if_number, &if_notsmi);
......@@ -2618,26 +2618,25 @@ void ToObjectStub::GenerateAssembly(CodeStubAssembler* assembler) const {
instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)),
&if_jsreceiver);
Node* constructor_function_index = assembler->LoadObjectField(
map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset,
MachineType::Uint8());
assembler->GotoIf(
assembler->Word32Equal(
constructor_function_index,
assembler->Int32Constant(Map::kNoConstructorFunctionIndex)),
&if_noconstructor);
Node* constructor_function_index =
assembler->LoadMapConstructorFunctionIndex(map);
assembler->GotoIf(assembler->WordEqual(constructor_function_index,
assembler->IntPtrConstant(
Map::kNoConstructorFunctionIndex)),
&if_noconstructor);
constructor_function_index_var.Bind(constructor_function_index);
assembler->Goto(&if_wrapjsvalue);
assembler->Bind(&if_number);
constructor_function_index_var.Bind(
assembler->Int32Constant(Context::NUMBER_FUNCTION_INDEX));
assembler->IntPtrConstant(Context::NUMBER_FUNCTION_INDEX));
assembler->Goto(&if_wrapjsvalue);
assembler->Bind(&if_wrapjsvalue);
Node* native_context = assembler->LoadNativeContext(context);
Node* constructor = assembler->LoadFixedArrayElement(
native_context, constructor_function_index_var.value());
native_context, constructor_function_index_var.value(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
Node* initial_map = assembler->LoadObjectField(
constructor, JSFunction::kPrototypeOrInitialMapOffset);
Node* js_value = assembler->Allocate(JSValue::kSize);
......@@ -4427,9 +4426,10 @@ void LoadApiGetterStub::GenerateAssembly(CodeStubAssembler* assembler) const {
Node* holder = receiver;
Node* map = assembler->LoadMap(receiver);
Node* descriptors = assembler->LoadMapDescriptors(map);
Node* offset =
assembler->Int32Constant(DescriptorArray::ToValueIndex(index()));
Node* callback = assembler->LoadFixedArrayElement(descriptors, offset);
Node* value_index =
assembler->IntPtrConstant(DescriptorArray::ToValueIndex(index()));
Node* callback = assembler->LoadFixedArrayElement(
descriptors, value_index, 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->TailCallStub(CodeFactory::ApiGetter(isolate()), context, receiver,
holder, callback);
}
......@@ -5193,7 +5193,7 @@ compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
Label if_normal(assembler), if_generator(assembler), if_async(assembler),
if_class_constructor(assembler), if_function_without_prototype(assembler),
load_map(assembler);
Variable map_index(assembler, MachineRepresentation::kTagged);
Variable map_index(assembler, MachineType::PointerRepresentation());
Node* is_not_normal = assembler->Word32And(
compiler_hints,
......@@ -5228,8 +5228,9 @@ compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&if_normal);
{
map_index.Bind(assembler->Select(
is_strict, assembler->Int32Constant(Context::STRICT_FUNCTION_MAP_INDEX),
assembler->Int32Constant(Context::SLOPPY_FUNCTION_MAP_INDEX)));
is_strict,
assembler->IntPtrConstant(Context::STRICT_FUNCTION_MAP_INDEX),
assembler->IntPtrConstant(Context::SLOPPY_FUNCTION_MAP_INDEX)));
assembler->Goto(&load_map);
}
......@@ -5237,8 +5238,8 @@ compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
{
map_index.Bind(assembler->Select(
is_strict,
assembler->Int32Constant(Context::STRICT_GENERATOR_FUNCTION_MAP_INDEX),
assembler->Int32Constant(
assembler->IntPtrConstant(Context::STRICT_GENERATOR_FUNCTION_MAP_INDEX),
assembler->IntPtrConstant(
Context::SLOPPY_GENERATOR_FUNCTION_MAP_INDEX)));
assembler->Goto(&load_map);
}
......@@ -5247,21 +5248,21 @@ compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
{
map_index.Bind(assembler->Select(
is_strict,
assembler->Int32Constant(Context::STRICT_ASYNC_FUNCTION_MAP_INDEX),
assembler->Int32Constant(Context::SLOPPY_ASYNC_FUNCTION_MAP_INDEX)));
assembler->IntPtrConstant(Context::STRICT_ASYNC_FUNCTION_MAP_INDEX),
assembler->IntPtrConstant(Context::SLOPPY_ASYNC_FUNCTION_MAP_INDEX)));
assembler->Goto(&load_map);
}
assembler->Bind(&if_class_constructor);
{
map_index.Bind(
assembler->Int32Constant(Context::STRICT_FUNCTION_MAP_INDEX));
assembler->IntPtrConstant(Context::STRICT_FUNCTION_MAP_INDEX));
assembler->Goto(&load_map);
}
assembler->Bind(&if_function_without_prototype);
{
map_index.Bind(assembler->Int32Constant(
map_index.Bind(assembler->IntPtrConstant(
Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
assembler->Goto(&load_map);
}
......@@ -5272,7 +5273,8 @@ compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
// as the map of the allocated object.
Node* native_context = assembler->LoadNativeContext(context);
Node* map_slot_value =
assembler->LoadFixedArrayElement(native_context, map_index.value());
assembler->LoadFixedArrayElement(native_context, map_index.value(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->StoreMapNoWriteBarrier(result, map_slot_value);
// Initialize the rest of the function.
......
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