OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/execution.h" | 7 #include "src/execution.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 std::make_pair("var a = { val: 11 }; return ++a.val;", | 2224 std::make_pair("var a = { val: 11 }; return ++a.val;", |
2225 handle(Smi::FromInt(12), isolate)), | 2225 handle(Smi::FromInt(12), isolate)), |
2226 std::make_pair("var name = 'val'; var a = { val: 22 }; return --a[name];", | 2226 std::make_pair("var name = 'val'; var a = { val: 22 }; return --a[name];", |
2227 handle(Smi::FromInt(21), isolate)), | 2227 handle(Smi::FromInt(21), isolate)), |
2228 std::make_pair("var name = 'val'; var a = { val: 22 }; return a[name]++;", | 2228 std::make_pair("var name = 'val'; var a = { val: 22 }; return a[name]++;", |
2229 handle(Smi::FromInt(22), isolate)), | 2229 handle(Smi::FromInt(22), isolate)), |
2230 std::make_pair("var a = 1; (function() { a = 2 })(); return ++a;", | 2230 std::make_pair("var a = 1; (function() { a = 2 })(); return ++a;", |
2231 handle(Smi::FromInt(3), isolate)), | 2231 handle(Smi::FromInt(3), isolate)), |
2232 std::make_pair("var a = 1; (function() { a = 2 })(); return a--;", | 2232 std::make_pair("var a = 1; (function() { a = 2 })(); return a--;", |
2233 handle(Smi::FromInt(2), isolate)), | 2233 handle(Smi::FromInt(2), isolate)), |
| 2234 std::make_pair("var i = 5; while(i--) {}; return i;", |
| 2235 handle(Smi::FromInt(-1), isolate)), |
| 2236 std::make_pair("var i = 1; if(i--) { return 1; } else { return 2; };", |
| 2237 handle(Smi::FromInt(1), isolate)), |
| 2238 std::make_pair("var i = -2; do {} while(i++) {}; return i;", |
| 2239 handle(Smi::FromInt(1), isolate)), |
| 2240 std::make_pair("var i = -1; for(; i++; ) {}; return i", |
| 2241 handle(Smi::FromInt(1), isolate)), |
| 2242 std::make_pair("var i = 20; switch(i++) {\n" |
| 2243 " case 20: return 1;\n" |
| 2244 " default: return 2;\n" |
| 2245 "}", |
| 2246 handle(Smi::FromInt(1), isolate)), |
2234 }; | 2247 }; |
2235 | 2248 |
2236 for (size_t i = 0; i < arraysize(count_ops); i++) { | 2249 for (size_t i = 0; i < arraysize(count_ops); i++) { |
2237 std::string source(InterpreterTester::SourceForBody(count_ops[i].first)); | 2250 std::string source(InterpreterTester::SourceForBody(count_ops[i].first)); |
2238 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 2251 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
2239 auto callable = tester.GetCallable<>(); | 2252 auto callable = tester.GetCallable<>(); |
2240 | 2253 |
2241 Handle<i::Object> return_value = callable().ToHandleChecked(); | 2254 Handle<i::Object> return_value = callable().ToHandleChecked(); |
2242 CHECK(return_value->SameValue(*count_ops[i].second)); | 2255 CHECK(return_value->SameValue(*count_ops[i].second)); |
2243 } | 2256 } |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3545 auto callable = tester.GetCallable<>(); | 3558 auto callable = tester.GetCallable<>(); |
3546 | 3559 |
3547 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3560 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3548 CHECK(return_value->SameValue(*eval_global[i].second)); | 3561 CHECK(return_value->SameValue(*eval_global[i].second)); |
3549 } | 3562 } |
3550 } | 3563 } |
3551 | 3564 |
3552 } // namespace interpreter | 3565 } // namespace interpreter |
3553 } // namespace internal | 3566 } // namespace internal |
3554 } // namespace v8 | 3567 } // namespace v8 |
OLD | NEW |