Commit 4a743610 authored by bmeurer's avatar bmeurer Committed by Commit bot

[csa] SubString should enforce Stringness of first parameter.

The CodeStubAssembler::SubString method should not try to be defensive
about non-string inputs, but really enforce String receiver. Passing
a non-String input will result in crash in the %SubString runtime
function anyway.

R=jgruber@chromium.org

Review-Url: https://codereview.chromium.org/2700103002
Cr-Commit-Position: refs/heads/master@{#43267}
parent e1f7ae33
......@@ -3292,17 +3292,13 @@ Node* CodeStubAssembler::SubString(Node* context, Node* string, Node* from,
Variable var_result(this, MachineRepresentation::kTagged); // String.
// Make sure first argument is a string.
// Bailout if receiver is a Smi.
GotoIf(TaggedIsSmi(string), &runtime);
CSA_ASSERT(this, TaggedIsNotSmi(string));
CSA_ASSERT(this, IsString(string));
// Load the instance type of the {string}.
Node* const instance_type = LoadInstanceType(string);
var_instance_type.Bind(instance_type);
// Check if {string} is a String.
GotoUnless(IsStringInstanceType(instance_type), &runtime);
// Make sure that both from and to are non-negative smis.
GotoUnless(TaggedIsPositiveSmi(from), &runtime);
......
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