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

Side by Side Diff: src/builtins/builtins-array.cc

Issue 2319243002: [stubs] Fixing loads/stores from arrays by int32 offsets/indices. Step 3. (Closed)
Patch Set: Fixing redness Created 4 years, 3 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
« no previous file with comments | « no previous file | src/code-stub-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 7
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 10
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) { 1262 void Builtins::Generate_ArrayIncludes(CodeStubAssembler* assembler) {
1263 typedef compiler::Node Node; 1263 typedef compiler::Node Node;
1264 typedef CodeStubAssembler::Label Label; 1264 typedef CodeStubAssembler::Label Label;
1265 typedef CodeStubAssembler::Variable Variable; 1265 typedef CodeStubAssembler::Variable Variable;
1266 1266
1267 Node* array = assembler->Parameter(0); 1267 Node* array = assembler->Parameter(0);
1268 Node* search_element = assembler->Parameter(1); 1268 Node* search_element = assembler->Parameter(1);
1269 Node* start_from = assembler->Parameter(2); 1269 Node* start_from = assembler->Parameter(2);
1270 Node* context = assembler->Parameter(3 + 2); 1270 Node* context = assembler->Parameter(3 + 2);
1271 1271
1272 Node* int32_zero = assembler->Int32Constant(0); 1272 Node* intptr_zero = assembler->IntPtrConstant(0);
1273 Node* int32_one = assembler->Int32Constant(1); 1273 Node* intptr_one = assembler->IntPtrConstant(1);
1274 1274
1275 Node* the_hole = assembler->TheHoleConstant(); 1275 Node* the_hole = assembler->TheHoleConstant();
1276 Node* undefined = assembler->UndefinedConstant(); 1276 Node* undefined = assembler->UndefinedConstant();
1277 Node* heap_number_map = assembler->HeapNumberMapConstant(); 1277 Node* heap_number_map = assembler->HeapNumberMapConstant();
1278 1278
1279 Variable len_var(assembler, MachineRepresentation::kWord32), 1279 Variable len_var(assembler, MachineType::PointerRepresentation()),
1280 index_var(assembler, MachineRepresentation::kWord32), 1280 index_var(assembler, MachineType::PointerRepresentation()),
1281 start_from_var(assembler, MachineRepresentation::kWord32); 1281 start_from_var(assembler, MachineType::PointerRepresentation());
1282 1282
1283 Label init_k(assembler), return_true(assembler), return_false(assembler), 1283 Label init_k(assembler), return_true(assembler), return_false(assembler),
1284 call_runtime(assembler); 1284 call_runtime(assembler);
1285 1285
1286 Label init_len(assembler); 1286 Label init_len(assembler);
1287 1287
1288 index_var.Bind(int32_zero); 1288 index_var.Bind(intptr_zero);
1289 len_var.Bind(int32_zero); 1289 len_var.Bind(intptr_zero);
1290 1290
1291 // Take slow path if not a JSArray, if retrieving elements requires 1291 // Take slow path if not a JSArray, if retrieving elements requires
1292 // traversing prototype, or if access checks are required. 1292 // traversing prototype, or if access checks are required.
1293 assembler->BranchIfFastJSArray(array, context, &init_len, &call_runtime); 1293 assembler->BranchIfFastJSArray(array, context, &init_len, &call_runtime);
1294 1294
1295 assembler->Bind(&init_len); 1295 assembler->Bind(&init_len);
1296 { 1296 {
1297 // Handle case where JSArray length is not an Smi in the runtime 1297 // Handle case where JSArray length is not an Smi in the runtime
1298 Node* len = assembler->LoadObjectField(array, JSArray::kLengthOffset); 1298 Node* len = assembler->LoadObjectField(array, JSArray::kLengthOffset);
1299 assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime); 1299 assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime);
1300 1300
1301 len_var.Bind(assembler->SmiToWord(len)); 1301 len_var.Bind(assembler->SmiToWord(len));
1302 assembler->Branch(assembler->Word32Equal(len_var.value(), int32_zero), 1302 assembler->Branch(assembler->WordEqual(len_var.value(), intptr_zero),
1303 &return_false, &init_k); 1303 &return_false, &init_k);
1304 } 1304 }
1305 1305
1306 assembler->Bind(&init_k); 1306 assembler->Bind(&init_k);
1307 { 1307 {
1308 Label done(assembler), init_k_smi(assembler), init_k_heap_num(assembler), 1308 Label done(assembler), init_k_smi(assembler), init_k_heap_num(assembler),
1309 init_k_zero(assembler), init_k_n(assembler); 1309 init_k_zero(assembler), init_k_n(assembler);
1310 Callable call_to_integer = CodeFactory::ToInteger(assembler->isolate()); 1310 Callable call_to_integer = CodeFactory::ToInteger(assembler->isolate());
1311 Node* tagged_n = assembler->CallStub(call_to_integer, context, start_from); 1311 Node* tagged_n = assembler->CallStub(call_to_integer, context, start_from);
1312 1312
1313 assembler->Branch(assembler->WordIsSmi(tagged_n), &init_k_smi, 1313 assembler->Branch(assembler->WordIsSmi(tagged_n), &init_k_smi,
1314 &init_k_heap_num); 1314 &init_k_heap_num);
1315 1315
1316 assembler->Bind(&init_k_smi); 1316 assembler->Bind(&init_k_smi);
1317 { 1317 {
1318 start_from_var.Bind(assembler->SmiToWord32(tagged_n)); 1318 start_from_var.Bind(assembler->SmiUntag(tagged_n));
1319 assembler->Goto(&init_k_n); 1319 assembler->Goto(&init_k_n);
1320 } 1320 }
1321 1321
1322 assembler->Bind(&init_k_heap_num); 1322 assembler->Bind(&init_k_heap_num);
1323 { 1323 {
1324 Label do_return_false(assembler); 1324 Label do_return_false(assembler);
1325 Node* fp_len = assembler->ChangeInt32ToFloat64(len_var.value()); 1325 // This round is lossless for all valid lengths.
1326 Node* fp_len = assembler->RoundIntPtrToFloat64(len_var.value());
1326 Node* fp_n = assembler->LoadHeapNumberValue(tagged_n); 1327 Node* fp_n = assembler->LoadHeapNumberValue(tagged_n);
1327 assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len), 1328 assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len),
1328 &do_return_false); 1329 &do_return_false);
1329 start_from_var.Bind(assembler->TruncateFloat64ToWord32(fp_n)); 1330 start_from_var.Bind(assembler->ChangeInt32ToIntPtr(
1331 assembler->TruncateFloat64ToWord32(fp_n)));
1330 assembler->Goto(&init_k_n); 1332 assembler->Goto(&init_k_n);
1331 1333
1332 assembler->Bind(&do_return_false); 1334 assembler->Bind(&do_return_false);
1333 { 1335 {
1334 index_var.Bind(int32_zero); 1336 index_var.Bind(intptr_zero);
1335 assembler->Goto(&return_false); 1337 assembler->Goto(&return_false);
1336 } 1338 }
1337 } 1339 }
1338 1340
1339 assembler->Bind(&init_k_n); 1341 assembler->Bind(&init_k_n);
1340 { 1342 {
1341 Label if_positive(assembler), if_negative(assembler), done(assembler); 1343 Label if_positive(assembler), if_negative(assembler), done(assembler);
1342 assembler->Branch( 1344 assembler->Branch(
1343 assembler->Int32LessThan(start_from_var.value(), int32_zero), 1345 assembler->IntPtrLessThan(start_from_var.value(), intptr_zero),
1344 &if_negative, &if_positive); 1346 &if_negative, &if_positive);
1345 1347
1346 assembler->Bind(&if_positive); 1348 assembler->Bind(&if_positive);
1347 { 1349 {
1348 index_var.Bind(start_from_var.value()); 1350 index_var.Bind(start_from_var.value());
1349 assembler->Goto(&done); 1351 assembler->Goto(&done);
1350 } 1352 }
1351 1353
1352 assembler->Bind(&if_negative); 1354 assembler->Bind(&if_negative);
1353 { 1355 {
1354 index_var.Bind( 1356 index_var.Bind(
1355 assembler->Int32Add(len_var.value(), start_from_var.value())); 1357 assembler->IntPtrAdd(len_var.value(), start_from_var.value()));
1356 assembler->Branch( 1358 assembler->Branch(
1357 assembler->Int32LessThan(index_var.value(), int32_zero), 1359 assembler->IntPtrLessThan(index_var.value(), intptr_zero),
1358 &init_k_zero, &done); 1360 &init_k_zero, &done);
1359 } 1361 }
1360 1362
1361 assembler->Bind(&init_k_zero); 1363 assembler->Bind(&init_k_zero);
1362 { 1364 {
1363 index_var.Bind(int32_zero); 1365 index_var.Bind(intptr_zero);
1364 assembler->Goto(&done); 1366 assembler->Goto(&done);
1365 } 1367 }
1366 1368
1367 assembler->Bind(&done); 1369 assembler->Bind(&done);
1368 } 1370 }
1369 } 1371 }
1370 1372
1371 static int32_t kElementsKind[] = { 1373 static int32_t kElementsKind[] = {
1372 FAST_SMI_ELEMENTS, FAST_HOLEY_SMI_ELEMENTS, FAST_ELEMENTS, 1374 FAST_SMI_ELEMENTS, FAST_HOLEY_SMI_ELEMENTS, FAST_ELEMENTS,
1373 FAST_HOLEY_ELEMENTS, FAST_DOUBLE_ELEMENTS, FAST_HOLEY_DOUBLE_ELEMENTS, 1375 FAST_HOLEY_ELEMENTS, FAST_DOUBLE_ELEMENTS, FAST_HOLEY_DOUBLE_ELEMENTS,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 1411 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
1410 assembler->Goto(&heap_num_loop); 1412 assembler->Goto(&heap_num_loop);
1411 1413
1412 assembler->Bind(&not_heap_num); 1414 assembler->Bind(&not_heap_num);
1413 Node* search_type = assembler->LoadMapInstanceType(map); 1415 Node* search_type = assembler->LoadMapInstanceType(map);
1414 assembler->GotoIf( 1416 assembler->GotoIf(
1415 assembler->Int32LessThan( 1417 assembler->Int32LessThan(
1416 search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 1418 search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1417 &string_loop); 1419 &string_loop);
1418 assembler->GotoIf( 1420 assembler->GotoIf(
1419 assembler->WordEqual(search_type, 1421 assembler->Word32Equal(search_type,
1420 assembler->Int32Constant(SIMD128_VALUE_TYPE)), 1422 assembler->Int32Constant(SIMD128_VALUE_TYPE)),
1421 &simd_loop); 1423 &simd_loop);
1422 assembler->Goto(&ident_loop); 1424 assembler->Goto(&ident_loop);
1423 1425
1424 assembler->Bind(&ident_loop); 1426 assembler->Bind(&ident_loop);
1425 { 1427 {
1426 assembler->GotoUnless( 1428 assembler->GotoUnless(
1427 assembler->Int32LessThan(index_var.value(), len_var.value()), 1429 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1428 &return_false); 1430 &return_false);
1429 Node* element_k = 1431 Node* element_k = assembler->LoadFixedArrayElement(
1430 assembler->LoadFixedArrayElement(elements, index_var.value()); 1432 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1431 assembler->GotoIf(assembler->WordEqual(element_k, search_element), 1433 assembler->GotoIf(assembler->WordEqual(element_k, search_element),
1432 &return_true); 1434 &return_true);
1433 1435
1434 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1436 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1435 assembler->Goto(&ident_loop); 1437 assembler->Goto(&ident_loop);
1436 } 1438 }
1437 1439
1438 assembler->Bind(&undef_loop); 1440 assembler->Bind(&undef_loop);
1439 { 1441 {
1440 assembler->GotoUnless( 1442 assembler->GotoUnless(
1441 assembler->Int32LessThan(index_var.value(), len_var.value()), 1443 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1442 &return_false); 1444 &return_false);
1443 Node* element_k = 1445 Node* element_k = assembler->LoadFixedArrayElement(
1444 assembler->LoadFixedArrayElement(elements, index_var.value()); 1446 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1445 assembler->GotoIf(assembler->WordEqual(element_k, undefined), 1447 assembler->GotoIf(assembler->WordEqual(element_k, undefined),
1446 &return_true); 1448 &return_true);
1447 assembler->GotoIf(assembler->WordEqual(element_k, the_hole), 1449 assembler->GotoIf(assembler->WordEqual(element_k, the_hole),
1448 &return_true); 1450 &return_true);
1449 1451
1450 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1452 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1451 assembler->Goto(&undef_loop); 1453 assembler->Goto(&undef_loop);
1452 } 1454 }
1453 1455
1454 assembler->Bind(&heap_num_loop); 1456 assembler->Bind(&heap_num_loop);
1455 { 1457 {
1456 Label nan_loop(assembler, &index_var), 1458 Label nan_loop(assembler, &index_var),
1457 not_nan_loop(assembler, &index_var); 1459 not_nan_loop(assembler, &index_var);
1458 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop, 1460 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop,
1459 &not_nan_loop); 1461 &not_nan_loop);
1460 1462
1461 assembler->Bind(&not_nan_loop); 1463 assembler->Bind(&not_nan_loop);
1462 { 1464 {
1463 Label continue_loop(assembler), not_smi(assembler); 1465 Label continue_loop(assembler), not_smi(assembler);
1464 assembler->GotoUnless( 1466 assembler->GotoUnless(
1465 assembler->Int32LessThan(index_var.value(), len_var.value()), 1467 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1466 &return_false); 1468 &return_false);
1467 Node* element_k = 1469 Node* element_k = assembler->LoadFixedArrayElement(
1468 assembler->LoadFixedArrayElement(elements, index_var.value()); 1470 elements, index_var.value(), 0,
1471 CodeStubAssembler::INTPTR_PARAMETERS);
1469 assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi); 1472 assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi);
1470 assembler->Branch( 1473 assembler->Branch(
1471 assembler->Float64Equal(search_num.value(), 1474 assembler->Float64Equal(search_num.value(),
1472 assembler->SmiToFloat64(element_k)), 1475 assembler->SmiToFloat64(element_k)),
1473 &return_true, &continue_loop); 1476 &return_true, &continue_loop);
1474 1477
1475 assembler->Bind(&not_smi); 1478 assembler->Bind(&not_smi);
1476 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k), 1479 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k),
1477 heap_number_map), 1480 heap_number_map),
1478 &continue_loop); 1481 &continue_loop);
1479 assembler->BranchIfFloat64Equal( 1482 assembler->BranchIfFloat64Equal(
1480 search_num.value(), assembler->LoadHeapNumberValue(element_k), 1483 search_num.value(), assembler->LoadHeapNumberValue(element_k),
1481 &return_true, &continue_loop); 1484 &return_true, &continue_loop);
1482 1485
1483 assembler->Bind(&continue_loop); 1486 assembler->Bind(&continue_loop);
1484 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1487 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1485 assembler->Goto(&not_nan_loop); 1488 assembler->Goto(&not_nan_loop);
1486 } 1489 }
1487 1490
1488 assembler->Bind(&nan_loop); 1491 assembler->Bind(&nan_loop);
1489 { 1492 {
1490 Label continue_loop(assembler); 1493 Label continue_loop(assembler);
1491 assembler->GotoUnless( 1494 assembler->GotoUnless(
1492 assembler->Int32LessThan(index_var.value(), len_var.value()), 1495 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1493 &return_false); 1496 &return_false);
1494 Node* element_k = 1497 Node* element_k = assembler->LoadFixedArrayElement(
1495 assembler->LoadFixedArrayElement(elements, index_var.value()); 1498 elements, index_var.value(), 0,
1499 CodeStubAssembler::INTPTR_PARAMETERS);
1496 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop); 1500 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
1497 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k), 1501 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k),
1498 heap_number_map), 1502 heap_number_map),
1499 &continue_loop); 1503 &continue_loop);
1500 assembler->BranchIfFloat64IsNaN( 1504 assembler->BranchIfFloat64IsNaN(
1501 assembler->LoadHeapNumberValue(element_k), &return_true, 1505 assembler->LoadHeapNumberValue(element_k), &return_true,
1502 &continue_loop); 1506 &continue_loop);
1503 1507
1504 assembler->Bind(&continue_loop); 1508 assembler->Bind(&continue_loop);
1505 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1509 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1506 assembler->Goto(&nan_loop); 1510 assembler->Goto(&nan_loop);
1507 } 1511 }
1508 } 1512 }
1509 1513
1510 assembler->Bind(&string_loop); 1514 assembler->Bind(&string_loop);
1511 { 1515 {
1512 Label continue_loop(assembler); 1516 Label continue_loop(assembler);
1513 assembler->GotoUnless( 1517 assembler->GotoUnless(
1514 assembler->Int32LessThan(index_var.value(), len_var.value()), 1518 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1515 &return_false); 1519 &return_false);
1516 Node* element_k = 1520 Node* element_k = assembler->LoadFixedArrayElement(
1517 assembler->LoadFixedArrayElement(elements, index_var.value()); 1521 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1518 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop); 1522 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
1519 assembler->GotoUnless(assembler->Int32LessThan( 1523 assembler->GotoUnless(assembler->Int32LessThan(
1520 assembler->LoadInstanceType(element_k), 1524 assembler->LoadInstanceType(element_k),
1521 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 1525 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1522 &continue_loop); 1526 &continue_loop);
1523 1527
1524 // TODO(bmeurer): Consider inlining the StringEqual logic here. 1528 // TODO(bmeurer): Consider inlining the StringEqual logic here.
1525 Callable callable = CodeFactory::StringEqual(assembler->isolate()); 1529 Callable callable = CodeFactory::StringEqual(assembler->isolate());
1526 Node* result = 1530 Node* result =
1527 assembler->CallStub(callable, context, search_element, element_k); 1531 assembler->CallStub(callable, context, search_element, element_k);
1528 assembler->Branch( 1532 assembler->Branch(
1529 assembler->WordEqual(assembler->BooleanConstant(true), result), 1533 assembler->WordEqual(assembler->BooleanConstant(true), result),
1530 &return_true, &continue_loop); 1534 &return_true, &continue_loop);
1531 1535
1532 assembler->Bind(&continue_loop); 1536 assembler->Bind(&continue_loop);
1533 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1537 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1534 assembler->Goto(&string_loop); 1538 assembler->Goto(&string_loop);
1535 } 1539 }
1536 1540
1537 assembler->Bind(&simd_loop); 1541 assembler->Bind(&simd_loop);
1538 { 1542 {
1539 Label continue_loop(assembler, &index_var), 1543 Label continue_loop(assembler, &index_var),
1540 loop_body(assembler, &index_var); 1544 loop_body(assembler, &index_var);
1541 Node* map = assembler->LoadMap(search_element); 1545 Node* map = assembler->LoadMap(search_element);
1542 1546
1543 assembler->Goto(&loop_body); 1547 assembler->Goto(&loop_body);
1544 assembler->Bind(&loop_body); 1548 assembler->Bind(&loop_body);
1545 assembler->GotoUnless( 1549 assembler->GotoUnless(
1546 assembler->Int32LessThan(index_var.value(), len_var.value()), 1550 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1547 &return_false); 1551 &return_false);
1548 1552
1549 Node* element_k = 1553 Node* element_k = assembler->LoadFixedArrayElement(
1550 assembler->LoadFixedArrayElement(elements, index_var.value()); 1554 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1551 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop); 1555 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
1552 1556
1553 Node* map_k = assembler->LoadMap(element_k); 1557 Node* map_k = assembler->LoadMap(element_k);
1554 assembler->BranchIfSimd128Equal(search_element, map, element_k, map_k, 1558 assembler->BranchIfSimd128Equal(search_element, map, element_k, map_k,
1555 &return_true, &continue_loop); 1559 &return_true, &continue_loop);
1556 1560
1557 assembler->Bind(&continue_loop); 1561 assembler->Bind(&continue_loop);
1558 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1562 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1559 assembler->Goto(&loop_body); 1563 assembler->Goto(&loop_body);
1560 } 1564 }
1561 } 1565 }
1562 1566
1563 assembler->Bind(&if_packed_doubles); 1567 assembler->Bind(&if_packed_doubles);
1564 { 1568 {
1565 Label nan_loop(assembler, &index_var), not_nan_loop(assembler, &index_var), 1569 Label nan_loop(assembler, &index_var), not_nan_loop(assembler, &index_var),
1566 hole_loop(assembler, &index_var), search_notnan(assembler); 1570 hole_loop(assembler, &index_var), search_notnan(assembler);
1567 Variable search_num(assembler, MachineRepresentation::kFloat64); 1571 Variable search_num(assembler, MachineRepresentation::kFloat64);
1568 1572
1569 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan); 1573 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan);
1570 search_num.Bind(assembler->SmiToFloat64(search_element)); 1574 search_num.Bind(assembler->SmiToFloat64(search_element));
1571 assembler->Goto(&not_nan_loop); 1575 assembler->Goto(&not_nan_loop);
1572 1576
1573 assembler->Bind(&search_notnan); 1577 assembler->Bind(&search_notnan);
1574 assembler->GotoIf(assembler->WordNotEqual( 1578 assembler->GotoIf(assembler->WordNotEqual(
1575 assembler->LoadMap(search_element), heap_number_map), 1579 assembler->LoadMap(search_element), heap_number_map),
1576 &return_false); 1580 &return_false);
1577 1581
1578 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 1582 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
1579 1583
1580 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop, 1584 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop,
1581 &not_nan_loop); 1585 &not_nan_loop);
1582 1586
1583 // Search for HeapNumber 1587 // Search for HeapNumber
1584 assembler->Bind(&not_nan_loop); 1588 assembler->Bind(&not_nan_loop);
1585 { 1589 {
1586 Label continue_loop(assembler); 1590 Label continue_loop(assembler);
1587 assembler->GotoUnless( 1591 assembler->GotoUnless(
1588 assembler->Int32LessThan(index_var.value(), len_var.value()), 1592 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1589 &return_false); 1593 &return_false);
1590 Node* element_k = assembler->LoadFixedDoubleArrayElement( 1594 Node* element_k = assembler->LoadFixedDoubleArrayElement(
1591 elements, index_var.value(), MachineType::Float64()); 1595 elements, index_var.value(), MachineType::Float64(), 0,
1596 CodeStubAssembler::INTPTR_PARAMETERS);
1592 assembler->BranchIfFloat64Equal(element_k, search_num.value(), 1597 assembler->BranchIfFloat64Equal(element_k, search_num.value(),
1593 &return_true, &continue_loop); 1598 &return_true, &continue_loop);
1594 assembler->Bind(&continue_loop); 1599 assembler->Bind(&continue_loop);
1595 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1600 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1596 assembler->Goto(&not_nan_loop); 1601 assembler->Goto(&not_nan_loop);
1597 } 1602 }
1598 1603
1599 // Search for NaN 1604 // Search for NaN
1600 assembler->Bind(&nan_loop); 1605 assembler->Bind(&nan_loop);
1601 { 1606 {
1602 Label continue_loop(assembler); 1607 Label continue_loop(assembler);
1603 assembler->GotoUnless( 1608 assembler->GotoUnless(
1604 assembler->Int32LessThan(index_var.value(), len_var.value()), 1609 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1605 &return_false); 1610 &return_false);
1606 Node* element_k = assembler->LoadFixedDoubleArrayElement( 1611 Node* element_k = assembler->LoadFixedDoubleArrayElement(
1607 elements, index_var.value(), MachineType::Float64()); 1612 elements, index_var.value(), MachineType::Float64(), 0,
1613 CodeStubAssembler::INTPTR_PARAMETERS);
1608 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop); 1614 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop);
1609 assembler->Bind(&continue_loop); 1615 assembler->Bind(&continue_loop);
1610 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1616 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1611 assembler->Goto(&nan_loop); 1617 assembler->Goto(&nan_loop);
1612 } 1618 }
1613 } 1619 }
1614 1620
1615 assembler->Bind(&if_holey_doubles); 1621 assembler->Bind(&if_holey_doubles);
1616 { 1622 {
1617 Label nan_loop(assembler, &index_var), not_nan_loop(assembler, &index_var), 1623 Label nan_loop(assembler, &index_var), not_nan_loop(assembler, &index_var),
1618 hole_loop(assembler, &index_var), search_notnan(assembler); 1624 hole_loop(assembler, &index_var), search_notnan(assembler);
1619 Variable search_num(assembler, MachineRepresentation::kFloat64); 1625 Variable search_num(assembler, MachineRepresentation::kFloat64);
1620 1626
(...skipping 11 matching lines...) Expand all
1632 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 1638 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
1633 1639
1634 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop, 1640 assembler->BranchIfFloat64IsNaN(search_num.value(), &nan_loop,
1635 &not_nan_loop); 1641 &not_nan_loop);
1636 1642
1637 // Search for HeapNumber 1643 // Search for HeapNumber
1638 assembler->Bind(&not_nan_loop); 1644 assembler->Bind(&not_nan_loop);
1639 { 1645 {
1640 Label continue_loop(assembler); 1646 Label continue_loop(assembler);
1641 assembler->GotoUnless( 1647 assembler->GotoUnless(
1642 assembler->Int32LessThan(index_var.value(), len_var.value()), 1648 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1643 &return_false); 1649 &return_false);
1644 1650
1645 if (kPointerSize == kDoubleSize) { 1651 if (kPointerSize == kDoubleSize) {
1646 Node* element = assembler->LoadFixedDoubleArrayElement( 1652 Node* element = assembler->LoadFixedDoubleArrayElement(
1647 elements, index_var.value(), MachineType::Uint64()); 1653 elements, index_var.value(), MachineType::Uint64(), 0,
1654 CodeStubAssembler::INTPTR_PARAMETERS);
1648 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); 1655 Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
1649 assembler->GotoIf(assembler->Word64Equal(element, the_hole), 1656 assembler->GotoIf(assembler->Word64Equal(element, the_hole),
1650 &continue_loop); 1657 &continue_loop);
1651 } else { 1658 } else {
1652 Node* element_upper = assembler->LoadFixedDoubleArrayElement( 1659 Node* element_upper = assembler->LoadFixedDoubleArrayElement(
1653 elements, index_var.value(), MachineType::Uint32(), 1660 elements, index_var.value(), MachineType::Uint32(),
1654 kIeeeDoubleExponentWordOffset); 1661 kIeeeDoubleExponentWordOffset,
1662 CodeStubAssembler::INTPTR_PARAMETERS);
1655 assembler->GotoIf( 1663 assembler->GotoIf(
1656 assembler->Word32Equal(element_upper, 1664 assembler->Word32Equal(element_upper,
1657 assembler->Int32Constant(kHoleNanUpper32)), 1665 assembler->Int32Constant(kHoleNanUpper32)),
1658 &continue_loop); 1666 &continue_loop);
1659 } 1667 }
1660 1668
1661 Node* element_k = assembler->LoadFixedDoubleArrayElement( 1669 Node* element_k = assembler->LoadFixedDoubleArrayElement(
1662 elements, index_var.value(), MachineType::Float64()); 1670 elements, index_var.value(), MachineType::Float64(), 0,
1671 CodeStubAssembler::INTPTR_PARAMETERS);
1663 assembler->BranchIfFloat64Equal(element_k, search_num.value(), 1672 assembler->BranchIfFloat64Equal(element_k, search_num.value(),
1664 &return_true, &continue_loop); 1673 &return_true, &continue_loop);
1665 assembler->Bind(&continue_loop); 1674 assembler->Bind(&continue_loop);
1666 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1675 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1667 assembler->Goto(&not_nan_loop); 1676 assembler->Goto(&not_nan_loop);
1668 } 1677 }
1669 1678
1670 // Search for NaN 1679 // Search for NaN
1671 assembler->Bind(&nan_loop); 1680 assembler->Bind(&nan_loop);
1672 { 1681 {
1673 Label continue_loop(assembler); 1682 Label continue_loop(assembler);
1674 assembler->GotoUnless( 1683 assembler->GotoUnless(
1675 assembler->Int32LessThan(index_var.value(), len_var.value()), 1684 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1676 &return_false); 1685 &return_false);
1677 1686
1678 if (kPointerSize == kDoubleSize) { 1687 if (kPointerSize == kDoubleSize) {
1679 Node* element = assembler->LoadFixedDoubleArrayElement( 1688 Node* element = assembler->LoadFixedDoubleArrayElement(
1680 elements, index_var.value(), MachineType::Uint64()); 1689 elements, index_var.value(), MachineType::Uint64(), 0,
1690 CodeStubAssembler::INTPTR_PARAMETERS);
1681 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); 1691 Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
1682 assembler->GotoIf(assembler->Word64Equal(element, the_hole), 1692 assembler->GotoIf(assembler->Word64Equal(element, the_hole),
1683 &continue_loop); 1693 &continue_loop);
1684 } else { 1694 } else {
1685 Node* element_upper = assembler->LoadFixedDoubleArrayElement( 1695 Node* element_upper = assembler->LoadFixedDoubleArrayElement(
1686 elements, index_var.value(), MachineType::Uint32(), 1696 elements, index_var.value(), MachineType::Uint32(),
1687 kIeeeDoubleExponentWordOffset); 1697 kIeeeDoubleExponentWordOffset,
1698 CodeStubAssembler::INTPTR_PARAMETERS);
1688 assembler->GotoIf( 1699 assembler->GotoIf(
1689 assembler->Word32Equal(element_upper, 1700 assembler->Word32Equal(element_upper,
1690 assembler->Int32Constant(kHoleNanUpper32)), 1701 assembler->Int32Constant(kHoleNanUpper32)),
1691 &continue_loop); 1702 &continue_loop);
1692 } 1703 }
1693 1704
1694 Node* element_k = assembler->LoadFixedDoubleArrayElement( 1705 Node* element_k = assembler->LoadFixedDoubleArrayElement(
1695 elements, index_var.value(), MachineType::Float64()); 1706 elements, index_var.value(), MachineType::Float64(), 0,
1707 CodeStubAssembler::INTPTR_PARAMETERS);
1696 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop); 1708 assembler->BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop);
1697 assembler->Bind(&continue_loop); 1709 assembler->Bind(&continue_loop);
1698 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1710 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1699 assembler->Goto(&nan_loop); 1711 assembler->Goto(&nan_loop);
1700 } 1712 }
1701 1713
1702 // Search for the Hole 1714 // Search for the Hole
1703 assembler->Bind(&hole_loop); 1715 assembler->Bind(&hole_loop);
1704 { 1716 {
1705 assembler->GotoUnless( 1717 assembler->GotoUnless(
1706 assembler->Int32LessThan(index_var.value(), len_var.value()), 1718 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1707 &return_false); 1719 &return_false);
1708 1720
1709 if (kPointerSize == kDoubleSize) { 1721 if (kPointerSize == kDoubleSize) {
1710 Node* element = assembler->LoadFixedDoubleArrayElement( 1722 Node* element = assembler->LoadFixedDoubleArrayElement(
1711 elements, index_var.value(), MachineType::Uint64()); 1723 elements, index_var.value(), MachineType::Uint64(), 0,
1724 CodeStubAssembler::INTPTR_PARAMETERS);
1712 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); 1725 Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
1713 assembler->GotoIf(assembler->Word64Equal(element, the_hole), 1726 assembler->GotoIf(assembler->Word64Equal(element, the_hole),
1714 &return_true); 1727 &return_true);
1715 } else { 1728 } else {
1716 Node* element_upper = assembler->LoadFixedDoubleArrayElement( 1729 Node* element_upper = assembler->LoadFixedDoubleArrayElement(
1717 elements, index_var.value(), MachineType::Uint32(), 1730 elements, index_var.value(), MachineType::Uint32(),
1718 kIeeeDoubleExponentWordOffset); 1731 kIeeeDoubleExponentWordOffset,
1732 CodeStubAssembler::INTPTR_PARAMETERS);
1719 assembler->GotoIf( 1733 assembler->GotoIf(
1720 assembler->Word32Equal(element_upper, 1734 assembler->Word32Equal(element_upper,
1721 assembler->Int32Constant(kHoleNanUpper32)), 1735 assembler->Int32Constant(kHoleNanUpper32)),
1722 &return_true); 1736 &return_true);
1723 } 1737 }
1724 1738
1725 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1739 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1726 assembler->Goto(&hole_loop); 1740 assembler->Goto(&hole_loop);
1727 } 1741 }
1728 } 1742 }
1729 1743
1730 assembler->Bind(&return_true); 1744 assembler->Bind(&return_true);
1731 assembler->Return(assembler->BooleanConstant(true)); 1745 assembler->Return(assembler->BooleanConstant(true));
1732 1746
1733 assembler->Bind(&return_false); 1747 assembler->Bind(&return_false);
1734 assembler->Return(assembler->BooleanConstant(false)); 1748 assembler->Return(assembler->BooleanConstant(false));
1735 1749
1736 assembler->Bind(&call_runtime); 1750 assembler->Bind(&call_runtime);
1737 assembler->Return(assembler->CallRuntime(Runtime::kArrayIncludes_Slow, 1751 assembler->Return(assembler->CallRuntime(Runtime::kArrayIncludes_Slow,
1738 context, array, search_element, 1752 context, array, search_element,
1739 start_from)); 1753 start_from));
1740 } 1754 }
1741 1755
1742 void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) { 1756 void Builtins::Generate_ArrayIndexOf(CodeStubAssembler* assembler) {
1743 typedef compiler::Node Node; 1757 typedef compiler::Node Node;
1744 typedef CodeStubAssembler::Label Label; 1758 typedef CodeStubAssembler::Label Label;
1745 typedef CodeStubAssembler::Variable Variable; 1759 typedef CodeStubAssembler::Variable Variable;
1746 1760
1747 Node* array = assembler->Parameter(0); 1761 Node* array = assembler->Parameter(0);
1748 Node* search_element = assembler->Parameter(1); 1762 Node* search_element = assembler->Parameter(1);
1749 Node* start_from = assembler->Parameter(2); 1763 Node* start_from = assembler->Parameter(2);
1750 Node* context = assembler->Parameter(3 + 2); 1764 Node* context = assembler->Parameter(3 + 2);
1751 1765
1752 Node* int32_zero = assembler->Int32Constant(0); 1766 Node* intptr_zero = assembler->IntPtrConstant(0);
1753 Node* int32_one = assembler->Int32Constant(1); 1767 Node* intptr_one = assembler->IntPtrConstant(1);
1754 1768
1755 Node* undefined = assembler->UndefinedConstant(); 1769 Node* undefined = assembler->UndefinedConstant();
1756 Node* heap_number_map = assembler->HeapNumberMapConstant(); 1770 Node* heap_number_map = assembler->HeapNumberMapConstant();
1757 1771
1758 Variable len_var(assembler, MachineRepresentation::kWord32), 1772 Variable len_var(assembler, MachineType::PointerRepresentation()),
1759 index_var(assembler, MachineRepresentation::kWord32), 1773 index_var(assembler, MachineType::PointerRepresentation()),
1760 start_from_var(assembler, MachineRepresentation::kWord32); 1774 start_from_var(assembler, MachineType::PointerRepresentation());
1761 1775
1762 Label init_k(assembler), return_found(assembler), return_not_found(assembler), 1776 Label init_k(assembler), return_found(assembler), return_not_found(assembler),
1763 call_runtime(assembler); 1777 call_runtime(assembler);
1764 1778
1765 Label init_len(assembler); 1779 Label init_len(assembler);
1766 1780
1767 index_var.Bind(int32_zero); 1781 index_var.Bind(intptr_zero);
1768 len_var.Bind(int32_zero); 1782 len_var.Bind(intptr_zero);
1769 1783
1770 // Take slow path if not a JSArray, if retrieving elements requires 1784 // Take slow path if not a JSArray, if retrieving elements requires
1771 // traversing prototype, or if access checks are required. 1785 // traversing prototype, or if access checks are required.
1772 assembler->BranchIfFastJSArray(array, context, &init_len, &call_runtime); 1786 assembler->BranchIfFastJSArray(array, context, &init_len, &call_runtime);
1773 1787
1774 assembler->Bind(&init_len); 1788 assembler->Bind(&init_len);
1775 { 1789 {
1776 // Handle case where JSArray length is not an Smi in the runtime 1790 // Handle case where JSArray length is not an Smi in the runtime
1777 Node* len = assembler->LoadObjectField(array, JSArray::kLengthOffset); 1791 Node* len = assembler->LoadObjectField(array, JSArray::kLengthOffset);
1778 assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime); 1792 assembler->GotoUnless(assembler->WordIsSmi(len), &call_runtime);
1779 1793
1780 len_var.Bind(assembler->SmiToWord(len)); 1794 len_var.Bind(assembler->SmiToWord(len));
1781 assembler->Branch(assembler->Word32Equal(len_var.value(), int32_zero), 1795 assembler->Branch(assembler->WordEqual(len_var.value(), intptr_zero),
1782 &return_not_found, &init_k); 1796 &return_not_found, &init_k);
1783 } 1797 }
1784 1798
1785 assembler->Bind(&init_k); 1799 assembler->Bind(&init_k);
1786 { 1800 {
1787 Label done(assembler), init_k_smi(assembler), init_k_heap_num(assembler), 1801 Label done(assembler), init_k_smi(assembler), init_k_heap_num(assembler),
1788 init_k_zero(assembler), init_k_n(assembler); 1802 init_k_zero(assembler), init_k_n(assembler);
1789 Callable call_to_integer = CodeFactory::ToInteger(assembler->isolate()); 1803 Callable call_to_integer = CodeFactory::ToInteger(assembler->isolate());
1790 Node* tagged_n = assembler->CallStub(call_to_integer, context, start_from); 1804 Node* tagged_n = assembler->CallStub(call_to_integer, context, start_from);
1791 1805
1792 assembler->Branch(assembler->WordIsSmi(tagged_n), &init_k_smi, 1806 assembler->Branch(assembler->WordIsSmi(tagged_n), &init_k_smi,
1793 &init_k_heap_num); 1807 &init_k_heap_num);
1794 1808
1795 assembler->Bind(&init_k_smi); 1809 assembler->Bind(&init_k_smi);
1796 { 1810 {
1797 start_from_var.Bind(assembler->SmiToWord32(tagged_n)); 1811 start_from_var.Bind(assembler->SmiUntag(tagged_n));
1798 assembler->Goto(&init_k_n); 1812 assembler->Goto(&init_k_n);
1799 } 1813 }
1800 1814
1801 assembler->Bind(&init_k_heap_num); 1815 assembler->Bind(&init_k_heap_num);
1802 { 1816 {
1803 Label do_return_not_found(assembler); 1817 Label do_return_not_found(assembler);
1804 Node* fp_len = assembler->ChangeInt32ToFloat64(len_var.value()); 1818 // This round is lossless for all valid lengths.
1819 Node* fp_len = assembler->RoundIntPtrToFloat64(len_var.value());
1805 Node* fp_n = assembler->LoadHeapNumberValue(tagged_n); 1820 Node* fp_n = assembler->LoadHeapNumberValue(tagged_n);
1806 assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len), 1821 assembler->GotoIf(assembler->Float64GreaterThanOrEqual(fp_n, fp_len),
1807 &do_return_not_found); 1822 &do_return_not_found);
1808 start_from_var.Bind(assembler->TruncateFloat64ToWord32(fp_n)); 1823 start_from_var.Bind(assembler->ChangeInt32ToIntPtr(
1824 assembler->TruncateFloat64ToWord32(fp_n)));
1809 assembler->Goto(&init_k_n); 1825 assembler->Goto(&init_k_n);
1810 1826
1811 assembler->Bind(&do_return_not_found); 1827 assembler->Bind(&do_return_not_found);
1812 { 1828 {
1813 index_var.Bind(int32_zero); 1829 index_var.Bind(intptr_zero);
1814 assembler->Goto(&return_not_found); 1830 assembler->Goto(&return_not_found);
1815 } 1831 }
1816 } 1832 }
1817 1833
1818 assembler->Bind(&init_k_n); 1834 assembler->Bind(&init_k_n);
1819 { 1835 {
1820 Label if_positive(assembler), if_negative(assembler), done(assembler); 1836 Label if_positive(assembler), if_negative(assembler), done(assembler);
1821 assembler->Branch( 1837 assembler->Branch(
1822 assembler->Int32LessThan(start_from_var.value(), int32_zero), 1838 assembler->IntPtrLessThan(start_from_var.value(), intptr_zero),
1823 &if_negative, &if_positive); 1839 &if_negative, &if_positive);
1824 1840
1825 assembler->Bind(&if_positive); 1841 assembler->Bind(&if_positive);
1826 { 1842 {
1827 index_var.Bind(start_from_var.value()); 1843 index_var.Bind(start_from_var.value());
1828 assembler->Goto(&done); 1844 assembler->Goto(&done);
1829 } 1845 }
1830 1846
1831 assembler->Bind(&if_negative); 1847 assembler->Bind(&if_negative);
1832 { 1848 {
1833 index_var.Bind( 1849 index_var.Bind(
1834 assembler->Int32Add(len_var.value(), start_from_var.value())); 1850 assembler->IntPtrAdd(len_var.value(), start_from_var.value()));
1835 assembler->Branch( 1851 assembler->Branch(
1836 assembler->Int32LessThan(index_var.value(), int32_zero), 1852 assembler->IntPtrLessThan(index_var.value(), intptr_zero),
1837 &init_k_zero, &done); 1853 &init_k_zero, &done);
1838 } 1854 }
1839 1855
1840 assembler->Bind(&init_k_zero); 1856 assembler->Bind(&init_k_zero);
1841 { 1857 {
1842 index_var.Bind(int32_zero); 1858 index_var.Bind(intptr_zero);
1843 assembler->Goto(&done); 1859 assembler->Goto(&done);
1844 } 1860 }
1845 1861
1846 assembler->Bind(&done); 1862 assembler->Bind(&done);
1847 } 1863 }
1848 } 1864 }
1849 1865
1850 static int32_t kElementsKind[] = { 1866 static int32_t kElementsKind[] = {
1851 FAST_SMI_ELEMENTS, FAST_HOLEY_SMI_ELEMENTS, FAST_ELEMENTS, 1867 FAST_SMI_ELEMENTS, FAST_HOLEY_SMI_ELEMENTS, FAST_ELEMENTS,
1852 FAST_HOLEY_ELEMENTS, FAST_DOUBLE_ELEMENTS, FAST_HOLEY_DOUBLE_ELEMENTS, 1868 FAST_HOLEY_ELEMENTS, FAST_DOUBLE_ELEMENTS, FAST_HOLEY_DOUBLE_ELEMENTS,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 1904 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
1889 assembler->Goto(&heap_num_loop); 1905 assembler->Goto(&heap_num_loop);
1890 1906
1891 assembler->Bind(&not_heap_num); 1907 assembler->Bind(&not_heap_num);
1892 Node* search_type = assembler->LoadMapInstanceType(map); 1908 Node* search_type = assembler->LoadMapInstanceType(map);
1893 assembler->GotoIf( 1909 assembler->GotoIf(
1894 assembler->Int32LessThan( 1910 assembler->Int32LessThan(
1895 search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 1911 search_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1896 &string_loop); 1912 &string_loop);
1897 assembler->GotoIf( 1913 assembler->GotoIf(
1898 assembler->WordEqual(search_type, 1914 assembler->Word32Equal(search_type,
1899 assembler->Int32Constant(SIMD128_VALUE_TYPE)), 1915 assembler->Int32Constant(SIMD128_VALUE_TYPE)),
1900 &simd_loop); 1916 &simd_loop);
1901 assembler->Goto(&ident_loop); 1917 assembler->Goto(&ident_loop);
1902 1918
1903 assembler->Bind(&ident_loop); 1919 assembler->Bind(&ident_loop);
1904 { 1920 {
1905 assembler->GotoUnless( 1921 assembler->GotoUnless(
1906 assembler->Int32LessThan(index_var.value(), len_var.value()), 1922 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1907 &return_not_found); 1923 &return_not_found);
1908 Node* element_k = 1924 Node* element_k = assembler->LoadFixedArrayElement(
1909 assembler->LoadFixedArrayElement(elements, index_var.value()); 1925 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1910 assembler->GotoIf(assembler->WordEqual(element_k, search_element), 1926 assembler->GotoIf(assembler->WordEqual(element_k, search_element),
1911 &return_found); 1927 &return_found);
1912 1928
1913 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1929 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1914 assembler->Goto(&ident_loop); 1930 assembler->Goto(&ident_loop);
1915 } 1931 }
1916 1932
1917 assembler->Bind(&undef_loop); 1933 assembler->Bind(&undef_loop);
1918 { 1934 {
1919 assembler->GotoUnless( 1935 assembler->GotoUnless(
1920 assembler->Int32LessThan(index_var.value(), len_var.value()), 1936 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1921 &return_not_found); 1937 &return_not_found);
1922 Node* element_k = 1938 Node* element_k = assembler->LoadFixedArrayElement(
1923 assembler->LoadFixedArrayElement(elements, index_var.value()); 1939 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1924 assembler->GotoIf(assembler->WordEqual(element_k, undefined), 1940 assembler->GotoIf(assembler->WordEqual(element_k, undefined),
1925 &return_found); 1941 &return_found);
1926 1942
1927 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1943 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1928 assembler->Goto(&undef_loop); 1944 assembler->Goto(&undef_loop);
1929 } 1945 }
1930 1946
1931 assembler->Bind(&heap_num_loop); 1947 assembler->Bind(&heap_num_loop);
1932 { 1948 {
1933 Label not_nan_loop(assembler, &index_var); 1949 Label not_nan_loop(assembler, &index_var);
1934 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found, 1950 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found,
1935 &not_nan_loop); 1951 &not_nan_loop);
1936 1952
1937 assembler->Bind(&not_nan_loop); 1953 assembler->Bind(&not_nan_loop);
1938 { 1954 {
1939 Label continue_loop(assembler), not_smi(assembler); 1955 Label continue_loop(assembler), not_smi(assembler);
1940 assembler->GotoUnless( 1956 assembler->GotoUnless(
1941 assembler->Int32LessThan(index_var.value(), len_var.value()), 1957 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1942 &return_not_found); 1958 &return_not_found);
1943 Node* element_k = 1959 Node* element_k = assembler->LoadFixedArrayElement(
1944 assembler->LoadFixedArrayElement(elements, index_var.value()); 1960 elements, index_var.value(), 0,
1961 CodeStubAssembler::INTPTR_PARAMETERS);
1945 assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi); 1962 assembler->GotoUnless(assembler->WordIsSmi(element_k), &not_smi);
1946 assembler->Branch( 1963 assembler->Branch(
1947 assembler->Float64Equal(search_num.value(), 1964 assembler->Float64Equal(search_num.value(),
1948 assembler->SmiToFloat64(element_k)), 1965 assembler->SmiToFloat64(element_k)),
1949 &return_found, &continue_loop); 1966 &return_found, &continue_loop);
1950 1967
1951 assembler->Bind(&not_smi); 1968 assembler->Bind(&not_smi);
1952 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k), 1969 assembler->GotoIf(assembler->WordNotEqual(assembler->LoadMap(element_k),
1953 heap_number_map), 1970 heap_number_map),
1954 &continue_loop); 1971 &continue_loop);
1955 assembler->BranchIfFloat64Equal( 1972 assembler->BranchIfFloat64Equal(
1956 search_num.value(), assembler->LoadHeapNumberValue(element_k), 1973 search_num.value(), assembler->LoadHeapNumberValue(element_k),
1957 &return_found, &continue_loop); 1974 &return_found, &continue_loop);
1958 1975
1959 assembler->Bind(&continue_loop); 1976 assembler->Bind(&continue_loop);
1960 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 1977 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1961 assembler->Goto(&not_nan_loop); 1978 assembler->Goto(&not_nan_loop);
1962 } 1979 }
1963 } 1980 }
1964 1981
1965 assembler->Bind(&string_loop); 1982 assembler->Bind(&string_loop);
1966 { 1983 {
1967 Label continue_loop(assembler); 1984 Label continue_loop(assembler);
1968 assembler->GotoUnless( 1985 assembler->GotoUnless(
1969 assembler->Int32LessThan(index_var.value(), len_var.value()), 1986 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
1970 &return_not_found); 1987 &return_not_found);
1971 Node* element_k = 1988 Node* element_k = assembler->LoadFixedArrayElement(
1972 assembler->LoadFixedArrayElement(elements, index_var.value()); 1989 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
1973 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop); 1990 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
1974 assembler->GotoUnless(assembler->Int32LessThan( 1991 assembler->GotoUnless(assembler->Int32LessThan(
1975 assembler->LoadInstanceType(element_k), 1992 assembler->LoadInstanceType(element_k),
1976 assembler->Int32Constant(FIRST_NONSTRING_TYPE)), 1993 assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
1977 &continue_loop); 1994 &continue_loop);
1978 1995
1979 // TODO(bmeurer): Consider inlining the StringEqual logic here. 1996 // TODO(bmeurer): Consider inlining the StringEqual logic here.
1980 Callable callable = CodeFactory::StringEqual(assembler->isolate()); 1997 Callable callable = CodeFactory::StringEqual(assembler->isolate());
1981 Node* result = 1998 Node* result =
1982 assembler->CallStub(callable, context, search_element, element_k); 1999 assembler->CallStub(callable, context, search_element, element_k);
1983 assembler->Branch( 2000 assembler->Branch(
1984 assembler->WordEqual(assembler->BooleanConstant(true), result), 2001 assembler->WordEqual(assembler->BooleanConstant(true), result),
1985 &return_found, &continue_loop); 2002 &return_found, &continue_loop);
1986 2003
1987 assembler->Bind(&continue_loop); 2004 assembler->Bind(&continue_loop);
1988 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 2005 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
1989 assembler->Goto(&string_loop); 2006 assembler->Goto(&string_loop);
1990 } 2007 }
1991 2008
1992 assembler->Bind(&simd_loop); 2009 assembler->Bind(&simd_loop);
1993 { 2010 {
1994 Label continue_loop(assembler, &index_var), 2011 Label continue_loop(assembler, &index_var),
1995 loop_body(assembler, &index_var); 2012 loop_body(assembler, &index_var);
1996 Node* map = assembler->LoadMap(search_element); 2013 Node* map = assembler->LoadMap(search_element);
1997 2014
1998 assembler->Goto(&loop_body); 2015 assembler->Goto(&loop_body);
1999 assembler->Bind(&loop_body); 2016 assembler->Bind(&loop_body);
2000 assembler->GotoUnless( 2017 assembler->GotoUnless(
2001 assembler->Int32LessThan(index_var.value(), len_var.value()), 2018 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
2002 &return_not_found); 2019 &return_not_found);
2003 2020
2004 Node* element_k = 2021 Node* element_k = assembler->LoadFixedArrayElement(
2005 assembler->LoadFixedArrayElement(elements, index_var.value()); 2022 elements, index_var.value(), 0, CodeStubAssembler::INTPTR_PARAMETERS);
2006 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop); 2023 assembler->GotoIf(assembler->WordIsSmi(element_k), &continue_loop);
2007 2024
2008 Node* map_k = assembler->LoadMap(element_k); 2025 Node* map_k = assembler->LoadMap(element_k);
2009 assembler->BranchIfSimd128Equal(search_element, map, element_k, map_k, 2026 assembler->BranchIfSimd128Equal(search_element, map, element_k, map_k,
2010 &return_found, &continue_loop); 2027 &return_found, &continue_loop);
2011 2028
2012 assembler->Bind(&continue_loop); 2029 assembler->Bind(&continue_loop);
2013 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 2030 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
2014 assembler->Goto(&loop_body); 2031 assembler->Goto(&loop_body);
2015 } 2032 }
2016 } 2033 }
2017 2034
2018 assembler->Bind(&if_packed_doubles); 2035 assembler->Bind(&if_packed_doubles);
2019 { 2036 {
2020 Label not_nan_loop(assembler, &index_var), search_notnan(assembler); 2037 Label not_nan_loop(assembler, &index_var), search_notnan(assembler);
2021 Variable search_num(assembler, MachineRepresentation::kFloat64); 2038 Variable search_num(assembler, MachineRepresentation::kFloat64);
2022 2039
2023 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan); 2040 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan);
2024 search_num.Bind(assembler->SmiToFloat64(search_element)); 2041 search_num.Bind(assembler->SmiToFloat64(search_element));
2025 assembler->Goto(&not_nan_loop); 2042 assembler->Goto(&not_nan_loop);
2026 2043
2027 assembler->Bind(&search_notnan); 2044 assembler->Bind(&search_notnan);
2028 assembler->GotoIf(assembler->WordNotEqual( 2045 assembler->GotoIf(assembler->WordNotEqual(
2029 assembler->LoadMap(search_element), heap_number_map), 2046 assembler->LoadMap(search_element), heap_number_map),
2030 &return_not_found); 2047 &return_not_found);
2031 2048
2032 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 2049 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
2033 2050
2034 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found, 2051 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found,
2035 &not_nan_loop); 2052 &not_nan_loop);
2036 2053
2037 // Search for HeapNumber 2054 // Search for HeapNumber
2038 assembler->Bind(&not_nan_loop); 2055 assembler->Bind(&not_nan_loop);
2039 { 2056 {
2040 Label continue_loop(assembler); 2057 Label continue_loop(assembler);
2041 assembler->GotoUnless( 2058 assembler->GotoUnless(
2042 assembler->Int32LessThan(index_var.value(), len_var.value()), 2059 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
2043 &return_not_found); 2060 &return_not_found);
2044 Node* element_k = assembler->LoadFixedDoubleArrayElement( 2061 Node* element_k = assembler->LoadFixedDoubleArrayElement(
2045 elements, index_var.value(), MachineType::Float64()); 2062 elements, index_var.value(), MachineType::Float64(), 0,
2063 CodeStubAssembler::INTPTR_PARAMETERS);
2046 assembler->BranchIfFloat64Equal(element_k, search_num.value(), 2064 assembler->BranchIfFloat64Equal(element_k, search_num.value(),
2047 &return_found, &continue_loop); 2065 &return_found, &continue_loop);
2048 assembler->Bind(&continue_loop); 2066 assembler->Bind(&continue_loop);
2049 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 2067 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
2050 assembler->Goto(&not_nan_loop); 2068 assembler->Goto(&not_nan_loop);
2051 } 2069 }
2052 } 2070 }
2053 2071
2054 assembler->Bind(&if_holey_doubles); 2072 assembler->Bind(&if_holey_doubles);
2055 { 2073 {
2056 Label not_nan_loop(assembler, &index_var), search_notnan(assembler); 2074 Label not_nan_loop(assembler, &index_var), search_notnan(assembler);
2057 Variable search_num(assembler, MachineRepresentation::kFloat64); 2075 Variable search_num(assembler, MachineRepresentation::kFloat64);
2058 2076
2059 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan); 2077 assembler->GotoUnless(assembler->WordIsSmi(search_element), &search_notnan);
2060 search_num.Bind(assembler->SmiToFloat64(search_element)); 2078 search_num.Bind(assembler->SmiToFloat64(search_element));
2061 assembler->Goto(&not_nan_loop); 2079 assembler->Goto(&not_nan_loop);
2062 2080
2063 assembler->Bind(&search_notnan); 2081 assembler->Bind(&search_notnan);
2064 assembler->GotoIf(assembler->WordNotEqual( 2082 assembler->GotoIf(assembler->WordNotEqual(
2065 assembler->LoadMap(search_element), heap_number_map), 2083 assembler->LoadMap(search_element), heap_number_map),
2066 &return_not_found); 2084 &return_not_found);
2067 2085
2068 search_num.Bind(assembler->LoadHeapNumberValue(search_element)); 2086 search_num.Bind(assembler->LoadHeapNumberValue(search_element));
2069 2087
2070 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found, 2088 assembler->BranchIfFloat64IsNaN(search_num.value(), &return_not_found,
2071 &not_nan_loop); 2089 &not_nan_loop);
2072 2090
2073 // Search for HeapNumber 2091 // Search for HeapNumber
2074 assembler->Bind(&not_nan_loop); 2092 assembler->Bind(&not_nan_loop);
2075 { 2093 {
2076 Label continue_loop(assembler); 2094 Label continue_loop(assembler);
2077 assembler->GotoUnless( 2095 assembler->GotoUnless(
2078 assembler->Int32LessThan(index_var.value(), len_var.value()), 2096 assembler->UintPtrLessThan(index_var.value(), len_var.value()),
2079 &return_not_found); 2097 &return_not_found);
2080 2098
2081 if (kPointerSize == kDoubleSize) { 2099 if (kPointerSize == kDoubleSize) {
2082 Node* element = assembler->LoadFixedDoubleArrayElement( 2100 Node* element = assembler->LoadFixedDoubleArrayElement(
2083 elements, index_var.value(), MachineType::Uint64()); 2101 elements, index_var.value(), MachineType::Uint64(), 0,
2102 CodeStubAssembler::INTPTR_PARAMETERS);
2084 Node* the_hole = assembler->Int64Constant(kHoleNanInt64); 2103 Node* the_hole = assembler->Int64Constant(kHoleNanInt64);
2085 assembler->GotoIf(assembler->Word64Equal(element, the_hole), 2104 assembler->GotoIf(assembler->Word64Equal(element, the_hole),
2086 &continue_loop); 2105 &continue_loop);
2087 } else { 2106 } else {
2088 Node* element_upper = assembler->LoadFixedDoubleArrayElement( 2107 Node* element_upper = assembler->LoadFixedDoubleArrayElement(
2089 elements, index_var.value(), MachineType::Uint32(), 2108 elements, index_var.value(), MachineType::Uint32(),
2090 kIeeeDoubleExponentWordOffset); 2109 kIeeeDoubleExponentWordOffset,
2110 CodeStubAssembler::INTPTR_PARAMETERS);
2091 assembler->GotoIf( 2111 assembler->GotoIf(
2092 assembler->Word32Equal(element_upper, 2112 assembler->Word32Equal(element_upper,
2093 assembler->Int32Constant(kHoleNanUpper32)), 2113 assembler->Int32Constant(kHoleNanUpper32)),
2094 &continue_loop); 2114 &continue_loop);
2095 } 2115 }
2096 2116
2097 Node* element_k = assembler->LoadFixedDoubleArrayElement( 2117 Node* element_k = assembler->LoadFixedDoubleArrayElement(
2098 elements, index_var.value(), MachineType::Float64()); 2118 elements, index_var.value(), MachineType::Float64(), 0,
2119 CodeStubAssembler::INTPTR_PARAMETERS);
2099 assembler->BranchIfFloat64Equal(element_k, search_num.value(), 2120 assembler->BranchIfFloat64Equal(element_k, search_num.value(),
2100 &return_found, &continue_loop); 2121 &return_found, &continue_loop);
2101 assembler->Bind(&continue_loop); 2122 assembler->Bind(&continue_loop);
2102 index_var.Bind(assembler->Int32Add(index_var.value(), int32_one)); 2123 index_var.Bind(assembler->IntPtrAdd(index_var.value(), intptr_one));
2103 assembler->Goto(&not_nan_loop); 2124 assembler->Goto(&not_nan_loop);
2104 } 2125 }
2105 } 2126 }
2106 2127
2107 assembler->Bind(&return_found); 2128 assembler->Bind(&return_found);
2108 assembler->Return(assembler->ChangeInt32ToTagged(index_var.value())); 2129 assembler->Return(assembler->ChangeInt32ToTagged(index_var.value()));
2109 2130
2110 assembler->Bind(&return_not_found); 2131 assembler->Bind(&return_not_found);
2111 assembler->Return(assembler->NumberConstant(-1)); 2132 assembler->Return(assembler->NumberConstant(-1));
2112 2133
2113 assembler->Bind(&call_runtime); 2134 assembler->Bind(&call_runtime);
2114 assembler->Return(assembler->CallRuntime(Runtime::kArrayIndexOf, context, 2135 assembler->Return(assembler->CallRuntime(Runtime::kArrayIndexOf, context,
2115 array, search_element, start_from)); 2136 array, search_element, start_from));
2116 } 2137 }
2117 2138
2118 } // namespace internal 2139 } // namespace internal
2119 } // namespace v8 2140 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698