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 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 std::string source( | 3086 std::string source( |
3087 InterpreterTester::SourceForBody(to_name_tests[i].first)); | 3087 InterpreterTester::SourceForBody(to_name_tests[i].first)); |
3088 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 3088 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
3089 auto callable = tester.GetCallable<>(); | 3089 auto callable = tester.GetCallable<>(); |
3090 | 3090 |
3091 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3091 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3092 CHECK(return_value->SameValue(*to_name_tests[i].second)); | 3092 CHECK(return_value->SameValue(*to_name_tests[i].second)); |
3093 } | 3093 } |
3094 } | 3094 } |
3095 | 3095 |
| 3096 |
| 3097 TEST(TemporaryRegisterAllocation) { |
| 3098 HandleAndZoneScope handles; |
| 3099 i::Isolate* isolate = handles.main_isolate(); |
| 3100 i::Factory* factory = isolate->factory(); |
| 3101 |
| 3102 std::pair<const char*, Handle<Object>> reg_tests[] = { |
| 3103 {"function add(a, b, c) {" |
| 3104 " return a + b + c;" |
| 3105 "}" |
| 3106 "function f() {" |
| 3107 " var a = 10, b = 10;" |
| 3108 " return add(a, b++, b);" |
| 3109 "}", |
| 3110 factory->NewNumberFromInt(31)}, |
| 3111 {"function add(a, b, c, d) {" |
| 3112 " return a + b + c + d;" |
| 3113 "}" |
| 3114 "function f() {" |
| 3115 " var x = 10, y = 20, z = 30;" |
| 3116 " return x + add(x, (y= x++), x, z);" |
| 3117 "}", |
| 3118 factory->NewNumberFromInt(71)}, |
| 3119 }; |
| 3120 |
| 3121 for (size_t i = 0; i < arraysize(reg_tests); i++) { |
| 3122 InterpreterTester tester(handles.main_isolate(), reg_tests[i].first); |
| 3123 auto callable = tester.GetCallable<>(); |
| 3124 |
| 3125 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3126 CHECK(return_value->SameValue(*reg_tests[i].second)); |
| 3127 } |
| 3128 } |
| 3129 |
3096 } // namespace interpreter | 3130 } // namespace interpreter |
3097 } // namespace internal | 3131 } // namespace internal |
3098 } // namespace v8 | 3132 } // namespace v8 |
OLD | NEW |