Reviewers: Michael Starzinger,

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

Please review this at https://codereview.chromium.org/1042843002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+9, -3 lines):
  M src/hydrogen.h
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 4389bfe78ab391c44a24a8ab36874e57968046cf..389a943ee66f274c60a112769b60a9a521e16e39 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6840,13 +6840,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());
 }

@@ -11879,7 +11884,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());
 }

Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 268976af3ddb5416234e77dfe297fadcdfed6c25..d4b33ac5a9ecd61b268fa94ea6b4b85910ebc05f 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -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));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to