From: jarin@chromium.org Date: Fri, 12 Sep 2014 10:58:43 +0000 (+0000) Subject: Reland "Change the order of arguments of the (One|Two)ByteSeqStringSetChar intrinsic." X-Git-Tag: upstream/4.7.83~6949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4012624006f273e8a91d777ffc341214a235634;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index fe51f54..a6f48a5 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(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) { diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 74682e3..141fc04 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(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) { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index ee0ed36..8dbe464 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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(); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 2c2b527..6b687e5 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(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); diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 36c0b52..e679a29 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(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) { diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index b7d8929..277aceb 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(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) { diff --git a/src/runtime.cc b/src/runtime.cc index 2a1df1e..20f3110 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_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; } diff --git a/src/string.js b/src/string.js index ae65264..99f5fc9 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(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; } diff --git a/src/uri.js b/src/uri.js index 88ea75f..09079bc 100644 --- a/src/uri.js +++ b/src/uri.js @@ -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); } } diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 7f371c8..0633cdf 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(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); diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 2eb7ac8..98f1b60 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(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); diff --git a/test/mjsunit/lithium/SeqStringSetChar.js b/test/mjsunit/lithium/SeqStringSetChar.js index 3c890a8..c5bd145 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(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; } diff --git a/test/mjsunit/regress/regress-crbug-320922.js b/test/mjsunit/regress/regress-crbug-320922.js index 4a5b581..9ba759a 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(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); diff --git a/test/mjsunit/regress/regress-seqstrsetchar-ex1.js b/test/mjsunit/regress/regress-seqstrsetchar-ex1.js index c85cf56..1fd8d81 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(two_byte, j, code); + %_TwoByteSeqStringSetChar(j, code, two_byte); } return one_byte + two_byte; } diff --git a/test/mjsunit/regress/regress-seqstrsetchar-ex3.js b/test/mjsunit/regress/regress-seqstrsetchar-ex3.js index 43d2b08..0a6b211 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(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]); diff --git a/test/mjsunit/regress/string-set-char-deopt.js b/test/mjsunit/regress/string-set-char-deopt.js index 9f6d434..a4b34e8 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(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; } diff --git a/test/mjsunit/string-natives.js b/test/mjsunit/string-natives.js index 7a9009b..40fe9c6 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(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 = [];