Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1693833002: Remove strong mode support from binary operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mistake. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 HandleAndZoneScope handles; 416 HandleAndZoneScope handles;
417 i::Factory* factory = handles.main_isolate()->factory(); 417 i::Factory* factory = handles.main_isolate()->factory();
418 BytecodeArrayBuilder builder(handles.main_isolate(), 418 BytecodeArrayBuilder builder(handles.main_isolate(),
419 handles.main_zone(), 1, 0, 1); 419 handles.main_zone(), 1, 0, 1);
420 Register reg(0); 420 Register reg(0);
421 int lhs = lhs_inputs[l]; 421 int lhs = lhs_inputs[l];
422 int rhs = rhs_inputs[r]; 422 int rhs = rhs_inputs[r];
423 builder.LoadLiteral(Smi::FromInt(lhs)) 423 builder.LoadLiteral(Smi::FromInt(lhs))
424 .StoreAccumulatorInRegister(reg) 424 .StoreAccumulatorInRegister(reg)
425 .LoadLiteral(Smi::FromInt(rhs)) 425 .LoadLiteral(Smi::FromInt(rhs))
426 .BinaryOperation(kShiftOperators[o], reg, Strength::WEAK) 426 .BinaryOperation(kShiftOperators[o], reg)
427 .Return(); 427 .Return();
428 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 428 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
429 429
430 InterpreterTester tester(handles.main_isolate(), bytecode_array); 430 InterpreterTester tester(handles.main_isolate(), bytecode_array);
431 auto callable = tester.GetCallable<>(); 431 auto callable = tester.GetCallable<>();
432 Handle<Object> return_value = callable().ToHandleChecked(); 432 Handle<Object> return_value = callable().ToHandleChecked();
433 Handle<Object> expected_value = 433 Handle<Object> expected_value =
434 factory->NewNumber(BinaryOpC(kShiftOperators[o], lhs, rhs)); 434 factory->NewNumber(BinaryOpC(kShiftOperators[o], lhs, rhs));
435 CHECK(return_value->SameValue(*expected_value)); 435 CHECK(return_value->SameValue(*expected_value));
436 } 436 }
(...skipping 11 matching lines...) Expand all
448 HandleAndZoneScope handles; 448 HandleAndZoneScope handles;
449 i::Factory* factory = handles.main_isolate()->factory(); 449 i::Factory* factory = handles.main_isolate()->factory();
450 BytecodeArrayBuilder builder(handles.main_isolate(), 450 BytecodeArrayBuilder builder(handles.main_isolate(),
451 handles.main_zone(), 1, 0, 1); 451 handles.main_zone(), 1, 0, 1);
452 Register reg(0); 452 Register reg(0);
453 int lhs = lhs_inputs[l]; 453 int lhs = lhs_inputs[l];
454 int rhs = rhs_inputs[r]; 454 int rhs = rhs_inputs[r];
455 builder.LoadLiteral(Smi::FromInt(lhs)) 455 builder.LoadLiteral(Smi::FromInt(lhs))
456 .StoreAccumulatorInRegister(reg) 456 .StoreAccumulatorInRegister(reg)
457 .LoadLiteral(Smi::FromInt(rhs)) 457 .LoadLiteral(Smi::FromInt(rhs))
458 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) 458 .BinaryOperation(kArithmeticOperators[o], reg)
459 .Return(); 459 .Return();
460 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 460 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
461 461
462 InterpreterTester tester(handles.main_isolate(), bytecode_array); 462 InterpreterTester tester(handles.main_isolate(), bytecode_array);
463 auto callable = tester.GetCallable<>(); 463 auto callable = tester.GetCallable<>();
464 Handle<Object> return_value = callable().ToHandleChecked(); 464 Handle<Object> return_value = callable().ToHandleChecked();
465 Handle<Object> expected_value = 465 Handle<Object> expected_value =
466 factory->NewNumber(BinaryOpC(kArithmeticOperators[o], lhs, rhs)); 466 factory->NewNumber(BinaryOpC(kArithmeticOperators[o], lhs, rhs));
467 CHECK(return_value->SameValue(*expected_value)); 467 CHECK(return_value->SameValue(*expected_value));
468 } 468 }
(...skipping 12 matching lines...) Expand all
481 HandleAndZoneScope handles; 481 HandleAndZoneScope handles;
482 i::Factory* factory = handles.main_isolate()->factory(); 482 i::Factory* factory = handles.main_isolate()->factory();
483 BytecodeArrayBuilder builder(handles.main_isolate(), 483 BytecodeArrayBuilder builder(handles.main_isolate(),
484 handles.main_zone(), 1, 0, 1); 484 handles.main_zone(), 1, 0, 1);
485 Register reg(0); 485 Register reg(0);
486 double lhs = lhs_inputs[l]; 486 double lhs = lhs_inputs[l];
487 double rhs = rhs_inputs[r]; 487 double rhs = rhs_inputs[r];
488 builder.LoadLiteral(factory->NewNumber(lhs)) 488 builder.LoadLiteral(factory->NewNumber(lhs))
489 .StoreAccumulatorInRegister(reg) 489 .StoreAccumulatorInRegister(reg)
490 .LoadLiteral(factory->NewNumber(rhs)) 490 .LoadLiteral(factory->NewNumber(rhs))
491 .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK) 491 .BinaryOperation(kArithmeticOperators[o], reg)
492 .Return(); 492 .Return();
493 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 493 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
494 494
495 InterpreterTester tester(handles.main_isolate(), bytecode_array); 495 InterpreterTester tester(handles.main_isolate(), bytecode_array);
496 auto callable = tester.GetCallable<>(); 496 auto callable = tester.GetCallable<>();
497 Handle<Object> return_value = callable().ToHandleChecked(); 497 Handle<Object> return_value = callable().ToHandleChecked();
498 Handle<Object> expected_value = 498 Handle<Object> expected_value =
499 factory->NewNumber(BinaryOpC(kArithmeticOperators[o], lhs, rhs)); 499 factory->NewNumber(BinaryOpC(kArithmeticOperators[o], lhs, rhs));
500 CHECK(return_value->SameValue(*expected_value)); 500 CHECK(return_value->SameValue(*expected_value));
501 } 501 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 factory->NewStringFromStaticChars("2.5")}, 536 factory->NewStringFromStaticChars("2.5")},
537 }; 537 };
538 538
539 for (size_t i = 0; i < arraysize(test_cases); i++) { 539 for (size_t i = 0; i < arraysize(test_cases); i++) {
540 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 540 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
541 0, 1); 541 0, 1);
542 Register reg(0); 542 Register reg(0);
543 builder.LoadLiteral(test_cases[i].lhs) 543 builder.LoadLiteral(test_cases[i].lhs)
544 .StoreAccumulatorInRegister(reg) 544 .StoreAccumulatorInRegister(reg)
545 .LoadLiteral(test_cases[i].rhs) 545 .LoadLiteral(test_cases[i].rhs)
546 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 546 .BinaryOperation(Token::Value::ADD, reg)
547 .Return(); 547 .Return();
548 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 548 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
549 549
550 InterpreterTester tester(handles.main_isolate(), bytecode_array); 550 InterpreterTester tester(handles.main_isolate(), bytecode_array);
551 auto callable = tester.GetCallable<>(); 551 auto callable = tester.GetCallable<>();
552 Handle<Object> return_value = callable().ToHandleChecked(); 552 Handle<Object> return_value = callable().ToHandleChecked();
553 CHECK(return_value->SameValue(*test_cases[i].expected_value)); 553 CHECK(return_value->SameValue(*test_cases[i].expected_value));
554 } 554 }
555 } 555 }
556 556
(...skipping 18 matching lines...) Expand all
575 .ToHandleChecked(); 575 .ToHandleChecked();
576 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(3)); 576 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(3));
577 } 577 }
578 578
579 579
580 TEST(InterpreterParameter8) { 580 TEST(InterpreterParameter8) {
581 HandleAndZoneScope handles; 581 HandleAndZoneScope handles;
582 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 8, 582 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 8,
583 0, 0); 583 0, 0);
584 builder.LoadAccumulatorWithRegister(builder.Parameter(0)) 584 builder.LoadAccumulatorWithRegister(builder.Parameter(0))
585 .BinaryOperation(Token::Value::ADD, builder.Parameter(1), Strength::WEAK) 585 .BinaryOperation(Token::Value::ADD, builder.Parameter(1))
586 .BinaryOperation(Token::Value::ADD, builder.Parameter(2), Strength::WEAK) 586 .BinaryOperation(Token::Value::ADD, builder.Parameter(2))
587 .BinaryOperation(Token::Value::ADD, builder.Parameter(3), Strength::WEAK) 587 .BinaryOperation(Token::Value::ADD, builder.Parameter(3))
588 .BinaryOperation(Token::Value::ADD, builder.Parameter(4), Strength::WEAK) 588 .BinaryOperation(Token::Value::ADD, builder.Parameter(4))
589 .BinaryOperation(Token::Value::ADD, builder.Parameter(5), Strength::WEAK) 589 .BinaryOperation(Token::Value::ADD, builder.Parameter(5))
590 .BinaryOperation(Token::Value::ADD, builder.Parameter(6), Strength::WEAK) 590 .BinaryOperation(Token::Value::ADD, builder.Parameter(6))
591 .BinaryOperation(Token::Value::ADD, builder.Parameter(7), Strength::WEAK) 591 .BinaryOperation(Token::Value::ADD, builder.Parameter(7))
592 .Return(); 592 .Return();
593 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 593 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
594 594
595 InterpreterTester tester(handles.main_isolate(), bytecode_array); 595 InterpreterTester tester(handles.main_isolate(), bytecode_array);
596 typedef Handle<Object> H; 596 typedef Handle<Object> H;
597 auto callable = tester.GetCallable<H, H, H, H, H, H, H, H>(); 597 auto callable = tester.GetCallable<H, H, H, H, H, H, H, H>();
598 598
599 Handle<Smi> arg1 = Handle<Smi>(Smi::FromInt(1), handles.main_isolate()); 599 Handle<Smi> arg1 = Handle<Smi>(Smi::FromInt(1), handles.main_isolate());
600 Handle<Smi> arg2 = Handle<Smi>(Smi::FromInt(2), handles.main_isolate()); 600 Handle<Smi> arg2 = Handle<Smi>(Smi::FromInt(2), handles.main_isolate());
601 Handle<Smi> arg3 = Handle<Smi>(Smi::FromInt(3), handles.main_isolate()); 601 Handle<Smi> arg3 = Handle<Smi>(Smi::FromInt(3), handles.main_isolate());
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 .StoreAccumulatorInRegister(reg) 1073 .StoreAccumulatorInRegister(reg)
1074 .LoadAccumulatorWithRegister(scratch); 1074 .LoadAccumulatorWithRegister(scratch);
1075 } 1075 }
1076 1076
1077 1077
1078 static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder& builder, 1078 static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder& builder,
1079 Register reg, int value, 1079 Register reg, int value,
1080 Register scratch) { 1080 Register scratch) {
1081 return builder.StoreAccumulatorInRegister(scratch) 1081 return builder.StoreAccumulatorInRegister(scratch)
1082 .LoadLiteral(Smi::FromInt(value)) 1082 .LoadLiteral(Smi::FromInt(value))
1083 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 1083 .BinaryOperation(Token::Value::ADD, reg)
1084 .StoreAccumulatorInRegister(reg) 1084 .StoreAccumulatorInRegister(reg)
1085 .LoadAccumulatorWithRegister(scratch); 1085 .LoadAccumulatorWithRegister(scratch);
1086 } 1086 }
1087 1087
1088 1088
1089 TEST(InterpreterJumps) { 1089 TEST(InterpreterJumps) {
1090 HandleAndZoneScope handles; 1090 HandleAndZoneScope handles;
1091 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, 1091 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0,
1092 0, 2); 1092 0, 2);
1093 Register reg(0), scratch(1); 1093 Register reg(0), scratch(1);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 Token::Value comparison = kComparisonTypes[c]; 1233 Token::Value comparison = kComparisonTypes[c];
1234 for (size_t i = 0; i < arraysize(inputs); i++) { 1234 for (size_t i = 0; i < arraysize(inputs); i++) {
1235 for (size_t j = 0; j < arraysize(inputs); j++) { 1235 for (size_t j = 0; j < arraysize(inputs); j++) {
1236 HandleAndZoneScope handles; 1236 HandleAndZoneScope handles;
1237 BytecodeArrayBuilder builder(handles.main_isolate(), 1237 BytecodeArrayBuilder builder(handles.main_isolate(),
1238 handles.main_zone(), 0, 0, 1); 1238 handles.main_zone(), 0, 0, 1);
1239 Register r0(0); 1239 Register r0(0);
1240 builder.LoadLiteral(Smi::FromInt(inputs[i])) 1240 builder.LoadLiteral(Smi::FromInt(inputs[i]))
1241 .StoreAccumulatorInRegister(r0) 1241 .StoreAccumulatorInRegister(r0)
1242 .LoadLiteral(Smi::FromInt(inputs[j])) 1242 .LoadLiteral(Smi::FromInt(inputs[j]))
1243 .CompareOperation(comparison, r0, Strength::WEAK) 1243 .CompareOperation(comparison, r0)
1244 .Return(); 1244 .Return();
1245 1245
1246 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1246 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1247 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1247 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1248 auto callable = tester.GetCallable<>(); 1248 auto callable = tester.GetCallable<>();
1249 Handle<Object> return_value = callable().ToHandleChecked(); 1249 Handle<Object> return_value = callable().ToHandleChecked();
1250 CHECK(return_value->IsBoolean()); 1250 CHECK(return_value->IsBoolean());
1251 CHECK_EQ(return_value->BooleanValue(), 1251 CHECK_EQ(return_value->BooleanValue(),
1252 CompareC(comparison, inputs[i], inputs[j])); 1252 CompareC(comparison, inputs[i], inputs[j]));
1253 } 1253 }
(...skipping 15 matching lines...) Expand all
1269 for (size_t i = 0; i < arraysize(inputs); i++) { 1269 for (size_t i = 0; i < arraysize(inputs); i++) {
1270 for (size_t j = 0; j < arraysize(inputs); j++) { 1270 for (size_t j = 0; j < arraysize(inputs); j++) {
1271 HandleAndZoneScope handles; 1271 HandleAndZoneScope handles;
1272 i::Factory* factory = handles.main_isolate()->factory(); 1272 i::Factory* factory = handles.main_isolate()->factory();
1273 BytecodeArrayBuilder builder(handles.main_isolate(), 1273 BytecodeArrayBuilder builder(handles.main_isolate(),
1274 handles.main_zone(), 0, 0, 1); 1274 handles.main_zone(), 0, 0, 1);
1275 Register r0(0); 1275 Register r0(0);
1276 builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) 1276 builder.LoadLiteral(factory->NewHeapNumber(inputs[i]))
1277 .StoreAccumulatorInRegister(r0) 1277 .StoreAccumulatorInRegister(r0)
1278 .LoadLiteral(factory->NewHeapNumber(inputs[j])) 1278 .LoadLiteral(factory->NewHeapNumber(inputs[j]))
1279 .CompareOperation(comparison, r0, Strength::WEAK) 1279 .CompareOperation(comparison, r0)
1280 .Return(); 1280 .Return();
1281 1281
1282 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1282 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1283 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1283 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1284 auto callable = tester.GetCallable<>(); 1284 auto callable = tester.GetCallable<>();
1285 Handle<Object> return_value = callable().ToHandleChecked(); 1285 Handle<Object> return_value = callable().ToHandleChecked();
1286 CHECK(return_value->IsBoolean()); 1286 CHECK(return_value->IsBoolean());
1287 CHECK_EQ(return_value->BooleanValue(), 1287 CHECK_EQ(return_value->BooleanValue(),
1288 CompareC(comparison, inputs[i], inputs[j])); 1288 CompareC(comparison, inputs[i], inputs[j]));
1289 } 1289 }
(...skipping 12 matching lines...) Expand all
1302 const char* lhs = inputs[i].c_str(); 1302 const char* lhs = inputs[i].c_str();
1303 const char* rhs = inputs[j].c_str(); 1303 const char* rhs = inputs[j].c_str();
1304 HandleAndZoneScope handles; 1304 HandleAndZoneScope handles;
1305 i::Factory* factory = handles.main_isolate()->factory(); 1305 i::Factory* factory = handles.main_isolate()->factory();
1306 BytecodeArrayBuilder builder(handles.main_isolate(), 1306 BytecodeArrayBuilder builder(handles.main_isolate(),
1307 handles.main_zone(), 0, 0, 1); 1307 handles.main_zone(), 0, 0, 1);
1308 Register r0(0); 1308 Register r0(0);
1309 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) 1309 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs))
1310 .StoreAccumulatorInRegister(r0) 1310 .StoreAccumulatorInRegister(r0)
1311 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) 1311 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs))
1312 .CompareOperation(comparison, r0, Strength::WEAK) 1312 .CompareOperation(comparison, r0)
1313 .Return(); 1313 .Return();
1314 1314
1315 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1315 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1316 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1316 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1317 auto callable = tester.GetCallable<>(); 1317 auto callable = tester.GetCallable<>();
1318 Handle<Object> return_value = callable().ToHandleChecked(); 1318 Handle<Object> return_value = callable().ToHandleChecked();
1319 CHECK(return_value->IsBoolean()); 1319 CHECK(return_value->IsBoolean());
1320 CHECK_EQ(return_value->BooleanValue(), 1320 CHECK_EQ(return_value->BooleanValue(),
1321 CompareC(comparison, inputs[i], inputs[j])); 1321 CompareC(comparison, inputs[i], inputs[j]));
1322 } 1322 }
(...skipping 25 matching lines...) Expand all
1348 HandleAndZoneScope handles; 1348 HandleAndZoneScope handles;
1349 i::Factory* factory = handles.main_isolate()->factory(); 1349 i::Factory* factory = handles.main_isolate()->factory();
1350 BytecodeArrayBuilder builder(handles.main_isolate(), 1350 BytecodeArrayBuilder builder(handles.main_isolate(),
1351 handles.main_zone(), 0, 0, 1); 1351 handles.main_zone(), 0, 0, 1);
1352 Register r0(0); 1352 Register r0(0);
1353 if (pass == 0) { 1353 if (pass == 0) {
1354 // Comparison with HeapNumber on the lhs and String on the rhs 1354 // Comparison with HeapNumber on the lhs and String on the rhs
1355 builder.LoadLiteral(factory->NewNumber(lhs)) 1355 builder.LoadLiteral(factory->NewNumber(lhs))
1356 .StoreAccumulatorInRegister(r0) 1356 .StoreAccumulatorInRegister(r0)
1357 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) 1357 .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr))
1358 .CompareOperation(comparison, r0, Strength::WEAK) 1358 .CompareOperation(comparison, r0)
1359 .Return(); 1359 .Return();
1360 } else { 1360 } else {
1361 // Comparison with HeapNumber on the rhs and String on the lhs 1361 // Comparison with HeapNumber on the rhs and String on the lhs
1362 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr)) 1362 builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr))
1363 .StoreAccumulatorInRegister(r0) 1363 .StoreAccumulatorInRegister(r0)
1364 .LoadLiteral(factory->NewNumber(rhs)) 1364 .LoadLiteral(factory->NewNumber(rhs))
1365 .CompareOperation(comparison, r0, Strength::WEAK) 1365 .CompareOperation(comparison, r0)
1366 .Return(); 1366 .Return();
1367 } 1367 }
1368 1368
1369 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1369 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1370 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1370 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1371 auto callable = tester.GetCallable<>(); 1371 auto callable = tester.GetCallable<>();
1372 Handle<Object> return_value = callable().ToHandleChecked(); 1372 Handle<Object> return_value = callable().ToHandleChecked();
1373 CHECK(return_value->IsBoolean()); 1373 CHECK(return_value->IsBoolean());
1374 CHECK_EQ(return_value->BooleanValue(), 1374 CHECK_EQ(return_value->BooleanValue(),
1375 CompareC(comparison, lhs, rhs, true)); 1375 CompareC(comparison, lhs, rhs, true));
(...skipping 13 matching lines...) Expand all
1389 Handle<i::Object> other = factory->NewNumber(3.3333); 1389 Handle<i::Object> other = factory->NewNumber(3.3333);
1390 Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other}; 1390 Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other};
1391 for (size_t i = 0; i < arraysize(cases); i++) { 1391 for (size_t i = 0; i < arraysize(cases); i++) {
1392 bool expected_value = (i == 0); 1392 bool expected_value = (i == 0);
1393 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, 1393 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0,
1394 0, 1); 1394 0, 1);
1395 Register r0(0); 1395 Register r0(0);
1396 builder.LoadLiteral(cases[i]); 1396 builder.LoadLiteral(cases[i]);
1397 builder.StoreAccumulatorInRegister(r0) 1397 builder.StoreAccumulatorInRegister(r0)
1398 .LoadLiteral(func) 1398 .LoadLiteral(func)
1399 .CompareOperation(Token::Value::INSTANCEOF, r0, Strength::WEAK) 1399 .CompareOperation(Token::Value::INSTANCEOF, r0)
1400 .Return(); 1400 .Return();
1401 1401
1402 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1402 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1403 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1403 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1404 auto callable = tester.GetCallable<>(); 1404 auto callable = tester.GetCallable<>();
1405 Handle<Object> return_value = callable().ToHandleChecked(); 1405 Handle<Object> return_value = callable().ToHandleChecked();
1406 CHECK(return_value->IsBoolean()); 1406 CHECK(return_value->IsBoolean());
1407 CHECK_EQ(return_value->BooleanValue(), expected_value); 1407 CHECK_EQ(return_value->BooleanValue(), expected_value);
1408 } 1408 }
1409 } 1409 }
1410 1410
1411 1411
1412 TEST(InterpreterTestIn) { 1412 TEST(InterpreterTestIn) {
1413 HandleAndZoneScope handles; 1413 HandleAndZoneScope handles;
1414 i::Factory* factory = handles.main_isolate()->factory(); 1414 i::Factory* factory = handles.main_isolate()->factory();
1415 // Allocate an array 1415 // Allocate an array
1416 Handle<i::JSArray> array = 1416 Handle<i::JSArray> array =
1417 factory->NewJSArray(0, i::ElementsKind::FAST_SMI_ELEMENTS); 1417 factory->NewJSArray(0, i::ElementsKind::FAST_SMI_ELEMENTS);
1418 // Check for these properties on the array object 1418 // Check for these properties on the array object
1419 const char* properties[] = {"length", "fuzzle", "x", "0"}; 1419 const char* properties[] = {"length", "fuzzle", "x", "0"};
1420 for (size_t i = 0; i < arraysize(properties); i++) { 1420 for (size_t i = 0; i < arraysize(properties); i++) {
1421 bool expected_value = (i == 0); 1421 bool expected_value = (i == 0);
1422 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0, 1422 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 0,
1423 0, 1); 1423 0, 1);
1424 Register r0(0); 1424 Register r0(0);
1425 builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i])) 1425 builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i]))
1426 .StoreAccumulatorInRegister(r0) 1426 .StoreAccumulatorInRegister(r0)
1427 .LoadLiteral(Handle<Object>::cast(array)) 1427 .LoadLiteral(Handle<Object>::cast(array))
1428 .CompareOperation(Token::Value::IN, r0, Strength::WEAK) 1428 .CompareOperation(Token::Value::IN, r0)
1429 .Return(); 1429 .Return();
1430 1430
1431 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1431 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1432 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1432 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1433 auto callable = tester.GetCallable<>(); 1433 auto callable = tester.GetCallable<>();
1434 Handle<Object> return_value = callable().ToHandleChecked(); 1434 Handle<Object> return_value = callable().ToHandleChecked();
1435 CHECK(return_value->IsBoolean()); 1435 CHECK(return_value->IsBoolean());
1436 CHECK_EQ(return_value->BooleanValue(), expected_value); 1436 CHECK_EQ(return_value->BooleanValue(), expected_value);
1437 } 1437 }
1438 } 1438 }
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 Handle<i::Object> return_value = callable().ToHandleChecked(); 4158 Handle<i::Object> return_value = callable().ToHandleChecked();
4159 CHECK(return_value->SameValue(*const_decl[i].second)); 4159 CHECK(return_value->SameValue(*const_decl[i].second));
4160 } 4160 }
4161 4161
4162 FLAG_legacy_const = old_flag_legacy_const; 4162 FLAG_legacy_const = old_flag_legacy_const;
4163 } 4163 }
4164 4164
4165 } // namespace interpreter 4165 } // namespace interpreter
4166 } // namespace internal 4166 } // namespace internal
4167 } // namespace v8 4167 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698