Reland "Change the order of arguments of the (One|Two)ByteSeqStringSetChar intrinsic."

This relands commit r23899.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23910 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
jarin@chromium.org 2014-09-12 10:58:43 +00:00
parent d6c7c3f875
commit e401262400
17 changed files with 87 additions and 89 deletions

View File

@ -3444,9 +3444,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = r1;
Register value = r2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {
@ -3477,9 +3477,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = r1;
Register value = r2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {

View File

@ -3131,9 +3131,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register value = x2;
Register scratch = x10;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(value, index);
if (FLAG_debug_code) {
@ -3161,9 +3161,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register value = x2;
Register scratch = x10;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(value, index);
if (FLAG_debug_code) {

View File

@ -11539,10 +11539,9 @@ void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) {
void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
CallRuntime* call) {
DCHECK(call->arguments()->length() == 3);
// We need to follow the evaluation order of full codegen.
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(2)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* string = Pop();
HValue* value = Pop();
HValue* index = Pop();
@ -11556,10 +11555,9 @@ void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar(
CallRuntime* call) {
DCHECK(call->arguments()->length() == 3);
// We need to follow the evaluation order of full codegen.
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(2)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* string = Pop();
HValue* value = Pop();
HValue* index = Pop();

View File

@ -3362,9 +3362,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = ebx;
Register value = ecx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ pop(value);
__ pop(index);
@ -3398,9 +3398,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = ebx;
Register value = ecx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ pop(value);
__ pop(index);

View File

@ -3435,9 +3435,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = a1;
Register value = a2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {
@ -3472,9 +3472,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = a1;
Register value = a2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {

View File

@ -3434,9 +3434,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = a1;
Register value = a2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {
@ -3471,9 +3471,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = a1;
Register value = a2;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(index, value);
if (FLAG_debug_code) {

View File

@ -15415,9 +15415,9 @@ RUNTIME_FUNCTION(RuntimeReference_StringCharAt) {
RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_CHECKED(SeqOneByteString, string, 0);
CONVERT_INT32_ARG_CHECKED(index, 1);
CONVERT_INT32_ARG_CHECKED(value, 2);
CONVERT_INT32_ARG_CHECKED(index, 0);
CONVERT_INT32_ARG_CHECKED(value, 1);
CONVERT_ARG_CHECKED(SeqOneByteString, string, 2);
string->SeqOneByteStringSet(index, value);
return string;
}
@ -15426,9 +15426,9 @@ RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) {
RUNTIME_FUNCTION(RuntimeReference_TwoByteSeqStringSetChar) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0);
CONVERT_INT32_ARG_CHECKED(index, 1);
CONVERT_INT32_ARG_CHECKED(value, 2);
CONVERT_INT32_ARG_CHECKED(index, 0);
CONVERT_INT32_ARG_CHECKED(value, 1);
CONVERT_ARG_CHECKED(SeqTwoByteString, string, 2);
string->SeqTwoByteStringSet(index, value);
return string;
}

View File

@ -812,7 +812,7 @@ function StringFromCharCode(code) {
if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
if (code < 0) code = code & 0xffff;
if (code > 0xff) break;
%_OneByteSeqStringSetChar(one_byte, i, code);
%_OneByteSeqStringSetChar(i, code, one_byte);
}
if (i == n) return one_byte;
one_byte = %TruncateString(one_byte, i);
@ -821,7 +821,7 @@ function StringFromCharCode(code) {
for (var j = 0; i < n; i++, j++) {
var code = %_Arguments(i);
if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
%_TwoByteSeqStringSetChar(two_byte, j, code);
%_TwoByteSeqStringSetChar(j, code, two_byte);
}
return one_byte + two_byte;
}

View File

@ -172,10 +172,10 @@
throw new $URIError("URI malformed");
}
if (value < 0x10000) {
%_TwoByteSeqStringSetChar(result, index++, value);
%_TwoByteSeqStringSetChar(index++, value, result);
} else {
%_TwoByteSeqStringSetChar(result, index++, (value >> 10) + 0xd7c0);
%_TwoByteSeqStringSetChar(result, index++, (value & 0x3ff) + 0xdc00);
%_TwoByteSeqStringSetChar(index++, (value >> 10) + 0xd7c0, result);
%_TwoByteSeqStringSetChar(index++, (value & 0x3ff) + 0xdc00, result);
}
return index;
}
@ -205,7 +205,7 @@
var result = %NewString(array.length, NEW_ONE_BYTE_STRING);
for (var i = 0; i < array.length; i++) {
%_OneByteSeqStringSetChar(result, i, array[i]);
%_OneByteSeqStringSetChar(i, array[i], result);
}
return result;
}
@ -225,16 +225,16 @@
var cc = URIHexCharsToCharCode(uri.charCodeAt(k+1), uri.charCodeAt(k+2));
if (cc >> 7) break; // Assumption wrong, two-byte string.
if (reserved(cc)) {
%_OneByteSeqStringSetChar(one_byte, index++, 37); // '%'.
%_OneByteSeqStringSetChar(one_byte, index++, uri.charCodeAt(k+1));
%_OneByteSeqStringSetChar(one_byte, index++, uri.charCodeAt(k+2));
%_OneByteSeqStringSetChar(index++, 37, one_byte); // '%'.
%_OneByteSeqStringSetChar(index++, uri.charCodeAt(k+1), one_byte);
%_OneByteSeqStringSetChar(index++, uri.charCodeAt(k+2), one_byte);
} else {
%_OneByteSeqStringSetChar(one_byte, index++, cc);
%_OneByteSeqStringSetChar(index++, cc, one_byte);
}
k += 2;
} else {
if (code > 0x7f) break; // Assumption wrong, two-byte string.
%_OneByteSeqStringSetChar(one_byte, index++, code);
%_OneByteSeqStringSetChar(index++, code, one_byte);
}
}
@ -264,14 +264,14 @@
}
index = URIDecodeOctets(octets, two_byte, index);
} else if (reserved(cc)) {
%_TwoByteSeqStringSetChar(two_byte, index++, 37); // '%'.
%_TwoByteSeqStringSetChar(two_byte, index++, uri.charCodeAt(k - 1));
%_TwoByteSeqStringSetChar(two_byte, index++, uri.charCodeAt(k));
%_TwoByteSeqStringSetChar(index++, 37, two_byte); // '%'.
%_TwoByteSeqStringSetChar(index++, uri.charCodeAt(k - 1), two_byte);
%_TwoByteSeqStringSetChar(index++, uri.charCodeAt(k), two_byte);
} else {
%_TwoByteSeqStringSetChar(two_byte, index++, cc);
%_TwoByteSeqStringSetChar(index++, cc, two_byte);
}
} else {
%_TwoByteSeqStringSetChar(two_byte, index++, code);
%_TwoByteSeqStringSetChar(index++, code, two_byte);
}
}

