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

Side by Side Diff: src/elements.cc

Issue 11365111: Object.observe: generate change records for indexed properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments; simplifications. Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/elements.h ('k') | src/objects.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 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
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)) {
585 return ABSENT;
586 }
587 return backing_store->is_the_hole(key) ? ABSENT : NONE;
588 }
589
567 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array, 590 MUST_USE_RESULT virtual MaybeObject* SetLength(JSArray* array,
568 Object* length) { 591 Object* length) {
569 return ElementsAccessorSubclass::SetLengthImpl( 592 return ElementsAccessorSubclass::SetLengthImpl(
570 array, length, BackingStore::cast(array->elements())); 593 array, length, BackingStore::cast(array->elements()));
571 } 594 }
572 595
573 MUST_USE_RESULT static MaybeObject* SetLengthImpl( 596 MUST_USE_RESULT static MaybeObject* SetLengthImpl(
574 JSObject* obj, 597 JSObject* obj,
575 Object* length, 598 Object* length,
576 BackingStore* backing_store); 599 BackingStore* backing_store);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, 1159 MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver,
1137 JSObject* obj, 1160 JSObject* obj,
1138 uint32_t key, 1161 uint32_t key,
1139 BackingStore* backing_store) { 1162 BackingStore* backing_store) {
1140 return 1163 return
1141 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store) 1164 key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store)
1142 ? backing_store->get(key) 1165 ? backing_store->get(key)
1143 : backing_store->GetHeap()->undefined_value(); 1166 : backing_store->GetHeap()->undefined_value();
1144 } 1167 }
1145 1168
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
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
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 Object* probe = GetParameterMapArg(obj, parameter_map, key);
1544 if (!probe->IsTheHole()) {
1545 return NONE;
1546 } else {
1547 // If not aliased, check the arguments.
1548 FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
1549 return ElementsAccessor::ForArray(arguments)->GetAttributes(
1550 receiver, obj, key, arguments);
1551 }
1552 }
1553
1493 MUST_USE_RESULT static MaybeObject* SetLengthImpl( 1554 MUST_USE_RESULT static MaybeObject* SetLengthImpl(
1494 JSObject* obj, 1555 JSObject* obj,
1495 Object* length, 1556 Object* length,
1496 FixedArray* parameter_map) { 1557 FixedArray* parameter_map) {
1497 // TODO(mstarzinger): This was never implemented but will be used once we 1558 // TODO(mstarzinger): This was never implemented but will be used once we
1498 // correctly implement [[DefineOwnProperty]] on arrays. 1559 // correctly implement [[DefineOwnProperty]] on arrays.
1499 UNIMPLEMENTED(); 1560 UNIMPLEMENTED();
1500 return obj; 1561 return obj;
1501 } 1562 }
1502 1563
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1748 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1688 new_backing_store->set(0, length); 1749 new_backing_store->set(0, length);
1689 { MaybeObject* result = array->SetContent(new_backing_store); 1750 { MaybeObject* result = array->SetContent(new_backing_store);
1690 if (result->IsFailure()) return result; 1751 if (result->IsFailure()) return result;
1691 } 1752 }
1692 return array; 1753 return array;
1693 } 1754 }
1694 1755
1695 1756
1696 } } // namespace v8::internal 1757 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698