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
......@@ -1269,24 +1269,24 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
Node* start_from = assembler->Parameter(2);
Node* context = assembler->Parameter(3 + 2);
Node* int32_zero = assembler->Int32Constant(0);
Node* int32_one = assembler->Int32Constant(1);
Node* intptr_zero = assembler->IntPtrConstant(0);
Node* intptr_one = assembler->IntPtrConstant(1);
Node* the_hole = assembler->TheHoleConstant();
Node* undefined = assembler->UndefinedConstant();
Node* heap_number_map = assembler->HeapNumberMapConstant();
Variable len_var(assembler, MachineRepresentation::kWord32),
index_var(assembler, MachineRepresentation::kWord32),
start_from_var(assembler, MachineRepresentation::kWord32);
Variable len_var(assembler, MachineType::PointerRepresentation()),
index_var(assembler, MachineType::PointerRepresentation()),
start_from_var(assembler, MachineType::PointerRepresentation());
Label init_k(assembler), return_true(assembler), return_false(assembler),
call_runtime(assembler);
Label init_len(assembler);
index_var.Bind(int32_zero);
len_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
len_var.Bind(intptr_zero);
// Take slow path if not a JSArray, if retrieving elements requires
// traversing prototype, or if access checks are required.
......@@ -1299,7 +1299,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime);
len_var.Bind(assembler->SmiToWord(len));
assembler->Branch(assembler->Word32Equal(len_var.value(), int32_zero),
assembler->Branch(assembler->WordEqual(len_var.value(), intptr_zero),
&return_false, &init_k);
}
......@@ -1315,23 +1315,25 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->Bind(&init_k_smi);
{
start_from_var.Bind(assembler->SmiToWord32(tagged_n));
start_from_var.Bind(assembler->SmiUntag(tagged_n));
assembler->Goto(&init_k_n);
}
assembler->Bind(&init_k_heap_num);
{
Label do_return_false(assembler);
Node* fp_len = assembler->ChangeInt32ToFloat64(len_var.value());
// This round is lossless for all valid lengths.
Node* fp_len = assembler->RoundIntPtrToFloat64(len_var.value());
Node* fp_n = assembler->LoadHeapNumberValue(tagged_n);
assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len),
&do_return_false);
start_from_var.Bind(assembler->TruncateFloat64ToWord32(fp_n));
start_from_var.Bind(assembler->ChangeInt32ToIntPtr(
assembler->TruncateFloat64ToWord32(fp_n)));
assembler->Goto(&init_k_n);
assembler->Bind(&do_return_false);
{
index_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
assembler->Goto(&return_false);
}
}
......@@ -1340,7 +1342,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label if_positive(assembler), if_negative(assembler), done(assembler);
assembler->Branch(
assembler->Int32LessThan(start_from_var.value(), int32_zero),
assembler->IntPtrLessThan(start_from_var.value(), intptr_zero),
&if_negative, &if_positive);
assembler->Bind(&if_positive);
......@@ -1352,15 +1354,15 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->Bind(&if_negative);
{
index_var.Bind(
assembler->Int32Add(len_var.value(), start_from_var.value()));
assembler->IntPtrAdd(len_var.value(), start_from_var.value()));
assembler->Branch(
assembler->Int32LessThan(index_var.value(), int32_zero),
assembler->IntPtrLessThan(index_var.value(), intptr_zero),
&init_k_zero, &done);
}
assembler->Bind(&init_k_zero);
{
index_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
assembler->Goto(&done);
}
......@@ -1416,7 +1418,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
&string_loop);
assembler->GotoIf(
assembler->WordEqual(search_type,
assembler->Word32Equal(search_type,
assembler->Int32Constant(SIMD128_VALUE_TYPE)),
&simd_loop);
assembler->Goto(&ident_loop);
......@@ -1424,30 +1426,30 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->Bind(&ident_loop);
{
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordEqual(element_k, search_element),
&return_true);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&ident_loop);
}
assembler->Bind(&undef_loop);
{
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordEqual(element_k, undefined),
&return_true);
assembler->GotoIf(assembler->WordEqual(element_k, the_hole),
&return_true);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&undef_loop);
}
......@@ -1462,10 +1464,11 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler), not_smi(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi);
assembler->Branch(
assembler->Float64Equal(search_num.value(),
......@@ -1481,7 +1484,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
&return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
......@@ -1489,10 +1492,11 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k),
heap_number_map),
......@@ -1502,7 +1506,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
&continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&nan_loop);
}
}
......@@ -1511,10 +1515,10 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
assembler->GotoUnless(assembler->Int32LessThan(
assembler->LoadInstanceType(element_k),
......@@ -1530,7 +1534,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
&return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&string_loop);
}
......@@ -1543,11 +1547,11 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->Goto(&loop_body);
assembler->Bind(&loop_body);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
Node* map_k = assembler->LoadMap(element_k);
......@@ -1555,7 +1559,7 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
&return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&loop_body);
}
}
......@@ -1585,14 +1589,15 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64Equal(element_k, search_num.value(),
&return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
......@@ -1601,13 +1606,14 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&nan_loop);
}
}
......@@ -1639,19 +1645,21 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
if (kPointerSize == kDoubleSize) {
Node* element = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint64());
elements, index_var.value(), MachineType::Uint64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
assembler->GotoIf(assembler->Word64Equal(element, the_hole),
&continue_loop);
} else {
Node* element_upper = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint32(),
kIeeeDoubleExponentWordOffset);
kIeeeDoubleExponentWordOffset,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(
assembler->Word32Equal(element_upper,
assembler->Int32Constant(kHoleNanUpper32)),
......@@ -1659,11 +1667,12 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
}
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64Equal(element_k, search_num.value(),
&return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
......@@ -1672,19 +1681,21 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
if (kPointerSize == kDoubleSize) {
Node* element = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint64());
elements, index_var.value(), MachineType::Uint64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
assembler->GotoIf(assembler->Word64Equal(element, the_hole),
&continue_loop);
} else {
Node* element_upper = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint32(),
kIeeeDoubleExponentWordOffset);
kIeeeDoubleExponentWordOffset,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(
assembler->Word32Equal(element_upper,
assembler->Int32Constant(kHoleNanUpper32)),
......@@ -1692,10 +1703,11 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
}
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&nan_loop);
}
......@@ -1703,26 +1715,28 @@ void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
assembler->Bind(&hole_loop);
{
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_false);
if (kPointerSize == kDoubleSize) {
Node* element = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint64());
elements, index_var.value(), MachineType::Uint64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
assembler->GotoIf(assembler->Word64Equal(element, the_hole),
&return_true);
} else {
Node* element_upper = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint32(),
kIeeeDoubleExponentWordOffset);
kIeeeDoubleExponentWordOffset,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(
assembler->Word32Equal(element_upper,
assembler->Int32Constant(kHoleNanUpper32)),
&return_true);
}
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&hole_loop);
}
}
......@@ -1749,23 +1763,23 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
Node* start_from = assembler->Parameter(2);
Node* context = assembler->Parameter(3 + 2);
Node* int32_zero = assembler->Int32Constant(0);
Node* int32_one = assembler->Int32Constant(1);
Node* intptr_zero = assembler->IntPtrConstant(0);
Node* intptr_one = assembler->IntPtrConstant(1);
Node* undefined = assembler->UndefinedConstant();
Node* heap_number_map = assembler->HeapNumberMapConstant();
Variable len_var(assembler, MachineRepresentation::kWord32),
index_var(assembler, MachineRepresentation::kWord32),
start_from_var(assembler, MachineRepresentation::kWord32);
Variable len_var(assembler, MachineType::PointerRepresentation()),
index_var(assembler, MachineType::PointerRepresentation()),
start_from_var(assembler, MachineType::PointerRepresentation());
Label init_k(assembler), return_found(assembler), return_not_found(assembler),
call_runtime(assembler);
Label init_len(assembler);
index_var.Bind(int32_zero);
len_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
len_var.Bind(intptr_zero);
// Take slow path if not a JSArray, if retrieving elements requires
// traversing prototype, or if access checks are required.
......@@ -1778,7 +1792,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime);
len_var.Bind(assembler->SmiToWord(len));
assembler->Branch(assembler->Word32Equal(len_var.value(), int32_zero),
assembler->Branch(assembler->WordEqual(len_var.value(), intptr_zero),
&return_not_found, &init_k);
}
......@@ -1794,23 +1808,25 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
assembler->Bind(&init_k_smi);
{
start_from_var.Bind(assembler->SmiToWord32(tagged_n));
start_from_var.Bind(assembler->SmiUntag(tagged_n));
assembler->Goto(&init_k_n);
}
assembler->Bind(&init_k_heap_num);
{
Label do_return_not_found(assembler);
Node* fp_len = assembler->ChangeInt32ToFloat64(len_var.value());
// This round is lossless for all valid lengths.
Node* fp_len = assembler->RoundIntPtrToFloat64(len_var.value());
Node* fp_n = assembler->LoadHeapNumberValue(tagged_n);
assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len),
&do_return_not_found);
start_from_var.Bind(assembler->TruncateFloat64ToWord32(fp_n));
start_from_var.Bind(assembler->ChangeInt32ToIntPtr(
assembler->TruncateFloat64ToWord32(fp_n)));
assembler->Goto(&init_k_n);
assembler->Bind(&do_return_not_found);
{
index_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
assembler->Goto(&return_not_found);
}
}
......@@ -1819,7 +1835,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
{
Label if_positive(assembler), if_negative(assembler), done(assembler);
assembler->Branch(
assembler->Int32LessThan(start_from_var.value(), int32_zero),
assembler->IntPtrLessThan(start_from_var.value(), intptr_zero),
&if_negative, &if_positive);
assembler->Bind(&if_positive);
......@@ -1831,15 +1847,15 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
assembler->Bind(&if_negative);
{
index_var.Bind(
assembler->Int32Add(len_var.value(), start_from_var.value()));
assembler->IntPtrAdd(len_var.value(), start_from_var.value()));
assembler->Branch(
assembler->Int32LessThan(index_var.value(), int32_zero),
assembler->IntPtrLessThan(index_var.value(), intptr_zero),
&init_k_zero, &done);
}
assembler->Bind(&init_k_zero);
{
index_var.Bind(int32_zero);
index_var.Bind(intptr_zero);
assembler->Goto(&done);
}
......@@ -1895,7 +1911,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
&string_loop);
assembler->GotoIf(
assembler->WordEqual(search_type,
assembler->Word32Equal(search_type,
assembler->Int32Constant(SIMD128_VALUE_TYPE)),
&simd_loop);
assembler->Goto(&ident_loop);
......@@ -1903,28 +1919,28 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
assembler->Bind(&ident_loop);
{
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordEqual(element_k, search_element),
&return_found);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&ident_loop);
}
assembler->Bind(&undef_loop);
{
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordEqual(element_k, undefined),
&return_found);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&undef_loop);
}
......@@ -1938,10 +1954,11 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler), not_smi(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi);
assembler->Branch(
assembler->Float64Equal(search_num.value(),
......@@ -1957,7 +1974,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
&return_found, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
}
......@@ -1966,10 +1983,10 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
assembler->GotoUnless(assembler->Int32LessThan(
assembler->LoadInstanceType(element_k),
......@@ -1985,7 +2002,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
&return_found, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&string_loop);
}
......@@ -1998,11 +2015,11 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
assembler->Goto(&loop_body);
assembler->Bind(&loop_body);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k =
assembler->LoadFixedArrayElement(elements, index_var.value());
Node* element_k = assembler->LoadFixedArrayElement(
elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
Node* map_k = assembler->LoadMap(element_k);
......@@ -2010,7 +2027,7 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
&return_found, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&loop_body);
}
}
......@@ -2039,14 +2056,15 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64Equal(element_k, search_num.value(),
&return_found, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
}
......@@ -2075,19 +2093,21 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
{
Label continue_loop(assembler);
assembler->GotoUnless(
assembler->Int32LessThan(index_var.value(), len_var.value()),
assembler->UintPtrLessThan(index_var.value(), len_var.value()),
&return_not_found);
if (kPointerSize == kDoubleSize) {
Node* element = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint64());
elements, index_var.value(), MachineType::Uint64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
assembler->GotoIf(assembler->Word64Equal(element, the_hole),
&continue_loop);
} else {
Node* element_upper = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Uint32(),
kIeeeDoubleExponentWordOffset);
kIeeeDoubleExponentWordOffset,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->GotoIf(
assembler->Word32Equal(element_upper,
assembler->Int32Constant(kHoleNanUpper32)),
......@@ -2095,11 +2115,12 @@ void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
}
Node* element_k = assembler->LoadFixedDoubleArrayElement(
elements, index_var.value(), MachineType::Float64());
elements, index_var.value(), MachineType::Float64(), 0,
CodeStubAssembler::INTPTR_PARAMETERS);
assembler->BranchIfFloat64Equal(element_k, search_num.value(),
&return_found, &continue_loop);
assembler->Bind(&continue_loop);
index_var.Bind(assembler->Int32Add(index_var.value(), int32_one));
index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
assembler->Goto(&not_nan_loop);
}
}
......
......@@ -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,7 +1464,7 @@ void CodeStubAssembler::FillFixedArrayWithValue(
Bind(&decrement);
current.Bind(IntPtrSub(
current.value(),
Int32Constant(IsFastDoubleElementsKind(kind) ? kDoubleSize
IntPtrConstant(IsFastDoubleElementsKind(kind) ? kDoubleSize
: kPointerSize)));
if (is_double) {
// Don't use doubles to store the hole double, since manipulating the
......@@ -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,
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)),
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