Index: src/code-stub-assembler.cc |
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
index 7ec5a88e5610048c7d9f54a990c39a50ea4b92a6..6874e6fb0855edf05e9659404cc8974de24da456 100644 |
--- a/src/code-stub-assembler.cc |
+++ b/src/code-stub-assembler.cc |
@@ -2216,6 +2216,31 @@ 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); |
+ { |
+ 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)), |