Cherry pick http://codereview.chromium.org/1745017/

"Port regexp fix (backslash-b at end of input) to partial snapshots branch."

Fix bug: 2632771

Change-Id: I7f4db0c9db76de0cb6408b7e3c17055e030f4d75
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index 4094365..019de68 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -4844,17 +4844,18 @@
 
     SetRelation word_relation =
         CharacterRange::WordCharacterRelation(following_chars);
-    if (word_relation.ContainedIn()) {
-      // Following character is definitely a word character.
-      type = (type == AssertionNode::AT_BOUNDARY) ?
-                  AssertionNode::AFTER_NONWORD_CHARACTER :
-                  AssertionNode::AFTER_WORD_CHARACTER;
-      that->set_type(type);
-    } else if (word_relation.Disjoint()) {
+    if (word_relation.Disjoint()) {
+      // Includes the case where following_chars is empty (e.g., end-of-input).
       // Following character is definitely *not* a word character.
       type = (type == AssertionNode::AT_BOUNDARY) ?
-                  AssertionNode::AFTER_WORD_CHARACTER :
-                  AssertionNode::AFTER_NONWORD_CHARACTER;
+                 AssertionNode::AFTER_WORD_CHARACTER :
+                 AssertionNode::AFTER_NONWORD_CHARACTER;
+      that->set_type(type);
+    } else if (word_relation.ContainedIn()) {
+      // Following character is definitely a word character.
+      type = (type == AssertionNode::AT_BOUNDARY) ?
+                 AssertionNode::AFTER_NONWORD_CHARACTER :
+                 AssertionNode::AFTER_WORD_CHARACTER;
       that->set_type(type);
     }
   }