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

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

Issue 2235983003: [builtins] Migrate StringToNumber to TurboFan builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | 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 50c34b90a3ccf6fa022a772dcda4ca3e609f05d2..0d04a02e241132e87aaea3ffb17add337002e901 100644
--- a/src/builtins/builtins-conversion.cc
+++ b/src/builtins/builtins-conversion.cc
@@ -109,6 +109,38 @@ void Builtins::Generate_NonPrimitiveToPrimitive_String(
Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kString);
}
+void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
+ typedef CodeStubAssembler::Label Label;
+ typedef compiler::Node Node;
+ typedef TypeConversionDescriptor Descriptor;
+
+ Node* input = assembler->Parameter(Descriptor::kArgument);
+ Node* context = assembler->Parameter(Descriptor::kContext);
+
+ Label runtime(assembler);
+
+ // Check if string has a cached array index.
+ Node* hash = assembler->LoadNameHashField(input);
+ Node* bit = assembler->Word32And(
+ hash, assembler->Int32Constant(String::kContainsCachedArrayIndexMask));
+ assembler->GotoIf(assembler->Word32NotEqual(bit, assembler->Int32Constant(0)),
+ &runtime);
+
+ assembler->Return(assembler->SmiTag(
+ assembler->BitFieldDecode<String::ArrayIndexValueBits>(hash)));
+
+ assembler->Bind(&runtime);
+ {
+ // Note: We cannot tail call to the runtime here, as js-to-wasm
+ // 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);
+ }
+}
+
// ES6 section 7.1.3 ToNumber ( argument )
void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) {
typedef CodeStubAssembler::Label Label;
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698