View File

@ -3351,9 +3351,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = rbx;
Register value = rcx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(value);
__ Pop(index);
@ -3384,9 +3384,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = rbx;
Register value = rcx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ Pop(value);
__ Pop(index);

View File

@ -3356,9 +3356,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
Register index = ebx;
Register value = ecx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ pop(value);
__ pop(index);
@ -3392,9 +3392,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
Register index = ebx;
Register value = ecx;
VisitForStackValue(args->at(1)); // index
VisitForStackValue(args->at(2)); // value
VisitForAccumulatorValue(args->at(0)); // string
VisitForStackValue(args->at(0)); // index
VisitForStackValue(args->at(1)); // value
VisitForAccumulatorValue(args->at(2)); // string
__ pop(value);
__ pop(index);

View File

@ -29,13 +29,13 @@
function MyStringFromCharCode(code, i) {
var one_byte = %NewString(3, true);
%_OneByteSeqStringSetChar(one_byte, 0, code);
%_OneByteSeqStringSetChar(one_byte, 1, code);
%_OneByteSeqStringSetChar(one_byte, i, code);
%_OneByteSeqStringSetChar(0, code, one_byte);
%_OneByteSeqStringSetChar(1, code, one_byte);
%_OneByteSeqStringSetChar(i, code, one_byte);
var two_byte = %NewString(3, false);
%_TwoByteSeqStringSetChar(two_byte, 0, code);
%_TwoByteSeqStringSetChar(two_byte, 1, code);
%_TwoByteSeqStringSetChar(two_byte, i, code);
%_TwoByteSeqStringSetChar(0, code, two_byte);
%_TwoByteSeqStringSetChar(1, code, two_byte);
%_TwoByteSeqStringSetChar(i, code, two_byte);
return one_byte + two_byte;
}

