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

Unified Diff: src/code-stubs.cc

Issue 2364473006: [stubs] Extract ToInteger to CodeStubAssembler (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 4dbd881adfde49da613975e7a75e39e3e0a38d10..d553e39d047769c64b6ba099996106868c4a33fa 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -4927,64 +4927,12 @@ void ToLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
void ToIntegerStub::GenerateAssembly(CodeStubAssembler* assembler) const {
- typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
- typedef CodeStubAssembler::Variable Variable;
-
- Node* context = assembler->Parameter(1);
- // We might need to loop once for ToNumber conversion.
- Variable var_arg(assembler, MachineRepresentation::kTagged);
- Label loop(assembler, &var_arg);
- var_arg.Bind(assembler->Parameter(0));
- assembler->Goto(&loop);
- assembler->Bind(&loop);
- {
- // Shared entry points.
- Label return_arg(assembler), return_zero(assembler, Label::kDeferred);
-
- // Load the current {arg} value.
- Node* arg = var_arg.value();
-
- // Check if {arg} is a Smi.
- assembler->GotoIf(assembler->WordIsSmi(arg), &return_arg);
-
- // Check if {arg} is a HeapNumber.
- Label if_argisheapnumber(assembler),
- if_argisnotheapnumber(assembler, Label::kDeferred);
- assembler->Branch(assembler->WordEqual(assembler->LoadMap(arg),
- assembler->HeapNumberMapConstant()),
- &if_argisheapnumber, &if_argisnotheapnumber);
-
- assembler->Bind(&if_argisheapnumber);
- {
- // Load the floating-point value of {arg}.
- Node* arg_value = assembler->LoadHeapNumberValue(arg);
-
- // Check if {arg} is NaN.
- assembler->GotoUnless(assembler->Float64Equal(arg_value, arg_value),
- &return_zero);
-
- // Truncate {arg} towards zero.
- Node* value = assembler->Float64Trunc(arg_value);
- var_arg.Bind(assembler->ChangeFloat64ToTagged(value));
- assembler->Goto(&return_arg);
- }
-
- assembler->Bind(&if_argisnotheapnumber);
- {
- // Need to convert {arg} to a Number first.
- Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate());
- var_arg.Bind(assembler->CallStub(callable, context, arg));
- assembler->Goto(&loop);
- }
-
- assembler->Bind(&return_arg);
- assembler->Return(var_arg.value());
+ Node* input = assembler->Parameter(Descriptor::kArgument);
+ Node* context = assembler->Parameter(Descriptor::kContext);
- assembler->Bind(&return_zero);
- assembler->Return(assembler->SmiConstant(Smi::FromInt(0)));
- }
+ assembler->Return(assembler->ToInteger(context, input));
}
void StoreInterceptorStub::GenerateAssembly(
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698