Commit 55a64bf7 authored by svenpanne's avatar svenpanne Committed by Commit bot

[Crankshaft] Don't add an instruction twice for %_StringGetLength.

Review URL: https://codereview.chromium.org/1042843002

Cr-Commit-Position: refs/heads/master@{#27521}
parent de9c3e59
......@@ -6832,13 +6832,18 @@ HInstruction* HGraphBuilder::AddLoadStringInstanceType(HValue* string) {
HInstruction* HGraphBuilder::AddLoadStringLength(HValue* string) {
return AddInstruction(BuildLoadStringLength(string));
}
HInstruction* HGraphBuilder::BuildLoadStringLength(HValue* string) {
if (string->IsConstant()) {
HConstant* c_string = HConstant::cast(string);
if (c_string->HasStringValue()) {
return Add<HConstant>(c_string->StringValue()->length());
return New<HConstant>(c_string->StringValue()->length());
}
}
return Add<HLoadNamedField>(string, nullptr,
return New<HLoadNamedField>(string, nullptr,
HObjectAccess::ForStringLength());
}
......@@ -11871,7 +11876,7 @@ void HOptimizedGraphBuilder::GenerateStringGetLength(CallRuntime* call) {
DCHECK(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* string = Pop();
HInstruction* result = AddLoadStringLength(string);
HInstruction* result = BuildLoadStringLength(string);
return ast_context()->ReturnInstruction(result, call->id());
}
......
......@@ -1418,6 +1418,7 @@ class HGraphBuilder {
HInstruction* AddLoadStringInstanceType(HValue* string);
HInstruction* AddLoadStringLength(HValue* string);
HInstruction* BuildLoadStringLength(HValue* string);
HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map> map) {
return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
Add<HConstant>(map));
......
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