View File

@ -30,7 +30,7 @@
var string = "hello world";
var expected = "Hello " + "world";
function Capitalize() {
%_OneByteSeqStringSetChar(string, 0, 0x48);
%_OneByteSeqStringSetChar(0, 0x48, string);
}
Capitalize();
assertEquals(expected, string);
@ -40,7 +40,7 @@ assertEquals(expected, string);
var twobyte = "\u20ACello world";
function TwoByteCapitalize() {
%_TwoByteSeqStringSetChar(twobyte, 0, 0x48);
%_TwoByteSeqStringSetChar(0, 0x48, twobyte);
}
TwoByteCapitalize();
assertEquals(expected, twobyte);

View File

@ -47,7 +47,7 @@ function StringFromCharCode(code) {
var two_byte = %NewString(n - i, false);
for (var j = 0; i < n; i++, j++) {
var code = %_Arguments(i);
%_TwoByteSeqStringSetChar(two_byte, j, code);
%_TwoByteSeqStringSetChar(j, code, two_byte);
}
return one_byte + two_byte;
}

View File

@ -30,8 +30,8 @@
function test() {
var string = %NewString(10, true);
for (var i = 0; i < 10; i++) {
%_OneByteSeqStringSetChar(string, i, 65);
%_OneByteSeqStringSetChar(string, i, 66);
%_OneByteSeqStringSetChar(i, 65, string);
%_OneByteSeqStringSetChar(i, 66, string);
}
for (var i = 0; i < 10; i++) {
assertEquals("B", string[i]);

View File

@ -34,7 +34,7 @@
function f(string, osr) {
var world = " world";
%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48));
%_OneByteSeqStringSetChar(0, (deopt(), 0x48), string);
if (osr) while (%GetOptimizationStatus(f) == 2) {}
@ -56,7 +56,7 @@
}
function f(string) {
g(%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48)));
g(%_OneByteSeqStringSetChar(0, (deopt(), 0x48), string));
return string;
}
@ -75,7 +75,7 @@
}
function f(string) {
g(%_TwoByteSeqStringSetChar(string, 0, (deopt(), 0x48)));
g(%_TwoByteSeqStringSetChar(0, (deopt(), 0x48), string));
return string;
}

View File

@ -29,27 +29,27 @@
function test() {
var s1 = %NewString(26, true);
for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, 65);
for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, 65, s1);
assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s1);
%_OneByteSeqStringSetChar(s1, 25, 66);
%_OneByteSeqStringSetChar(25, 66, s1);
assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s1);
for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, i+65);
for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, i+65, s1);
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1);
s1 = %TruncateString(s1, 13);
assertEquals("ABCDEFGHIJKLM", s1);
var s2 = %NewString(26, false);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, 65);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, 65, s2);
assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s2);
%_TwoByteSeqStringSetChar(s2, 25, 66);
%_TwoByteSeqStringSetChar(25, 66, s2);
assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s2);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, i+65);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+65, s2);
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2);
s2 = %TruncateString(s2, 13);
assertEquals("ABCDEFGHIJKLM", s2);
var s3 = %NewString(26, false);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s3, i, i+1000);
for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+1000, s3);
for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000));
var a = [];