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 return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) | |
585 ? NONE : ABSENT; | |
rossberg
2012/11/07 18:41:42
That was wrong.
Michael Starzinger
2012/11/07 19:43:49
Nice catch.
| |
586 } | |
587 | |
567 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, | 588 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, |
568 Object* length) { | 589 Object* length) { |
569 return ElementsAccessorSubclass::SetLengthImpl( | 590 return ElementsAccessorSubclass::SetLengthImpl( |
570 array, length, BackingStore::cast(array->elements())); | 591 array, length, BackingStore::cast(array->elements())); |
571 } | 592 } |
572 | 593 |
573 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 594 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
574 JSObject* obj, | 595 JSObject* obj, |
575 Object* length, | 596 Object* length, |
576 BackingStore* backing_store); | 597 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, | 1157 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, |
1137 JSObject* obj, | 1158 JSObject* obj, |
1138 uint32_t key, | 1159 uint32_t key, |
1139 BackingStore* backing_store) { | 1160 BackingStore* backing_store) { |
1140 return | 1161 return |
1141 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | 1162 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) |
1142 ? backing_store->get(key) | 1163 ? backing_store->get(key) |
1143 : backing_store->GetHeap()->undefined_value(); | 1164 : backing_store->GetHeap()->undefined_value(); |
1144 } | 1165 } |
1145 | 1166 |
1167 | |
1168 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1169 Object* receiver, | |
1170 JSObject* obj, | |
1171 uint32_t key, | |
1172 BackingStore* backing_store) { | |
1173 return | |
1174 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) | |
1175 ? NONE : ABSENT; | |
1176 } | |
1177 | |
1146 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1178 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1147 JSObject* obj, | 1179 JSObject* obj, |
1148 Object* length, | 1180 Object* length, |
1149 BackingStore* backing_store) { | 1181 BackingStore* backing_store) { |
1150 // External arrays do not support changing their length. | 1182 // External arrays do not support changing their length. |
1151 UNREACHABLE(); | 1183 UNREACHABLE(); |
1152 return obj; | 1184 return obj; |
1153 } | 1185 } |
1154 | 1186 |
1155 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, | 1187 MUST_USE_RESULT virtual MaybeObject* Delete(JSObject* obj, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 element, | 1456 element, |
1425 key, | 1457 key, |
1426 obj); | 1458 obj); |
1427 } else { | 1459 } else { |
1428 return element; | 1460 return element; |
1429 } | 1461 } |
1430 } | 1462 } |
1431 return obj->GetHeap()->the_hole_value(); | 1463 return obj->GetHeap()->the_hole_value(); |
1432 } | 1464 } |
1433 | 1465 |
1466 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1467 Object* receiver, | |
1468 JSObject* obj, | |
1469 uint32_t key, | |
1470 SeededNumberDictionary* backing_store) { | |
1471 int entry = backing_store->FindEntry(key); | |
1472 if (entry != SeededNumberDictionary::kNotFound) | |
Michael Starzinger
2012/11/07 11:47:48
Curly brackets around body.
rossberg
2012/11/07 18:41:42
Done.
| |
1473 return backing_store->DetailsAt(entry).attributes(); | |
1474 return ABSENT; | |
1475 } | |
1476 | |
1434 static bool HasElementImpl(Object* receiver, | 1477 static bool HasElementImpl(Object* receiver, |
1435 JSObject* holder, | 1478 JSObject* holder, |
1436 uint32_t key, | 1479 uint32_t key, |
1437 SeededNumberDictionary* backing_store) { | 1480 SeededNumberDictionary* backing_store) { |
1438 return backing_store->FindEntry(key) != | 1481 return backing_store->FindEntry(key) != |
1439 SeededNumberDictionary::kNotFound; | 1482 SeededNumberDictionary::kNotFound; |
1440 } | 1483 } |
1441 | 1484 |
1442 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, | 1485 static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict, |
1443 uint32_t index) { | 1486 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)); | 1526 Context* context = Context::cast(parameter_map->get(0)); |
1484 int context_index = entry->aliased_context_slot(); | 1527 int context_index = entry->aliased_context_slot(); |
1485 ASSERT(!context->get(context_index)->IsTheHole()); | 1528 ASSERT(!context->get(context_index)->IsTheHole()); |
1486 return context->get(context_index); | 1529 return context->get(context_index); |
1487 } else { | 1530 } else { |
1488 return result; | 1531 return result; |
1489 } | 1532 } |
1490 } | 1533 } |
1491 } | 1534 } |
1492 | 1535 |
1536 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | |
1537 Object* receiver, | |
1538 JSObject* obj, | |
1539 uint32_t key, | |
1540 FixedArray* parameter_map) { | |
1541 // Aliased parameters and non-aliased elements in a fast backing store | |
1542 // behave as FAST_ELEMENT. Non-aliased elements in a dictionary | |
1543 // backing store behave as DICTIONARY_ELEMENT. | |
1544 uint32_t length = parameter_map->length(); | |
1545 Object* probe = key < (length - 2) ? parameter_map->get(key + 2) : NULL; | |
Michael Starzinger
2012/11/07 11:47:48
Better use the GetParameterMapArg() helper for tha
rossberg
2012/11/07 18:41:42
Done.
| |
1546 if (probe != NULL && !probe->IsTheHole()) return NONE; | |
1547 // If not aliased, check the arguments. | |
1548 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | |
1549 if (arguments->IsDictionary()) { | |
Michael Starzinger
2012/11/07 11:47:48
Better delegate to the elements accessor for the u
rossberg
2012/11/07 18:41:42
Done.
| |
1550 SeededNumberDictionary* dictionary = | |
1551 SeededNumberDictionary::cast(arguments); | |
1552 int entry = dictionary->FindEntry(key); | |
1553 if (entry != SeededNumberDictionary::kNotFound) | |
1554 return dictionary->DetailsAt(entry).attributes(); | |
1555 } | |
1556 return ABSENT; | |
1557 } | |
1558 | |
1493 MUST_USE_RESULT static MaybeObject* SetLengthImpl( | 1559 MUST_USE_RESULT static MaybeObject* SetLengthImpl( |
1494 JSObject* obj, | 1560 JSObject* obj, |
1495 Object* length, | 1561 Object* length, |
1496 FixedArray* parameter_map) { | 1562 FixedArray* parameter_map) { |
1497 // TODO(mstarzinger): This was never implemented but will be used once we | 1563 // TODO(mstarzinger): This was never implemented but will be used once we |
1498 // correctly implement [[DefineOwnProperty]] on arrays. | 1564 // correctly implement [[DefineOwnProperty]] on arrays. |
1499 UNIMPLEMENTED(); | 1565 UNIMPLEMENTED(); |
1500 return obj; | 1566 return obj; |
1501 } | 1567 } |
1502 | 1568 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1687 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1753 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1688 new_backing_store->set(0, length); | 1754 new_backing_store->set(0, length); |
1689 { MaybeObject* result = array->SetContent(new_backing_store); | 1755 { MaybeObject* result = array->SetContent(new_backing_store); |
1690 if (result->IsFailure()) return result; | 1756 if (result->IsFailure()) return result; |
1691 } | 1757 } |
1692 return array; | 1758 return array; |
1693 } | 1759 } |
1694 | 1760 |
1695 | 1761 |
1696 } } // namespace v8::internal | 1762 } } // namespace v8::internal |
OLD | NEW |