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)), |