Commit 56eac828 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[cleanup] StringToNumber and NumberToString don't need a context.

These operations don't need to access per-native context data and
cannot throw exceptions.

Bug: v8:5268, v8:5269
Change-Id: Id7fdbee2b39f96717de83b3cef5ab789424f8338
Reviewed-on: https://chromium-review.googlesource.com/779142
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50639}
parent 1f3cdb70
...@@ -99,10 +99,9 @@ TF_BUILTIN(NonPrimitiveToPrimitive_String, ConversionBuiltinsAssembler) { ...@@ -99,10 +99,9 @@ TF_BUILTIN(NonPrimitiveToPrimitive_String, ConversionBuiltinsAssembler) {
} }
TF_BUILTIN(StringToNumber, CodeStubAssembler) { TF_BUILTIN(StringToNumber, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* input = Parameter(Descriptor::kArgument); Node* input = Parameter(Descriptor::kArgument);
Return(StringToNumber(context, input)); Return(StringToNumber(input));
} }
TF_BUILTIN(ToName, CodeStubAssembler) { TF_BUILTIN(ToName, CodeStubAssembler) {
...@@ -145,10 +144,9 @@ TF_BUILTIN(ToNumber, CodeStubAssembler) { ...@@ -145,10 +144,9 @@ TF_BUILTIN(ToNumber, CodeStubAssembler) {
// ES section #sec-tostring-applied-to-the-number-type // ES section #sec-tostring-applied-to-the-number-type
TF_BUILTIN(NumberToString, CodeStubAssembler) { TF_BUILTIN(NumberToString, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* input = Parameter(Descriptor::kArgument); Node* input = Parameter(Descriptor::kArgument);
Return(NumberToString(context, input)); Return(NumberToString(input));
} }
// ES section #sec-tostring // ES section #sec-tostring
......
...@@ -5187,8 +5187,7 @@ TNode<String> CodeStubAssembler::StringFromCodePoint(TNode<Int32T> codepoint, ...@@ -5187,8 +5187,7 @@ TNode<String> CodeStubAssembler::StringFromCodePoint(TNode<Int32T> codepoint,
return CAST(var_result.value()); return CAST(var_result.value());
} }
TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<Context> context, TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<String> input) {
SloppyTNode<String> input) {
CSA_SLOW_ASSERT(this, IsString(input)); CSA_SLOW_ASSERT(this, IsString(input));
Label runtime(this, Label::kDeferred); Label runtime(this, Label::kDeferred);
Label end(this); Label end(this);
...@@ -5206,7 +5205,8 @@ TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<Context> context, ...@@ -5206,7 +5205,8 @@ TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<Context> context,
BIND(&runtime); BIND(&runtime);
{ {
var_result = CAST(CallRuntime(Runtime::kStringToNumber, context, input)); var_result =
CAST(CallRuntime(Runtime::kStringToNumber, NoContextConstant(), input));
Goto(&end); Goto(&end);
} }
...@@ -5214,7 +5214,7 @@ TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<Context> context, ...@@ -5214,7 +5214,7 @@ TNode<Number> CodeStubAssembler::StringToNumber(SloppyTNode<Context> context,
return var_result; return var_result;
} }
Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) { Node* CodeStubAssembler::NumberToString(Node* argument) {
VARIABLE(result, MachineRepresentation::kTagged); VARIABLE(result, MachineRepresentation::kTagged);
Label runtime(this, Label::kDeferred), smi(this), done(this, &result); Label runtime(this, Label::kDeferred), smi(this), done(this, &result);
...@@ -5265,8 +5265,8 @@ Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) { ...@@ -5265,8 +5265,8 @@ Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) {
BIND(&runtime); BIND(&runtime);
{ {
// No cache entry, go to the runtime. // No cache entry, go to the runtime.
result.Bind( result.Bind(CallRuntime(Runtime::kNumberToStringSkipCache,
CallRuntime(Runtime::kNumberToStringSkipCache, context, argument)); NoContextConstant(), argument));
} }
Goto(&done); Goto(&done);
...@@ -5369,7 +5369,7 @@ Node* CodeStubAssembler::NonNumberToNumberOrNumeric( ...@@ -5369,7 +5369,7 @@ Node* CodeStubAssembler::NonNumberToNumberOrNumeric(
BIND(&if_inputisstring); BIND(&if_inputisstring);
{ {
// The {input} is a String, use the fast stub to convert it to a Number. // The {input} is a String, use the fast stub to convert it to a Number.
var_result.Bind(StringToNumber(context, input)); var_result.Bind(StringToNumber(input));
Goto(&end); Goto(&end);
} }
...@@ -5667,7 +5667,7 @@ TNode<String> CodeStubAssembler::ToString(SloppyTNode<Context> context, ...@@ -5667,7 +5667,7 @@ TNode<String> CodeStubAssembler::ToString(SloppyTNode<Context> context,
Branch(IsHeapNumberMap(input_map), &is_number, &not_heap_number); Branch(IsHeapNumberMap(input_map), &is_number, &not_heap_number);
BIND(&is_number); BIND(&is_number);
result.Bind(NumberToString(context, input)); result.Bind(NumberToString(input));
Goto(&done); Goto(&done);
BIND(&not_heap_number); BIND(&not_heap_number);
......
...@@ -1204,9 +1204,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1204,9 +1204,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// Type conversion helpers. // Type conversion helpers.
enum class BigIntHandling { kConvertToNumber, kThrow }; enum class BigIntHandling { kConvertToNumber, kThrow };
// Convert a String to a Number. // Convert a String to a Number.
TNode<Number> StringToNumber(SloppyTNode<Context> context, TNode<Number> StringToNumber(SloppyTNode<String> input);
SloppyTNode<String> input); // Convert a Number to a String.
Node* NumberToString(Node* context, Node* input); Node* NumberToString(Node* input);
// Convert an object to a name. // Convert an object to a name.
Node* ToName(Node* context, Node* input); Node* ToName(Node* context, Node* input);
// Convert a Non-Number object to a Number. // Convert a Non-Number object to a Number.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment