Revision: 17985
Author:   [email protected]
Date:     Fri Nov 22 07:27:26 2013 UTC
Log: Rework BuildCheckString() to be compatible with the other BuildCheck*() methods.

[email protected]

Review URL: https://codereview.chromium.org/79343009
http://code.google.com/p/v8/source/detail?r=17985

Modified:
 /branches/bleeding_edge/src/code-stubs-hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h

=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Wed Nov 20 12:00:57 2013 UTC +++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Fri Nov 22 07:27:26 2013 UTC
@@ -992,16 +992,10 @@

   // Make sure that both arguments are strings if not known in advance.
   if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
-    IfBuilder if_leftnotstring(this);
-    if_leftnotstring.IfNot<HIsStringAndBranch>(left);
-    if_leftnotstring.Then();
-    if_leftnotstring.Deopt("Expected string for LHS of string addition");
+    left = BuildCheckString(left);
   }
   if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
-    IfBuilder if_rightnotstring(this);
-    if_rightnotstring.IfNot<HIsStringAndBranch>(right);
-    if_rightnotstring.Then();
-    if_rightnotstring.Deopt("Expected string for RHS of string addition");
+    right = BuildCheckString(right);
   }

   return BuildStringAdd(left, right, pretenure_flag);
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Thu Nov 21 17:21:00 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc     Fri Nov 22 07:27:26 2013 UTC
@@ -1273,17 +1273,14 @@
 }


-HValue* HGraphBuilder::BuildCheckString(
-    HValue* object, const char* failure_reason) {
-  if (!object->type().IsString()) {
-    ASSERT(!object->IsConstant() ||
-           !HConstant::cast(object)->HasStringValue());
-    IfBuilder if_isstring(this);
-    if_isstring.If<HIsStringAndBranch>(object);
-    if_isstring.Then();
-    if_isstring.ElseDeopt(failure_reason);
+HValue* HGraphBuilder::BuildCheckString(HValue* string) {
+  if (!string->type().IsString()) {
+    ASSERT(!string->IsConstant() ||
+           !HConstant::cast(string)->HasStringValue());
+    BuildCheckHeapObject(string);
+    return Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING);
   }
-  return object;
+  return string;
 }


@@ -8657,14 +8654,12 @@
       (left_type->Is(Type::String()) || right_type->Is(Type::String()))) {
     // Validate type feedback for left argument.
     if (left_type->Is(Type::String())) {
-      left = BuildCheckString(
-          left, "Expected string for LHS of binary operation");
+      left = BuildCheckString(left);
     }

     // Validate type feedback for right argument.
     if (right_type->Is(Type::String())) {
-      right = BuildCheckString(
-          right, "Expected string for RHS of binary operation");
+      right = BuildCheckString(right);
     }

     // Convert left argument as necessary.
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Wed Nov 20 12:00:57 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.h      Fri Nov 22 07:27:26 2013 UTC
@@ -1256,7 +1256,7 @@

   HValue* BuildCheckHeapObject(HValue* object);
   HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
-  HValue* BuildCheckString(HValue* object, const char* failure_reason);
+  HValue* BuildCheckString(HValue* string);
   HValue* BuildWrapReceiver(HValue* object, HValue* function);

   // Building common constructs

--
--
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/groups/opt_out.

Reply via email to