OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 | 557 |
558 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, | 558 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, |
559 JSObject* obj, | 559 JSObject* obj, |
560 uint32_t key, | 560 uint32_t key, |
561 BackingStore* backing_store) { | 561 BackingStore* backing_store) { |
562 return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) | 562 return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) |
563 ? backing_store->get(key) | 563 ? backing_store->get(key) |
564 : backing_store->GetHeap()->the_hole_value(); | 564 : backing_store->GetHeap()->the_hole_value(); |
565 } | 565 } |
566 | 566 |
567 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( | |
568 Object* receiver, | |
569 JSObject* holder, | |
570 uint32_t key, | |
571 FixedArrayBase* backing_store) { | |
572 if (backing_store == NULL) { | |
573 backing_store = holder->elements(); | |
574 } | |
575 return ElementsAccessorSubclass::GetAttributesImpl( | |
576 receiver, holder, key, BackingStore::cast(backing_store)); | |
577 } | |
578 | |
579 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
580 Object* receiver, | |
581 JSObject* obj, | |
582 uint32_t key, | |
583 BackingStore* backing_store) { | |
584 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) | |
Michael Starzinger
2012/11/07 19:43:50
Curly brackets around body.
rossberg
2012/11/08 11:22:56
Done.
| |
585 return ABSENT; | |
586 return backing_store->get(key)->IsTheHole() ? ABSENT : NONE; | |
Toon Verwaest
2012/11/08 10:01:31
You can probably use is_the_hole(key) here.
rossberg
2012/11/08 11:22:56
Done.
| |
587 } | |
588 | |
567 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, | 589 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, |
568 Object* length) { | 590 Object* length) { |
569 return ElementsAccessorSubclass::SetLengthImpl( | 591 return ElementsAccessorSubclass::SetLengthImpl( |
570 array, length, BackingStore::cast(array->elements())); | 592 array, length, BackingStore::cast(array->elements())); |
571 } | 593 } |
572 | 594 |
573 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 595 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
574 JSObject* obj, | 596 JSObject* obj, |
575 Object* length, | 597 Object* length, |
576 BackingStore* backing_store); | 598 BackingStore* backing_store); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1136 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, | 1158 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, |
1137 JSObject* obj, | 1159 JSObject* obj, |
1138 uint32_t key, | 1160 uint32_t key, |
1139 BackingStore* backing_store) { | 1161 BackingStore* backing_store) { |
1140 return | 1162 return |
1141 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | 1163 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
1142 ? backing_store->get(key) | 1164 ? backing_store->get(key) |
1143 : backing_store->GetHeap()->undefined_value(); | 1165 : backing_store->GetHeap()->undefined_value(); |
1144 } | 1166 } |
1145 | 1167 |
1168 | |
Michael Starzinger
2012/11/07 19:54:03
Drop one of the two newlines.
rossberg
2012/11/08 11:22:56
Done.
| |
1169 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1170 Object* receiver, | |
1171 JSObject* obj, | |
1172 uint32_t key, | |
1173 BackingStore* backing_store) { | |
1174 return | |
1175 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | |
1176 ? NONE : ABSENT; | |
1177 } | |
1178 | |
1146 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1179 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1147 JSObject* obj, | 1180 JSObject* obj, |
1148 Object* length, | 1181 Object* length, |
1149 BackingStore* backing_store) { | 1182 BackingStore* backing_store) { |
1150 // External arrays do not support changing their length. | 1183 // External arrays do not support changing their length. |
1151 UNREACHABLE(); | 1184 UNREACHABLE(); |
1152 return obj; | 1185 return obj; |
1153 } | 1186 } |
1154 | 1187 |
1155 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, | 1188 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 element, | 1457 element, |
1425 key, | 1458 key, |
1426 obj); | 1459 obj); |
1427 } else { | 1460 } else { |
1428 return element; | 1461 return element; |
1429 } | 1462 } |
1430 } | 1463 } |
1431 return obj->GetHeap()->the_hole_value(); | 1464 return obj->GetHeap()->the_hole_value(); |
1432 } | 1465 } |
1433 | 1466 |
1467 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1468 Object* receiver, | |
1469 JSObject* obj, | |
1470 uint32_t key, | |
1471 SeededNumberDictionary* backing_store) { | |
1472 int entry = backing_store->FindEntry(key); | |
1473 if (entry != SeededNumberDictionary::kNotFound) { | |
1474 return backing_store->DetailsAt(entry).attributes(); | |
1475 } | |
1476 return ABSENT; | |
1477 } | |
1478 | |
1434 static bool HasElementImpl(Object* receiver, | 1479 static bool HasElementImpl(Object* receiver, |
1435 JSObject* holder, | 1480 JSObject* holder, |
1436 uint32_t key, | 1481 uint32_t key, |
1437 SeededNumberDictionary* backing_store) { | 1482 SeededNumberDictionary* backing_store) { |
1438 return backing_store->FindEntry(key) != | 1483 return backing_store->FindEntry(key) != |
1439 SeededNumberDictionary::kNotFound; | 1484 SeededNumberDictionary::kNotFound; |
1440 } | 1485 } |
1441 | 1486 |
1442 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, | 1487 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, |
1443 uint32_t index) { | 1488 uint32_t index) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1483 Context* context = Context::cast(parameter_map->get(0)); | 1528 Context* context = Context::cast(parameter_map->get(0)); |
1484 int context_index = entry->aliased_context_slot(); | 1529 int context_index = entry->aliased_context_slot(); |
1485 ASSERT(!context->get(context_index)->IsTheHole()); | 1530 ASSERT(!context->get(context_index)->IsTheHole()); |
1486 return context->get(context_index); | 1531 return context->get(context_index); |
1487 } else { | 1532 } else { |
1488 return result; | 1533 return result; |
1489 } | 1534 } |
1490 } | 1535 } |
1491 } | 1536 } |
1492 | 1537 |
1538 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1539 Object* receiver, | |
1540 JSObject* obj, | |
1541 uint32_t key, | |
1542 FixedArray* parameter_map) { | |
1543 // Aliased parameters and non-aliased elements in a fast backing store | |
Michael Starzinger
2012/11/07 19:43:50
I think we can drop all three lines of comments. I
rossberg
2012/11/08 11:22:56
Done.
| |
1544 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary | |
1545 // backing store behave as DICTIONARY_ELEMENT. | |
1546 Object* probe = GetParameterMapArg(obj, parameter_map, key); | |
1547 if (!probe->IsTheHole()) { | |
1548 return NONE; | |
1549 } else { | |
1550 // If not aliased, check the arguments. | |
1551 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | |
Toon Verwaest
2012/11/08 10:01:31
Can we use a constant here? (kArgumentsIndex or so
rossberg
2012/11/08 11:22:56
Just mirrored this after GetImpl, which does the s
| |
1552 return ElementsAccessor::ForArray(arguments)->GetAttributes( | |
1553 receiver, obj, key, arguments); | |
1554 } | |
1555 } | |
1556 | |
1493 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1557 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1494 JSObject* obj, | 1558 JSObject* obj, |
1495 Object* length, | 1559 Object* length, |
1496 FixedArray* parameter_map) { | 1560 FixedArray* parameter_map) { |
1497 // TODO(mstarzinger): This was never implemented but will be used once we | 1561 // TODO(mstarzinger): This was never implemented but will be used once we |
1498 // correctly implement [[DefineOwnProperty]] on arrays. | 1562 // correctly implement [[DefineOwnProperty]] on arrays. |
1499 UNIMPLEMENTED(); | 1563 UNIMPLEMENTED(); |
1500 return obj; | 1564 return obj; |
1501 } | 1565 } |
1502 | 1566 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1687 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1751 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1688 new_backing_store->set(0, length); | 1752 new_backing_store->set(0, length); |
1689 { MaybeObject* result = array->SetContent(new_backing_store); | 1753 { MaybeObject* result = array->SetContent(new_backing_store); |
1690 if (result->IsFailure()) return result; | 1754 if (result->IsFailure()) return result; |
1691 } | 1755 } |
1692 return array; | 1756 return array; |
1693 } | 1757 } |
1694 | 1758 |
1695 | 1759 |
1696 } } // namespace v8::internal | 1760 } } // namespace v8::internal |
OLD | NEW |