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

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

Issue 2293943002: [builtins] Create StringToNumber helper. (Closed)
Patch Set: Created 4 years, 4 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
« src/builtins/builtins.h ('K') | « src/builtins/builtins.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-conversion.cc
diff --git a/src/builtins/builtins-conversion.cc b/src/builtins/builtins-conversion.cc
index 0d04a02e241132e87aaea3ffb17add337002e901..9cb9eeadf7f329f9219f3ef08d7b44fff4c1a80e 100644
--- a/src/builtins/builtins-conversion.cc
+++ b/src/builtins/builtins-conversion.cc
@@ -109,15 +109,17 @@ void Builtins::Generate_NonPrimitiveToPrimitive_String(
Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kString);
}
-void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
+compiler::Node* Builtins::GenerateImpl_StringToNumber(
+ CodeStubAssembler* assembler, compiler::Node* input,
+ compiler::Node* context) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
- typedef TypeConversionDescriptor Descriptor;
+ typedef CodeStubAssembler::Variable Variable;
- Node* input = assembler->Parameter(Descriptor::kArgument);
- Node* context = assembler->Parameter(Descriptor::kContext);
+ Label runtime(assembler, Label::kDeferred);
+ Label end(assembler);
- Label runtime(assembler);
+ Variable var_result(assembler, MachineRepresentation::kTagged);
// Check if string has a cached array index.
Node* hash = assembler->LoadNameHashField(input);
@@ -126,8 +128,9 @@ void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
assembler->GotoIf(assembler->Word32NotEqual(bit, assembler->Int32Constant(0)),
&runtime);
- assembler->Return(assembler->SmiTag(
+ var_result.Bind(assembler->SmiTag(
assembler->BitFieldDecode<String::ArrayIndexValueBits>(hash)));
+ assembler->Goto(&end);
assembler->Bind(&runtime);
{
@@ -135,10 +138,20 @@ void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
// trampolines also use this code currently, and they declare all
// outgoing parameters as untagged, while we would push a tagged
// object here.
- Node* result =
- assembler->CallRuntime(Runtime::kStringToNumber, context, input);
- assembler->Return(result);
+ var_result.Bind(
+ assembler->CallRuntime(Runtime::kStringToNumber, context, input));
+ assembler->Goto(&end);
}
+
+ assembler->Bind(&end);
+ return var_result.value();
+}
+
+void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
+ typedef TypeConversionDescriptor Descriptor;
+ assembler->Return(Builtins::GenerateImpl_StringToNumber(
+ assembler, assembler->Parameter(Descriptor::kArgument),
+ assembler->Parameter(Descriptor::kContext)));
}
// ES6 section 7.1.3 ToNumber ( argument )
@@ -183,9 +196,8 @@ void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) {
assembler->Bind(&if_inputisstring);
{
// The {input} is a String, use the fast stub to convert it to a Number.
- // TODO(bmeurer): Consider inlining the StringToNumber logic here.
- Callable callable = CodeFactory::StringToNumber(assembler->isolate());
- assembler->TailCallStub(callable, context, input);
+ assembler->Return(
+ Builtins::GenerateImpl_StringToNumber(assembler, input, context));
}
assembler->Bind(&if_inputisoddball);
« src/builtins/builtins.h ('K') | « src/builtins/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698