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

Unified Diff: src/builtins/builtins-number.cc

Issue 2432923002: [builtins] Optimize Number.parseInt for HeapNumbers in Signed32 range. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-number.cc
diff --git a/src/builtins/builtins-number.cc b/src/builtins/builtins-number.cc
index 2e4aa799806c95b1aa1818f230749d4c9cc07c71..6ce4644624c2dd4dc11c575f4618c3c253cadc21 100644
--- a/src/builtins/builtins-number.cc
+++ b/src/builtins/builtins-number.cc
@@ -301,22 +301,29 @@ void Builtins::Generate_NumberParseInt(CodeStubAssembler* assembler) {
assembler->Bind(&if_inputisheapnumber);
{
- // Check if the absolute {input} value is in the ]0.01,1e9[ range.
+ // Check if the {input} value is in Signed32 range.
+ Label if_inputissigned32(assembler);
Node* input_value = assembler->LoadHeapNumberValue(input);
+ Node* input_value32 = assembler->TruncateFloat64ToWord32(input_value);
+ assembler->GotoIf(
+ assembler->Float64Equal(
+ input_value, assembler->ChangeInt32ToFloat64(input_value32)),
+ &if_inputissigned32);
+
+ // Check if the absolute {input} value is in the ]0.01,1e9[ range.
Node* input_value_abs = assembler->Float64Abs(input_value);
assembler->GotoUnless(
assembler->Float64LessThan(input_value_abs,
assembler->Float64Constant(1e9)),
&if_generic);
- assembler->GotoUnless(
- assembler->Float64LessThan(assembler->Float64Constant(0.01),
- input_value_abs),
- &if_generic);
+ assembler->Branch(assembler->Float64LessThan(
+ assembler->Float64Constant(0.01), input_value_abs),
+ &if_inputissigned32, &if_generic);
// Return the truncated int32 value, and return the tagged result.
- Node* input_value32 = assembler->TruncateFloat64ToWord32(input_value);
- Node* result = assembler->SmiFromWord32(input_value32);
+ assembler->Bind(&if_inputissigned32);
+ Node* result = assembler->ChangeInt32ToTagged(input_value32);
assembler->Return(result);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698