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

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

Issue 2293943002: [builtins] Create StringToNumber helper. (Closed)
Patch Set: [builtins] Create StringToNumber helper. 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
« src/builtins/builtins-conversion.cc ('K') | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index a9bb408048773244644c417279111be93ff571b6..debbc30e70f474ec3e383b1573bc4ecda9fa3387 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -2216,6 +2216,35 @@ Node* CodeStubAssembler::StringFromCharCode(Node* code) {
return var_result.value();
}
+Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) {
+ Label runtime(this, Label::kDeferred);
+ Label end(this);
+
+ Variable var_result(this, MachineRepresentation::kTagged);
+
+ // Check if string has a cached array index.
+ Node* hash = LoadNameHashField(input);
+ Node* bit =
+ Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask));
+ GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime);
+
+ var_result.Bind(SmiTag(BitFieldDecode<String::ArrayIndexValueBits>(hash)));
+ Goto(&end);
+
+ Bind(&runtime);
+ {
+ // Note: We cannot tail call to the runtime here, as js-to-wasm
Benedikt Meurer 2016/09/02 04:23:48 Nit: remove this note as now with the helper we ca
+ // trampolines also use this code currently, and they declare all
+ // outgoing parameters as untagged, while we would push a tagged
+ // object here.
+ var_result.Bind(CallRuntime(Runtime::kStringToNumber, context, input));
+ Goto(&end);
+ }
+
+ Bind(&end);
+ return var_result.value();
+}
+
Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
uint32_t mask) {
return Word32Shr(Word32And(word32, Int32Constant(mask)),
« src/builtins/builtins-conversion.cc ('K') | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698