| 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/bytecode-array-iterator.h" | 10 #include "src/interpreter/bytecode-array-iterator.h" |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 CHECK(return_value->IsBoolean()); | 1255 CHECK(return_value->IsBoolean()); |
| 1256 CHECK_EQ(return_value->BooleanValue(), | 1256 CHECK_EQ(return_value->BooleanValue(), |
| 1257 CompareC(comparison, inputs[i], inputs[j])); | 1257 CompareC(comparison, inputs[i], inputs[j])); |
| 1258 } | 1258 } |
| 1259 } | 1259 } |
| 1260 } | 1260 } |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 | 1263 |
| 1264 TEST(InterpreterStringComparisons) { | 1264 TEST(InterpreterStringComparisons) { |
| 1265 HandleAndZoneScope handles; |
| 1266 i::Isolate* isolate = handles.main_isolate(); |
| 1267 i::Factory* factory = isolate->factory(); |
| 1268 |
| 1265 std::string inputs[] = {"A", "abc", "z", "", "Foo!", "Foo"}; | 1269 std::string inputs[] = {"A", "abc", "z", "", "Foo!", "Foo"}; |
| 1266 | 1270 |
| 1267 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { | 1271 for (size_t c = 0; c < arraysize(kComparisonTypes); c++) { |
| 1268 Token::Value comparison = kComparisonTypes[c]; | 1272 Token::Value comparison = kComparisonTypes[c]; |
| 1269 for (size_t i = 0; i < arraysize(inputs); i++) { | 1273 for (size_t i = 0; i < arraysize(inputs); i++) { |
| 1270 for (size_t j = 0; j < arraysize(inputs); j++) { | 1274 for (size_t j = 0; j < arraysize(inputs); j++) { |
| 1275 CanonicalHandleScope canonical(isolate); |
| 1271 const char* lhs = inputs[i].c_str(); | 1276 const char* lhs = inputs[i].c_str(); |
| 1272 const char* rhs = inputs[j].c_str(); | 1277 const char* rhs = inputs[j].c_str(); |
| 1273 HandleAndZoneScope handles; | |
| 1274 i::Factory* factory = handles.main_isolate()->factory(); | |
| 1275 BytecodeArrayBuilder builder(handles.main_isolate(), | 1278 BytecodeArrayBuilder builder(handles.main_isolate(), |
| 1276 handles.main_zone(), 0, 0, 1); | 1279 handles.main_zone(), 0, 0, 1); |
| 1277 | |
| 1278 Register r0(0); | 1280 Register r0(0); |
| 1279 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) | 1281 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) |
| 1280 .StoreAccumulatorInRegister(r0) | 1282 .StoreAccumulatorInRegister(r0) |
| 1281 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) | 1283 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) |
| 1282 .CompareOperation(comparison, r0) | 1284 .CompareOperation(comparison, r0) |
| 1283 .Return(); | 1285 .Return(); |
| 1284 | 1286 |
| 1285 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1287 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1286 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1288 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1287 auto callable = tester.GetCallable<>(); | 1289 auto callable = tester.GetCallable<>(); |
| (...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 auto callable = tester.GetCallable<>(); | 4204 auto callable = tester.GetCallable<>(); |
| 4203 | 4205 |
| 4204 Handle<i::Object> return_value = callable().ToHandleChecked(); | 4206 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 4205 CHECK(return_value->SameValue(*tests[i].second)); | 4207 CHECK(return_value->SameValue(*tests[i].second)); |
| 4206 } | 4208 } |
| 4207 } | 4209 } |
| 4208 | 4210 |
| 4209 } // namespace interpreter | 4211 } // namespace interpreter |
| 4210 } // namespace internal | 4212 } // namespace internal |
| 4211 } // namespace v8 | 4213 } // namespace v8 |
| OLD | NEW |