Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: src/code-stub-assembler.cc

Issue 2405253006: [builtins] implement Array.prototype[@@iterator] in TFJ builtins (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 6adec9aff6fd100da4efb4b4baa942b281566f2f..7c8fe49aa7f8652f974a9bfdbf22c995e18f98eb 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -1041,6 +1041,44 @@ Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node,
return Load(MachineType::AnyTagged(), object, offset);
}
+Node* CodeStubAssembler::LoadFixedTypedArrayElement(
+ Node* data_pointer, Node* index_node, ElementsKind elements_kind,
+ ParameterMode parameter_mode) {
+ Node* offset =
+ ElementOffsetFromIndex(index_node, elements_kind, parameter_mode, 0);
+ MachineType type;
+ switch (elements_kind) {
+ case UINT8_ELEMENTS: /* fall through */
+ case UINT8_CLAMPED_ELEMENTS:
+ type = MachineType::Uint8();
+ break;
+ case INT8_ELEMENTS:
+ type = MachineType::Int8();
+ break;
+ case UINT16_ELEMENTS:
+ type = MachineType::Uint16();
+ break;
+ case INT16_ELEMENTS:
+ type = MachineType::Int16();
+ break;
+ case UINT32_ELEMENTS:
+ type = MachineType::Uint32();
+ break;
+ case INT32_ELEMENTS:
+ type = MachineType::Int32();
+ break;
+ case FLOAT32_ELEMENTS:
+ type = MachineType::Float32();
+ break;
+ case FLOAT64_ELEMENTS:
+ type = MachineType::Float64();
+ break;
+ default:
+ UNREACHABLE();
+ }
+ return Load(type, data_pointer, offset);
+}
+
Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement(
Node* object, Node* index_node, int additional_offset,
ParameterMode parameter_mode) {
@@ -7242,5 +7280,56 @@ compiler::Node* CodeStubAssembler::InstanceOf(compiler::Node* object,
return result.value();
}
+compiler::Node* CodeStubAssembler::NumberInc(compiler::Node* value) {
+ Variable var_result(this, MachineRepresentation::kTagged),
+ var_finc_value(this, MachineRepresentation::kFloat64);
+ Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this);
+ Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
+
+ Bind(&if_issmi);
+ {
+ // Try fast Smi addition first.
+ Node* one = SmiConstant(Smi::FromInt(1));
+ Node* pair = SmiAddWithOverflow(value, one);
+ Node* overflow = Projection(1, pair);
+
+ // Check if the Smi addition overflowed.
+ Label if_overflow(this), if_notoverflow(this);
+ Branch(overflow, &if_overflow, &if_notoverflow);
+
+ Bind(&if_notoverflow);
+ var_result.Bind(Projection(0, pair));
+ Goto(&end);
+
+ Bind(&if_overflow);
+ {
+ var_finc_value.Bind(SmiToFloat64(value));
+ Goto(&do_finc);
+ }
+ }
+
+ Bind(&if_isnotsmi);
+ {
+ // Check if the value is a HeapNumber.
+ Assert(IsHeapNumberMap(LoadMap(value)));
+
+ // Load the HeapNumber value.
+ var_finc_value.Bind(LoadHeapNumberValue(value));
+ Goto(&do_finc);
+ }
+
+ Bind(&do_finc);
+ {
+ Node* finc_value = var_finc_value.value();
+ Node* one = Float64Constant(1.0);
+ Node* finc_result = Float64Add(finc_value, one);
+ var_result.Bind(ChangeFloat64ToTagged(finc_result));
+ Goto(&end);
+ }
+
+ Bind(&end);
+ return var_result.value();
+}
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698