Reviewers: Jakob,
Description:
Fix for (One|Two)ByteSeqStringSetChar evaluation order/deopt.
This makes the evaluation order consistent between full codegen
and Hydrogen (so that deopt does not screw up stack).
[email protected]
BUG=
Please review this at https://codereview.chromium.org/159983008/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+44, -22 lines):
M src/hydrogen.cc
A + test/mjsunit/regress/string-set-char-deopt.js
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
038efcc4297361685009d3e7079f9a3fab4b4e77..b2bf66cb9d8902f0b929e5cfef2aa845454eda08
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -10259,12 +10259,13 @@ void
HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) {
void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
CallRuntime* call) {
ASSERT(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();
- HValue* string = Pop();
Add<HSeqStringSetChar>(String::ONE_BYTE_ENCODING, string,
index, value);
Add<HSimulate>(call->id(), FIXED_SIMULATE);
@@ -10275,12 +10276,13 @@ void
HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar(
CallRuntime* call) {
ASSERT(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();
- HValue* string = Pop();
Add<HSeqStringSetChar>(String::TWO_BYTE_ENCODING, string,
index, value);
Add<HSimulate>(call->id(), FIXED_SIMULATE);
Index: test/mjsunit/regress/string-set-char-deopt.js
diff --git a/test/mjsunit/regress/binop-in-effect-context-deopt.js
b/test/mjsunit/regress/string-set-char-deopt.js
similarity index 65%
copy from test/mjsunit/regress/binop-in-effect-context-deopt.js
copy to test/mjsunit/regress/string-set-char-deopt.js
index
fb7280a0d1128c6baad81e759aad6b6bec3c6528..9f6d43453840e41d73c4a4f5702346d0fe6e16fa
100644
--- a/test/mjsunit/regress/binop-in-effect-context-deopt.js
+++ b/test/mjsunit/regress/string-set-char-deopt.js
@@ -27,39 +27,59 @@
// Flags: --allow-natives-syntax
-(function BinopInEffectContextDeoptAndOsr() {
- function f(a, deopt, osr) {
- var result = (a + 10, "result");
- var dummy = deopt + 0;
+(function OneByteSeqStringSetCharDeoptOsr() {
+ function deopt() {
+ %DeoptimizeFunction(f);
+ }
+
+ function f(string, osr) {
+ var world = " world";
+ %_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48));
+
if (osr) while (%GetOptimizationStatus(f) == 2) {}
- return result;
+
+ return string + world;
}
- assertEquals("result", f(true, 3, false));
- assertEquals("result", f(true, 3, false));
+ assertEquals("Hello " + "world", f("hello", false));
%OptimizeFunctionOnNextCall(f);
- assertEquals("result", f(true, "foo", true));
+ assertEquals("Hello " + "world", f("hello", true));
})();
-(function BinopInEffectContextLazyDeopt() {
- function deopt_f() {
+(function OneByteSeqStringSetCharDeopt() {
+ function deopt() {
%DeoptimizeFunction(f);
- return "dummy";
}
- function h() {
- return { toString : deopt_f };
+ function g(x) {
+ }
+
+ function f(string) {
+ g(%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48)));
+ return string;
+ }
+
+ assertEquals("Hell" + "o", f("hello"));
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals("Hell" + "o", f("hello"));
+})();
+
+
+(function TwoByteSeqStringSetCharDeopt() {
+ function deopt() {
+ %DeoptimizeFunction(f);
}
function g(x) {
}
- function f() {
- return g(void(h() + ""));
- };
+ function f(string) {
+ g(%_TwoByteSeqStringSetChar(string, 0, (deopt(), 0x48)));
+ return string;
+ }
- f();
+ assertEquals("Hell" + "o", f("\u20ACello"));
%OptimizeFunctionOnNextCall(f);
- f();
+ assertEquals("Hell" + "o", f("\u20ACello"));
})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.