Index: src/js/regexp.js |
diff --git a/src/js/regexp.js b/src/js/regexp.js |
index b3d28bab50af3f1d33398fde9ef6c98b2334df32..396b694ea65a35a03292a2a0d964690297121397 100644 |
--- a/src/js/regexp.js |
+++ b/src/js/regexp.js |
@@ -178,20 +178,11 @@ |
var sticky = TO_BOOLEAN(REGEXP_STICKY(this)); |
var updateLastIndex = global || sticky; |
if (updateLastIndex) { |
- // TODO(jgruber): This is actually ToLength in the spec, but we bailout |
- // to the runtime in %_RegExpExec if lastIndex is not a Smi, so we are |
- // smart here and trick both TurboFan and Crankshaft to produce a Smi. |
- // This is a terrible hack, and correct for subtle reasons; it's a clear |
- // indicator that we need a predictable RegExp implementation where we |
- // don't need to add specific work-arounds for certain compiler issues. |
- lastIndex = +this.lastIndex; |
+ lastIndex = TO_LENGTH(this.lastIndex); |
if (lastIndex > string.length) { |
this.lastIndex = 0; |
return null; |
- } else if (lastIndex <= 0) { |
- lastIndex = 0; |
- } |
- lastIndex = lastIndex|0; |
+ } |
} else { |
lastIndex = 0; |
} |