From: jarin@chromium.org Date: Fri, 12 Sep 2014 08:49:22 +0000 (+0000) Subject: Revert "Change the order of arguments of the (One|Two)ByteSeqStringSetChar intrinsic." X-Git-Tag: upstream/4.7.83~6957 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc0674d0a74bbe71794eaffe94c758f7ca861c9e;p=platform%2Fupstream%2Fv8.git Revert "Change the order of arguments of the (One|Two)ByteSeqStringSetChar intrinsic." This reverts commit r23899. TBR=ulan@chromium.org Review URL: https://codereview.chromium.org/552253003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23902 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index a6f48a5..fe51f54 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -3444,9 +3444,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = r1; Register value = r2; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // 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(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(index, value); if (FLAG_debug_code) { diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 141fc04..74682e3 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -3131,9 +3131,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register value = x2; Register scratch = x10; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // 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(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(value, index); if (FLAG_debug_code) { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 8dbe464..ee0ed36 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -11539,9 +11539,10 @@ void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) { void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( CallRuntime* call) { DCHECK(call->arguments()->length() == 3); - CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); + // We need to follow the evaluation order of full codegen. 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(); @@ -11555,9 +11556,10 @@ void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( CallRuntime* call) { DCHECK(call->arguments()->length() == 3); - CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); + // We need to follow the evaluation order of full codegen. 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(); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 6b687e5..2c2b527 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -3362,9 +3362,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = ebx; Register value = ecx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ pop(value); __ pop(index); @@ -3398,9 +3398,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { Register index = ebx; Register value = ecx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ pop(value); __ pop(index); diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index e679a29..36c0b52 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3435,9 +3435,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = a1; Register value = a2; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // 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(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(index, value); if (FLAG_debug_code) { diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 277aceb..b7d8929 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -3434,9 +3434,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = a1; Register value = a2; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // 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(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(index, value); if (FLAG_debug_code) { diff --git a/src/runtime.cc b/src/runtime.cc index 138924f..f0c1d95 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -15415,9 +15415,9 @@ RUNTIME_FUNCTION(RuntimeReference_StringCharAt) { RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) { SealHandleScope shs(isolate); DCHECK(args.length() == 3); - CONVERT_INT32_ARG_CHECKED(index, 0); - CONVERT_INT32_ARG_CHECKED(value, 1); - CONVERT_ARG_CHECKED(SeqOneByteString, string, 2); + CONVERT_ARG_CHECKED(SeqOneByteString, string, 0); + CONVERT_INT32_ARG_CHECKED(index, 1); + CONVERT_INT32_ARG_CHECKED(value, 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_INT32_ARG_CHECKED(index, 0); - CONVERT_INT32_ARG_CHECKED(value, 1); - CONVERT_ARG_CHECKED(SeqTwoByteString, string, 2); + CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0); + CONVERT_INT32_ARG_CHECKED(index, 1); + CONVERT_INT32_ARG_CHECKED(value, 2); string->SeqTwoByteStringSet(index, value); return string; } diff --git a/src/string.js b/src/string.js index 99f5fc9..ae65264 100644 --- a/src/string.js +++ b/src/string.js @@ -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(i, code, one_byte); + %_OneByteSeqStringSetChar(one_byte, i, code); } 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(j, code, two_byte); + %_TwoByteSeqStringSetChar(two_byte, j, code); } return one_byte + two_byte; } diff --git a/src/uri.js b/src/uri.js index a2a36cf..88ea75f 100644 --- a/src/uri.js +++ b/src/uri.js @@ -172,10 +172,10 @@ throw new $URIError("URI malformed"); } if (value < 0x10000) { - %_TwoByteSeqStringSetChar(index++, value, result); + %_TwoByteSeqStringSetChar(result, index++, value); } else { - %_TwoByteSeqStringSetChar(index++, (value >> 10) + 0xd7c0, result); - %_TwoByteSeqStringSetChar(index++, (value & 0x3ff) + 0xdc00, result); + %_TwoByteSeqStringSetChar(result, index++, (value >> 10) + 0xd7c0); + %_TwoByteSeqStringSetChar(result, index++, (value & 0x3ff) + 0xdc00); } return index; } @@ -205,7 +205,7 @@ var result = %NewString(array.length, NEW_ONE_BYTE_STRING); for (var i = 0; i < array.length; i++) { - %_OneByteSeqStringSetChar(i, array[i], result); + %_OneByteSeqStringSetChar(result, i, array[i]); } 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(index++, 37, one_bye); // '%'. - %_OneByteSeqStringSetChar(index++, uri.charCodeAt(k+1), one_byte); - %_OneByteSeqStringSetChar(index++, uri.charCodeAt(k+2), one_byte); + %_OneByteSeqStringSetChar(one_byte, index++, 37); // '%'. + %_OneByteSeqStringSetChar(one_byte, index++, uri.charCodeAt(k+1)); + %_OneByteSeqStringSetChar(one_byte, index++, uri.charCodeAt(k+2)); } else { - %_OneByteSeqStringSetChar(index++, cc, one_byte); + %_OneByteSeqStringSetChar(one_byte, index++, cc); } k += 2; } else { if (code > 0x7f) break; // Assumption wrong, two-byte string. - %_OneByteSeqStringSetChar(index++, code, one_byte); + %_OneByteSeqStringSetChar(one_byte, index++, code); } } @@ -264,14 +264,14 @@ } index = URIDecodeOctets(octets, two_byte, index); } else if (reserved(cc)) { - %_TwoByteSeqStringSetChar(index++, 37, two_byte); // '%'. - %_TwoByteSeqStringSetChar(index++, uri.charCodeAt(k - 1), two_byte); - %_TwoByteSeqStringSetChar(index++, uri.charCodeAt(k), two_byte); + %_TwoByteSeqStringSetChar(two_byte, index++, 37); // '%'. + %_TwoByteSeqStringSetChar(two_byte, index++, uri.charCodeAt(k - 1)); + %_TwoByteSeqStringSetChar(two_byte, index++, uri.charCodeAt(k)); } else { - %_TwoByteSeqStringSetChar(index++, cc, two_byte); + %_TwoByteSeqStringSetChar(two_byte, index++, cc); } } else { - %_TwoByteSeqStringSetChar(index++, code, two_byte); + %_TwoByteSeqStringSetChar(two_byte, index++, code); } } diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 0633cdf..7f371c8 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -3351,9 +3351,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = rbx; Register value = rcx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(value); __ Pop(index); @@ -3384,9 +3384,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { Register index = rbx; Register value = rcx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ Pop(value); __ Pop(index); diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 98f1b60..2eb7ac8 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -3356,9 +3356,9 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { Register index = ebx; Register value = ecx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ pop(value); __ pop(index); @@ -3392,9 +3392,9 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { Register index = ebx; Register value = ecx; - VisitForStackValue(args->at(0)); // index - VisitForStackValue(args->at(1)); // value - VisitForAccumulatorValue(args->at(2)); // string + VisitForStackValue(args->at(1)); // index + VisitForStackValue(args->at(2)); // value + VisitForAccumulatorValue(args->at(0)); // string __ pop(value); __ pop(index); diff --git a/test/mjsunit/lithium/SeqStringSetChar.js b/test/mjsunit/lithium/SeqStringSetChar.js index c5bd145..3c890a8 100644 --- a/test/mjsunit/lithium/SeqStringSetChar.js +++ b/test/mjsunit/lithium/SeqStringSetChar.js @@ -29,13 +29,13 @@ function MyStringFromCharCode(code, i) { var one_byte = %NewString(3, true); - %_OneByteSeqStringSetChar(0, code, one_byte); - %_OneByteSeqStringSetChar(1, code, one_byte); - %_OneByteSeqStringSetChar(i, code, one_byte); + %_OneByteSeqStringSetChar(one_byte, 0, code); + %_OneByteSeqStringSetChar(one_byte, 1, code); + %_OneByteSeqStringSetChar(one_byte, i, code); var two_byte = %NewString(3, false); - %_TwoByteSeqStringSetChar(0, code, two_byte); - %_TwoByteSeqStringSetChar(1, code, two_byte); - %_TwoByteSeqStringSetChar(i, code, two_byte); + %_TwoByteSeqStringSetChar(two_byte, 0, code); + %_TwoByteSeqStringSetChar(two_byte, 1, code); + %_TwoByteSeqStringSetChar(two_byte, i, code); return one_byte + two_byte; } diff --git a/test/mjsunit/regress/regress-crbug-320922.js b/test/mjsunit/regress/regress-crbug-320922.js index 9ba759a..4a5b581 100644 --- a/test/mjsunit/regress/regress-crbug-320922.js +++ b/test/mjsunit/regress/regress-crbug-320922.js @@ -30,7 +30,7 @@ var string = "hello world"; var expected = "Hello " + "world"; function Capitalize() { - %_OneByteSeqStringSetChar(0, 0x48, string); + %_OneByteSeqStringSetChar(string, 0, 0x48); } Capitalize(); assertEquals(expected, string); @@ -40,7 +40,7 @@ assertEquals(expected, string); var twobyte = "\u20ACello world"; function TwoByteCapitalize() { - %_TwoByteSeqStringSetChar(0, 0x48, twobyte); + %_TwoByteSeqStringSetChar(twobyte, 0, 0x48); } TwoByteCapitalize(); assertEquals(expected, twobyte); diff --git a/test/mjsunit/regress/regress-seqstrsetchar-ex1.js b/test/mjsunit/regress/regress-seqstrsetchar-ex1.js index 1fd8d81..c85cf56 100644 --- a/test/mjsunit/regress/regress-seqstrsetchar-ex1.js +++ b/test/mjsunit/regress/regress-seqstrsetchar-ex1.js @@ -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(j, code, two_byte); + %_TwoByteSeqStringSetChar(two_byte, j, code); } return one_byte + two_byte; } diff --git a/test/mjsunit/regress/regress-seqstrsetchar-ex3.js b/test/mjsunit/regress/regress-seqstrsetchar-ex3.js index 0a6b211..43d2b08 100644 --- a/test/mjsunit/regress/regress-seqstrsetchar-ex3.js +++ b/test/mjsunit/regress/regress-seqstrsetchar-ex3.js @@ -30,8 +30,8 @@ function test() { var string = %NewString(10, true); for (var i = 0; i < 10; i++) { - %_OneByteSeqStringSetChar(i, 65, string); - %_OneByteSeqStringSetChar(i, 66, string); + %_OneByteSeqStringSetChar(string, i, 65); + %_OneByteSeqStringSetChar(string, i, 66); } for (var i = 0; i < 10; i++) { assertEquals("B", string[i]); diff --git a/test/mjsunit/regress/string-set-char-deopt.js b/test/mjsunit/regress/string-set-char-deopt.js index a4b34e8..9f6d434 100644 --- a/test/mjsunit/regress/string-set-char-deopt.js +++ b/test/mjsunit/regress/string-set-char-deopt.js @@ -34,7 +34,7 @@ function f(string, osr) { var world = " world"; - %_OneByteSeqStringSetChar(0, (deopt(), 0x48), string); + %_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48)); if (osr) while (%GetOptimizationStatus(f) == 2) {} @@ -56,7 +56,7 @@ } function f(string) { - g(%_OneByteSeqStringSetChar(0, (deopt(), 0x48), string)); + g(%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48))); return string; } @@ -75,7 +75,7 @@ } function f(string) { - g(%_TwoByteSeqStringSetChar(0, (deopt(), 0x48), string)); + g(%_TwoByteSeqStringSetChar(string, 0, (deopt(), 0x48))); return string; } diff --git a/test/mjsunit/string-natives.js b/test/mjsunit/string-natives.js index 40fe9c6..7a9009b 100644 --- a/test/mjsunit/string-natives.js +++ b/test/mjsunit/string-natives.js @@ -29,27 +29,27 @@ function test() { var s1 = %NewString(26, true); - for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, 65, s1); + for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, 65); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s1); - %_OneByteSeqStringSetChar(25, 66, s1); + %_OneByteSeqStringSetChar(s1, 25, 66); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s1); - for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, i+65, s1); + for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, i+65); assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1); s1 = %TruncateString(s1, 13); assertEquals("ABCDEFGHIJKLM", s1); var s2 = %NewString(26, false); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, 65, s2); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, 65); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s2); - %_TwoByteSeqStringSetChar(25, 66, s2); + %_TwoByteSeqStringSetChar(s2, 25, 66); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s2); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+65, s2); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, i+65); assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2); s2 = %TruncateString(s2, 13); assertEquals("ABCDEFGHIJKLM", s2); var s3 = %NewString(26, false); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+1000, s3); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s3, i, i+1000); for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000)); var a = [];