Commit fd940f5c authored by bmeurer's avatar bmeurer Committed by Commit bot

[builtins] Rewrite String.fromCharCode w/o %_Arguments.

This is the very last use of %_Arguments and %_ArgumentsLength,
and also the main blocker for not inlining builtins.

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1681403006

Cr-Commit-Position: refs/heads/master@{#33939}
parent 5bb459ba
...@@ -559,28 +559,14 @@ function StringTrimRight() { ...@@ -559,28 +559,14 @@ function StringTrimRight() {
// ECMA-262, section 15.5.3.2 // ECMA-262, section 15.5.3.2
function StringFromCharCode(code) { function StringFromCharCode(_) { // length == 1
var n = %_ArgumentsLength(); "use strict";
if (n === 1) return %_StringCharFromCode(code & 0xffff); var s = "";
var n = arguments.length;
var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); for (var i = 0; i < n; ++i) {
var i; s += %_StringCharFromCode(arguments[i] & 0xffff);
for (i = 0; i < n; i++) { }
code = %_Arguments(i) & 0xffff; return s;
if (code > 0xff) break;
%_OneByteSeqStringSetChar(i, code, one_byte);
}
if (i == n) return one_byte;
one_byte = %TruncateString(one_byte, i);
var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
%_TwoByteSeqStringSetChar(0, code, two_byte);
i++;
for (var j = 1; i < n; i++, j++) {
code = %_Arguments(i) & 0xffff;
%_TwoByteSeqStringSetChar(j, code, two_byte);
}
return one_byte + two_byte;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment