OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 "'use strict';" | 1001 "'use strict';" |
1002 "g(15);x", | 1002 "g(15);x", |
1003 EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); | 1003 EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); |
1004 context.Check("h({})", EXPECT_RESULT, number_string); | 1004 context.Check("h({})", EXPECT_RESULT, number_string); |
1005 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); | 1005 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); |
1006 context.Check("h({})", EXPECT_RESULT, number_string); | 1006 context.Check("h({})", EXPECT_RESULT, number_string); |
1007 } | 1007 } |
1008 } | 1008 } |
1009 | 1009 |
1010 | 1010 |
1011 TEST(CrossScriptICs) { | 1011 TEST(CrossScriptLoadICs) { |
1012 i::FLAG_harmony_scoping = true; | 1012 i::FLAG_harmony_scoping = true; |
1013 i::FLAG_allow_natives_syntax = true; | 1013 i::FLAG_allow_natives_syntax = true; |
1014 | 1014 |
1015 HandleScope handle_scope(CcTest::isolate()); | 1015 HandleScope handle_scope(CcTest::isolate()); |
1016 | 1016 |
1017 { | 1017 { |
1018 SimpleContext context; | 1018 SimpleContext context; |
1019 context.Check( | 1019 context.Check( |
1020 "x = 15;" | 1020 "x = 15;" |
1021 "function f() { return x; }" | 1021 "function f() { return x; }" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 "let x = 5;" | 1055 "let x = 5;" |
1056 "f()", | 1056 "f()", |
1057 EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); | 1057 EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); |
1058 for (int k = 0; k < 3; k++) { | 1058 for (int k = 0; k < 3; k++) { |
1059 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); | 1059 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5)); |
1060 } | 1060 } |
1061 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT, | 1061 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT, |
1062 Number::New(CcTest::isolate(), 5)); | 1062 Number::New(CcTest::isolate(), 5)); |
1063 } | 1063 } |
1064 } | 1064 } |
| 1065 |
| 1066 |
| 1067 TEST(CrossScriptStoreICs) { |
| 1068 i::FLAG_harmony_scoping = true; |
| 1069 i::FLAG_allow_natives_syntax = true; |
| 1070 |
| 1071 HandleScope handle_scope(CcTest::isolate()); |
| 1072 |
| 1073 { |
| 1074 SimpleContext context; |
| 1075 context.Check( |
| 1076 "var global = this;" |
| 1077 "x = 15;" |
| 1078 "function f(v) { x = v; }" |
| 1079 "function g(v) { x = v; }" |
| 1080 "f(10); x", |
| 1081 EXPECT_RESULT, Number::New(CcTest::isolate(), 10)); |
| 1082 context.Check( |
| 1083 "'use strict';" |
| 1084 "let x = 5;" |
| 1085 "f(7); x", |
| 1086 EXPECT_RESULT, Number::New(CcTest::isolate(), 7)); |
| 1087 context.Check("global.x", EXPECT_RESULT, |
| 1088 Number::New(CcTest::isolate(), 10)); |
| 1089 for (int k = 0; k < 3; k++) { |
| 1090 context.Check("g(31); x", EXPECT_RESULT, |
| 1091 Number::New(CcTest::isolate(), 31)); |
| 1092 } |
| 1093 context.Check("global.x", EXPECT_RESULT, |
| 1094 Number::New(CcTest::isolate(), 10)); |
| 1095 for (int k = 0; k < 3; k++) { |
| 1096 context.Check("f(32); x", EXPECT_RESULT, |
| 1097 Number::New(CcTest::isolate(), 32)); |
| 1098 } |
| 1099 context.Check("global.x", EXPECT_RESULT, |
| 1100 Number::New(CcTest::isolate(), 10)); |
| 1101 context.Check("%OptimizeFunctionOnNextCall(g); g(18); x", EXPECT_RESULT, |
| 1102 Number::New(CcTest::isolate(), 18)); |
| 1103 context.Check("global.x", EXPECT_RESULT, |
| 1104 Number::New(CcTest::isolate(), 10)); |
| 1105 context.Check("%OptimizeFunctionOnNextCall(f); f(33); x", EXPECT_RESULT, |
| 1106 Number::New(CcTest::isolate(), 33)); |
| 1107 context.Check("global.x", EXPECT_RESULT, |
| 1108 Number::New(CcTest::isolate(), 10)); |
| 1109 } |
| 1110 { |
| 1111 SimpleContext context; |
| 1112 context.Check( |
| 1113 "var global = this;" |
| 1114 "x = 15;" |
| 1115 "function f(v) { x = v; }" |
| 1116 "f(10); x", |
| 1117 EXPECT_RESULT, Number::New(CcTest::isolate(), 10)); |
| 1118 for (int k = 0; k < 3; k++) { |
| 1119 context.Check("f(18); x", EXPECT_RESULT, |
| 1120 Number::New(CcTest::isolate(), 18)); |
| 1121 } |
| 1122 context.Check("%OptimizeFunctionOnNextCall(f); f(20); x", EXPECT_RESULT, |
| 1123 Number::New(CcTest::isolate(), 20)); |
| 1124 context.Check( |
| 1125 "'use strict';" |
| 1126 "let x = 5;" |
| 1127 "f(8); x", |
| 1128 EXPECT_RESULT, Number::New(CcTest::isolate(), 8)); |
| 1129 context.Check("global.x", EXPECT_RESULT, |
| 1130 Number::New(CcTest::isolate(), 20)); |
| 1131 for (int k = 0; k < 3; k++) { |
| 1132 context.Check("f(13); x", EXPECT_RESULT, |
| 1133 Number::New(CcTest::isolate(), 13)); |
| 1134 } |
| 1135 context.Check("global.x", EXPECT_RESULT, |
| 1136 Number::New(CcTest::isolate(), 20)); |
| 1137 context.Check("%OptimizeFunctionOnNextCall(f); f(41); x", EXPECT_RESULT, |
| 1138 Number::New(CcTest::isolate(), 41)); |
| 1139 context.Check("global.x", EXPECT_RESULT, |
| 1140 Number::New(CcTest::isolate(), 20)); |
| 1141 } |
| 1142 } |
OLD | NEW |