-
bmeurer authored
For string wrappers (JSValue instances with [[StringData]] internal fields), we can shortcirciut the ToPrimitive if (a) the {input} map matches the initial map of the String function, (b) the {input} [[Prototype]] is the unmodified %StringPrototype% (i.e. no one monkey-patched toString, @@toPrimitive or valueOf), and (c) the %ObjectPrototype% (i.e. the [[Prototype]] of the %StringPrototype%) is also unmodified, that is no one sneaked a @@toPrimitive into the %ObjectPrototype%. If all these assumptions hold, we can just take the [[StringData]] value and return it. This just repairs a regression introduced by removing the weird (and broken) intrinsic %_IsStringWrapperSafeForDefaultValue, which was intendend to something similar to this, although less efficient and wrong in the presence of @@toPrimitive. Long-term we might want to move into the direction of having a ToPrimitiveStub that can do common cases while staying in JavaScript land (i.e. not going to C++). R=jarin@chromium.org BUG=chromium:532524 LOG=n Review URL: https://codereview.chromium.org/1366563002 Cr-Commit-Position: refs/heads/master@{#30890}
17f59878