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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2028333002: Revert of Extend HasProperty stub with dictionary-mode and double-elements objects support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « src/code-stub-assembler.h ('k') | src/globals.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/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 Node* CodeStubAssembler::NullConstant() { 53 Node* CodeStubAssembler::NullConstant() {
54 return LoadRoot(Heap::kNullValueRootIndex); 54 return LoadRoot(Heap::kNullValueRootIndex);
55 } 55 }
56 56
57 Node* CodeStubAssembler::UndefinedConstant() { 57 Node* CodeStubAssembler::UndefinedConstant() {
58 return LoadRoot(Heap::kUndefinedValueRootIndex); 58 return LoadRoot(Heap::kUndefinedValueRootIndex);
59 } 59 }
60 60
61 Node* CodeStubAssembler::TheHoleConstant() {
62 return LoadRoot(Heap::kTheHoleValueRootIndex);
63 }
64
65 Node* CodeStubAssembler::HashSeed() {
66 return SmiToWord32(LoadRoot(Heap::kHashSeedRootIndex));
67 }
68
69 Node* CodeStubAssembler::StaleRegisterConstant() { 61 Node* CodeStubAssembler::StaleRegisterConstant() {
70 return LoadRoot(Heap::kStaleRegisterRootIndex); 62 return LoadRoot(Heap::kStaleRegisterRootIndex);
71 } 63 }
72 64
73 Node* CodeStubAssembler::Float64Round(Node* x) { 65 Node* CodeStubAssembler::Float64Round(Node* x) {
74 Node* one = Float64Constant(1.0); 66 Node* one = Float64Constant(1.0);
75 Node* one_half = Float64Constant(0.5); 67 Node* one_half = Float64Constant(0.5);
76 68
77 Variable var_x(this, MachineRepresentation::kFloat64); 69 Variable var_x(this, MachineRepresentation::kFloat64);
78 Label return_x(this); 70 Label return_x(this);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 478 }
487 479
488 Node* CodeStubAssembler::LoadMap(Node* object) { 480 Node* CodeStubAssembler::LoadMap(Node* object) {
489 return LoadObjectField(object, HeapObject::kMapOffset); 481 return LoadObjectField(object, HeapObject::kMapOffset);
490 } 482 }
491 483
492 Node* CodeStubAssembler::LoadInstanceType(Node* object) { 484 Node* CodeStubAssembler::LoadInstanceType(Node* object) {
493 return LoadMapInstanceType(LoadMap(object)); 485 return LoadMapInstanceType(LoadMap(object));
494 } 486 }
495 487
496 Node* CodeStubAssembler::LoadProperties(Node* object) {
497 return LoadObjectField(object, JSObject::kPropertiesOffset);
498 }
499
500 Node* CodeStubAssembler::LoadElements(Node* object) { 488 Node* CodeStubAssembler::LoadElements(Node* object) {
501 return LoadObjectField(object, JSObject::kElementsOffset); 489 return LoadObjectField(object, JSObject::kElementsOffset);
502 } 490 }
503 491
504 Node* CodeStubAssembler::LoadFixedArrayBaseLength(Node* array) { 492 Node* CodeStubAssembler::LoadFixedArrayBaseLength(Node* array) {
505 return LoadObjectField(array, FixedArrayBase::kLengthOffset); 493 return LoadObjectField(array, FixedArrayBase::kLengthOffset);
506 } 494 }
507 495
508 Node* CodeStubAssembler::LoadMapBitField(Node* map) { 496 Node* CodeStubAssembler::LoadMapBitField(Node* map) {
509 return Load(MachineType::Uint8(), map, 497 return Load(MachineType::Uint8(), map,
(...skipping 16 matching lines...) Expand all
526 } 514 }
527 515
528 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { 516 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
529 return LoadObjectField(map, Map::kDescriptorsOffset); 517 return LoadObjectField(map, Map::kDescriptorsOffset);
530 } 518 }
531 519
532 Node* CodeStubAssembler::LoadMapPrototype(Node* map) { 520 Node* CodeStubAssembler::LoadMapPrototype(Node* map) {
533 return LoadObjectField(map, Map::kPrototypeOffset); 521 return LoadObjectField(map, Map::kPrototypeOffset);
534 } 522 }
535 523
536 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) { 524 Node* CodeStubAssembler::LoadNameHash(Node* name) {
537 return Load(MachineType::Uint8(), map,
538 IntPtrConstant(Map::kInstanceSizeOffset - kHeapObjectTag));
539 }
540
541 Node* CodeStubAssembler::LoadNameHashField(Node* name) {
542 return Load(MachineType::Uint32(), name, 525 return Load(MachineType::Uint32(), name,
543 IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag)); 526 IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag));
544 } 527 }
545 528
546 Node* CodeStubAssembler::LoadNameHash(Node* name, Label* if_hash_not_computed) {
547 Node* hash_field = LoadNameHashField(name);
548 if (if_hash_not_computed != nullptr) {
549 GotoIf(WordEqual(
550 Word32And(hash_field, Int32Constant(Name::kHashNotComputedMask)),
551 Int32Constant(0)),
552 if_hash_not_computed);
553 }
554 return Word32Shr(hash_field, Int32Constant(Name::kHashShift));
555 }
556
557 Node* CodeStubAssembler::LoadStringLength(Node* object) {
558 return LoadObjectField(object, String::kLengthOffset);
559 }
560
561 Node* CodeStubAssembler::LoadJSValueValue(Node* object) {
562 return LoadObjectField(object, JSValue::kValueOffset);
563 }
564
565 Node* CodeStubAssembler::AllocateUninitializedFixedArray(Node* length) { 529 Node* CodeStubAssembler::AllocateUninitializedFixedArray(Node* length) {
566 Node* header_size = IntPtrConstant(FixedArray::kHeaderSize); 530 Node* header_size = IntPtrConstant(FixedArray::kHeaderSize);
567 Node* data_size = WordShl(length, IntPtrConstant(kPointerSizeLog2)); 531 Node* data_size = WordShl(length, IntPtrConstant(kPointerSizeLog2));
568 Node* total_size = IntPtrAdd(data_size, header_size); 532 Node* total_size = IntPtrAdd(data_size, header_size);
569 533
570 Node* result = Allocate(total_size, kNone); 534 Node* result = Allocate(total_size, kNone);
571 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kFixedArrayMapRootIndex)); 535 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kFixedArrayMapRootIndex));
572 StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset, 536 StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset,
573 SmiTag(length)); 537 SmiTag(length));
574 538
575 return result; 539 return result;
576 } 540 }
577 541
578 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, 542 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node,
579 int additional_offset, 543 int additional_offset,
580 ParameterMode parameter_mode) { 544 ParameterMode parameter_mode) {
581 int32_t header_size = 545 int32_t header_size =
582 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; 546 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
583 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, 547 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS,
584 parameter_mode, header_size); 548 parameter_mode, header_size);
585 return Load(MachineType::AnyTagged(), object, offset); 549 return Load(MachineType::AnyTagged(), object, offset);
586 } 550 }
587 551
588 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( 552 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) {
589 Node* object, Node* index_node, MachineType machine_type, 553 return Load(MachineType::Uint8(), map,
590 int additional_offset, ParameterMode parameter_mode) { 554 IntPtrConstant(Map::kInstanceSizeOffset - kHeapObjectTag));
591 int32_t header_size =
592 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag;
593 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS,
594 parameter_mode, header_size);
595 return Load(machine_type, object, offset);
596 } 555 }
597 556
598 Node* CodeStubAssembler::LoadNativeContext(Node* context) { 557 Node* CodeStubAssembler::LoadNativeContext(Node* context) {
599 return LoadFixedArrayElement(context, 558 return LoadFixedArrayElement(context,
600 Int32Constant(Context::NATIVE_CONTEXT_INDEX)); 559 Int32Constant(Context::NATIVE_CONTEXT_INDEX));
601 } 560 }
602 561
603 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, 562 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind,
604 Node* native_context) { 563 Node* native_context) {
605 return LoadFixedArrayElement(native_context, 564 return LoadFixedArrayElement(native_context,
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 } 1386 }
1428 1387
1429 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, 1388 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
1430 uint32_t mask) { 1389 uint32_t mask) {
1431 return Word32Shr(Word32And(word32, Int32Constant(mask)), 1390 return Word32Shr(Word32And(word32, Int32Constant(mask)),
1432 Int32Constant(shift)); 1391 Int32Constant(shift));
1433 } 1392 }
1434 1393
1435 void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex, 1394 void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex,
1436 Variable* var_index, Label* if_keyisunique, 1395 Variable* var_index, Label* if_keyisunique,
1437 Label* if_bailout) { 1396 Label* call_runtime) {
1438 DCHECK_EQ(MachineRepresentation::kWord32, var_index->rep()); 1397 DCHECK_EQ(MachineRepresentation::kWord32, var_index->rep());
1439 1398
1440 Label if_keyissmi(this), if_keyisnotsmi(this); 1399 Label if_keyissmi(this), if_keyisnotsmi(this);
1441 Branch(WordIsSmi(key), &if_keyissmi, &if_keyisnotsmi); 1400 Branch(WordIsSmi(key), &if_keyissmi, &if_keyisnotsmi);
1442 Bind(&if_keyissmi); 1401 Bind(&if_keyissmi);
1443 { 1402 {
1444 // Negative smi keys are named properties. Handle in the runtime. 1403 // Negative smi keys are named properties. Handle in the runtime.
1445 GotoUnless(WordIsPositiveSmi(key), if_bailout); 1404 Label if_keyispositive(this);
1405 Branch(WordIsPositiveSmi(key), &if_keyispositive, call_runtime);
1406 Bind(&if_keyispositive);
1446 1407
1447 var_index->Bind(SmiToWord32(key)); 1408 var_index->Bind(SmiToWord32(key));
1448 Goto(if_keyisindex); 1409 Goto(if_keyisindex);
1449 } 1410 }
1450 1411
1451 Bind(&if_keyisnotsmi); 1412 Bind(&if_keyisnotsmi);
1452 1413
1453 Node* key_instance_type = LoadInstanceType(key); 1414 Node* key_instance_type = LoadInstanceType(key);
1454 // Symbols are unique. 1415 Label if_keyisnotsymbol(this);
1455 GotoIf(Word32Equal(key_instance_type, Int32Constant(SYMBOL_TYPE)), 1416 Branch(Word32Equal(key_instance_type, Int32Constant(SYMBOL_TYPE)),
1456 if_keyisunique); 1417 if_keyisunique, &if_keyisnotsymbol);
1418 Bind(&if_keyisnotsymbol);
1419 {
1420 Label if_keyisinternalized(this);
1421 Node* bits =
1422 WordAnd(key_instance_type,
1423 Int32Constant(kIsNotStringMask | kIsNotInternalizedMask));
1424 Branch(Word32Equal(bits, Int32Constant(kStringTag | kInternalizedTag)),
1425 &if_keyisinternalized, call_runtime);
1426 Bind(&if_keyisinternalized);
1457 1427
1458 Label if_keyisinternalized(this); 1428 // Check whether the key is an array index passed in as string. Handle
1459 Node* bits = 1429 // uniform with smi keys if so.
1460 WordAnd(key_instance_type, 1430 // TODO(verwaest): Also support non-internalized strings.
1461 Int32Constant(kIsNotStringMask | kIsNotInternalizedMask)); 1431 Node* hash = LoadNameHash(key);
1462 Branch(Word32Equal(bits, Int32Constant(kStringTag | kInternalizedTag)), 1432 Node* bit =
1463 &if_keyisinternalized, if_bailout); 1433 Word32And(hash, Int32Constant(internal::Name::kIsNotArrayIndexMask));
1464 Bind(&if_keyisinternalized); 1434 Label if_isarrayindex(this);
1465 1435 Branch(Word32Equal(bit, Int32Constant(0)), &if_isarrayindex,
1466 // Check whether the key is an array index passed in as string. Handle 1436 if_keyisunique);
1467 // uniform with smi keys if so. 1437 Bind(&if_isarrayindex);
1468 // TODO(verwaest): Also support non-internalized strings. 1438 var_index->Bind(BitFieldDecode<internal::Name::ArrayIndexValueBits>(hash));
1469 Node* hash = LoadNameHashField(key); 1439 Goto(if_keyisindex);
1470 Node* bit = Word32And(hash, Int32Constant(Name::kIsNotArrayIndexMask));
1471 GotoIf(Word32NotEqual(bit, Int32Constant(0)), if_keyisunique);
1472 // Key is an index. Check if it is small enough to be encoded in the
1473 // hash_field. Handle too big array index in runtime.
1474 bit = Word32And(hash, Int32Constant(Name::kContainsCachedArrayIndexMask));
1475 GotoIf(Word32NotEqual(bit, Int32Constant(0)), if_bailout);
1476 var_index->Bind(BitFieldDecode<Name::ArrayIndexValueBits>(hash));
1477 Goto(if_keyisindex);
1478 }
1479
1480 template <typename Dictionary>
1481 void CodeStubAssembler::NameDictionaryLookup(
1482 Node* dictionary, Node* unique_name, Label* if_found_, Variable* var_entry,
1483 Label* if_not_found, int inlined_probes) {
1484 DCHECK_EQ(MachineRepresentation::kWord32, var_entry->rep());
1485
1486 // TODO(ishell): Remove this trampoline block once crbug/615621 is fixed.
1487 // This trampoline block is currently necessary here to generate a correct
1488 // phi for |var_entry|.
1489 Label if_found(this, var_entry);
1490
1491 const int kElementsStartOffset =
1492 Dictionary::kElementsStartIndex * kPointerSize;
1493
1494 Node* capacity = SmiToWord32(LoadFixedArrayElement(
1495 dictionary, Int32Constant(Dictionary::kCapacityIndex)));
1496 Node* mask = Int32Sub(capacity, Int32Constant(1));
1497 Node* hash = LoadNameHash(unique_name);
1498
1499 // See Dictionary::FirstProbe().
1500 Node* count = Int32Constant(0);
1501 Node* entry = Word32And(hash, mask);
1502
1503 for (int i = 0; i < inlined_probes; i++) {
1504 // See Dictionary::EntryToIndex()
1505 Node* index = Int32Mul(entry, Int32Constant(Dictionary::kEntrySize));
1506 Node* current =
1507 LoadFixedArrayElement(dictionary, index, kElementsStartOffset);
1508 var_entry->Bind(entry);
1509 GotoIf(WordEqual(current, unique_name), &if_found);
1510
1511 // See Dictionary::NextProbe().
1512 count = Int32Constant(i + 1);
1513 entry = Word32And(Int32Add(entry, count), mask);
1514 }
1515
1516 Node* undefined = UndefinedConstant();
1517
1518 Variable var_count(this, MachineRepresentation::kWord32);
1519 Variable* loop_vars[] = {&var_count, var_entry};
1520 Label loop(this, 2, loop_vars);
1521 var_count.Bind(count);
1522 var_entry->Bind(entry);
1523 Goto(&loop);
1524 Bind(&loop);
1525 {
1526 Node* count = var_count.value();
1527 Node* entry = var_entry->value();
1528
1529 // See Dictionary::EntryToIndex()
1530 Node* index = Int32Mul(entry, Int32Constant(Dictionary::kEntrySize));
1531 Node* current =
1532 LoadFixedArrayElement(dictionary, index, kElementsStartOffset);
1533 GotoIf(WordEqual(current, undefined), if_not_found);
1534 GotoIf(WordEqual(current, unique_name), &if_found);
1535
1536 // See Dictionary::NextProbe().
1537 count = Int32Add(count, Int32Constant(1));
1538 entry = Word32And(Int32Add(entry, count), mask);
1539
1540 var_count.Bind(count);
1541 var_entry->Bind(entry);
1542 Goto(&loop);
1543 }
1544 Bind(&if_found);
1545 Goto(if_found_);
1546 }
1547
1548 // Instantiate template methods to workaround GCC compilation issue.
1549 template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>(
1550 Node*, Node*, Label*, Variable*, Label*, int);
1551 template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>(
1552 Node*, Node*, Label*, Variable*, Label*, int);
1553
1554 Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) {
1555 // See v8::internal::ComputeIntegerHash()
1556 Node* hash = key;
1557 hash = Word32Xor(hash, seed);
1558 hash = Int32Add(Word32Xor(hash, Int32Constant(0xffffffff)),
1559 Word32Shl(hash, Int32Constant(15)));
1560 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12)));
1561 hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2)));
1562 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4)));
1563 hash = Int32Mul(hash, Int32Constant(2057));
1564 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16)));
1565 return Word32And(hash, Int32Constant(0x3fffffff));
1566 }
1567
1568 template <typename Dictionary>
1569 void CodeStubAssembler::NumberDictionaryLookup(Node* dictionary, Node* key,
1570 Label* if_found,
1571 Variable* var_entry,
1572 Label* if_not_found) {
1573 DCHECK_EQ(MachineRepresentation::kWord32, var_entry->rep());
1574
1575 const int kElementsStartOffset =
1576 Dictionary::kElementsStartIndex * kPointerSize;
1577
1578 Node* capacity = SmiToWord32(LoadFixedArrayElement(
1579 dictionary, Int32Constant(Dictionary::kCapacityIndex)));
1580 Node* mask = Int32Sub(capacity, Int32Constant(1));
1581
1582 Node* seed;
1583 if (Dictionary::ShapeT::UsesSeed) {
1584 seed = HashSeed();
1585 } else {
1586 seed = Int32Constant(kZeroHashSeed);
1587 }
1588 Node* hash = ComputeIntegerHash(key, seed);
1589 Node* key_as_float64 = ChangeUint32ToFloat64(key);
1590
1591 // See Dictionary::FirstProbe().
1592 Node* count = Int32Constant(0);
1593 Node* entry = Word32And(hash, mask);
1594
1595 Node* undefined = UndefinedConstant();
1596 Node* the_hole = TheHoleConstant();
1597
1598 Variable var_count(this, MachineRepresentation::kWord32);
1599 Variable* loop_vars[] = {&var_count, var_entry};
1600 Label loop(this, 2, loop_vars);
1601 var_count.Bind(count);
1602 var_entry->Bind(entry);
1603 Goto(&loop);
1604 Bind(&loop);
1605 {
1606 Node* count = var_count.value();
1607 Node* entry = var_entry->value();
1608
1609 // See Dictionary::EntryToIndex()
1610 Node* index = Int32Mul(entry, Int32Constant(Dictionary::kEntrySize));
1611 Node* current =
1612 LoadFixedArrayElement(dictionary, index, kElementsStartOffset);
1613 GotoIf(WordEqual(current, undefined), if_not_found);
1614 Label next_probe(this);
1615 {
1616 Label if_currentissmi(this), if_currentisnotsmi(this);
1617 Branch(WordIsSmi(current), &if_currentissmi, &if_currentisnotsmi);
1618 Bind(&if_currentissmi);
1619 {
1620 Node* current_value = SmiToWord32(current);
1621 Branch(Word32Equal(current_value, key), if_found, &next_probe);
1622 }
1623 Bind(&if_currentisnotsmi);
1624 {
1625 GotoIf(WordEqual(current, the_hole), &next_probe);
1626 // Current must be the Number.
1627 Node* current_value = LoadHeapNumberValue(current);
1628 Branch(Float64Equal(current_value, key_as_float64), if_found,
1629 &next_probe);
1630 }
1631 }
1632
1633 Bind(&next_probe);
1634 // See Dictionary::NextProbe().
1635 count = Int32Add(count, Int32Constant(1));
1636 entry = Word32And(Int32Add(entry, count), mask);
1637
1638 var_count.Bind(count);
1639 var_entry->Bind(entry);
1640 Goto(&loop);
1641 } 1440 }
1642 } 1441 }
1643 1442
1644 void CodeStubAssembler::TryLookupProperty(Node* object, Node* map, 1443 void CodeStubAssembler::TryLookupProperty(Node* object, Node* map,
1645 Node* instance_type, 1444 Node* instance_type, Node* name,
1646 Node* unique_name, Label* if_found, 1445 Label* if_found, Label* if_not_found,
1647 Label* if_not_found, 1446 Label* call_runtime) {
1648 Label* if_bailout) { 1447 {
1649 Label if_objectisspecial(this); 1448 Label if_objectissimple(this);
1650 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); 1449 Branch(Int32LessThanOrEqual(instance_type,
1651 GotoIf(Int32LessThanOrEqual(instance_type, 1450 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)),
1652 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)), 1451 call_runtime, &if_objectissimple);
1653 &if_objectisspecial); 1452 Bind(&if_objectissimple);
1453 }
1654 1454
1455 // TODO(verwaest): Perform a dictonary lookup on slow-mode receivers.
1655 Node* bit_field3 = LoadMapBitField3(map); 1456 Node* bit_field3 = LoadMapBitField3(map);
1656 Node* bit = BitFieldDecode<Map::DictionaryMap>(bit_field3); 1457 Node* bit = BitFieldDecode<Map::DictionaryMap>(bit_field3);
1657 Label if_isfastmap(this), if_isslowmap(this); 1458 Label if_isfastmap(this);
1658 Branch(Word32Equal(bit, Int32Constant(0)), &if_isfastmap, &if_isslowmap); 1459 Branch(Word32Equal(bit, Int32Constant(0)), &if_isfastmap, call_runtime);
1659 Bind(&if_isfastmap); 1460 Bind(&if_isfastmap);
1461 Node* nof = BitFieldDecode<Map::NumberOfOwnDescriptorsBits>(bit_field3);
1462 // Bail out to the runtime for large numbers of own descriptors. The stub only
1463 // does linear search, which becomes too expensive in that case.
1660 { 1464 {
1661 Node* nof = BitFieldDecode<Map::NumberOfOwnDescriptorsBits>(bit_field3); 1465 static const int32_t kMaxLinear = 210;
1662 // Bail out to the runtime for large numbers of own descriptors. The stub 1466 Label above_max(this), below_max(this);
1663 // only does linear search, which becomes too expensive in that case. 1467 Branch(Int32LessThanOrEqual(nof, Int32Constant(kMaxLinear)), &below_max,
1468 call_runtime);
1469 Bind(&below_max);
1470 }
1471 Node* descriptors = LoadMapDescriptors(map);
1472
1473 Variable var_descriptor(this, MachineRepresentation::kWord32);
1474 Label loop(this, &var_descriptor);
1475 var_descriptor.Bind(Int32Constant(0));
1476 Goto(&loop);
1477 Bind(&loop);
1478 {
1479 Node* index = var_descriptor.value();
1480 Node* offset = Int32Constant(DescriptorArray::ToKeyIndex(0));
1481 Node* factor = Int32Constant(DescriptorArray::kDescriptorSize);
1482 Label if_notdone(this);
1483 Branch(Word32Equal(index, nof), if_not_found, &if_notdone);
1484 Bind(&if_notdone);
1664 { 1485 {
1665 static const int32_t kMaxLinear = 210;
1666 GotoIf(Int32GreaterThan(nof, Int32Constant(kMaxLinear)), if_bailout);
1667 }
1668 Node* descriptors = LoadMapDescriptors(map);
1669
1670 Variable var_descriptor(this, MachineRepresentation::kWord32);
1671 Label loop(this, &var_descriptor);
1672 var_descriptor.Bind(Int32Constant(0));
1673 Goto(&loop);
1674 Bind(&loop);
1675 {
1676 Node* index = var_descriptor.value();
1677 Node* offset = Int32Constant(DescriptorArray::ToKeyIndex(0));
1678 Node* factor = Int32Constant(DescriptorArray::kDescriptorSize);
1679 GotoIf(Word32Equal(index, nof), if_not_found);
1680
1681 Node* array_index = Int32Add(offset, Int32Mul(index, factor)); 1486 Node* array_index = Int32Add(offset, Int32Mul(index, factor));
1682 Node* current = LoadFixedArrayElement(descriptors, array_index); 1487 Node* current = LoadFixedArrayElement(descriptors, array_index);
1683 GotoIf(WordEqual(current, unique_name), if_found); 1488 Label if_unequal(this);
1489 Branch(WordEqual(current, name), if_found, &if_unequal);
1490 Bind(&if_unequal);
1684 1491
1685 var_descriptor.Bind(Int32Add(index, Int32Constant(1))); 1492 var_descriptor.Bind(Int32Add(index, Int32Constant(1)));
1686 Goto(&loop); 1493 Goto(&loop);
1687 } 1494 }
1688 } 1495 }
1689 Bind(&if_isslowmap);
1690 {
1691 Variable var_entry(this, MachineRepresentation::kWord32);
1692 Node* dictionary = LoadProperties(object);
1693
1694 NameDictionaryLookup<NameDictionary>(dictionary, unique_name, if_found,
1695 &var_entry, if_not_found);
1696 }
1697 Bind(&if_objectisspecial);
1698 {
1699 // Handle global object here and other special objects in runtime.
1700 GotoUnless(Word32Equal(instance_type, Int32Constant(JS_GLOBAL_OBJECT_TYPE)),
1701 if_bailout);
1702 Variable var_entry(this, MachineRepresentation::kWord32);
1703 Node* dictionary = LoadProperties(object);
1704
1705 NameDictionaryLookup<GlobalDictionary>(dictionary, unique_name, if_found,
1706 &var_entry, if_not_found);
1707 }
1708 } 1496 }
1709 1497
1710 void CodeStubAssembler::TryLookupElement(Node* object, Node* map, 1498 void CodeStubAssembler::TryLookupElement(Node* object, Node* map,
1711 Node* instance_type, Node* index, 1499 Node* instance_type, Node* index,
1712 Label* if_found, Label* if_not_found, 1500 Label* if_found, Label* if_not_found,
1713 Label* if_bailout) { 1501 Label* call_runtime) {
1714 // Handle special objects in runtime. 1502 {
1715 GotoIf(Int32LessThanOrEqual(instance_type, 1503 Label if_objectissimple(this);
1716 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)), 1504 Branch(Int32LessThanOrEqual(instance_type,
1717 if_bailout); 1505 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)),
1506 call_runtime, &if_objectissimple);
1507 Bind(&if_objectissimple);
1508 }
1718 1509
1719 Node* bit_field2 = LoadMapBitField2(map); 1510 Node* bit_field2 = LoadMapBitField2(map);
1720 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2); 1511 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2);
1721 1512
1722 // TODO(verwaest): Support other elements kinds as well. 1513 // TODO(verwaest): Support other elements kinds as well.
1723 Label if_isobjectorsmi(this), if_isdouble(this), if_isdictionary(this), 1514 Label if_isobjectorsmi(this);
1724 if_isfaststringwrapper(this), if_isslowstringwrapper(this); 1515 Branch(
1725 // clang-format off 1516 Int32LessThanOrEqual(elements_kind, Int32Constant(FAST_HOLEY_ELEMENTS)),
1726 int32_t values[] = { 1517 &if_isobjectorsmi, call_runtime);
1727 // Handled by {if_isobjectorsmi}.
1728 FAST_SMI_ELEMENTS, FAST_HOLEY_SMI_ELEMENTS, FAST_ELEMENTS,
1729 FAST_HOLEY_ELEMENTS,
1730 // Handled by {if_isdouble}.
1731 FAST_DOUBLE_ELEMENTS, FAST_HOLEY_DOUBLE_ELEMENTS,
1732 // Handled by {if_isdictionary}.
1733 DICTIONARY_ELEMENTS,
1734 // Handled by {if_isfaststringwrapper}.
1735 FAST_STRING_WRAPPER_ELEMENTS,
1736 // Handled by {if_isslowstringwrapper}.
1737 SLOW_STRING_WRAPPER_ELEMENTS,
1738 // Handled by {if_not_found}.
1739 NO_ELEMENTS,
1740 };
1741 Label* labels[] = {
1742 &if_isobjectorsmi, &if_isobjectorsmi, &if_isobjectorsmi,
1743 &if_isobjectorsmi,
1744 &if_isdouble, &if_isdouble,
1745 &if_isdictionary,
1746 &if_isfaststringwrapper,
1747 &if_isslowstringwrapper,
1748 if_not_found,
1749 };
1750 // clang-format on
1751 STATIC_ASSERT(arraysize(values) == arraysize(labels));
1752 Switch(elements_kind, if_bailout, values, labels, arraysize(values));
1753
1754 Bind(&if_isobjectorsmi); 1518 Bind(&if_isobjectorsmi);
1755 { 1519 {
1756 Node* elements = LoadElements(object); 1520 Node* elements = LoadElements(object);
1757 Node* length = LoadFixedArrayBaseLength(elements); 1521 Node* length = LoadFixedArrayBaseLength(elements);
1758 1522
1759 GotoIf(Int32GreaterThanOrEqual(index, SmiToWord32(length)), if_not_found); 1523 Label if_iskeyinrange(this);
1524 Branch(Int32LessThan(index, SmiToWord32(length)), &if_iskeyinrange,
1525 if_not_found);
1760 1526
1527 Bind(&if_iskeyinrange);
1761 Node* element = LoadFixedArrayElement(elements, index); 1528 Node* element = LoadFixedArrayElement(elements, index);
1762 Node* the_hole = TheHoleConstant(); 1529 Node* the_hole = LoadRoot(Heap::kTheHoleValueRootIndex);
1763 Branch(WordEqual(element, the_hole), if_not_found, if_found); 1530 Branch(WordEqual(element, the_hole), if_not_found, if_found);
1764 } 1531 }
1765 Bind(&if_isdouble);
1766 {
1767 Node* elements = LoadElements(object);
1768 Node* length = LoadFixedArrayBaseLength(elements);
1769
1770 GotoIf(Int32GreaterThanOrEqual(index, SmiToWord32(length)), if_not_found);
1771
1772 if (kPointerSize == kDoubleSize) {
1773 Node* element =
1774 LoadFixedDoubleArrayElement(elements, index, MachineType::Uint64());
1775 Node* the_hole = Int64Constant(kHoleNanInt64);
1776 Branch(Word64Equal(element, the_hole), if_not_found, if_found);
1777 } else {
1778 Node* element_upper =
1779 LoadFixedDoubleArrayElement(elements, index, MachineType::Uint32(),
1780 kIeeeDoubleExponentWordOffset);
1781 Branch(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)),
1782 if_not_found, if_found);
1783 }
1784 }
1785 Bind(&if_isdictionary);
1786 {
1787 Variable var_entry(this, MachineRepresentation::kWord32);
1788 Node* elements = LoadElements(object);
1789 NumberDictionaryLookup<SeededNumberDictionary>(elements, index, if_found,
1790 &var_entry, if_not_found);
1791 }
1792 Bind(&if_isfaststringwrapper);
1793 {
1794 Assert(Word32Equal(LoadInstanceType(object), Int32Constant(JS_VALUE_TYPE)));
1795 Node* string = LoadJSValueValue(object);
1796 Assert(Int32LessThan(LoadInstanceType(string),
1797 Int32Constant(FIRST_NONSTRING_TYPE)));
1798 Node* length = LoadStringLength(string);
1799 GotoIf(Int32LessThan(index, SmiToWord32(length)), if_found);
1800 Goto(&if_isobjectorsmi);
1801 }
1802 Bind(&if_isslowstringwrapper);
1803 {
1804 Assert(Word32Equal(LoadInstanceType(object), Int32Constant(JS_VALUE_TYPE)));
1805 Node* string = LoadJSValueValue(object);
1806 Assert(Int32LessThan(LoadInstanceType(string),
1807 Int32Constant(FIRST_NONSTRING_TYPE)));
1808 Node* length = LoadStringLength(string);
1809 GotoIf(Int32LessThan(index, SmiToWord32(length)), if_found);
1810 Goto(&if_isdictionary);
1811 }
1812 } 1532 }
1813 1533
1814 // Instantiate template methods to workaround GCC compilation issue.
1815 template void CodeStubAssembler::NumberDictionaryLookup<SeededNumberDictionary>(
1816 Node*, Node*, Label*, Variable*, Label*);
1817 template void CodeStubAssembler::NumberDictionaryLookup<
1818 UnseededNumberDictionary>(Node*, Node*, Label*, Variable*, Label*);
1819
1820 Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable, 1534 Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable,
1821 Node* object) { 1535 Node* object) {
1822 Variable var_result(this, MachineRepresentation::kTagged); 1536 Variable var_result(this, MachineRepresentation::kTagged);
1823 Label return_false(this), return_true(this), 1537 Label return_false(this), return_true(this),
1824 return_runtime(this, Label::kDeferred), return_result(this); 1538 return_runtime(this, Label::kDeferred), return_result(this);
1825 1539
1826 // Goto runtime if {object} is a Smi. 1540 // Goto runtime if {object} is a Smi.
1827 GotoIf(WordIsSmi(object), &return_runtime); 1541 GotoIf(WordIsSmi(object), &return_runtime);
1828 1542
1829 // Load map of {object}. 1543 // Load map of {object}.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 } 1698 }
1985 return IntPtrAdd( 1699 return IntPtrAdd(
1986 IntPtrConstant(base_size), 1700 IntPtrConstant(base_size),
1987 (element_size_shift >= 0) 1701 (element_size_shift >= 0)
1988 ? WordShl(index_node, IntPtrConstant(element_size_shift)) 1702 ? WordShl(index_node, IntPtrConstant(element_size_shift))
1989 : WordShr(index_node, IntPtrConstant(-element_size_shift))); 1703 : WordShr(index_node, IntPtrConstant(-element_size_shift)));
1990 } 1704 }
1991 1705
1992 } // namespace internal 1706 } // namespace internal
1993 } // namespace v8 1707 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698