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

Side by Side Diff: src/objects.cc

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 75
76 MaybeObject* Object::ToObject(Context* native_context) { 76 MaybeObject* Object::ToObject(Context* native_context) {
77 if (IsNumber()) { 77 if (IsNumber()) {
78 return CreateJSValue(native_context->number_function(), this); 78 return CreateJSValue(native_context->number_function(), this);
79 } else if (IsBoolean()) { 79 } else if (IsBoolean()) {
80 return CreateJSValue(native_context->boolean_function(), this); 80 return CreateJSValue(native_context->boolean_function(), this);
81 } else if (IsString()) { 81 } else if (IsString()) {
82 return CreateJSValue(native_context->string_function(), this); 82 return CreateJSValue(native_context->string_function(), this);
83 } else if (IsSymbol()) {
84 return CreateJSValue(native_context->symbol_function(), this);
83 } 85 }
84 ASSERT(IsJSObject()); 86 ASSERT(IsJSObject());
85 return this; 87 return this;
86 } 88 }
87 89
88 90
89 MaybeObject* Object::ToObject(Isolate* isolate) { 91 MaybeObject* Object::ToObject(Isolate* isolate) {
90 if (IsJSReceiver()) { 92 if (IsJSReceiver()) {
91 return this; 93 return this;
92 } else if (IsNumber()) { 94 } else if (IsNumber()) {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 case NONEXISTENT: 682 case NONEXISTENT:
681 UNREACHABLE(); 683 UNREACHABLE();
682 } 684 }
683 } 685 }
684 686
685 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); 687 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
686 return ABSENT; 688 return ABSENT;
687 } 689 }
688 690
689 691
690 Object* JSObject::GetNormalizedProperty(LookupResult* result) { 692 Object* JSObject::GetNormalizedProperty(const LookupResult* result) {
691 ASSERT(!HasFastProperties()); 693 ASSERT(!HasFastProperties());
692 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); 694 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
693 if (IsGlobalObject()) { 695 if (IsGlobalObject()) {
694 value = PropertyCell::cast(value)->value(); 696 value = PropertyCell::cast(value)->value();
695 } 697 }
696 ASSERT(!value->IsPropertyCell() && !value->IsCell()); 698 ASSERT(!value->IsPropertyCell() && !value->IsCell());
697 return value; 699 return value;
698 } 700 }
699 701
700 702
701 void JSObject::SetNormalizedProperty(Handle<JSObject> object, 703 void JSObject::SetNormalizedProperty(Handle<JSObject> object,
702 LookupResult* result, 704 const LookupResult* result,
703 Handle<Object> value) { 705 Handle<Object> value) {
704 ASSERT(!object->HasFastProperties()); 706 ASSERT(!object->HasFastProperties());
705 NameDictionary* property_dictionary = object->property_dictionary(); 707 NameDictionary* property_dictionary = object->property_dictionary();
706 if (object->IsGlobalObject()) { 708 if (object->IsGlobalObject()) {
707 Handle<PropertyCell> cell(PropertyCell::cast( 709 Handle<PropertyCell> cell(PropertyCell::cast(
708 property_dictionary->ValueAt(result->GetDictionaryEntry()))); 710 property_dictionary->ValueAt(result->GetDictionaryEntry())));
709 PropertyCell::SetValueInferType(cell, value); 711 PropertyCell::SetValueInferType(cell, value);
710 } else { 712 } else {
711 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value); 713 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value);
712 } 714 }
(...skipping 12 matching lines...) Expand all
725 727
726 728
727 void JSObject::SetNormalizedProperty(Handle<JSObject> object, 729 void JSObject::SetNormalizedProperty(Handle<JSObject> object,
728 Handle<Name> name, 730 Handle<Name> name,
729 Handle<Object> value, 731 Handle<Object> value,
730 PropertyDetails details) { 732 PropertyDetails details) {
731 ASSERT(!object->HasFastProperties()); 733 ASSERT(!object->HasFastProperties());
732 Handle<NameDictionary> property_dictionary(object->property_dictionary()); 734 Handle<NameDictionary> property_dictionary(object->property_dictionary());
733 735
734 if (!name->IsUniqueName()) { 736 if (!name->IsUniqueName()) {
735 name = object->GetIsolate()->factory()->InternalizedStringFromString( 737 name = object->GetIsolate()->factory()->InternalizeString(
736 Handle<String>::cast(name)); 738 Handle<String>::cast(name));
737 } 739 }
738 740
739 int entry = property_dictionary->FindEntry(*name); 741 int entry = property_dictionary->FindEntry(*name);
740 if (entry == NameDictionary::kNotFound) { 742 if (entry == NameDictionary::kNotFound) {
741 Handle<Object> store_value = value; 743 Handle<Object> store_value = value;
742 if (object->IsGlobalObject()) { 744 if (object->IsGlobalObject()) {
743 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); 745 store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
744 } 746 }
745 747
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1268 }
1267 #endif // DEBUG 1269 #endif // DEBUG
1268 Heap* heap = GetHeap(); 1270 Heap* heap = GetHeap();
1269 int size = this->Size(); // Byte size of the original string. 1271 int size = this->Size(); // Byte size of the original string.
1270 if (size < ExternalString::kShortSize) { 1272 if (size < ExternalString::kShortSize) {
1271 return false; 1273 return false;
1272 } 1274 }
1273 bool is_ascii = this->IsOneByteRepresentation(); 1275 bool is_ascii = this->IsOneByteRepresentation();
1274 bool is_internalized = this->IsInternalizedString(); 1276 bool is_internalized = this->IsInternalizedString();
1275 1277
1276 // Morph the object to an external string by adjusting the map and 1278 // Morph the string to an external string by replacing the map and
1277 // reinitializing the fields. 1279 // reinitializing the fields. This won't work if
1278 if (size >= ExternalString::kSize) { 1280 // - the space the existing string occupies is too small for a regular
1281 // external string.
1282 // - the existing string is in old pointer space and the backing store of
1283 // the external string is not aligned. The GC cannot deal with fields
1284 // containing an unaligned address that points to outside of V8's heap.
1285 // In either case we resort to a short external string instead, omitting
1286 // the field caching the address of the backing store. When we encounter
1287 // short external strings in generated code, we need to bailout to runtime.
1288 if (size < ExternalString::kSize ||
1289 (!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) &&
1290 heap->old_pointer_space()->Contains(this))) {
1279 this->set_map_no_write_barrier( 1291 this->set_map_no_write_barrier(
1280 is_internalized 1292 is_internalized
1281 ? (is_ascii 1293 ? (is_ascii
1282 ? heap->external_internalized_string_with_one_byte_data_map() 1294 ? heap->
1283 : heap->external_internalized_string_map()) 1295 short_external_internalized_string_with_one_byte_data_map()
1296 : heap->short_external_internalized_string_map())
1284 : (is_ascii 1297 : (is_ascii
1285 ? heap->external_string_with_one_byte_data_map() 1298 ? heap->short_external_string_with_one_byte_data_map()
1286 : heap->external_string_map())); 1299 : heap->short_external_string_map()));
1287 } else { 1300 } else {
1288 this->set_map_no_write_barrier( 1301 this->set_map_no_write_barrier(
1289 is_internalized 1302 is_internalized
1290 ? (is_ascii 1303 ? (is_ascii
1291 ? heap-> 1304 ? heap->external_internalized_string_with_one_byte_data_map()
1292 short_external_internalized_string_with_one_byte_data_map() 1305 : heap->external_internalized_string_map())
1293 : heap->short_external_internalized_string_map()) 1306 : (is_ascii
1294 : (is_ascii 1307 ? heap->external_string_with_one_byte_data_map()
1295 ? heap->short_external_string_with_one_byte_data_map() 1308 : heap->external_string_map()));
1296 : heap->short_external_string_map()));
1297 } 1309 }
1298 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); 1310 ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
1299 self->set_resource(resource); 1311 self->set_resource(resource);
1300 if (is_internalized) self->Hash(); // Force regeneration of the hash value. 1312 if (is_internalized) self->Hash(); // Force regeneration of the hash value.
1301 1313
1302 // Fill the remainder of the string with dead wood. 1314 // Fill the remainder of the string with dead wood.
1303 int new_size = this->Size(); // Byte size of the external String object. 1315 int new_size = this->Size(); // Byte size of the external String object.
1304 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); 1316 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
1305 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { 1317 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
1306 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), 1318 MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
(...skipping 20 matching lines...) Expand all
1327 resource->length() * sizeof(smart_chars[0])) == 0); 1339 resource->length() * sizeof(smart_chars[0])) == 0);
1328 } 1340 }
1329 #endif // DEBUG 1341 #endif // DEBUG
1330 Heap* heap = GetHeap(); 1342 Heap* heap = GetHeap();
1331 int size = this->Size(); // Byte size of the original string. 1343 int size = this->Size(); // Byte size of the original string.
1332 if (size < ExternalString::kShortSize) { 1344 if (size < ExternalString::kShortSize) {
1333 return false; 1345 return false;
1334 } 1346 }
1335 bool is_internalized = this->IsInternalizedString(); 1347 bool is_internalized = this->IsInternalizedString();
1336 1348
1337 // Morph the object to an external string by adjusting the map and 1349 // Morph the string to an external string by replacing the map and
1338 // reinitializing the fields. Use short version if space is limited. 1350 // reinitializing the fields. This won't work if
1339 if (size >= ExternalString::kSize) { 1351 // - the space the existing string occupies is too small for a regular
1352 // external string.
1353 // - the existing string is in old pointer space and the backing store of
1354 // the external string is not aligned. The GC cannot deal with fields
1355 // containing an unaligned address that points to outside of V8's heap.
1356 // In either case we resort to a short external string instead, omitting
1357 // the field caching the address of the backing store. When we encounter
1358 // short external strings in generated code, we need to bailout to runtime.
1359 if (size < ExternalString::kSize ||
1360 (!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) &&
1361 heap->old_pointer_space()->Contains(this))) {
1362 this->set_map_no_write_barrier(
1363 is_internalized ? heap->short_external_ascii_internalized_string_map()
1364 : heap->short_external_ascii_string_map());
1365 } else {
1340 this->set_map_no_write_barrier( 1366 this->set_map_no_write_barrier(
1341 is_internalized ? heap->external_ascii_internalized_string_map() 1367 is_internalized ? heap->external_ascii_internalized_string_map()
1342 : heap->external_ascii_string_map()); 1368 : heap->external_ascii_string_map());
1343 } else {
1344 this->set_map_no_write_barrier(
1345 is_internalized ? heap->short_external_ascii_internalized_string_map()
1346 : heap->short_external_ascii_string_map());
1347 } 1369 }
1348 ExternalAsciiString* self = ExternalAsciiString::cast(this); 1370 ExternalAsciiString* self = ExternalAsciiString::cast(this);
1349 self->set_resource(resource); 1371 self->set_resource(resource);
1350 if (is_internalized) self->Hash(); // Force regeneration of the hash value. 1372 if (is_internalized) self->Hash(); // Force regeneration of the hash value.
1351 1373
1352 // Fill the remainder of the string with dead wood. 1374 // Fill the remainder of the string with dead wood.
1353 int new_size = this->Size(); // Byte size of the external String object. 1375 int new_size = this->Size(); // Byte size of the external String object.
1354 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); 1376 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
1355 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { 1377 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
1356 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), 1378 MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 const char* reason, 1569 const char* reason,
1548 int modify_index, 1570 int modify_index,
1549 int split, 1571 int split,
1550 int descriptors, 1572 int descriptors,
1551 bool constant_to_field, 1573 bool constant_to_field,
1552 Representation old_representation, 1574 Representation old_representation,
1553 Representation new_representation) { 1575 Representation new_representation) {
1554 PrintF(file, "[generalizing "); 1576 PrintF(file, "[generalizing ");
1555 constructor_name()->PrintOn(file); 1577 constructor_name()->PrintOn(file);
1556 PrintF(file, "] "); 1578 PrintF(file, "] ");
1557 String::cast(instance_descriptors()->GetKey(modify_index))->PrintOn(file); 1579 Name* name = instance_descriptors()->GetKey(modify_index);
1580 if (name->IsString()) {
1581 String::cast(name)->PrintOn(file);
1582 } else {
1583 PrintF(file, "{symbol %p}", static_cast<void*>(name));
1584 }
1558 if (constant_to_field) { 1585 if (constant_to_field) {
1559 PrintF(file, ":c->f"); 1586 PrintF(file, ":c->f");
1560 } else { 1587 } else {
1561 PrintF(file, ":%s->%s", 1588 PrintF(file, ":%s->%s",
1562 old_representation.Mnemonic(), 1589 old_representation.Mnemonic(),
1563 new_representation.Mnemonic()); 1590 new_representation.Mnemonic());
1564 } 1591 }
1565 PrintF(file, " ("); 1592 PrintF(file, " (");
1566 if (strlen(reason) > 0) { 1593 if (strlen(reason) > 0) {
1567 PrintF(file, "%s", reason); 1594 PrintF(file, "%s", reason);
(...skipping 19 matching lines...) Expand all
1587 Representation n_r = n->GetDetails(i).representation(); 1614 Representation n_r = n->GetDetails(i).representation();
1588 if (!o_r.Equals(n_r)) { 1615 if (!o_r.Equals(n_r)) {
1589 String::cast(o->GetKey(i))->PrintOn(file); 1616 String::cast(o->GetKey(i))->PrintOn(file);
1590 PrintF(file, ":%s->%s ", o_r.Mnemonic(), n_r.Mnemonic()); 1617 PrintF(file, ":%s->%s ", o_r.Mnemonic(), n_r.Mnemonic());
1591 } else if (o->GetDetails(i).type() == CONSTANT && 1618 } else if (o->GetDetails(i).type() == CONSTANT &&
1592 n->GetDetails(i).type() == FIELD) { 1619 n->GetDetails(i).type() == FIELD) {
1593 Name* name = o->GetKey(i); 1620 Name* name = o->GetKey(i);
1594 if (name->IsString()) { 1621 if (name->IsString()) {
1595 String::cast(name)->PrintOn(file); 1622 String::cast(name)->PrintOn(file);
1596 } else { 1623 } else {
1597 PrintF(file, "???"); 1624 PrintF(file, "{symbol %p}", static_cast<void*>(name));
1598 } 1625 }
1599 PrintF(file, " "); 1626 PrintF(file, " ");
1600 } 1627 }
1601 } 1628 }
1602 PrintF(file, "\n"); 1629 PrintF(file, "\n");
1603 } 1630 }
1604 1631
1605 1632
1606 void HeapObject::HeapObjectShortPrint(StringStream* accumulator) { 1633 void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
1607 Heap* heap = GetHeap(); 1634 Heap* heap = GetHeap();
(...skipping 26 matching lines...) Expand all
1634 case FIXED_DOUBLE_ARRAY_TYPE: 1661 case FIXED_DOUBLE_ARRAY_TYPE:
1635 accumulator->Add("<FixedDoubleArray[%u]>", 1662 accumulator->Add("<FixedDoubleArray[%u]>",
1636 FixedDoubleArray::cast(this)->length()); 1663 FixedDoubleArray::cast(this)->length());
1637 break; 1664 break;
1638 case BYTE_ARRAY_TYPE: 1665 case BYTE_ARRAY_TYPE:
1639 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); 1666 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length());
1640 break; 1667 break;
1641 case FREE_SPACE_TYPE: 1668 case FREE_SPACE_TYPE:
1642 accumulator->Add("<FreeSpace[%u]>", FreeSpace::cast(this)->Size()); 1669 accumulator->Add("<FreeSpace[%u]>", FreeSpace::cast(this)->Size());
1643 break; 1670 break;
1644 case EXTERNAL_PIXEL_ARRAY_TYPE: 1671 #define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
1645 accumulator->Add("<ExternalPixelArray[%u]>", 1672 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1646 ExternalPixelArray::cast(this)->length()); 1673 accumulator->Add("<External" #Type "Array[%u]>", \
1674 External##Type##Array::cast(this)->length()); \
1675 break; \
1676 case FIXED_##TYPE##_ARRAY_TYPE: \
1677 accumulator->Add("<Fixed" #Type "Array[%u]>", \
1678 Fixed##Type##Array::cast(this)->length()); \
1647 break; 1679 break;
1648 case EXTERNAL_BYTE_ARRAY_TYPE: 1680
1649 accumulator->Add("<ExternalByteArray[%u]>", 1681 TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT)
1650 ExternalByteArray::cast(this)->length()); 1682 #undef TYPED_ARRAY_SHORT_PRINT
1651 break; 1683
1652 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
1653 accumulator->Add("<ExternalUnsignedByteArray[%u]>",
1654 ExternalUnsignedByteArray::cast(this)->length());
1655 break;
1656 case EXTERNAL_SHORT_ARRAY_TYPE:
1657 accumulator->Add("<ExternalShortArray[%u]>",
1658 ExternalShortArray::cast(this)->length());
1659 break;
1660 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
1661 accumulator->Add("<ExternalUnsignedShortArray[%u]>",
1662 ExternalUnsignedShortArray::cast(this)->length());
1663 break;
1664 case EXTERNAL_INT_ARRAY_TYPE:
1665 accumulator->Add("<ExternalIntArray[%u]>",
1666 ExternalIntArray::cast(this)->length());
1667 break;
1668 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
1669 accumulator->Add("<ExternalUnsignedIntArray[%u]>",
1670 ExternalUnsignedIntArray::cast(this)->length());
1671 break;
1672 case EXTERNAL_FLOAT_ARRAY_TYPE:
1673 accumulator->Add("<ExternalFloatArray[%u]>",
1674 ExternalFloatArray::cast(this)->length());
1675 break;
1676 case EXTERNAL_DOUBLE_ARRAY_TYPE:
1677 accumulator->Add("<ExternalDoubleArray[%u]>",
1678 ExternalDoubleArray::cast(this)->length());
1679 break;
1680 case FIXED_UINT8_ARRAY_TYPE:
1681 accumulator->Add("<FixedUint8Array[%u]>",
1682 FixedUint8Array::cast(this)->length());
1683 break;
1684 case SHARED_FUNCTION_INFO_TYPE: { 1684 case SHARED_FUNCTION_INFO_TYPE: {
1685 SharedFunctionInfo* shared = SharedFunctionInfo::cast(this); 1685 SharedFunctionInfo* shared = SharedFunctionInfo::cast(this);
1686 SmartArrayPointer<char> debug_name = 1686 SmartArrayPointer<char> debug_name =
1687 shared->DebugName()->ToCString(); 1687 shared->DebugName()->ToCString();
1688 if (debug_name[0] != 0) { 1688 if (debug_name[0] != 0) {
1689 accumulator->Add("<SharedFunctionInfo %s>", debug_name.get()); 1689 accumulator->Add("<SharedFunctionInfo %s>", debug_name.get());
1690 } else { 1690 } else {
1691 accumulator->Add("<SharedFunctionInfo>"); 1691 accumulator->Add("<SharedFunctionInfo>");
1692 } 1692 }
1693 break; 1693 break;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 break; 1850 break;
1851 case CELL_TYPE: 1851 case CELL_TYPE:
1852 Cell::BodyDescriptor::IterateBody(this, v); 1852 Cell::BodyDescriptor::IterateBody(this, v);
1853 break; 1853 break;
1854 case PROPERTY_CELL_TYPE: 1854 case PROPERTY_CELL_TYPE:
1855 PropertyCell::BodyDescriptor::IterateBody(this, v); 1855 PropertyCell::BodyDescriptor::IterateBody(this, v);
1856 break; 1856 break;
1857 case SYMBOL_TYPE: 1857 case SYMBOL_TYPE:
1858 Symbol::BodyDescriptor::IterateBody(this, v); 1858 Symbol::BodyDescriptor::IterateBody(this, v);
1859 break; 1859 break;
1860
1860 case HEAP_NUMBER_TYPE: 1861 case HEAP_NUMBER_TYPE:
1861 case FILLER_TYPE: 1862 case FILLER_TYPE:
1862 case BYTE_ARRAY_TYPE: 1863 case BYTE_ARRAY_TYPE:
1863 case FREE_SPACE_TYPE: 1864 case FREE_SPACE_TYPE:
1864 case EXTERNAL_PIXEL_ARRAY_TYPE:
1865 case EXTERNAL_BYTE_ARRAY_TYPE:
1866 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
1867 case EXTERNAL_SHORT_ARRAY_TYPE:
1868 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
1869 case EXTERNAL_INT_ARRAY_TYPE:
1870 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
1871 case EXTERNAL_FLOAT_ARRAY_TYPE:
1872 case EXTERNAL_DOUBLE_ARRAY_TYPE:
1873 case FIXED_INT8_ARRAY_TYPE:
1874 case FIXED_UINT8_ARRAY_TYPE:
1875 case FIXED_INT16_ARRAY_TYPE:
1876 case FIXED_UINT16_ARRAY_TYPE:
1877 case FIXED_INT32_ARRAY_TYPE:
1878 case FIXED_UINT32_ARRAY_TYPE:
1879 case FIXED_FLOAT32_ARRAY_TYPE:
1880 case FIXED_FLOAT64_ARRAY_TYPE:
1881 case FIXED_UINT8_CLAMPED_ARRAY_TYPE:
1882 break; 1865 break;
1866
1867 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1868 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
1869 case FIXED_##TYPE##_ARRAY_TYPE: \
1870 break;
1871
1872 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1873 #undef TYPED_ARRAY_CASE
1874
1883 case SHARED_FUNCTION_INFO_TYPE: { 1875 case SHARED_FUNCTION_INFO_TYPE: {
1884 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); 1876 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v);
1885 break; 1877 break;
1886 } 1878 }
1887 1879
1888 #define MAKE_STRUCT_CASE(NAME, Name, name) \ 1880 #define MAKE_STRUCT_CASE(NAME, Name, name) \
1889 case NAME##_TYPE: 1881 case NAME##_TYPE:
1890 STRUCT_LIST(MAKE_STRUCT_CASE) 1882 STRUCT_LIST(MAKE_STRUCT_CASE)
1891 #undef MAKE_STRUCT_CASE 1883 #undef MAKE_STRUCT_CASE
1892 if (type == ALLOCATION_SITE_TYPE) { 1884 if (type == ALLOCATION_SITE_TYPE) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 StrictModeFlag strict_mode, 2152 StrictModeFlag strict_mode,
2161 JSReceiver::StoreFromKeyed store_mode, 2153 JSReceiver::StoreFromKeyed store_mode,
2162 ExtensibilityCheck extensibility_check, 2154 ExtensibilityCheck extensibility_check,
2163 ValueType value_type, 2155 ValueType value_type,
2164 StoreMode mode, 2156 StoreMode mode,
2165 TransitionFlag transition_flag) { 2157 TransitionFlag transition_flag) {
2166 ASSERT(!object->IsJSGlobalProxy()); 2158 ASSERT(!object->IsJSGlobalProxy());
2167 Isolate* isolate = object->GetIsolate(); 2159 Isolate* isolate = object->GetIsolate();
2168 2160
2169 if (!name->IsUniqueName()) { 2161 if (!name->IsUniqueName()) {
2170 name = isolate->factory()->InternalizedStringFromString( 2162 name = isolate->factory()->InternalizeString(
2171 Handle<String>::cast(name)); 2163 Handle<String>::cast(name));
2172 } 2164 }
2173 2165
2174 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && 2166 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK &&
2175 !object->map()->is_extensible()) { 2167 !object->map()->is_extensible()) {
2176 if (strict_mode == kNonStrictMode) { 2168 if (strict_mode == kNonStrictMode) {
2177 return value; 2169 return value;
2178 } else { 2170 } else {
2179 Handle<Object> args[1] = { name }; 2171 Handle<Object> args[1] = { name };
2180 Handle<Object> error = isolate->factory()->NewTypeError( 2172 Handle<Object> error = isolate->factory()->NewTypeError(
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 if (transition != TransitionArray::kNotFound) { 2577 if (transition != TransitionArray::kNotFound) {
2586 transitions->GetTarget(transition)->DeprecateTransitionTree(); 2578 transitions->GetTarget(transition)->DeprecateTransitionTree();
2587 } 2579 }
2588 } 2580 }
2589 2581
2590 // Don't overwrite the empty descriptor array. 2582 // Don't overwrite the empty descriptor array.
2591 if (NumberOfOwnDescriptors() == 0) return; 2583 if (NumberOfOwnDescriptors() == 0) return;
2592 2584
2593 DescriptorArray* to_replace = instance_descriptors(); 2585 DescriptorArray* to_replace = instance_descriptors();
2594 Map* current = this; 2586 Map* current = this;
2587 GetHeap()->incremental_marking()->RecordWrites(to_replace);
2595 while (current->instance_descriptors() == to_replace) { 2588 while (current->instance_descriptors() == to_replace) {
2596 current->SetEnumLength(kInvalidEnumCacheSentinel); 2589 current->SetEnumLength(kInvalidEnumCacheSentinel);
2597 current->set_instance_descriptors(new_descriptors); 2590 current->set_instance_descriptors(new_descriptors);
2598 Object* next = current->GetBackPointer(); 2591 Object* next = current->GetBackPointer();
2599 if (next->IsUndefined()) break; 2592 if (next->IsUndefined()) break;
2600 current = Map::cast(next); 2593 current = Map::cast(next);
2601 } 2594 }
2602 2595
2603 set_owns_descriptors(false); 2596 set_owns_descriptors(false);
2604 } 2597 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 int nof_callbacks = callbacks->length(); 3136 int nof_callbacks = callbacks->length();
3144 3137
3145 Isolate* isolate = array->GetIsolate(); 3138 Isolate* isolate = array->GetIsolate();
3146 // Ensure the keys are unique names before writing them into the 3139 // Ensure the keys are unique names before writing them into the
3147 // instance descriptor. Since it may cause a GC, it has to be done before we 3140 // instance descriptor. Since it may cause a GC, it has to be done before we
3148 // temporarily put the heap in an invalid state while appending descriptors. 3141 // temporarily put the heap in an invalid state while appending descriptors.
3149 for (int i = 0; i < nof_callbacks; ++i) { 3142 for (int i = 0; i < nof_callbacks; ++i) {
3150 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i))); 3143 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i)));
3151 if (entry->name()->IsUniqueName()) continue; 3144 if (entry->name()->IsUniqueName()) continue;
3152 Handle<String> key = 3145 Handle<String> key =
3153 isolate->factory()->InternalizedStringFromString( 3146 isolate->factory()->InternalizeString(
3154 Handle<String>(String::cast(entry->name()))); 3147 Handle<String>(String::cast(entry->name())));
3155 entry->set_name(*key); 3148 entry->set_name(*key);
3156 } 3149 }
3157 3150
3158 // Fill in new callback descriptors. Process the callbacks from 3151 // Fill in new callback descriptors. Process the callbacks from
3159 // back to front so that the last callback with a given name takes 3152 // back to front so that the last callback with a given name takes
3160 // precedence over previously added callbacks with that name. 3153 // precedence over previously added callbacks with that name.
3161 for (int i = nof_callbacks - 1; i >= 0; i--) { 3154 for (int i = nof_callbacks - 1; i >= 0; i--) {
3162 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i)); 3155 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i));
3163 Name* key = Name::cast(entry->name()); 3156 Name* key = Name::cast(entry->name());
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 name, value, attributes, value_type, mode, extensibility_check); 4204 name, value, attributes, value_type, mode, extensibility_check);
4212 } 4205 }
4213 4206
4214 if (lookup.IsFound() && 4207 if (lookup.IsFound() &&
4215 (lookup.type() == INTERCEPTOR || lookup.type() == CALLBACKS)) { 4208 (lookup.type() == INTERCEPTOR || lookup.type() == CALLBACKS)) {
4216 object->LocalLookupRealNamedProperty(*name, &lookup); 4209 object->LocalLookupRealNamedProperty(*name, &lookup);
4217 } 4210 }
4218 4211
4219 // Check for accessor in prototype chain removed here in clone. 4212 // Check for accessor in prototype chain removed here in clone.
4220 if (!lookup.IsFound()) { 4213 if (!lookup.IsFound()) {
4214 object->map()->LookupTransition(*object, *name, &lookup);
4215 TransitionFlag flag = lookup.IsFound()
4216 ? OMIT_TRANSITION : INSERT_TRANSITION;
4221 // Neither properties nor transitions found. 4217 // Neither properties nor transitions found.
4222 return AddProperty(object, name, value, attributes, kNonStrictMode, 4218 return AddProperty(object, name, value, attributes, kNonStrictMode,
4223 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode); 4219 MAY_BE_STORE_FROM_KEYED, extensibility_check, value_type, mode, flag);
4224 } 4220 }
4225 4221
4226 Handle<Object> old_value = isolate->factory()->the_hole_value(); 4222 Handle<Object> old_value = isolate->factory()->the_hole_value();
4227 PropertyAttributes old_attributes = ABSENT; 4223 PropertyAttributes old_attributes = ABSENT;
4228 bool is_observed = FLAG_harmony_observation && 4224 bool is_observed = FLAG_harmony_observation &&
4229 object->map()->is_observed() && 4225 object->map()->is_observed() &&
4230 *name != isolate->heap()->hidden_string(); 4226 *name != isolate->heap()->hidden_string();
4231 if (is_observed && lookup.IsProperty()) { 4227 if (is_observed && lookup.IsProperty()) {
4232 if (lookup.IsDataProperty()) old_value = 4228 if (lookup.IsDataProperty()) old_value =
4233 Object::GetProperty(object, name); 4229 Object::GetProperty(object, name);
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
5372 5368
5373 // Check if the object is among the named properties. 5369 // Check if the object is among the named properties.
5374 Object* key = SlowReverseLookup(obj); 5370 Object* key = SlowReverseLookup(obj);
5375 if (!key->IsUndefined()) { 5371 if (!key->IsUndefined()) {
5376 return true; 5372 return true;
5377 } 5373 }
5378 5374
5379 // Check if the object is among the indexed properties. 5375 // Check if the object is among the indexed properties.
5380 ElementsKind kind = GetElementsKind(); 5376 ElementsKind kind = GetElementsKind();
5381 switch (kind) { 5377 switch (kind) {
5382 case EXTERNAL_PIXEL_ELEMENTS: 5378 // Raw pixels and external arrays do not reference other
5383 case EXTERNAL_BYTE_ELEMENTS: 5379 // objects.
5384 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 5380 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
5385 case EXTERNAL_SHORT_ELEMENTS: 5381 case EXTERNAL_##TYPE##_ELEMENTS: \
5386 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 5382 case TYPE##_ELEMENTS: \
5387 case EXTERNAL_INT_ELEMENTS: 5383 break;
5388 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 5384
5389 case EXTERNAL_FLOAT_ELEMENTS: 5385 TYPED_ARRAYS(TYPED_ARRAY_CASE)
5390 case EXTERNAL_DOUBLE_ELEMENTS: 5386 #undef TYPED_ARRAY_CASE
5387
5391 case FAST_DOUBLE_ELEMENTS: 5388 case FAST_DOUBLE_ELEMENTS:
5392 case FAST_HOLEY_DOUBLE_ELEMENTS: 5389 case FAST_HOLEY_DOUBLE_ELEMENTS:
5393 case UINT8_ELEMENTS:
5394 case INT8_ELEMENTS:
5395 case UINT16_ELEMENTS:
5396 case INT16_ELEMENTS:
5397 case UINT32_ELEMENTS:
5398 case INT32_ELEMENTS:
5399 case FLOAT32_ELEMENTS:
5400 case FLOAT64_ELEMENTS:
5401 case UINT8_CLAMPED_ELEMENTS:
5402 // Raw pixels and external arrays do not reference other
5403 // objects.
5404 break; 5390 break;
5405 case FAST_SMI_ELEMENTS: 5391 case FAST_SMI_ELEMENTS:
5406 case FAST_HOLEY_SMI_ELEMENTS: 5392 case FAST_HOLEY_SMI_ELEMENTS:
5407 break; 5393 break;
5408 case FAST_ELEMENTS: 5394 case FAST_ELEMENTS:
5409 case FAST_HOLEY_ELEMENTS: 5395 case FAST_HOLEY_ELEMENTS:
5410 case DICTIONARY_ELEMENTS: { 5396 case DICTIONARY_ELEMENTS: {
5411 FixedArray* elements = FixedArray::cast(this->elements()); 5397 FixedArray* elements = FixedArray::cast(this->elements());
5412 if (ReferencesObjectFromElements(elements, kind, obj)) return true; 5398 if (ReferencesObjectFromElements(elements, kind, obj)) return true;
5413 break; 5399 break;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5456 return true; 5442 return true;
5457 } 5443 }
5458 } else if (ctxobj == obj) { 5444 } else if (ctxobj == obj) {
5459 return true; 5445 return true;
5460 } 5446 }
5461 } 5447 }
5462 } 5448 }
5463 5449
5464 // Check the context extension (if any) if it can have references. 5450 // Check the context extension (if any) if it can have references.
5465 if (context->has_extension() && !context->IsCatchContext()) { 5451 if (context->has_extension() && !context->IsCatchContext()) {
5452 // With harmony scoping, a JSFunction may have a global context.
5453 // TODO(mvstanton): walk into the ScopeInfo.
5454 if (FLAG_harmony_scoping && context->IsGlobalContext()) {
5455 return false;
5456 }
5457
5466 return JSObject::cast(context->extension())->ReferencesObject(obj); 5458 return JSObject::cast(context->extension())->ReferencesObject(obj);
5467 } 5459 }
5468 } 5460 }
5469 5461
5470 // No references to object. 5462 // No references to object.
5471 return false; 5463 return false;
5472 } 5464 }
5473 5465
5474 5466
5475 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) { 5467 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
5873 element_dictionary->ValueAtPut(i, *result); 5865 element_dictionary->ValueAtPut(i, *result);
5874 } 5866 }
5875 } 5867 }
5876 } 5868 }
5877 } 5869 }
5878 break; 5870 break;
5879 } 5871 }
5880 case NON_STRICT_ARGUMENTS_ELEMENTS: 5872 case NON_STRICT_ARGUMENTS_ELEMENTS:
5881 UNIMPLEMENTED(); 5873 UNIMPLEMENTED();
5882 break; 5874 break;
5883 case EXTERNAL_PIXEL_ELEMENTS: 5875
5884 case EXTERNAL_BYTE_ELEMENTS: 5876
5885 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 5877 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
5886 case EXTERNAL_SHORT_ELEMENTS: 5878 case EXTERNAL_##TYPE##_ELEMENTS: \
5887 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 5879 case TYPE##_ELEMENTS: \
5888 case EXTERNAL_INT_ELEMENTS: 5880
5889 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 5881 TYPED_ARRAYS(TYPED_ARRAY_CASE)
5890 case EXTERNAL_FLOAT_ELEMENTS: 5882 #undef TYPED_ARRAY_CASE
5891 case EXTERNAL_DOUBLE_ELEMENTS: 5883
5892 case FAST_DOUBLE_ELEMENTS: 5884 case FAST_DOUBLE_ELEMENTS:
5893 case FAST_HOLEY_DOUBLE_ELEMENTS: 5885 case FAST_HOLEY_DOUBLE_ELEMENTS:
5894 case UINT8_ELEMENTS:
5895 case INT8_ELEMENTS:
5896 case UINT16_ELEMENTS:
5897 case INT16_ELEMENTS:
5898 case UINT32_ELEMENTS:
5899 case INT32_ELEMENTS:
5900 case FLOAT32_ELEMENTS:
5901 case FLOAT64_ELEMENTS:
5902 case UINT8_CLAMPED_ELEMENTS:
5903 // No contained objects, nothing to do. 5886 // No contained objects, nothing to do.
5904 break; 5887 break;
5905 } 5888 }
5906 } 5889 }
5907 5890
5908 return copy; 5891 return copy;
5909 } 5892 }
5910 5893
5911 5894
5912 Handle<JSObject> JSObject::DeepWalk( 5895 Handle<JSObject> JSObject::DeepWalk(
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
6121 PropertyAttributes attributes, 6104 PropertyAttributes attributes,
6122 v8::AccessControl access_control) { 6105 v8::AccessControl access_control) {
6123 switch (object->GetElementsKind()) { 6106 switch (object->GetElementsKind()) {
6124 case FAST_SMI_ELEMENTS: 6107 case FAST_SMI_ELEMENTS:
6125 case FAST_ELEMENTS: 6108 case FAST_ELEMENTS:
6126 case FAST_DOUBLE_ELEMENTS: 6109 case FAST_DOUBLE_ELEMENTS:
6127 case FAST_HOLEY_SMI_ELEMENTS: 6110 case FAST_HOLEY_SMI_ELEMENTS:
6128 case FAST_HOLEY_ELEMENTS: 6111 case FAST_HOLEY_ELEMENTS:
6129 case FAST_HOLEY_DOUBLE_ELEMENTS: 6112 case FAST_HOLEY_DOUBLE_ELEMENTS:
6130 break; 6113 break;
6131 case EXTERNAL_PIXEL_ELEMENTS: 6114
6132 case EXTERNAL_BYTE_ELEMENTS: 6115 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
6133 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 6116 case EXTERNAL_##TYPE##_ELEMENTS: \
6134 case EXTERNAL_SHORT_ELEMENTS: 6117 case TYPE##_ELEMENTS: \
6135 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 6118
6136 case EXTERNAL_INT_ELEMENTS: 6119 TYPED_ARRAYS(TYPED_ARRAY_CASE)
6137 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 6120 #undef TYPED_ARRAY_CASE
6138 case EXTERNAL_FLOAT_ELEMENTS:
6139 case EXTERNAL_DOUBLE_ELEMENTS:
6140 case UINT8_ELEMENTS:
6141 case INT8_ELEMENTS:
6142 case UINT16_ELEMENTS:
6143 case INT16_ELEMENTS:
6144 case UINT32_ELEMENTS:
6145 case INT32_ELEMENTS:
6146 case FLOAT32_ELEMENTS:
6147 case FLOAT64_ELEMENTS:
6148 case UINT8_CLAMPED_ELEMENTS:
6149 // Ignore getters and setters on pixel and external array elements. 6121 // Ignore getters and setters on pixel and external array elements.
6150 return; 6122 return;
6123
6151 case DICTIONARY_ELEMENTS: 6124 case DICTIONARY_ELEMENTS:
6152 if (UpdateGetterSetterInDictionary(object->element_dictionary(), 6125 if (UpdateGetterSetterInDictionary(object->element_dictionary(),
6153 index, 6126 index,
6154 *getter, 6127 *getter,
6155 *setter, 6128 *setter,
6156 attributes)) { 6129 attributes)) {
6157 return; 6130 return;
6158 } 6131 }
6159 break; 6132 break;
6160 case NON_STRICT_ARGUMENTS_ELEMENTS: { 6133 case NON_STRICT_ARGUMENTS_ELEMENTS: {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
6588 6561
6589 // Accessors overwrite previous callbacks (cf. with getters/setters). 6562 // Accessors overwrite previous callbacks (cf. with getters/setters).
6590 switch (object->GetElementsKind()) { 6563 switch (object->GetElementsKind()) {
6591 case FAST_SMI_ELEMENTS: 6564 case FAST_SMI_ELEMENTS:
6592 case FAST_ELEMENTS: 6565 case FAST_ELEMENTS:
6593 case FAST_DOUBLE_ELEMENTS: 6566 case FAST_DOUBLE_ELEMENTS:
6594 case FAST_HOLEY_SMI_ELEMENTS: 6567 case FAST_HOLEY_SMI_ELEMENTS:
6595 case FAST_HOLEY_ELEMENTS: 6568 case FAST_HOLEY_ELEMENTS:
6596 case FAST_HOLEY_DOUBLE_ELEMENTS: 6569 case FAST_HOLEY_DOUBLE_ELEMENTS:
6597 break; 6570 break;
6598 case EXTERNAL_PIXEL_ELEMENTS: 6571
6599 case EXTERNAL_BYTE_ELEMENTS: 6572 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
6600 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 6573 case EXTERNAL_##TYPE##_ELEMENTS: \
6601 case EXTERNAL_SHORT_ELEMENTS: 6574 case TYPE##_ELEMENTS: \
6602 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 6575
6603 case EXTERNAL_INT_ELEMENTS: 6576 TYPED_ARRAYS(TYPED_ARRAY_CASE)
6604 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 6577 #undef TYPED_ARRAY_CASE
6605 case EXTERNAL_FLOAT_ELEMENTS:
6606 case EXTERNAL_DOUBLE_ELEMENTS:
6607 case UINT8_ELEMENTS:
6608 case INT8_ELEMENTS:
6609 case UINT16_ELEMENTS:
6610 case INT16_ELEMENTS:
6611 case UINT32_ELEMENTS:
6612 case INT32_ELEMENTS:
6613 case FLOAT32_ELEMENTS:
6614 case FLOAT64_ELEMENTS:
6615 case UINT8_CLAMPED_ELEMENTS:
6616 // Ignore getters and setters on pixel and external array 6578 // Ignore getters and setters on pixel and external array
6617 // elements. 6579 // elements.
6618 return factory->undefined_value(); 6580 return factory->undefined_value();
6581
6619 case DICTIONARY_ELEMENTS: 6582 case DICTIONARY_ELEMENTS:
6620 break; 6583 break;
6621 case NON_STRICT_ARGUMENTS_ELEMENTS: 6584 case NON_STRICT_ARGUMENTS_ELEMENTS:
6622 UNIMPLEMENTED(); 6585 UNIMPLEMENTED();
6623 break; 6586 break;
6624 } 6587 }
6625 6588
6626 SetElementCallback(object, index, info, info->property_attributes()); 6589 SetElementCallback(object, index, info, info->property_attributes());
6627 } else { 6590 } else {
6628 // Lookup the name. 6591 // Lookup the name.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
6746 result->set_prototype(prototype()); 6709 result->set_prototype(prototype());
6747 result->set_constructor(constructor()); 6710 result->set_constructor(constructor());
6748 result->set_bit_field(bit_field()); 6711 result->set_bit_field(bit_field());
6749 result->set_bit_field2(bit_field2()); 6712 result->set_bit_field2(bit_field2());
6750 int new_bit_field3 = bit_field3(); 6713 int new_bit_field3 = bit_field3();
6751 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); 6714 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true);
6752 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); 6715 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0);
6753 new_bit_field3 = EnumLengthBits::update(new_bit_field3, 6716 new_bit_field3 = EnumLengthBits::update(new_bit_field3,
6754 kInvalidEnumCacheSentinel); 6717 kInvalidEnumCacheSentinel);
6755 new_bit_field3 = Deprecated::update(new_bit_field3, false); 6718 new_bit_field3 = Deprecated::update(new_bit_field3, false);
6756 new_bit_field3 = IsUnstable::update(new_bit_field3, false); 6719 if (!is_dictionary_map()) {
6720 new_bit_field3 = IsUnstable::update(new_bit_field3, false);
6721 }
6757 result->set_bit_field3(new_bit_field3); 6722 result->set_bit_field3(new_bit_field3);
6758 return result; 6723 return result;
6759 } 6724 }
6760 6725
6761 6726
6762 Handle<Map> Map::CopyNormalized(Handle<Map> map, 6727 Handle<Map> Map::CopyNormalized(Handle<Map> map,
6763 PropertyNormalizationMode mode, 6728 PropertyNormalizationMode mode,
6764 NormalizedMapSharingMode sharing) { 6729 NormalizedMapSharingMode sharing) {
6765 int new_instance_size = map->instance_size(); 6730 int new_instance_size = map->instance_size();
6766 if (mode == CLEAR_INOBJECT_PROPERTIES) { 6731 if (mode == CLEAR_INOBJECT_PROPERTIES) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
6854 // that the maps to which we push the new descriptor array back can rely 6819 // that the maps to which we push the new descriptor array back can rely
6855 // on a cache always being available once it is set. If the map has more 6820 // on a cache always being available once it is set. If the map has more
6856 // enumerated descriptors than available in the original cache, the cache 6821 // enumerated descriptors than available in the original cache, the cache
6857 // will be lazily replaced by the extended cache when needed. 6822 // will be lazily replaced by the extended cache when needed.
6858 if (descriptors->HasEnumCache()) { 6823 if (descriptors->HasEnumCache()) {
6859 new_descriptors->CopyEnumCacheFrom(descriptors); 6824 new_descriptors->CopyEnumCacheFrom(descriptors);
6860 } 6825 }
6861 6826
6862 Map* map; 6827 Map* map;
6863 // Replace descriptors by new_descriptors in all maps that share it. 6828 // Replace descriptors by new_descriptors in all maps that share it.
6829
6830 GetHeap()->incremental_marking()->RecordWrites(descriptors);
6864 for (Object* current = GetBackPointer(); 6831 for (Object* current = GetBackPointer();
6865 !current->IsUndefined(); 6832 !current->IsUndefined();
6866 current = map->GetBackPointer()) { 6833 current = map->GetBackPointer()) {
6867 map = Map::cast(current); 6834 map = Map::cast(current);
6868 if (map->instance_descriptors() != descriptors) break; 6835 if (map->instance_descriptors() != descriptors) break;
6869 map->set_instance_descriptors(new_descriptors); 6836 map->set_instance_descriptors(new_descriptors);
6870 } 6837 }
6871 6838
6872 set_instance_descriptors(new_descriptors); 6839 set_instance_descriptors(new_descriptors);
6873 } 6840 }
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
7551 Object* new_cache; 7518 Object* new_cache;
7552 { MaybeObject* maybe_new_cache = cache->Put(name, code); 7519 { MaybeObject* maybe_new_cache = cache->Put(name, code);
7553 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; 7520 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache;
7554 } 7521 }
7555 set_normal_type_cache(new_cache); 7522 set_normal_type_cache(new_cache);
7556 return this; 7523 return this;
7557 } 7524 }
7558 7525
7559 7526
7560 Object* CodeCache::Lookup(Name* name, Code::Flags flags) { 7527 Object* CodeCache::Lookup(Name* name, Code::Flags flags) {
7561 flags = Code::RemoveTypeFromFlags(flags); 7528 Object* result = LookupDefaultCache(name, Code::RemoveTypeFromFlags(flags));
7562 Object* result = LookupDefaultCache(name, flags); 7529 if (result->IsCode()) {
7563 if (result->IsCode()) return result; 7530 if (Code::cast(result)->flags() == flags) return result;
7531 return GetHeap()->undefined_value();
7532 }
7564 return LookupNormalTypeCache(name, flags); 7533 return LookupNormalTypeCache(name, flags);
7565 } 7534 }
7566 7535
7567 7536
7568 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { 7537 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) {
7569 FixedArray* cache = default_cache(); 7538 FixedArray* cache = default_cache();
7570 int length = cache->length(); 7539 int length = cache->length();
7571 for (int i = 0; i < length; i += kCodeCacheEntrySize) { 7540 for (int i = 0; i < length; i += kCodeCacheEntrySize) {
7572 Object* key = cache->get(i + kCodeCacheEntryNameOffset); 7541 Object* key = cache->get(i + kCodeCacheEntryNameOffset);
7573 // Skip deleted elements. 7542 // Skip deleted elements.
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
7898 { MaybeObject* maybe_obj = key.AsObject(GetHeap()); 7867 { MaybeObject* maybe_obj = key.AsObject(GetHeap());
7899 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 7868 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
7900 } 7869 }
7901 cache->set(EntryToIndex(entry), obj); 7870 cache->set(EntryToIndex(entry), obj);
7902 cache->set(EntryToIndex(entry) + 1, code); 7871 cache->set(EntryToIndex(entry) + 1, code);
7903 cache->ElementAdded(); 7872 cache->ElementAdded();
7904 return cache; 7873 return cache;
7905 } 7874 }
7906 7875
7907 7876
7877 void FixedArray::Shrink(int new_length) {
7878 ASSERT(0 <= new_length && new_length <= length());
7879 if (new_length < length()) {
7880 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), this, length() - new_length);
7881 }
7882 }
7883
7884
7908 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { 7885 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
7909 ElementsAccessor* accessor = array->GetElementsAccessor(); 7886 ElementsAccessor* accessor = array->GetElementsAccessor();
7910 MaybeObject* maybe_result = 7887 MaybeObject* maybe_result =
7911 accessor->AddElementsToFixedArray(array, array, this); 7888 accessor->AddElementsToFixedArray(array, array, this);
7912 FixedArray* result; 7889 FixedArray* result;
7913 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; 7890 if (!maybe_result->To<FixedArray>(&result)) return maybe_result;
7914 #ifdef ENABLE_SLOW_ASSERTS 7891 #ifdef ENABLE_SLOW_ASSERTS
7915 if (FLAG_enable_slow_asserts) { 7892 if (FLAG_enable_slow_asserts) {
7916 for (int i = 0; i < result->length(); i++) { 7893 for (int i = 0; i < result->length(); i++) {
7917 Object* current = result->get(i); 7894 Object* current = result->get(i);
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
9918 // "-name" all but the function "name" 9895 // "-name" all but the function "name"
9919 // "" only the top-level function 9896 // "" only the top-level function
9920 // "name" only the function "name" 9897 // "name" only the function "name"
9921 // "name*" only functions starting with "name" 9898 // "name*" only functions starting with "name"
9922 bool JSFunction::PassesFilter(const char* raw_filter) { 9899 bool JSFunction::PassesFilter(const char* raw_filter) {
9923 if (*raw_filter == '*') return true; 9900 if (*raw_filter == '*') return true;
9924 String* name = shared()->DebugName(); 9901 String* name = shared()->DebugName();
9925 Vector<const char> filter = CStrVector(raw_filter); 9902 Vector<const char> filter = CStrVector(raw_filter);
9926 if (filter.length() == 0) return name->length() == 0; 9903 if (filter.length() == 0) return name->length() == 0;
9927 if (filter[0] == '-') { 9904 if (filter[0] == '-') {
9905 // Negative filter.
9928 if (filter.length() == 1) { 9906 if (filter.length() == 1) {
9929 return (name->length() != 0); 9907 return (name->length() != 0);
9930 } else if (!name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) { 9908 } else if (name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
9931 return true; 9909 return false;
9932 } 9910 }
9911 if (filter[filter.length() - 1] == '*' &&
9912 name->IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
9913 return false;
9914 }
9915 return true;
9916
9933 } else if (name->IsUtf8EqualTo(filter)) { 9917 } else if (name->IsUtf8EqualTo(filter)) {
9934 return true; 9918 return true;
9935 } 9919 }
9936 if (filter[filter.length() - 1] == '*' && 9920 if (filter[filter.length() - 1] == '*' &&
9937 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { 9921 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
9938 return true; 9922 return true;
9939 } 9923 }
9940 return false; 9924 return false;
9941 } 9925 }
9942 9926
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
10561 10545
10562 void Code::FindAllTypes(TypeHandleList* types) { 10546 void Code::FindAllTypes(TypeHandleList* types) {
10563 ASSERT(is_inline_cache_stub()); 10547 ASSERT(is_inline_cache_stub());
10564 DisallowHeapAllocation no_allocation; 10548 DisallowHeapAllocation no_allocation;
10565 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10549 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10566 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10550 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10567 RelocInfo* info = it.rinfo(); 10551 RelocInfo* info = it.rinfo();
10568 Object* object = info->target_object(); 10552 Object* object = info->target_object();
10569 if (object->IsMap()) { 10553 if (object->IsMap()) {
10570 Handle<Map> map(Map::cast(object)); 10554 Handle<Map> map(Map::cast(object));
10571 types->Add(IC::MapToType(map)); 10555 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate()));
10572 } 10556 }
10573 } 10557 }
10574 } 10558 }
10575 10559
10576 10560
10577 void Code::ReplaceFirstMap(Map* replace_with) { 10561 void Code::ReplaceFirstMap(Map* replace_with) {
10578 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); 10562 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
10579 } 10563 }
10580 10564
10581 10565
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
10658 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); 10642 Code* target(Code::GetCodeFromTargetAddress(info->target_address()));
10659 if (target->is_inline_cache_stub()) { 10643 if (target->is_inline_cache_stub()) {
10660 if (kind == NULL || *kind == target->kind()) { 10644 if (kind == NULL || *kind == target->kind()) {
10661 IC::Clear(this->GetIsolate(), info->pc()); 10645 IC::Clear(this->GetIsolate(), info->pc());
10662 } 10646 }
10663 } 10647 }
10664 } 10648 }
10665 } 10649 }
10666 10650
10667 10651
10668 void Code::ClearTypeFeedbackCells(Heap* heap) { 10652 void Code::ClearTypeFeedbackInfo(Heap* heap) {
10669 if (kind() != FUNCTION) return; 10653 if (kind() != FUNCTION) return;
10670 Object* raw_info = type_feedback_info(); 10654 Object* raw_info = type_feedback_info();
10671 if (raw_info->IsTypeFeedbackInfo()) { 10655 if (raw_info->IsTypeFeedbackInfo()) {
10672 TypeFeedbackCells* type_feedback_cells = 10656 FixedArray* feedback_vector =
10673 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells(); 10657 TypeFeedbackInfo::cast(raw_info)->feedback_vector();
10674 for (int i = 0; i < type_feedback_cells->CellCount(); i++) { 10658 for (int i = 0; i < feedback_vector->length(); i++) {
10675 Cell* cell = type_feedback_cells->GetCell(i); 10659 Object* obj = feedback_vector->get(i);
10676 // Don't clear AllocationSites 10660 if (!obj->IsAllocationSite()) {
10677 Object* value = cell->value(); 10661 // TODO(mvstanton): Can't I avoid a write barrier for this sentinel?
10678 if (value == NULL || !value->IsAllocationSite()) { 10662 feedback_vector->set(i,
10679 cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap)); 10663 TypeFeedbackInfo::RawUninitializedSentinel(heap));
10680 } 10664 }
10681 } 10665 }
10682 } 10666 }
10683 } 10667 }
10684 10668
10685 10669
10686 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) { 10670 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) {
10687 DisallowHeapAllocation no_gc; 10671 DisallowHeapAllocation no_gc;
10688 ASSERT(kind() == FUNCTION); 10672 ASSERT(kind() == FUNCTION);
10689 BackEdgeTable back_edges(this, &no_gc); 10673 BackEdgeTable back_edges(this, &no_gc);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
11118 11102
11119 11103
11120 void Code::Disassemble(const char* name, FILE* out) { 11104 void Code::Disassemble(const char* name, FILE* out) {
11121 PrintF(out, "kind = %s\n", Kind2String(kind())); 11105 PrintF(out, "kind = %s\n", Kind2String(kind()));
11122 if (has_major_key()) { 11106 if (has_major_key()) {
11123 PrintF(out, "major_key = %s\n", 11107 PrintF(out, "major_key = %s\n",
11124 CodeStub::MajorName(CodeStub::GetMajorKey(this), true)); 11108 CodeStub::MajorName(CodeStub::GetMajorKey(this), true));
11125 } 11109 }
11126 if (is_inline_cache_stub()) { 11110 if (is_inline_cache_stub()) {
11127 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); 11111 PrintF(out, "ic_state = %s\n", ICState2String(ic_state()));
11128 PrintExtraICState(out, kind(), needs_extended_extra_ic_state(kind()) ? 11112 PrintExtraICState(out, kind(), extra_ic_state());
11129 extended_extra_ic_state() : extra_ic_state());
11130 if (ic_state() == MONOMORPHIC) { 11113 if (ic_state() == MONOMORPHIC) {
11131 PrintF(out, "type = %s\n", StubType2String(type())); 11114 PrintF(out, "type = %s\n", StubType2String(type()));
11132 } 11115 }
11133 if (is_call_stub() || is_keyed_call_stub()) {
11134 PrintF(out, "argc = %d\n", arguments_count());
11135 }
11136 if (is_compare_ic_stub()) { 11116 if (is_compare_ic_stub()) {
11137 ASSERT(major_key() == CodeStub::CompareIC); 11117 ASSERT(major_key() == CodeStub::CompareIC);
11138 CompareIC::State left_state, right_state, handler_state; 11118 CompareIC::State left_state, right_state, handler_state;
11139 Token::Value op; 11119 Token::Value op;
11140 ICCompareStub::DecodeMinorKey(stub_info(), &left_state, &right_state, 11120 ICCompareStub::DecodeMinorKey(stub_info(), &left_state, &right_state,
11141 &handler_state, &op); 11121 &handler_state, &op);
11142 PrintF(out, "compare_state = %s*%s -> %s\n", 11122 PrintF(out, "compare_state = %s*%s -> %s\n",
11143 CompareIC::GetStateName(left_state), 11123 CompareIC::GetStateName(left_state),
11144 CompareIC::GetStateName(right_state), 11124 CompareIC::GetStateName(right_state),
11145 CompareIC::GetStateName(handler_state)); 11125 CompareIC::GetStateName(handler_state));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
11298 GetElementsKind(), new_elements); 11278 GetElementsKind(), new_elements);
11299 } 11279 }
11300 11280
11301 if (IsJSArray()) { 11281 if (IsJSArray()) {
11302 JSArray::cast(this)->set_length(Smi::FromInt(length)); 11282 JSArray::cast(this)->set_length(Smi::FromInt(length));
11303 } 11283 }
11304 return new_elements; 11284 return new_elements;
11305 } 11285 }
11306 11286
11307 11287
11308 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) {
11309 if (kind != Code::OPTIMIZED_FUNCTION) return false;
11310
11311 if (object->IsMap()) {
11312 return Map::cast(object)->CanTransition() &&
11313 FLAG_collect_maps &&
11314 FLAG_weak_embedded_maps_in_optimized_code;
11315 }
11316
11317 if (object->IsJSObject() ||
11318 (object->IsCell() && Cell::cast(object)->value()->IsJSObject())) {
11319 return FLAG_weak_embedded_objects_in_optimized_code;
11320 }
11321
11322 return false;
11323 }
11324
11325
11326 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object, 11288 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
11327 int capacity, 11289 int capacity,
11328 int length) { 11290 int length) {
11329 CALL_HEAP_FUNCTION_VOID( 11291 CALL_HEAP_FUNCTION_VOID(
11330 object->GetIsolate(), 11292 object->GetIsolate(),
11331 object->SetFastDoubleElementsCapacityAndLength(capacity, length)); 11293 object->SetFastDoubleElementsCapacityAndLength(capacity, length));
11332 } 11294 }
11333 11295
11334 11296
11335 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( 11297 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength(
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
11595 break, 11557 break,
11596 return Handle<Map>()); 11558 return Handle<Map>());
11597 } 11559 }
11598 11560
11599 // Reload number of transitions as GC might shrink them. 11561 // Reload number of transitions as GC might shrink them.
11600 int last = map->NumberOfProtoTransitions(); 11562 int last = map->NumberOfProtoTransitions();
11601 int entry = header + last * step; 11563 int entry = header + last * step;
11602 11564
11603 cache->set(entry + kProtoTransitionPrototypeOffset, *prototype); 11565 cache->set(entry + kProtoTransitionPrototypeOffset, *prototype);
11604 cache->set(entry + kProtoTransitionMapOffset, *target_map); 11566 cache->set(entry + kProtoTransitionMapOffset, *target_map);
11605 map->SetNumberOfProtoTransitions(transitions); 11567 map->SetNumberOfProtoTransitions(last + 1);
11606 11568
11607 return map; 11569 return map;
11608 } 11570 }
11609 11571
11610 11572
11611 void Map::ZapTransitions() { 11573 void Map::ZapTransitions() {
11612 TransitionArray* transition_array = transitions(); 11574 TransitionArray* transition_array = transitions();
11613 // TODO(mstarzinger): Temporarily use a slower version instead of the faster 11575 // TODO(mstarzinger): Temporarily use a slower version instead of the faster
11614 // MemsetPointer to investigate a crasher. Switch back to MemsetPointer. 11576 // MemsetPointer to investigate a crasher. Switch back to MemsetPointer.
11615 Object** data = transition_array->data_start(); 11577 Object** data = transition_array->data_start();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
11784 for (int i = start; i < end; i++) { 11746 for (int i = start; i < end; i++) {
11785 if (object_at(i) == code) return true; 11747 if (object_at(i) == code) return true;
11786 } 11748 }
11787 return false; 11749 return false;
11788 } 11750 }
11789 11751
11790 11752
11791 bool DependentCode::MarkCodeForDeoptimization( 11753 bool DependentCode::MarkCodeForDeoptimization(
11792 Isolate* isolate, 11754 Isolate* isolate,
11793 DependentCode::DependencyGroup group) { 11755 DependentCode::DependencyGroup group) {
11794 ASSERT(AllowCodeDependencyChange::IsAllowed());
11795 DisallowHeapAllocation no_allocation_scope; 11756 DisallowHeapAllocation no_allocation_scope;
11796 DependentCode::GroupStartIndexes starts(this); 11757 DependentCode::GroupStartIndexes starts(this);
11797 int start = starts.at(group); 11758 int start = starts.at(group);
11798 int end = starts.at(group + 1); 11759 int end = starts.at(group + 1);
11799 int code_entries = starts.number_of_entries(); 11760 int code_entries = starts.number_of_entries();
11800 if (start == end) return false; 11761 if (start == end) return false;
11801 11762
11802 // Mark all the code that needs to be deoptimized. 11763 // Mark all the code that needs to be deoptimized.
11803 bool marked = false; 11764 bool marked = false;
11804 for (int i = start; i < end; i++) { 11765 for (int i = start; i < end; i++) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
12508 SetFastDoubleElementsCapacityAndLength(object, new_capacity, index + 1); 12469 SetFastDoubleElementsCapacityAndLength(object, new_capacity, index + 1);
12509 FixedDoubleArray::cast(object->elements())->set(index, double_value); 12470 FixedDoubleArray::cast(object->elements())->set(index, double_value);
12510 object->ValidateElements(); 12471 object->ValidateElements();
12511 return value; 12472 return value;
12512 } 12473 }
12513 } 12474 }
12514 12475
12515 // Otherwise default to slow case. 12476 // Otherwise default to slow case.
12516 ASSERT(object->HasFastDoubleElements()); 12477 ASSERT(object->HasFastDoubleElements());
12517 ASSERT(object->map()->has_fast_double_elements()); 12478 ASSERT(object->map()->has_fast_double_elements());
12518 ASSERT(object->elements()->IsFixedDoubleArray()); 12479 ASSERT(object->elements()->IsFixedDoubleArray() ||
12480 object->elements()->length() == 0);
12519 12481
12520 NormalizeElements(object); 12482 NormalizeElements(object);
12521 ASSERT(object->HasDictionaryElements()); 12483 ASSERT(object->HasDictionaryElements());
12522 return SetElement(object, index, value, NONE, strict_mode, check_prototype); 12484 return SetElement(object, index, value, NONE, strict_mode, check_prototype);
12523 } 12485 }
12524 12486
12525 12487
12526 Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object, 12488 Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
12527 uint32_t index, 12489 uint32_t index,
12528 Handle<Object> value, 12490 Handle<Object> value,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
12703 switch (object->GetElementsKind()) { 12665 switch (object->GetElementsKind()) {
12704 case FAST_SMI_ELEMENTS: 12666 case FAST_SMI_ELEMENTS:
12705 case FAST_ELEMENTS: 12667 case FAST_ELEMENTS:
12706 case FAST_HOLEY_SMI_ELEMENTS: 12668 case FAST_HOLEY_SMI_ELEMENTS:
12707 case FAST_HOLEY_ELEMENTS: 12669 case FAST_HOLEY_ELEMENTS:
12708 return SetFastElement(object, index, value, strict_mode, check_prototype); 12670 return SetFastElement(object, index, value, strict_mode, check_prototype);
12709 case FAST_DOUBLE_ELEMENTS: 12671 case FAST_DOUBLE_ELEMENTS:
12710 case FAST_HOLEY_DOUBLE_ELEMENTS: 12672 case FAST_HOLEY_DOUBLE_ELEMENTS:
12711 return SetFastDoubleElement(object, index, value, strict_mode, 12673 return SetFastDoubleElement(object, index, value, strict_mode,
12712 check_prototype); 12674 check_prototype);
12713 case EXTERNAL_PIXEL_ELEMENTS: { 12675
12714 ExternalPixelArray* pixels = ExternalPixelArray::cast(object->elements()); 12676 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
12715 return handle(pixels->SetValue(index, *value), isolate); 12677 case EXTERNAL_##TYPE##_ELEMENTS: { \
12678 Handle<External##Type##Array> array( \
12679 External##Type##Array::cast(object->elements())); \
12680 return External##Type##Array::SetValue(array, index, value); \
12681 } \
12682 case TYPE##_ELEMENTS: { \
12683 Handle<Fixed##Type##Array> array( \
12684 Fixed##Type##Array::cast(object->elements())); \
12685 return Fixed##Type##Array::SetValue(array, index, value); \
12716 } 12686 }
12717 case EXTERNAL_BYTE_ELEMENTS: { 12687
12718 Handle<ExternalByteArray> array( 12688 TYPED_ARRAYS(TYPED_ARRAY_CASE)
12719 ExternalByteArray::cast(object->elements())); 12689
12720 return ExternalByteArray::SetValue(array, index, value); 12690 #undef TYPED_ARRAY_CASE
12721 } 12691
12722 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
12723 Handle<ExternalUnsignedByteArray> array(
12724 ExternalUnsignedByteArray::cast(object->elements()));
12725 return ExternalUnsignedByteArray::SetValue(array, index, value);
12726 }
12727 case EXTERNAL_SHORT_ELEMENTS: {
12728 Handle<ExternalShortArray> array(ExternalShortArray::cast(
12729 object->elements()));
12730 return ExternalShortArray::SetValue(array, index, value);
12731 }
12732 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
12733 Handle<ExternalUnsignedShortArray> array(
12734 ExternalUnsignedShortArray::cast(object->elements()));
12735 return ExternalUnsignedShortArray::SetValue(array, index, value);
12736 }
12737 case EXTERNAL_INT_ELEMENTS: {
12738 Handle<ExternalIntArray> array(
12739 ExternalIntArray::cast(object->elements()));
12740 return ExternalIntArray::SetValue(array, index, value);
12741 }
12742 case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
12743 Handle<ExternalUnsignedIntArray> array(
12744 ExternalUnsignedIntArray::cast(object->elements()));
12745 return ExternalUnsignedIntArray::SetValue(array, index, value);
12746 }
12747 case EXTERNAL_FLOAT_ELEMENTS: {
12748 Handle<ExternalFloatArray> array(
12749 ExternalFloatArray::cast(object->elements()));
12750 return ExternalFloatArray::SetValue(array, index, value);
12751 }
12752 case EXTERNAL_DOUBLE_ELEMENTS: {
12753 Handle<ExternalDoubleArray> array(
12754 ExternalDoubleArray::cast(object->elements()));
12755 return ExternalDoubleArray::SetValue(array, index, value);
12756 }
12757 case UINT8_ELEMENTS: {
12758 Handle<FixedUint8Array> array(
12759 FixedUint8Array::cast(object->elements()));
12760 return FixedUint8Array::SetValue(array, index, value);
12761 }
12762 case UINT8_CLAMPED_ELEMENTS: {
12763 Handle<FixedUint8ClampedArray> array(
12764 FixedUint8ClampedArray::cast(object->elements()));
12765 return FixedUint8ClampedArray::SetValue(array, index, value);
12766 }
12767 case INT8_ELEMENTS: {
12768 Handle<FixedInt8Array> array(
12769 FixedInt8Array::cast(object->elements()));
12770 return FixedInt8Array::SetValue(array, index, value);
12771 }
12772 case UINT16_ELEMENTS: {
12773 Handle<FixedUint16Array> array(
12774 FixedUint16Array::cast(object->elements()));
12775 return FixedUint16Array::SetValue(array, index, value);
12776 }
12777 case INT16_ELEMENTS: {
12778 Handle<FixedInt16Array> array(
12779 FixedInt16Array::cast(object->elements()));
12780 return FixedInt16Array::SetValue(array, index, value);
12781 }
12782 case UINT32_ELEMENTS: {
12783 Handle<FixedUint32Array> array(
12784 FixedUint32Array::cast(object->elements()));
12785 return FixedUint32Array::SetValue(array, index, value);
12786 }
12787 case INT32_ELEMENTS: {
12788 Handle<FixedInt32Array> array(
12789 FixedInt32Array::cast(object->elements()));
12790 return FixedInt32Array::SetValue(array, index, value);
12791 }
12792 case FLOAT32_ELEMENTS: {
12793 Handle<FixedFloat32Array> array(
12794 FixedFloat32Array::cast(object->elements()));
12795 return FixedFloat32Array::SetValue(array, index, value);
12796 }
12797 case FLOAT64_ELEMENTS: {
12798 Handle<FixedFloat64Array> array(
12799 FixedFloat64Array::cast(object->elements()));
12800 return FixedFloat64Array::SetValue(array, index, value);
12801 }
12802 case DICTIONARY_ELEMENTS: 12692 case DICTIONARY_ELEMENTS:
12803 return SetDictionaryElement(object, index, value, attributes, strict_mode, 12693 return SetDictionaryElement(object, index, value, attributes, strict_mode,
12804 check_prototype, 12694 check_prototype,
12805 set_mode); 12695 set_mode);
12806 case NON_STRICT_ARGUMENTS_ELEMENTS: { 12696 case NON_STRICT_ARGUMENTS_ELEMENTS: {
12807 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); 12697 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()));
12808 uint32_t length = parameter_map->length(); 12698 uint32_t length = parameter_map->length();
12809 Handle<Object> probe = index < length - 2 ? 12699 Handle<Object> probe = index < length - 2 ?
12810 Handle<Object>(parameter_map->get(index + 2), isolate) : 12700 Handle<Object>(parameter_map->get(index + 2), isolate) :
12811 Handle<Object>(); 12701 Handle<Object>();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
12855 void AllocationSite::ResetPretenureDecision() { 12745 void AllocationSite::ResetPretenureDecision() {
12856 set_pretenure_decision(kUndecided); 12746 set_pretenure_decision(kUndecided);
12857 set_memento_found_count(0); 12747 set_memento_found_count(0);
12858 set_memento_create_count(0); 12748 set_memento_create_count(0);
12859 } 12749 }
12860 12750
12861 12751
12862 PretenureFlag AllocationSite::GetPretenureMode() { 12752 PretenureFlag AllocationSite::GetPretenureMode() {
12863 PretenureDecision mode = pretenure_decision(); 12753 PretenureDecision mode = pretenure_decision();
12864 // Zombie objects "decide" to be untenured. 12754 // Zombie objects "decide" to be untenured.
12865 return (mode == kTenure && GetHeap()->GetPretenureMode() == TENURED) 12755 return mode == kTenure ? TENURED : NOT_TENURED;
12866 ? TENURED : NOT_TENURED;
12867 } 12756 }
12868 12757
12869 12758
12870 bool AllocationSite::IsNestedSite() { 12759 bool AllocationSite::IsNestedSite() {
12871 ASSERT(FLAG_trace_track_allocation_sites); 12760 ASSERT(FLAG_trace_track_allocation_sites);
12872 Object* current = GetHeap()->allocation_sites_list(); 12761 Object* current = GetHeap()->allocation_sites_list();
12873 while (current->IsAllocationSite()) { 12762 while (current->IsAllocationSite()) {
12874 AllocationSite* current_site = AllocationSite::cast(current); 12763 AllocationSite* current_site = AllocationSite::cast(current);
12875 if (current_site->nested_site() == this) { 12764 if (current_site->nested_site() == this) {
12876 return true; 12765 return true;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
12953 object->UpdateAllocationSite(to_kind)); 12842 object->UpdateAllocationSite(to_kind));
12954 } 12843 }
12955 12844
12956 12845
12957 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12846 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12958 if (!IsJSArray()) return this; 12847 if (!IsJSArray()) return this;
12959 12848
12960 Heap* heap = GetHeap(); 12849 Heap* heap = GetHeap();
12961 if (!heap->InNewSpace(this)) return this; 12850 if (!heap->InNewSpace(this)) return this;
12962 12851
12852 // Check if there is potentially a memento behind the object. If
12853 // the last word of the momento is on another page we return
12854 // immediatelly.
12855 Address object_address = address();
12856 Address memento_address = object_address + JSArray::kSize;
12857 Address last_memento_word_address = memento_address + kPointerSize;
12858 if (!NewSpacePage::OnSamePage(object_address,
12859 last_memento_word_address)) {
12860 return this;
12861 }
12862
12963 // Either object is the last object in the new space, or there is another 12863 // Either object is the last object in the new space, or there is another
12964 // object of at least word size (the header map word) following it, so 12864 // object of at least word size (the header map word) following it, so
12965 // suffices to compare ptr and top here. 12865 // suffices to compare ptr and top here.
12966 Address ptr = address() + JSArray::kSize;
12967 Address top = heap->NewSpaceTop(); 12866 Address top = heap->NewSpaceTop();
12968 ASSERT(ptr == top || ptr + HeapObject::kHeaderSize <= top); 12867 ASSERT(memento_address == top ||
12969 if (ptr == top) return this; 12868 memento_address + HeapObject::kHeaderSize <= top);
12869 if (memento_address == top) return this;
12970 12870
12971 HeapObject* candidate = HeapObject::FromAddress(ptr); 12871 HeapObject* candidate = HeapObject::FromAddress(memento_address);
12972 if (candidate->map() != heap->allocation_memento_map()) return this; 12872 if (candidate->map() != heap->allocation_memento_map()) return this;
12973 12873
12974 AllocationMemento* memento = AllocationMemento::cast(candidate); 12874 AllocationMemento* memento = AllocationMemento::cast(candidate);
12975 if (!memento->IsValid()) return this; 12875 if (!memento->IsValid()) return this;
12976 12876
12977 // Walk through to the Allocation Site 12877 // Walk through to the Allocation Site
12978 AllocationSite* site = memento->GetAllocationSite(); 12878 AllocationSite* site = memento->GetAllocationSite();
12979 return site->DigestTransitionFeedback(to_kind); 12879 return site->DigestTransitionFeedback(to_kind);
12980 } 12880 }
12981 12881
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
13187 break; 13087 break;
13188 } 13088 }
13189 case FAST_DOUBLE_ELEMENTS: 13089 case FAST_DOUBLE_ELEMENTS:
13190 if (IsJSArray()) { 13090 if (IsJSArray()) {
13191 *capacity = backing_store_base->length(); 13091 *capacity = backing_store_base->length();
13192 *used = Smi::cast(JSArray::cast(this)->length())->value(); 13092 *used = Smi::cast(JSArray::cast(this)->length())->value();
13193 break; 13093 break;
13194 } 13094 }
13195 // Fall through if packing is not guaranteed. 13095 // Fall through if packing is not guaranteed.
13196 case FAST_HOLEY_DOUBLE_ELEMENTS: { 13096 case FAST_HOLEY_DOUBLE_ELEMENTS: {
13197 FixedDoubleArray* elms = FixedDoubleArray::cast(elements()); 13097 *capacity = elements()->length();
13198 *capacity = elms->length(); 13098 if (*capacity == 0) break;
13099 FixedDoubleArray * elms = FixedDoubleArray::cast(elements());
13199 for (int i = 0; i < *capacity; i++) { 13100 for (int i = 0; i < *capacity; i++) {
13200 if (!elms->is_the_hole(i)) ++(*used); 13101 if (!elms->is_the_hole(i)) ++(*used);
13201 } 13102 }
13202 break; 13103 break;
13203 } 13104 }
13204 case EXTERNAL_BYTE_ELEMENTS: 13105
13205 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 13106 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
13206 case EXTERNAL_SHORT_ELEMENTS: 13107 case EXTERNAL_##TYPE##_ELEMENTS: \
13207 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 13108 case TYPE##_ELEMENTS: \
13208 case EXTERNAL_INT_ELEMENTS: 13109
13209 case EXTERNAL_UNSIGNED_INT_ELEMENTS: 13110 TYPED_ARRAYS(TYPED_ARRAY_CASE)
13210 case EXTERNAL_FLOAT_ELEMENTS: 13111 #undef TYPED_ARRAY_CASE
13211 case EXTERNAL_DOUBLE_ELEMENTS: 13112 {
13212 case EXTERNAL_PIXEL_ELEMENTS:
13213 case UINT8_ELEMENTS:
13214 case INT8_ELEMENTS:
13215 case UINT16_ELEMENTS:
13216 case INT16_ELEMENTS:
13217 case UINT32_ELEMENTS:
13218 case INT32_ELEMENTS:
13219 case FLOAT32_ELEMENTS:
13220 case FLOAT64_ELEMENTS:
13221 case UINT8_CLAMPED_ELEMENTS: {
13222 // External arrays are considered 100% used. 13113 // External arrays are considered 100% used.
13223 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); 13114 FixedArrayBase* external_array = FixedArrayBase::cast(elements());
13224 *capacity = external_array->length(); 13115 *capacity = external_array->length();
13225 *used = external_array->length(); 13116 *used = external_array->length();
13226 break; 13117 break;
13227 } 13118 }
13228 } 13119 }
13229 } 13120 }
13230 13121
13231 13122
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
13707 if (!FixedDoubleArray::cast(elements())->is_the_hole(i)) { 13598 if (!FixedDoubleArray::cast(elements())->is_the_hole(i)) {
13708 if (storage != NULL) { 13599 if (storage != NULL) {
13709 storage->set(counter, Smi::FromInt(i)); 13600 storage->set(counter, Smi::FromInt(i));
13710 } 13601 }
13711 counter++; 13602 counter++;
13712 } 13603 }
13713 } 13604 }
13714 ASSERT(!storage || storage->length() >= counter); 13605 ASSERT(!storage || storage->length() >= counter);
13715 break; 13606 break;
13716 } 13607 }
13717 case EXTERNAL_PIXEL_ELEMENTS: { 13608
13718 int length = ExternalPixelArray::cast(elements())->length(); 13609 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
13719 while (counter < length) { 13610 case EXTERNAL_##TYPE##_ELEMENTS: \
13720 if (storage != NULL) { 13611 case TYPE##_ELEMENTS: \
13721 storage->set(counter, Smi::FromInt(counter)); 13612
13722 } 13613 TYPED_ARRAYS(TYPED_ARRAY_CASE)
13723 counter++; 13614 #undef TYPED_ARRAY_CASE
13724 } 13615 {
13725 ASSERT(!storage || storage->length() >= counter);
13726 break;
13727 }
13728 case EXTERNAL_BYTE_ELEMENTS:
13729 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
13730 case EXTERNAL_SHORT_ELEMENTS:
13731 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
13732 case EXTERNAL_INT_ELEMENTS:
13733 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
13734 case EXTERNAL_FLOAT_ELEMENTS:
13735 case EXTERNAL_DOUBLE_ELEMENTS:
13736 case UINT8_ELEMENTS:
13737 case INT8_ELEMENTS:
13738 case UINT16_ELEMENTS:
13739 case INT16_ELEMENTS:
13740 case UINT32_ELEMENTS:
13741 case INT32_ELEMENTS:
13742 case FLOAT32_ELEMENTS:
13743 case FLOAT64_ELEMENTS:
13744 case UINT8_CLAMPED_ELEMENTS: {
13745 int length = FixedArrayBase::cast(elements())->length(); 13616 int length = FixedArrayBase::cast(elements())->length();
13746 while (counter < length) { 13617 while (counter < length) {
13747 if (storage != NULL) { 13618 if (storage != NULL) {
13748 storage->set(counter, Smi::FromInt(counter)); 13619 storage->set(counter, Smi::FromInt(counter));
13749 } 13620 }
13750 counter++; 13621 counter++;
13751 } 13622 }
13752 ASSERT(!storage || storage->length() >= counter); 13623 ASSERT(!storage || storage->length() >= counter);
13753 break; 13624 break;
13754 } 13625 }
13626
13755 case DICTIONARY_ELEMENTS: { 13627 case DICTIONARY_ELEMENTS: {
13756 if (storage != NULL) { 13628 if (storage != NULL) {
13757 element_dictionary()->CopyKeysTo(storage, 13629 element_dictionary()->CopyKeysTo(storage,
13758 filter, 13630 filter,
13759 SeededNumberDictionary::SORTED); 13631 SeededNumberDictionary::SORTED);
13760 } 13632 }
13761 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter); 13633 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter);
13762 break; 13634 break;
13763 } 13635 }
13764 case NON_STRICT_ARGUMENTS_ELEMENTS: { 13636 case NON_STRICT_ARGUMENTS_ELEMENTS: {
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
14692 holes++; 14564 holes++;
14693 } 14565 }
14694 } 14566 }
14695 14567
14696 return isolate->factory()->NewNumberFromUint(result); 14568 return isolate->factory()->NewNumberFromUint(result);
14697 } 14569 }
14698 14570
14699 14571
14700 ExternalArrayType JSTypedArray::type() { 14572 ExternalArrayType JSTypedArray::type() {
14701 switch (elements()->map()->instance_type()) { 14573 switch (elements()->map()->instance_type()) {
14702 case EXTERNAL_BYTE_ARRAY_TYPE: 14574 #define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \
14703 return kExternalByteArray; 14575 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
14704 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: 14576 return kExternal##Type##Array;
14705 return kExternalUnsignedByteArray; 14577
14706 case EXTERNAL_SHORT_ARRAY_TYPE: 14578 TYPED_ARRAYS(INSTANCE_TYPE_TO_ARRAY_TYPE)
14707 return kExternalShortArray; 14579 #undef INSTANCE_TYPE_TO_ARRAY_TYPE
14708 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: 14580
14709 return kExternalUnsignedShortArray;
14710 case EXTERNAL_INT_ARRAY_TYPE:
14711 return kExternalIntArray;
14712 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
14713 return kExternalUnsignedIntArray;
14714 case EXTERNAL_FLOAT_ARRAY_TYPE:
14715 return kExternalFloatArray;
14716 case EXTERNAL_DOUBLE_ARRAY_TYPE:
14717 return kExternalDoubleArray;
14718 case EXTERNAL_PIXEL_ARRAY_TYPE:
14719 return kExternalPixelArray;
14720 default: 14581 default:
14721 return static_cast<ExternalArrayType>(-1); 14582 return static_cast<ExternalArrayType>(-1);
14722 } 14583 }
14723 } 14584 }
14724 14585
14725 14586
14726 size_t JSTypedArray::element_size() { 14587 size_t JSTypedArray::element_size() {
14727 switch (elements()->map()->instance_type()) { 14588 switch (elements()->map()->instance_type()) {
14728 case EXTERNAL_BYTE_ARRAY_TYPE: 14589 #define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size) \
14729 return 1; 14590 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
14730 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: 14591 return size;
14731 return 1; 14592
14732 case EXTERNAL_SHORT_ARRAY_TYPE: 14593 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE)
14733 return 2; 14594 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE
14734 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: 14595
14735 return 2;
14736 case EXTERNAL_INT_ARRAY_TYPE:
14737 return 4;
14738 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
14739 return 4;
14740 case EXTERNAL_FLOAT_ARRAY_TYPE:
14741 return 4;
14742 case EXTERNAL_DOUBLE_ARRAY_TYPE:
14743 return 8;
14744 case EXTERNAL_PIXEL_ARRAY_TYPE:
14745 return 1;
14746 default: 14596 default:
14747 UNREACHABLE(); 14597 UNREACHABLE();
14748 return 0; 14598 return 0;
14749 } 14599 }
14750 } 14600 }
14751 14601
14752 14602
14753 Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { 14603 Object* ExternalUint8ClampedArray::SetValue(uint32_t index, Object* value) {
14754 uint8_t clamped_value = 0; 14604 uint8_t clamped_value = 0;
14755 if (index < static_cast<uint32_t>(length())) { 14605 if (index < static_cast<uint32_t>(length())) {
14756 if (value->IsSmi()) { 14606 if (value->IsSmi()) {
14757 int int_value = Smi::cast(value)->value(); 14607 int int_value = Smi::cast(value)->value();
14758 if (int_value < 0) { 14608 if (int_value < 0) {
14759 clamped_value = 0; 14609 clamped_value = 0;
14760 } else if (int_value > 255) { 14610 } else if (int_value > 255) {
14761 clamped_value = 255; 14611 clamped_value = 255;
14762 } else { 14612 } else {
14763 clamped_value = static_cast<uint8_t>(int_value); 14613 clamped_value = static_cast<uint8_t>(int_value);
(...skipping 14 matching lines...) Expand all
14778 // Clamp undefined to zero (default). All other types have been 14628 // Clamp undefined to zero (default). All other types have been
14779 // converted to a number type further up in the call chain. 14629 // converted to a number type further up in the call chain.
14780 ASSERT(value->IsUndefined()); 14630 ASSERT(value->IsUndefined());
14781 } 14631 }
14782 set(index, clamped_value); 14632 set(index, clamped_value);
14783 } 14633 }
14784 return Smi::FromInt(clamped_value); 14634 return Smi::FromInt(clamped_value);
14785 } 14635 }
14786 14636
14787 14637
14638 Handle<Object> ExternalUint8ClampedArray::SetValue(
14639 Handle<ExternalUint8ClampedArray> array,
14640 uint32_t index,
14641 Handle<Object> value) {
14642 return Handle<Object>(array->SetValue(index, *value), array->GetIsolate());
14643 }
14644
14645
14788 template<typename ExternalArrayClass, typename ValueType> 14646 template<typename ExternalArrayClass, typename ValueType>
14789 static MaybeObject* ExternalArrayIntSetter(Heap* heap, 14647 static MaybeObject* ExternalArrayIntSetter(Heap* heap,
14790 ExternalArrayClass* receiver, 14648 ExternalArrayClass* receiver,
14791 uint32_t index, 14649 uint32_t index,
14792 Object* value) { 14650 Object* value) {
14793 ValueType cast_value = 0; 14651 ValueType cast_value = 0;
14794 if (index < static_cast<uint32_t>(receiver->length())) { 14652 if (index < static_cast<uint32_t>(receiver->length())) {
14795 if (value->IsSmi()) { 14653 if (value->IsSmi()) {
14796 int int_value = Smi::cast(value)->value(); 14654 int int_value = Smi::cast(value)->value();
14797 cast_value = static_cast<ValueType>(int_value); 14655 cast_value = static_cast<ValueType>(int_value);
14798 } else if (value->IsHeapNumber()) { 14656 } else if (value->IsHeapNumber()) {
14799 double double_value = HeapNumber::cast(value)->value(); 14657 double double_value = HeapNumber::cast(value)->value();
14800 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); 14658 cast_value = static_cast<ValueType>(DoubleToInt32(double_value));
14801 } else { 14659 } else {
14802 // Clamp undefined to zero (default). All other types have been 14660 // Clamp undefined to zero (default). All other types have been
14803 // converted to a number type further up in the call chain. 14661 // converted to a number type further up in the call chain.
14804 ASSERT(value->IsUndefined()); 14662 ASSERT(value->IsUndefined());
14805 } 14663 }
14806 receiver->set(index, cast_value); 14664 receiver->set(index, cast_value);
14807 } 14665 }
14808 return heap->NumberFromInt32(cast_value); 14666 return heap->NumberFromInt32(cast_value);
14809 } 14667 }
14810 14668
14811 14669
14812 Handle<Object> ExternalByteArray::SetValue(Handle<ExternalByteArray> array, 14670 Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array,
14813 uint32_t index, 14671 uint32_t index,
14814 Handle<Object> value) { 14672 Handle<Object> value) {
14815 CALL_HEAP_FUNCTION(array->GetIsolate(), 14673 CALL_HEAP_FUNCTION(array->GetIsolate(),
14816 array->SetValue(index, *value), 14674 array->SetValue(index, *value),
14817 Object); 14675 Object);
14818 } 14676 }
14819 14677
14820 14678
14821 MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) { 14679 MaybeObject* ExternalInt8Array::SetValue(uint32_t index, Object* value) {
14822 return ExternalArrayIntSetter<ExternalByteArray, int8_t> 14680 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>
14823 (GetHeap(), this, index, value); 14681 (GetHeap(), this, index, value);
14824 } 14682 }
14825 14683
14826 14684
14827 Handle<Object> ExternalUnsignedByteArray::SetValue( 14685 Handle<Object> ExternalUint8Array::SetValue(
14828 Handle<ExternalUnsignedByteArray> array, 14686 Handle<ExternalUint8Array> array,
14829 uint32_t index, 14687 uint32_t index,
14830 Handle<Object> value) { 14688 Handle<Object> value) {
14831 CALL_HEAP_FUNCTION(array->GetIsolate(), 14689 CALL_HEAP_FUNCTION(array->GetIsolate(),
14832 array->SetValue(index, *value), 14690 array->SetValue(index, *value),
14833 Object); 14691 Object);
14834 } 14692 }
14835 14693
14836 14694
14837 MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index, 14695 MaybeObject* ExternalUint8Array::SetValue(uint32_t index,
14838 Object* value) { 14696 Object* value) {
14839 return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t> 14697 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>
14840 (GetHeap(), this, index, value); 14698 (GetHeap(), this, index, value);
14841 } 14699 }
14842 14700
14843 14701
14844 Handle<Object> ExternalShortArray::SetValue( 14702 Handle<Object> ExternalInt16Array::SetValue(
14845 Handle<ExternalShortArray> array, 14703 Handle<ExternalInt16Array> array,
14846 uint32_t index, 14704 uint32_t index,
14847 Handle<Object> value) { 14705 Handle<Object> value) {
14848 CALL_HEAP_FUNCTION(array->GetIsolate(), 14706 CALL_HEAP_FUNCTION(array->GetIsolate(),
14849 array->SetValue(index, *value), 14707 array->SetValue(index, *value),
14850 Object); 14708 Object);
14851 } 14709 }
14852 14710
14853 14711
14854 MaybeObject* ExternalShortArray::SetValue(uint32_t index, 14712 MaybeObject* ExternalInt16Array::SetValue(uint32_t index,
14855 Object* value) { 14713 Object* value) {
14856 return ExternalArrayIntSetter<ExternalShortArray, int16_t> 14714 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>
14857 (GetHeap(), this, index, value); 14715 (GetHeap(), this, index, value);
14858 } 14716 }
14859 14717
14860 14718
14861 Handle<Object> ExternalUnsignedShortArray::SetValue( 14719 Handle<Object> ExternalUint16Array::SetValue(
14862 Handle<ExternalUnsignedShortArray> array, 14720 Handle<ExternalUint16Array> array,
14863 uint32_t index, 14721 uint32_t index,
14864 Handle<Object> value) { 14722 Handle<Object> value) {
14865 CALL_HEAP_FUNCTION(array->GetIsolate(), 14723 CALL_HEAP_FUNCTION(array->GetIsolate(),
14866 array->SetValue(index, *value), 14724 array->SetValue(index, *value),
14867 Object); 14725 Object);
14868 } 14726 }
14869 14727
14870 14728
14871 MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index, 14729 MaybeObject* ExternalUint16Array::SetValue(uint32_t index,
14872 Object* value) { 14730 Object* value) {
14873 return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t> 14731 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>
14874 (GetHeap(), this, index, value); 14732 (GetHeap(), this, index, value);
14875 } 14733 }
14876 14734
14877 14735
14878 Handle<Object> ExternalIntArray::SetValue(Handle<ExternalIntArray> array, 14736 Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array,
14879 uint32_t index, 14737 uint32_t index,
14880 Handle<Object> value) { 14738 Handle<Object> value) {
14881 CALL_HEAP_FUNCTION(array->GetIsolate(), 14739 CALL_HEAP_FUNCTION(array->GetIsolate(),
14882 array->SetValue(index, *value), 14740 array->SetValue(index, *value),
14883 Object); 14741 Object);
14884 } 14742 }
14885 14743
14886 14744
14887 MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) { 14745 MaybeObject* ExternalInt32Array::SetValue(uint32_t index, Object* value) {
14888 return ExternalArrayIntSetter<ExternalIntArray, int32_t> 14746 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>
14889 (GetHeap(), this, index, value); 14747 (GetHeap(), this, index, value);
14890 } 14748 }
14891 14749
14892 14750
14893 Handle<Object> ExternalUnsignedIntArray::SetValue( 14751 Handle<Object> ExternalUint32Array::SetValue(
14894 Handle<ExternalUnsignedIntArray> array, 14752 Handle<ExternalUint32Array> array,
14895 uint32_t index, 14753 uint32_t index,
14896 Handle<Object> value) { 14754 Handle<Object> value) {
14897 CALL_HEAP_FUNCTION(array->GetIsolate(), 14755 CALL_HEAP_FUNCTION(array->GetIsolate(),
14898 array->SetValue(index, *value), 14756 array->SetValue(index, *value),
14899 Object); 14757 Object);
14900 } 14758 }
14901 14759
14902 14760
14903 MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) { 14761 MaybeObject* ExternalUint32Array::SetValue(uint32_t index, Object* value) {
14904 uint32_t cast_value = 0; 14762 uint32_t cast_value = 0;
14905 Heap* heap = GetHeap(); 14763 Heap* heap = GetHeap();
14906 if (index < static_cast<uint32_t>(length())) { 14764 if (index < static_cast<uint32_t>(length())) {
14907 if (value->IsSmi()) { 14765 if (value->IsSmi()) {
14908 int int_value = Smi::cast(value)->value(); 14766 int int_value = Smi::cast(value)->value();
14909 cast_value = static_cast<uint32_t>(int_value); 14767 cast_value = static_cast<uint32_t>(int_value);
14910 } else if (value->IsHeapNumber()) { 14768 } else if (value->IsHeapNumber()) {
14911 double double_value = HeapNumber::cast(value)->value(); 14769 double double_value = HeapNumber::cast(value)->value();
14912 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); 14770 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value));
14913 } else { 14771 } else {
14914 // Clamp undefined to zero (default). All other types have been 14772 // Clamp undefined to zero (default). All other types have been
14915 // converted to a number type further up in the call chain. 14773 // converted to a number type further up in the call chain.
14916 ASSERT(value->IsUndefined()); 14774 ASSERT(value->IsUndefined());
14917 } 14775 }
14918 set(index, cast_value); 14776 set(index, cast_value);
14919 } 14777 }
14920 return heap->NumberFromUint32(cast_value); 14778 return heap->NumberFromUint32(cast_value);
14921 } 14779 }
14922 14780
14923 14781
14924 Handle<Object> ExternalFloatArray::SetValue(Handle<ExternalFloatArray> array, 14782 Handle<Object> ExternalFloat32Array::SetValue(
14925 uint32_t index, 14783 Handle<ExternalFloat32Array> array,
14926 Handle<Object> value) { 14784 uint32_t index,
14785 Handle<Object> value) {
14927 CALL_HEAP_FUNCTION(array->GetIsolate(), 14786 CALL_HEAP_FUNCTION(array->GetIsolate(),
14928 array->SetValue(index, *value), 14787 array->SetValue(index, *value),
14929 Object); 14788 Object);
14930 } 14789 }
14931 14790
14932 14791
14933 MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) { 14792 MaybeObject* ExternalFloat32Array::SetValue(uint32_t index, Object* value) {
14934 float cast_value = static_cast<float>(OS::nan_value()); 14793 float cast_value = static_cast<float>(OS::nan_value());
14935 Heap* heap = GetHeap(); 14794 Heap* heap = GetHeap();
14936 if (index < static_cast<uint32_t>(length())) { 14795 if (index < static_cast<uint32_t>(length())) {
14937 if (value->IsSmi()) { 14796 if (value->IsSmi()) {
14938 int int_value = Smi::cast(value)->value(); 14797 int int_value = Smi::cast(value)->value();
14939 cast_value = static_cast<float>(int_value); 14798 cast_value = static_cast<float>(int_value);
14940 } else if (value->IsHeapNumber()) { 14799 } else if (value->IsHeapNumber()) {
14941 double double_value = HeapNumber::cast(value)->value(); 14800 double double_value = HeapNumber::cast(value)->value();
14942 cast_value = static_cast<float>(double_value); 14801 cast_value = static_cast<float>(double_value);
14943 } else { 14802 } else {
14944 // Clamp undefined to NaN (default). All other types have been 14803 // Clamp undefined to NaN (default). All other types have been
14945 // converted to a number type further up in the call chain. 14804 // converted to a number type further up in the call chain.
14946 ASSERT(value->IsUndefined()); 14805 ASSERT(value->IsUndefined());
14947 } 14806 }
14948 set(index, cast_value); 14807 set(index, cast_value);
14949 } 14808 }
14950 return heap->AllocateHeapNumber(cast_value); 14809 return heap->AllocateHeapNumber(cast_value);
14951 } 14810 }
14952 14811
14953 14812
14954 Handle<Object> ExternalDoubleArray::SetValue(Handle<ExternalDoubleArray> array, 14813 Handle<Object> ExternalFloat64Array::SetValue(
14955 uint32_t index, 14814 Handle<ExternalFloat64Array> array,
14956 Handle<Object> value) { 14815 uint32_t index,
14816 Handle<Object> value) {
14957 CALL_HEAP_FUNCTION(array->GetIsolate(), 14817 CALL_HEAP_FUNCTION(array->GetIsolate(),
14958 array->SetValue(index, *value), 14818 array->SetValue(index, *value),
14959 Object); 14819 Object);
14960 } 14820 }
14961 14821
14962 14822
14963 MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) { 14823 MaybeObject* ExternalFloat64Array::SetValue(uint32_t index, Object* value) {
14964 double double_value = OS::nan_value(); 14824 double double_value = OS::nan_value();
14965 Heap* heap = GetHeap(); 14825 Heap* heap = GetHeap();
14966 if (index < static_cast<uint32_t>(length())) { 14826 if (index < static_cast<uint32_t>(length())) {
14967 if (value->IsSmi()) { 14827 if (value->IsSmi()) {
14968 int int_value = Smi::cast(value)->value(); 14828 int int_value = Smi::cast(value)->value();
14969 double_value = static_cast<double>(int_value); 14829 double_value = static_cast<double>(int_value);
14970 } else if (value->IsHeapNumber()) { 14830 } else if (value->IsHeapNumber()) {
14971 double_value = HeapNumber::cast(value)->value(); 14831 double_value = HeapNumber::cast(value)->value();
14972 } else { 14832 } else {
14973 // Clamp undefined to NaN (default). All other types have been 14833 // Clamp undefined to NaN (default). All other types have been
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
15641 15501
15642 15502
15643 15503
15644 template<typename Shape, typename Key> 15504 template<typename Shape, typename Key>
15645 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( 15505 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes(
15646 PropertyAttributes filter) { 15506 PropertyAttributes filter) {
15647 int capacity = HashTable<Shape, Key>::Capacity(); 15507 int capacity = HashTable<Shape, Key>::Capacity();
15648 int result = 0; 15508 int result = 0;
15649 for (int i = 0; i < capacity; i++) { 15509 for (int i = 0; i < capacity; i++) {
15650 Object* k = HashTable<Shape, Key>::KeyAt(i); 15510 Object* k = HashTable<Shape, Key>::KeyAt(i);
15651 if (HashTable<Shape, Key>::IsKey(k) && 15511 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) {
15652 !FilterKey(k, filter)) {
15653 PropertyDetails details = DetailsAt(i); 15512 PropertyDetails details = DetailsAt(i);
15654 if (details.IsDeleted()) continue; 15513 if (details.IsDeleted()) continue;
15655 PropertyAttributes attr = details.attributes(); 15514 PropertyAttributes attr = details.attributes();
15656 if ((attr & filter) == 0) result++; 15515 if ((attr & filter) == 0) result++;
15657 } 15516 }
15658 } 15517 }
15659 return result; 15518 return result;
15660 } 15519 }
15661 15520
15662 15521
15663 template<typename Shape, typename Key> 15522 template<typename Shape, typename Key>
15664 int Dictionary<Shape, Key>::NumberOfEnumElements() { 15523 int Dictionary<Shape, Key>::NumberOfEnumElements() {
15665 return NumberOfElementsFilterAttributes( 15524 return NumberOfElementsFilterAttributes(
15666 static_cast<PropertyAttributes>(DONT_ENUM)); 15525 static_cast<PropertyAttributes>(DONT_ENUM));
15667 } 15526 }
15668 15527
15669 15528
15670 template<typename Shape, typename Key> 15529 template<typename Shape, typename Key>
15671 void Dictionary<Shape, Key>::CopyKeysTo( 15530 void Dictionary<Shape, Key>::CopyKeysTo(
15672 FixedArray* storage, 15531 FixedArray* storage,
15673 PropertyAttributes filter, 15532 PropertyAttributes filter,
15674 typename Dictionary<Shape, Key>::SortMode sort_mode) { 15533 typename Dictionary<Shape, Key>::SortMode sort_mode) {
15675 ASSERT(storage->length() >= NumberOfEnumElements()); 15534 ASSERT(storage->length() >= NumberOfElementsFilterAttributes(filter));
15676 int capacity = HashTable<Shape, Key>::Capacity(); 15535 int capacity = HashTable<Shape, Key>::Capacity();
15677 int index = 0; 15536 int index = 0;
15678 for (int i = 0; i < capacity; i++) { 15537 for (int i = 0; i < capacity; i++) {
15679 Object* k = HashTable<Shape, Key>::KeyAt(i); 15538 Object* k = HashTable<Shape, Key>::KeyAt(i);
15680 if (HashTable<Shape, Key>::IsKey(k)) { 15539 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) {
15681 PropertyDetails details = DetailsAt(i); 15540 PropertyDetails details = DetailsAt(i);
15682 if (details.IsDeleted()) continue; 15541 if (details.IsDeleted()) continue;
15683 PropertyAttributes attr = details.attributes(); 15542 PropertyAttributes attr = details.attributes();
15684 if ((attr & filter) == 0) storage->set(index++, k); 15543 if ((attr & filter) == 0) storage->set(index++, k);
15685 } 15544 }
15686 } 15545 }
15687 if (sort_mode == Dictionary<Shape, Key>::SORTED) { 15546 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
15688 storage->SortPairs(storage, index); 15547 storage->SortPairs(storage, index);
15689 } 15548 }
15690 ASSERT(storage->length() >= index); 15549 ASSERT(storage->length() >= index);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
15732 return storage; 15591 return storage;
15733 } 15592 }
15734 15593
15735 15594
15736 template<typename Shape, typename Key> 15595 template<typename Shape, typename Key>
15737 void Dictionary<Shape, Key>::CopyKeysTo( 15596 void Dictionary<Shape, Key>::CopyKeysTo(
15738 FixedArray* storage, 15597 FixedArray* storage,
15739 int index, 15598 int index,
15740 PropertyAttributes filter, 15599 PropertyAttributes filter,
15741 typename Dictionary<Shape, Key>::SortMode sort_mode) { 15600 typename Dictionary<Shape, Key>::SortMode sort_mode) {
15742 ASSERT(storage->length() >= NumberOfElementsFilterAttributes( 15601 ASSERT(storage->length() >= NumberOfElementsFilterAttributes(filter));
15743 static_cast<PropertyAttributes>(NONE)));
15744 int capacity = HashTable<Shape, Key>::Capacity(); 15602 int capacity = HashTable<Shape, Key>::Capacity();
15745 for (int i = 0; i < capacity; i++) { 15603 for (int i = 0; i < capacity; i++) {
15746 Object* k = HashTable<Shape, Key>::KeyAt(i); 15604 Object* k = HashTable<Shape, Key>::KeyAt(i);
15747 if (HashTable<Shape, Key>::IsKey(k)) { 15605 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) {
15748 PropertyDetails details = DetailsAt(i); 15606 PropertyDetails details = DetailsAt(i);
15749 if (details.IsDeleted()) continue; 15607 if (details.IsDeleted()) continue;
15750 PropertyAttributes attr = details.attributes(); 15608 PropertyAttributes attr = details.attributes();
15751 if ((attr & filter) == 0) storage->set(index++, k); 15609 if ((attr & filter) == 0) storage->set(index++, k);
15752 } 15610 }
15753 } 15611 }
15754 if (sort_mode == Dictionary<Shape, Key>::SORTED) { 15612 if (sort_mode == Dictionary<Shape, Key>::SORTED) {
15755 storage->SortPairs(storage, index); 15613 storage->SortPairs(storage, index);
15756 } 15614 }
15757 ASSERT(storage->length() >= index); 15615 ASSERT(storage->length() >= index);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
15859 if (IsKey(k)) { 15717 if (IsKey(k)) {
15860 Object* value = ValueAt(i); 15718 Object* value = ValueAt(i);
15861 Name* key; 15719 Name* key;
15862 if (k->IsSymbol()) { 15720 if (k->IsSymbol()) {
15863 key = Symbol::cast(k); 15721 key = Symbol::cast(k);
15864 } else { 15722 } else {
15865 // Ensure the key is a unique name before writing into the 15723 // Ensure the key is a unique name before writing into the
15866 // instance descriptor. 15724 // instance descriptor.
15867 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); 15725 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k));
15868 if (!maybe_key->To(&key)) return maybe_key; 15726 if (!maybe_key->To(&key)) return maybe_key;
15727 if (key->Equals(heap->empty_string())) return this;
15869 } 15728 }
15870 15729
15871 PropertyDetails details = DetailsAt(i); 15730 PropertyDetails details = DetailsAt(i);
15872 int enumeration_index = details.dictionary_index(); 15731 int enumeration_index = details.dictionary_index();
15873 PropertyType type = details.type(); 15732 PropertyType type = details.type();
15874 15733
15875 if (value->IsJSFunction()) { 15734 if (value->IsJSFunction()) {
15876 ConstantDescriptor d(key, value, details.attributes()); 15735 ConstantDescriptor d(key, value, details.attributes());
15877 descriptors->Set(enumeration_index - 1, &d, witness); 15736 descriptors->Set(enumeration_index - 1, &d, witness);
15878 } else if (type == NORMAL) { 15737 } else if (type == NORMAL) {
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
16570 } 16429 }
16571 16430
16572 16431
16573 void JSTypedArray::Neuter() { 16432 void JSTypedArray::Neuter() {
16574 NeuterView(); 16433 NeuterView();
16575 set_length(Smi::FromInt(0)); 16434 set_length(Smi::FromInt(0));
16576 set_elements(GetHeap()->EmptyExternalArrayForMap(map())); 16435 set_elements(GetHeap()->EmptyExternalArrayForMap(map()));
16577 } 16436 }
16578 16437
16579 16438
16580 Type* PropertyCell::type() { 16439 HeapType* PropertyCell::type() {
16581 return static_cast<Type*>(type_raw()); 16440 return static_cast<HeapType*>(type_raw());
16582 } 16441 }
16583 16442
16584 16443
16585 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { 16444 void PropertyCell::set_type(HeapType* type, WriteBarrierMode ignored) {
16586 ASSERT(IsPropertyCell()); 16445 ASSERT(IsPropertyCell());
16587 set_type_raw(type, ignored); 16446 set_type_raw(type, ignored);
16588 } 16447 }
16589 16448
16590 16449
16591 Handle<Type> PropertyCell::UpdatedType(Handle<PropertyCell> cell, 16450 Handle<HeapType> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
16592 Handle<Object> value) { 16451 Handle<Object> value) {
16593 Isolate* isolate = cell->GetIsolate(); 16452 Isolate* isolate = cell->GetIsolate();
16594 Handle<Type> old_type(cell->type(), isolate); 16453 Handle<HeapType> old_type(cell->type(), isolate);
16595 // TODO(2803): Do not track ConsString as constant because they cannot be 16454 // TODO(2803): Do not track ConsString as constant because they cannot be
16596 // embedded into code. 16455 // embedded into code.
16597 Handle<Type> new_type = value->IsConsString() || value->IsTheHole() 16456 Handle<HeapType> new_type = value->IsConsString() || value->IsTheHole()
16598 ? Type::Any(isolate) : Type::Constant(value, isolate); 16457 ? HeapType::Any(isolate) : HeapType::Constant(value, isolate);
16599 16458
16600 if (new_type->Is(old_type)) { 16459 if (new_type->Is(old_type)) {
16601 return old_type; 16460 return old_type;
16602 } 16461 }
16603 16462
16604 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16463 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16605 isolate, DependentCode::kPropertyCellChangedGroup); 16464 isolate, DependentCode::kPropertyCellChangedGroup);
16606 16465
16607 if (old_type->Is(Type::None()) || old_type->Is(Type::Undefined())) { 16466 if (old_type->Is(HeapType::None()) || old_type->Is(HeapType::Undefined())) {
16608 return new_type; 16467 return new_type;
16609 } 16468 }
16610 16469
16611 return Type::Any(isolate); 16470 return HeapType::Any(isolate);
16612 } 16471 }
16613 16472
16614 16473
16615 void PropertyCell::SetValueInferType(Handle<PropertyCell> cell, 16474 void PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
16616 Handle<Object> value) { 16475 Handle<Object> value) {
16617 cell->set_value(*value); 16476 cell->set_value(*value);
16618 if (!Type::Any()->Is(cell->type())) { 16477 if (!HeapType::Any()->Is(cell->type())) {
16619 Handle<Type> new_type = UpdatedType(cell, value); 16478 Handle<HeapType> new_type = UpdatedType(cell, value);
16620 cell->set_type(*new_type); 16479 cell->set_type(*new_type);
16621 } 16480 }
16622 } 16481 }
16623 16482
16624 16483
16625 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { 16484 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) {
16626 Handle<DependentCode> dep(dependent_code()); 16485 Handle<DependentCode> dep(dependent_code());
16627 Handle<DependentCode> codes = 16486 Handle<DependentCode> codes =
16628 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, 16487 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup,
16629 info->object_wrapper()); 16488 info->object_wrapper());
16630 if (*codes != dependent_code()) set_dependent_code(*codes); 16489 if (*codes != dependent_code()) set_dependent_code(*codes);
16631 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16490 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16632 Handle<HeapObject>(this), info->zone()); 16491 Handle<HeapObject>(this), info->zone());
16633 } 16492 }
16634 16493
16635 16494
16636 const char* GetBailoutReason(BailoutReason reason) { 16495 const char* GetBailoutReason(BailoutReason reason) {
16637 ASSERT(reason < kLastErrorMessage); 16496 ASSERT(reason < kLastErrorMessage);
16638 #define ERROR_MESSAGES_TEXTS(C, T) T, 16497 #define ERROR_MESSAGES_TEXTS(C, T) T,
16639 static const char* error_messages_[] = { 16498 static const char* error_messages_[] = {
16640 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16499 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16641 }; 16500 };
16642 #undef ERROR_MESSAGES_TEXTS 16501 #undef ERROR_MESSAGES_TEXTS
16643 return error_messages_[reason]; 16502 return error_messages_[reason];
16644 } 16503 }
16645 16504
16646 16505
16647 } } // namespace v8::internal 16506 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698