OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 21 matching lines...) Expand all Loading... |
32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
33 #include "codegen.h" | 33 #include "codegen.h" |
34 #include "debug.h" | 34 #include "debug.h" |
35 #include "deoptimizer.h" | 35 #include "deoptimizer.h" |
36 #include "elements.h" | 36 #include "elements.h" |
37 #include "execution.h" | 37 #include "execution.h" |
38 #include "full-codegen.h" | 38 #include "full-codegen.h" |
39 #include "hydrogen.h" | 39 #include "hydrogen.h" |
40 #include "objects-inl.h" | 40 #include "objects-inl.h" |
41 #include "objects-visiting.h" | 41 #include "objects-visiting.h" |
| 42 #include "objects-visiting-inl.h" |
42 #include "macro-assembler.h" | 43 #include "macro-assembler.h" |
| 44 #include "mark-compact.h" |
43 #include "safepoint-table.h" | 45 #include "safepoint-table.h" |
44 #include "string-stream.h" | 46 #include "string-stream.h" |
45 #include "utils.h" | 47 #include "utils.h" |
46 #include "vm-state-inl.h" | 48 #include "vm-state-inl.h" |
47 | 49 |
48 #ifdef ENABLE_DISASSEMBLER | 50 #ifdef ENABLE_DISASSEMBLER |
49 #include "disasm.h" | 51 #include "disasm.h" |
50 #include "disassembler.h" | 52 #include "disassembler.h" |
51 #endif | 53 #endif |
52 | 54 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // from the DontDelete cell without checking if it contains | 461 // from the DontDelete cell without checking if it contains |
460 // the hole value. | 462 // the hole value. |
461 Object* new_map; | 463 Object* new_map; |
462 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | 464 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); |
463 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 465 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
464 } | 466 } |
465 set_map(Map::cast(new_map)); | 467 set_map(Map::cast(new_map)); |
466 } | 468 } |
467 JSGlobalPropertyCell* cell = | 469 JSGlobalPropertyCell* cell = |
468 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry)); | 470 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry)); |
469 cell->set_value(cell->heap()->the_hole_value()); | 471 cell->set_value(cell->GetHeap()->the_hole_value()); |
470 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 472 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
471 } else { | 473 } else { |
472 Object* deleted = dictionary->DeleteProperty(entry, mode); | 474 Object* deleted = dictionary->DeleteProperty(entry, mode); |
473 if (deleted == GetHeap()->true_value()) { | 475 if (deleted == GetHeap()->true_value()) { |
474 FixedArray* new_properties = NULL; | 476 FixedArray* new_properties = NULL; |
475 MaybeObject* maybe_properties = dictionary->Shrink(name); | 477 MaybeObject* maybe_properties = dictionary->Shrink(name); |
476 if (!maybe_properties->To(&new_properties)) { | 478 if (!maybe_properties->To(&new_properties)) { |
477 return maybe_properties; | 479 return maybe_properties; |
478 } | 480 } |
479 set_properties(new_properties); | 481 set_properties(new_properties); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 self->Hash(); // Force regeneration of the hash value. | 850 self->Hash(); // Force regeneration of the hash value. |
849 // Now morph this external string into a external symbol. | 851 // Now morph this external string into a external symbol. |
850 this->set_map(is_ascii ? | 852 this->set_map(is_ascii ? |
851 heap->external_symbol_with_ascii_data_map() : | 853 heap->external_symbol_with_ascii_data_map() : |
852 heap->external_symbol_map()); | 854 heap->external_symbol_map()); |
853 } | 855 } |
854 | 856 |
855 // Fill the remainder of the string with dead wood. | 857 // Fill the remainder of the string with dead wood. |
856 int new_size = this->Size(); // Byte size of the external String object. | 858 int new_size = this->Size(); // Byte size of the external String object. |
857 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 859 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
| 860 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
| 861 MemoryChunk::IncrementLiveBytes(this->address(), new_size - size); |
| 862 } |
858 return true; | 863 return true; |
859 } | 864 } |
860 | 865 |
861 | 866 |
862 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { | 867 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { |
863 #ifdef DEBUG | 868 #ifdef DEBUG |
864 if (FLAG_enable_slow_asserts) { | 869 if (FLAG_enable_slow_asserts) { |
865 // Assert that the resource and the string are equivalent. | 870 // Assert that the resource and the string are equivalent. |
866 ASSERT(static_cast<size_t>(this->length()) == resource->length()); | 871 ASSERT(static_cast<size_t>(this->length()) == resource->length()); |
867 ScopedVector<char> smart_chars(this->length()); | 872 ScopedVector<char> smart_chars(this->length()); |
(...skipping 26 matching lines...) Expand all Loading... |
894 // was a symbol to start with. | 899 // was a symbol to start with. |
895 if (is_symbol) { | 900 if (is_symbol) { |
896 self->Hash(); // Force regeneration of the hash value. | 901 self->Hash(); // Force regeneration of the hash value. |
897 // Now morph this external string into a external symbol. | 902 // Now morph this external string into a external symbol. |
898 this->set_map(heap->external_ascii_symbol_map()); | 903 this->set_map(heap->external_ascii_symbol_map()); |
899 } | 904 } |
900 | 905 |
901 // Fill the remainder of the string with dead wood. | 906 // Fill the remainder of the string with dead wood. |
902 int new_size = this->Size(); // Byte size of the external String object. | 907 int new_size = this->Size(); // Byte size of the external String object. |
903 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 908 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
| 909 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
| 910 MemoryChunk::IncrementLiveBytes(this->address(), new_size - size); |
| 911 } |
| 912 |
904 return true; | 913 return true; |
905 } | 914 } |
906 | 915 |
907 | 916 |
908 void String::StringShortPrint(StringStream* accumulator) { | 917 void String::StringShortPrint(StringStream* accumulator) { |
909 int len = length(); | 918 int len = length(); |
910 if (len > kMaxShortPrintLength) { | 919 if (len > kMaxShortPrintLength) { |
911 accumulator->Add("<Very long string[%u]>", len); | 920 accumulator->Add("<Very long string[%u]>", len); |
912 return; | 921 return; |
913 } | 922 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 } | 1007 } |
999 if (!printed) { | 1008 if (!printed) { |
1000 accumulator->Add("<JS Function>"); | 1009 accumulator->Add("<JS Function>"); |
1001 } | 1010 } |
1002 break; | 1011 break; |
1003 } | 1012 } |
1004 // All other JSObjects are rather similar to each other (JSObject, | 1013 // All other JSObjects are rather similar to each other (JSObject, |
1005 // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue). | 1014 // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue). |
1006 default: { | 1015 default: { |
1007 Map* map_of_this = map(); | 1016 Map* map_of_this = map(); |
1008 Heap* heap = map_of_this->heap(); | 1017 Heap* heap = GetHeap(); |
1009 Object* constructor = map_of_this->constructor(); | 1018 Object* constructor = map_of_this->constructor(); |
1010 bool printed = false; | 1019 bool printed = false; |
1011 if (constructor->IsHeapObject() && | 1020 if (constructor->IsHeapObject() && |
1012 !heap->Contains(HeapObject::cast(constructor))) { | 1021 !heap->Contains(HeapObject::cast(constructor))) { |
1013 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); | 1022 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); |
1014 } else { | 1023 } else { |
1015 bool global_object = IsJSGlobalProxy(); | 1024 bool global_object = IsJSGlobalProxy(); |
1016 if (constructor->IsJSFunction()) { | 1025 if (constructor->IsJSFunction()) { |
1017 if (!heap->Contains(JSFunction::cast(constructor)->shared())) { | 1026 if (!heap->Contains(JSFunction::cast(constructor)->shared())) { |
1018 accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!"); | 1027 accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!"); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 switch (map()->instance_type()) { | 1082 switch (map()->instance_type()) { |
1074 case MAP_TYPE: | 1083 case MAP_TYPE: |
1075 accumulator->Add("<Map>"); | 1084 accumulator->Add("<Map>"); |
1076 break; | 1085 break; |
1077 case FIXED_ARRAY_TYPE: | 1086 case FIXED_ARRAY_TYPE: |
1078 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); | 1087 accumulator->Add("<FixedArray[%u]>", FixedArray::cast(this)->length()); |
1079 break; | 1088 break; |
1080 case BYTE_ARRAY_TYPE: | 1089 case BYTE_ARRAY_TYPE: |
1081 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); | 1090 accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length()); |
1082 break; | 1091 break; |
| 1092 case FREE_SPACE_TYPE: |
| 1093 accumulator->Add("<FreeSpace[%u]>", FreeSpace::cast(this)->Size()); |
| 1094 break; |
1083 case EXTERNAL_PIXEL_ARRAY_TYPE: | 1095 case EXTERNAL_PIXEL_ARRAY_TYPE: |
1084 accumulator->Add("<ExternalPixelArray[%u]>", | 1096 accumulator->Add("<ExternalPixelArray[%u]>", |
1085 ExternalPixelArray::cast(this)->length()); | 1097 ExternalPixelArray::cast(this)->length()); |
1086 break; | 1098 break; |
1087 case EXTERNAL_BYTE_ARRAY_TYPE: | 1099 case EXTERNAL_BYTE_ARRAY_TYPE: |
1088 accumulator->Add("<ExternalByteArray[%u]>", | 1100 accumulator->Add("<ExternalByteArray[%u]>", |
1089 ExternalByteArray::cast(this)->length()); | 1101 ExternalByteArray::cast(this)->length()); |
1090 break; | 1102 break; |
1091 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | 1103 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
1092 accumulator->Add("<ExternalUnsignedByteArray[%u]>", | 1104 accumulator->Add("<ExternalUnsignedByteArray[%u]>", |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 break; | 1260 break; |
1249 case CODE_TYPE: | 1261 case CODE_TYPE: |
1250 reinterpret_cast<Code*>(this)->CodeIterateBody(v); | 1262 reinterpret_cast<Code*>(this)->CodeIterateBody(v); |
1251 break; | 1263 break; |
1252 case JS_GLOBAL_PROPERTY_CELL_TYPE: | 1264 case JS_GLOBAL_PROPERTY_CELL_TYPE: |
1253 JSGlobalPropertyCell::BodyDescriptor::IterateBody(this, v); | 1265 JSGlobalPropertyCell::BodyDescriptor::IterateBody(this, v); |
1254 break; | 1266 break; |
1255 case HEAP_NUMBER_TYPE: | 1267 case HEAP_NUMBER_TYPE: |
1256 case FILLER_TYPE: | 1268 case FILLER_TYPE: |
1257 case BYTE_ARRAY_TYPE: | 1269 case BYTE_ARRAY_TYPE: |
| 1270 case FREE_SPACE_TYPE: |
1258 case EXTERNAL_PIXEL_ARRAY_TYPE: | 1271 case EXTERNAL_PIXEL_ARRAY_TYPE: |
1259 case EXTERNAL_BYTE_ARRAY_TYPE: | 1272 case EXTERNAL_BYTE_ARRAY_TYPE: |
1260 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | 1273 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
1261 case EXTERNAL_SHORT_ARRAY_TYPE: | 1274 case EXTERNAL_SHORT_ARRAY_TYPE: |
1262 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | 1275 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
1263 case EXTERNAL_INT_ARRAY_TYPE: | 1276 case EXTERNAL_INT_ARRAY_TYPE: |
1264 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | 1277 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
1265 case EXTERNAL_FLOAT_ARRAY_TYPE: | 1278 case EXTERNAL_FLOAT_ARRAY_TYPE: |
1266 case EXTERNAL_DOUBLE_ARRAY_TYPE: | 1279 case EXTERNAL_DOUBLE_ARRAY_TYPE: |
1267 break; | 1280 break; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1517 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1505 } | 1518 } |
1506 | 1519 |
1507 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors); | 1520 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors); |
1508 Map::cast(new_map)->set_instance_descriptors(descriptors); | 1521 Map::cast(new_map)->set_instance_descriptors(descriptors); |
1509 Map* old_map = map(); | 1522 Map* old_map = map(); |
1510 set_map(Map::cast(new_map)); | 1523 set_map(Map::cast(new_map)); |
1511 | 1524 |
1512 // If the old map is the global object map (from new Object()), | 1525 // If the old map is the global object map (from new Object()), |
1513 // then transitions are not added to it, so we are done. | 1526 // then transitions are not added to it, so we are done. |
1514 Heap* heap = old_map->heap(); | 1527 Heap* heap = GetHeap(); |
1515 if (old_map == heap->isolate()->context()->global_context()-> | 1528 if (old_map == heap->isolate()->context()->global_context()-> |
1516 object_function()->map()) { | 1529 object_function()->map()) { |
1517 return function; | 1530 return function; |
1518 } | 1531 } |
1519 | 1532 |
1520 // Do not add CONSTANT_TRANSITIONS to global objects | 1533 // Do not add CONSTANT_TRANSITIONS to global objects |
1521 if (IsGlobalObject()) { | 1534 if (IsGlobalObject()) { |
1522 return function; | 1535 return function; |
1523 } | 1536 } |
1524 | 1537 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 return value; | 1593 return value; |
1581 } | 1594 } |
1582 | 1595 |
1583 | 1596 |
1584 MaybeObject* JSObject::AddProperty(String* name, | 1597 MaybeObject* JSObject::AddProperty(String* name, |
1585 Object* value, | 1598 Object* value, |
1586 PropertyAttributes attributes, | 1599 PropertyAttributes attributes, |
1587 StrictModeFlag strict_mode) { | 1600 StrictModeFlag strict_mode) { |
1588 ASSERT(!IsJSGlobalProxy()); | 1601 ASSERT(!IsJSGlobalProxy()); |
1589 Map* map_of_this = map(); | 1602 Map* map_of_this = map(); |
1590 Heap* heap = map_of_this->heap(); | 1603 Heap* heap = GetHeap(); |
1591 if (!map_of_this->is_extensible()) { | 1604 if (!map_of_this->is_extensible()) { |
1592 if (strict_mode == kNonStrictMode) { | 1605 if (strict_mode == kNonStrictMode) { |
1593 return heap->undefined_value(); | 1606 return heap->undefined_value(); |
1594 } else { | 1607 } else { |
1595 Handle<Object> args[1] = {Handle<String>(name)}; | 1608 Handle<Object> args[1] = {Handle<String>(name)}; |
1596 return heap->isolate()->Throw( | 1609 return heap->isolate()->Throw( |
1597 *FACTORY->NewTypeError("object_not_extensible", | 1610 *FACTORY->NewTypeError("object_not_extensible", |
1598 HandleVector(args, 1))); | 1611 HandleVector(args, 1))); |
1599 } | 1612 } |
1600 } | 1613 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 { MaybeObject* maybe_result = | 1680 { MaybeObject* maybe_result = |
1668 ConvertDescriptorToField(name, new_value, attributes); | 1681 ConvertDescriptorToField(name, new_value, attributes); |
1669 if (!maybe_result->ToObject(&result)) return maybe_result; | 1682 if (!maybe_result->ToObject(&result)) return maybe_result; |
1670 } | 1683 } |
1671 // If we get to this point we have succeeded - do not return failure | 1684 // If we get to this point we have succeeded - do not return failure |
1672 // after this point. Later stuff is optional. | 1685 // after this point. Later stuff is optional. |
1673 if (!HasFastProperties()) { | 1686 if (!HasFastProperties()) { |
1674 return result; | 1687 return result; |
1675 } | 1688 } |
1676 // Do not add transitions to the map of "new Object()". | 1689 // Do not add transitions to the map of "new Object()". |
1677 if (map() == old_map->heap()->isolate()->context()->global_context()-> | 1690 if (map() == GetIsolate()->context()->global_context()-> |
1678 object_function()->map()) { | 1691 object_function()->map()) { |
1679 return result; | 1692 return result; |
1680 } | 1693 } |
1681 | 1694 |
1682 MapTransitionDescriptor transition(name, | 1695 MapTransitionDescriptor transition(name, |
1683 map(), | 1696 map(), |
1684 attributes); | 1697 attributes); |
1685 Object* new_descriptors; | 1698 Object* new_descriptors; |
1686 { MaybeObject* maybe_new_descriptors = old_map->instance_descriptors()-> | 1699 { MaybeObject* maybe_new_descriptors = old_map->instance_descriptors()-> |
1687 CopyInsert(&transition, KEEP_TRANSITIONS); | 1700 CopyInsert(&transition, KEEP_TRANSITIONS); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 } else { | 1972 } else { |
1960 result->NotFound(); | 1973 result->NotFound(); |
1961 } | 1974 } |
1962 } | 1975 } |
1963 | 1976 |
1964 | 1977 |
1965 void Map::LookupInDescriptors(JSObject* holder, | 1978 void Map::LookupInDescriptors(JSObject* holder, |
1966 String* name, | 1979 String* name, |
1967 LookupResult* result) { | 1980 LookupResult* result) { |
1968 DescriptorArray* descriptors = instance_descriptors(); | 1981 DescriptorArray* descriptors = instance_descriptors(); |
1969 DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache(); | 1982 DescriptorLookupCache* cache = |
| 1983 GetHeap()->isolate()->descriptor_lookup_cache(); |
1970 int number = cache->Lookup(descriptors, name); | 1984 int number = cache->Lookup(descriptors, name); |
1971 if (number == DescriptorLookupCache::kAbsent) { | 1985 if (number == DescriptorLookupCache::kAbsent) { |
1972 number = descriptors->Search(name); | 1986 number = descriptors->Search(name); |
1973 cache->Update(descriptors, name, number); | 1987 cache->Update(descriptors, name, number); |
1974 } | 1988 } |
1975 if (number != DescriptorArray::kNotFound) { | 1989 if (number != DescriptorArray::kNotFound) { |
1976 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1990 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
1977 } else { | 1991 } else { |
1978 result->NotFound(); | 1992 result->NotFound(); |
1979 } | 1993 } |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 case CONSTANT_TRANSITION: | 2884 case CONSTANT_TRANSITION: |
2871 case NULL_DESCRIPTOR: | 2885 case NULL_DESCRIPTOR: |
2872 case INTERCEPTOR: | 2886 case INTERCEPTOR: |
2873 case ELEMENTS_TRANSITION: | 2887 case ELEMENTS_TRANSITION: |
2874 break; | 2888 break; |
2875 default: | 2889 default: |
2876 UNREACHABLE(); | 2890 UNREACHABLE(); |
2877 } | 2891 } |
2878 } | 2892 } |
2879 | 2893 |
2880 Heap* current_heap = map_of_this->heap(); | 2894 Heap* current_heap = GetHeap(); |
2881 | 2895 |
2882 // Copy the next enumeration index from instance descriptor. | 2896 // Copy the next enumeration index from instance descriptor. |
2883 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); | 2897 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
2884 dictionary->SetNextEnumerationIndex(index); | 2898 dictionary->SetNextEnumerationIndex(index); |
2885 | 2899 |
2886 { MaybeObject* maybe_obj = | 2900 { MaybeObject* maybe_obj = |
2887 current_heap->isolate()->context()->global_context()-> | 2901 current_heap->isolate()->context()->global_context()-> |
2888 normalized_map_cache()->Get(this, mode); | 2902 normalized_map_cache()->Get(this, mode); |
2889 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2903 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2890 } | 2904 } |
2891 Map* new_map = Map::cast(obj); | 2905 Map* new_map = Map::cast(obj); |
2892 | 2906 |
2893 // We have now successfully allocated all the necessary objects. | 2907 // We have now successfully allocated all the necessary objects. |
2894 // Changes can now be made with the guarantee that all of them take effect. | 2908 // Changes can now be made with the guarantee that all of them take effect. |
2895 | 2909 |
2896 // Resize the object in the heap if necessary. | 2910 // Resize the object in the heap if necessary. |
2897 int new_instance_size = new_map->instance_size(); | 2911 int new_instance_size = new_map->instance_size(); |
2898 int instance_size_delta = map_of_this->instance_size() - new_instance_size; | 2912 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
2899 ASSERT(instance_size_delta >= 0); | 2913 ASSERT(instance_size_delta >= 0); |
2900 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, | 2914 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, |
2901 instance_size_delta); | 2915 instance_size_delta); |
| 2916 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
| 2917 MemoryChunk::IncrementLiveBytes(this->address(), -instance_size_delta); |
| 2918 } |
| 2919 |
2902 | 2920 |
2903 set_map(new_map); | 2921 set_map(new_map); |
2904 new_map->clear_instance_descriptors(); | 2922 new_map->clear_instance_descriptors(); |
2905 | 2923 |
2906 set_properties(dictionary); | 2924 set_properties(dictionary); |
2907 | 2925 |
2908 current_heap->isolate()->counters()->props_to_dictionary()->Increment(); | 2926 current_heap->isolate()->counters()->props_to_dictionary()->Increment(); |
2909 | 2927 |
2910 #ifdef DEBUG | 2928 #ifdef DEBUG |
2911 if (FLAG_trace_normalization) { | 2929 if (FLAG_trace_normalization) { |
(...skipping 13 matching lines...) Expand all Loading... |
2925 } | 2943 } |
2926 | 2944 |
2927 | 2945 |
2928 MaybeObject* JSObject::NormalizeElements() { | 2946 MaybeObject* JSObject::NormalizeElements() { |
2929 ASSERT(!HasExternalArrayElements()); | 2947 ASSERT(!HasExternalArrayElements()); |
2930 | 2948 |
2931 // Find the backing store. | 2949 // Find the backing store. |
2932 FixedArrayBase* array = FixedArrayBase::cast(elements()); | 2950 FixedArrayBase* array = FixedArrayBase::cast(elements()); |
2933 Map* old_map = array->map(); | 2951 Map* old_map = array->map(); |
2934 bool is_arguments = | 2952 bool is_arguments = |
2935 (old_map == old_map->heap()->non_strict_arguments_elements_map()); | 2953 (old_map == old_map->GetHeap()->non_strict_arguments_elements_map()); |
2936 if (is_arguments) { | 2954 if (is_arguments) { |
2937 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); | 2955 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); |
2938 } | 2956 } |
2939 if (array->IsDictionary()) return array; | 2957 if (array->IsDictionary()) return array; |
2940 | 2958 |
2941 ASSERT(HasFastElements() || | 2959 ASSERT(HasFastElements() || |
2942 HasFastDoubleElements() || | 2960 HasFastDoubleElements() || |
2943 HasFastArgumentsElements()); | 2961 HasFastArgumentsElements()); |
2944 // Compute the effective length and allocate a new backing store. | 2962 // Compute the effective length and allocate a new backing store. |
2945 int length = IsJSArray() | 2963 int length = IsJSArray() |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2992 } else { | 3010 } else { |
2993 // Set the new map first to satify the elements type assert in | 3011 // Set the new map first to satify the elements type assert in |
2994 // set_elements(). | 3012 // set_elements(). |
2995 Object* new_map; | 3013 Object* new_map; |
2996 MaybeObject* maybe = GetElementsTransitionMap(DICTIONARY_ELEMENTS); | 3014 MaybeObject* maybe = GetElementsTransitionMap(DICTIONARY_ELEMENTS); |
2997 if (!maybe->ToObject(&new_map)) return maybe; | 3015 if (!maybe->ToObject(&new_map)) return maybe; |
2998 set_map(Map::cast(new_map)); | 3016 set_map(Map::cast(new_map)); |
2999 set_elements(dictionary); | 3017 set_elements(dictionary); |
3000 } | 3018 } |
3001 | 3019 |
3002 old_map->isolate()->counters()->elements_to_dictionary()->Increment(); | 3020 old_map->GetHeap()->isolate()->counters()->elements_to_dictionary()-> |
| 3021 Increment(); |
3003 | 3022 |
3004 #ifdef DEBUG | 3023 #ifdef DEBUG |
3005 if (FLAG_trace_normalization) { | 3024 if (FLAG_trace_normalization) { |
3006 PrintF("Object elements have been normalized:\n"); | 3025 PrintF("Object elements have been normalized:\n"); |
3007 Print(); | 3026 Print(); |
3008 } | 3027 } |
3009 #endif | 3028 #endif |
3010 | 3029 |
3011 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); | 3030 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); |
3012 return dictionary; | 3031 return dictionary; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 Object* key = NumberDictionary::cast(elements)->SlowReverseLookup(object); | 3312 Object* key = NumberDictionary::cast(elements)->SlowReverseLookup(object); |
3294 if (!key->IsUndefined()) return true; | 3313 if (!key->IsUndefined()) return true; |
3295 } | 3314 } |
3296 return false; | 3315 return false; |
3297 } | 3316 } |
3298 | 3317 |
3299 | 3318 |
3300 // Check whether this object references another object. | 3319 // Check whether this object references another object. |
3301 bool JSObject::ReferencesObject(Object* obj) { | 3320 bool JSObject::ReferencesObject(Object* obj) { |
3302 Map* map_of_this = map(); | 3321 Map* map_of_this = map(); |
3303 Heap* heap = map_of_this->heap(); | 3322 Heap* heap = GetHeap(); |
3304 AssertNoAllocation no_alloc; | 3323 AssertNoAllocation no_alloc; |
3305 | 3324 |
3306 // Is the object the constructor for this object? | 3325 // Is the object the constructor for this object? |
3307 if (map_of_this->constructor() == obj) { | 3326 if (map_of_this->constructor() == obj) { |
3308 return true; | 3327 return true; |
3309 } | 3328 } |
3310 | 3329 |
3311 // Is the object the prototype for this object? | 3330 // Is the object the prototype for this object? |
3312 if (map_of_this->prototype() == obj) { | 3331 if (map_of_this->prototype() == obj) { |
3313 return true; | 3332 return true; |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 } | 4110 } |
4092 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors)); | 4111 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors)); |
4093 return new_map; | 4112 return new_map; |
4094 } | 4113 } |
4095 | 4114 |
4096 | 4115 |
4097 MaybeObject* Map::UpdateCodeCache(String* name, Code* code) { | 4116 MaybeObject* Map::UpdateCodeCache(String* name, Code* code) { |
4098 // Allocate the code cache if not present. | 4117 // Allocate the code cache if not present. |
4099 if (code_cache()->IsFixedArray()) { | 4118 if (code_cache()->IsFixedArray()) { |
4100 Object* result; | 4119 Object* result; |
4101 { MaybeObject* maybe_result = code->heap()->AllocateCodeCache(); | 4120 { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache(); |
4102 if (!maybe_result->ToObject(&result)) return maybe_result; | 4121 if (!maybe_result->ToObject(&result)) return maybe_result; |
4103 } | 4122 } |
4104 set_code_cache(result); | 4123 set_code_cache(result); |
4105 } | 4124 } |
4106 | 4125 |
4107 // Update the code cache. | 4126 // Update the code cache. |
4108 return CodeCache::cast(code_cache())->Update(name, code); | 4127 return CodeCache::cast(code_cache())->Update(name, code); |
4109 } | 4128 } |
4110 | 4129 |
4111 | 4130 |
(...skipping 21 matching lines...) Expand all Loading... |
4133 // RemoveFromCodeCache so the code cache must be there. | 4152 // RemoveFromCodeCache so the code cache must be there. |
4134 ASSERT(!code_cache()->IsFixedArray()); | 4153 ASSERT(!code_cache()->IsFixedArray()); |
4135 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); | 4154 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); |
4136 } | 4155 } |
4137 | 4156 |
4138 | 4157 |
4139 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { | 4158 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { |
4140 // Traverse the transition tree without using a stack. We do this by | 4159 // Traverse the transition tree without using a stack. We do this by |
4141 // reversing the pointers in the maps and descriptor arrays. | 4160 // reversing the pointers in the maps and descriptor arrays. |
4142 Map* current = this; | 4161 Map* current = this; |
4143 Map* meta_map = heap()->meta_map(); | 4162 Map* meta_map = GetHeap()->meta_map(); |
4144 Object** map_or_index_field = NULL; | 4163 Object** map_or_index_field = NULL; |
4145 while (current != meta_map) { | 4164 while (current != meta_map) { |
4146 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( | 4165 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( |
4147 *RawField(current, Map::kInstanceDescriptorsOrBitField3Offset)); | 4166 *RawField(current, Map::kInstanceDescriptorsOrBitField3Offset)); |
4148 if (!d->IsEmpty()) { | 4167 if (!d->IsEmpty()) { |
4149 FixedArray* contents = reinterpret_cast<FixedArray*>( | 4168 FixedArray* contents = reinterpret_cast<FixedArray*>( |
4150 d->get(DescriptorArray::kContentArrayIndex)); | 4169 d->get(DescriptorArray::kContentArrayIndex)); |
4151 map_or_index_field = RawField(contents, HeapObject::kMapOffset); | 4170 map_or_index_field = RawField(contents, HeapObject::kMapOffset); |
4152 Object* map_or_index = *map_or_index_field; | 4171 Object* map_or_index = *map_or_index_field; |
4153 bool map_done = true; // Controls a nested continue statement. | 4172 bool map_done = true; // Controls a nested continue statement. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4186 Object* perhaps_map = prototype_transitions->get(i); | 4205 Object* perhaps_map = prototype_transitions->get(i); |
4187 if (perhaps_map->IsMap()) { | 4206 if (perhaps_map->IsMap()) { |
4188 Map* next = Map::cast(perhaps_map); | 4207 Map* next = Map::cast(perhaps_map); |
4189 next->set_map(current); | 4208 next->set_map(current); |
4190 *proto_map_or_index_field = | 4209 *proto_map_or_index_field = |
4191 Smi::FromInt(i + kProtoTransitionElementsPerEntry); | 4210 Smi::FromInt(i + kProtoTransitionElementsPerEntry); |
4192 current = next; | 4211 current = next; |
4193 continue; | 4212 continue; |
4194 } | 4213 } |
4195 } | 4214 } |
4196 *proto_map_or_index_field = heap()->fixed_array_map(); | 4215 *proto_map_or_index_field = GetHeap()->fixed_array_map(); |
4197 if (map_or_index_field != NULL) { | 4216 if (map_or_index_field != NULL) { |
4198 *map_or_index_field = heap()->fixed_array_map(); | 4217 *map_or_index_field = GetHeap()->fixed_array_map(); |
4199 } | 4218 } |
4200 | 4219 |
4201 // The callback expects a map to have a real map as its map, so we save | 4220 // The callback expects a map to have a real map as its map, so we save |
4202 // the map field, which is being used to track the traversal and put the | 4221 // the map field, which is being used to track the traversal and put the |
4203 // correct map (the meta_map) in place while we do the callback. | 4222 // correct map (the meta_map) in place while we do the callback. |
4204 Map* prev = current->map(); | 4223 Map* prev = current->map(); |
4205 current->set_map(meta_map); | 4224 current->set_map(meta_map); |
4206 callback(current, data); | 4225 callback(current, data); |
4207 current = prev; | 4226 current = prev; |
4208 } | 4227 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4411 uint32_t HashForObject(Object* obj) { | 4430 uint32_t HashForObject(Object* obj) { |
4412 FixedArray* pair = FixedArray::cast(obj); | 4431 FixedArray* pair = FixedArray::cast(obj); |
4413 String* name = String::cast(pair->get(0)); | 4432 String* name = String::cast(pair->get(0)); |
4414 Code* code = Code::cast(pair->get(1)); | 4433 Code* code = Code::cast(pair->get(1)); |
4415 return NameFlagsHashHelper(name, code->flags()); | 4434 return NameFlagsHashHelper(name, code->flags()); |
4416 } | 4435 } |
4417 | 4436 |
4418 MUST_USE_RESULT MaybeObject* AsObject() { | 4437 MUST_USE_RESULT MaybeObject* AsObject() { |
4419 ASSERT(code_ != NULL); | 4438 ASSERT(code_ != NULL); |
4420 Object* obj; | 4439 Object* obj; |
4421 { MaybeObject* maybe_obj = code_->heap()->AllocateFixedArray(2); | 4440 { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2); |
4422 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4441 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
4423 } | 4442 } |
4424 FixedArray* pair = FixedArray::cast(obj); | 4443 FixedArray* pair = FixedArray::cast(obj); |
4425 pair->set(0, name_); | 4444 pair->set(0, name_); |
4426 pair->set(1, code_); | 4445 pair->set(1, code_); |
4427 return pair; | 4446 return pair; |
4428 } | 4447 } |
4429 | 4448 |
4430 private: | 4449 private: |
4431 String* name_; | 4450 String* name_; |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6000 return CompareStringContentsPartial(isolate, | 6019 return CompareStringContentsPartial(isolate, |
6001 isolate->objects_string_compare_buffer_a(), rhs); | 6020 isolate->objects_string_compare_buffer_a(), rhs); |
6002 } | 6021 } |
6003 } | 6022 } |
6004 | 6023 |
6005 | 6024 |
6006 bool String::MarkAsUndetectable() { | 6025 bool String::MarkAsUndetectable() { |
6007 if (StringShape(this).IsSymbol()) return false; | 6026 if (StringShape(this).IsSymbol()) return false; |
6008 | 6027 |
6009 Map* map = this->map(); | 6028 Map* map = this->map(); |
6010 Heap* heap = map->heap(); | 6029 Heap* heap = GetHeap(); |
6011 if (map == heap->string_map()) { | 6030 if (map == heap->string_map()) { |
6012 this->set_map(heap->undetectable_string_map()); | 6031 this->set_map(heap->undetectable_string_map()); |
6013 return true; | 6032 return true; |
6014 } else if (map == heap->ascii_string_map()) { | 6033 } else if (map == heap->ascii_string_map()) { |
6015 this->set_map(heap->undetectable_ascii_string_map()); | 6034 this->set_map(heap->undetectable_ascii_string_map()); |
6016 return true; | 6035 return true; |
6017 } | 6036 } |
6018 // Rest cannot be marked as undetectable | 6037 // Rest cannot be marked as undetectable |
6019 return false; | 6038 return false; |
6020 } | 6039 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6254 // check if the target is live. If not, null the descriptor. | 6273 // check if the target is live. If not, null the descriptor. |
6255 // Also drop the back pointer for that map transition, so that this | 6274 // Also drop the back pointer for that map transition, so that this |
6256 // map is not reached again by following a back pointer from a | 6275 // map is not reached again by following a back pointer from a |
6257 // non-live object. | 6276 // non-live object. |
6258 PropertyDetails details(Smi::cast(contents->get(i + 1))); | 6277 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
6259 if (details.type() == MAP_TRANSITION || | 6278 if (details.type() == MAP_TRANSITION || |
6260 details.type() == ELEMENTS_TRANSITION || | 6279 details.type() == ELEMENTS_TRANSITION || |
6261 details.type() == CONSTANT_TRANSITION) { | 6280 details.type() == CONSTANT_TRANSITION) { |
6262 Map* target = reinterpret_cast<Map*>(contents->get(i)); | 6281 Map* target = reinterpret_cast<Map*>(contents->get(i)); |
6263 ASSERT(target->IsHeapObject()); | 6282 ASSERT(target->IsHeapObject()); |
6264 if (!target->IsMarked()) { | 6283 MarkBit map_mark = Marking::MarkBitFrom(target); |
| 6284 if (!map_mark.Get()) { |
6265 ASSERT(target->IsMap()); | 6285 ASSERT(target->IsMap()); |
6266 contents->set_unchecked(i + 1, NullDescriptorDetails); | 6286 contents->set_unchecked(i + 1, NullDescriptorDetails); |
6267 contents->set_null_unchecked(heap, i); | 6287 contents->set_null_unchecked(heap, i); |
6268 ASSERT(target->prototype() == this || | 6288 ASSERT(target->prototype() == this || |
6269 target->prototype() == real_prototype); | 6289 target->prototype() == real_prototype); |
6270 // Getter prototype() is read-only, set_prototype() has side effects. | 6290 // Getter prototype() is read-only, set_prototype() has side effects. |
6271 *RawField(target, Map::kPrototypeOffset) = real_prototype; | 6291 *RawField(target, Map::kPrototypeOffset) = real_prototype; |
6272 } | 6292 } |
6273 } | 6293 } |
6274 } | 6294 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6367 // See ECMA-262 13.2.2. | 6387 // See ECMA-262 13.2.2. |
6368 if (!value->IsJSObject()) { | 6388 if (!value->IsJSObject()) { |
6369 // Copy the map so this does not affect unrelated functions. | 6389 // Copy the map so this does not affect unrelated functions. |
6370 // Remove map transitions because they point to maps with a | 6390 // Remove map transitions because they point to maps with a |
6371 // different prototype. | 6391 // different prototype. |
6372 Object* new_object; | 6392 Object* new_object; |
6373 { MaybeObject* maybe_new_map = map()->CopyDropTransitions(); | 6393 { MaybeObject* maybe_new_map = map()->CopyDropTransitions(); |
6374 if (!maybe_new_map->ToObject(&new_object)) return maybe_new_map; | 6394 if (!maybe_new_map->ToObject(&new_object)) return maybe_new_map; |
6375 } | 6395 } |
6376 Map* new_map = Map::cast(new_object); | 6396 Map* new_map = Map::cast(new_object); |
6377 Heap* heap = new_map->heap(); | 6397 Heap* heap = new_map->GetHeap(); |
6378 set_map(new_map); | 6398 set_map(new_map); |
6379 new_map->set_constructor(value); | 6399 new_map->set_constructor(value); |
6380 new_map->set_non_instance_prototype(true); | 6400 new_map->set_non_instance_prototype(true); |
6381 construct_prototype = | 6401 construct_prototype = |
6382 heap->isolate()->context()->global_context()-> | 6402 heap->isolate()->context()->global_context()-> |
6383 initial_object_prototype(); | 6403 initial_object_prototype(); |
6384 } else { | 6404 } else { |
6385 map()->set_non_instance_prototype(false); | 6405 map()->set_non_instance_prototype(false); |
6386 } | 6406 } |
6387 | 6407 |
(...skipping 10 matching lines...) Expand all Loading... |
6398 if (map() == no_prototype_map) { | 6418 if (map() == no_prototype_map) { |
6399 // Be idempotent. | 6419 // Be idempotent. |
6400 return this; | 6420 return this; |
6401 } | 6421 } |
6402 | 6422 |
6403 ASSERT(!shared()->strict_mode() || | 6423 ASSERT(!shared()->strict_mode() || |
6404 map() == global_context->strict_mode_function_map()); | 6424 map() == global_context->strict_mode_function_map()); |
6405 ASSERT(shared()->strict_mode() || map() == global_context->function_map()); | 6425 ASSERT(shared()->strict_mode() || map() == global_context->function_map()); |
6406 | 6426 |
6407 set_map(no_prototype_map); | 6427 set_map(no_prototype_map); |
6408 set_prototype_or_initial_map(no_prototype_map->heap()->the_hole_value()); | 6428 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value()); |
6409 return this; | 6429 return this; |
6410 } | 6430 } |
6411 | 6431 |
6412 | 6432 |
6413 Object* JSFunction::SetInstanceClassName(String* name) { | 6433 Object* JSFunction::SetInstanceClassName(String* name) { |
6414 shared()->set_instance_class_name(name); | 6434 shared()->set_instance_class_name(name); |
6415 return this; | 6435 return this; |
6416 } | 6436 } |
6417 | 6437 |
6418 | 6438 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6706 if (Serializer::enabled()) return; | 6726 if (Serializer::enabled()) return; |
6707 | 6727 |
6708 if (map->unused_property_fields() == 0) return; | 6728 if (map->unused_property_fields() == 0) return; |
6709 | 6729 |
6710 // Nonzero counter is a leftover from the previous attempt interrupted | 6730 // Nonzero counter is a leftover from the previous attempt interrupted |
6711 // by GC, keep it. | 6731 // by GC, keep it. |
6712 if (construction_count() == 0) { | 6732 if (construction_count() == 0) { |
6713 set_construction_count(kGenerousAllocationCount); | 6733 set_construction_count(kGenerousAllocationCount); |
6714 } | 6734 } |
6715 set_initial_map(map); | 6735 set_initial_map(map); |
6716 Builtins* builtins = map->heap()->isolate()->builtins(); | 6736 Builtins* builtins = map->GetHeap()->isolate()->builtins(); |
6717 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), | 6737 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
6718 construct_stub()); | 6738 construct_stub()); |
6719 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); | 6739 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
6720 } | 6740 } |
6721 | 6741 |
6722 | 6742 |
6723 // Called from GC, hence reinterpret_cast and unchecked accessors. | 6743 // Called from GC, hence reinterpret_cast and unchecked accessors. |
6724 void SharedFunctionInfo::DetachInitialMap() { | 6744 void SharedFunctionInfo::DetachInitialMap() { |
6725 Map* map = reinterpret_cast<Map*>(initial_map()); | 6745 Map* map = reinterpret_cast<Map*>(initial_map()); |
6726 | 6746 |
6727 // Make the map remember to restore the link if it survives the GC. | 6747 // Make the map remember to restore the link if it survives the GC. |
6728 map->set_bit_field2( | 6748 map->set_bit_field2( |
6729 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); | 6749 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); |
6730 | 6750 |
6731 // Undo state changes made by StartInobjectTracking (except the | 6751 // Undo state changes made by StartInobjectTracking (except the |
6732 // construction_count). This way if the initial map does not survive the GC | 6752 // construction_count). This way if the initial map does not survive the GC |
6733 // then StartInobjectTracking will be called again the next time the | 6753 // then StartInobjectTracking will be called again the next time the |
6734 // constructor is called. The countdown will continue and (possibly after | 6754 // constructor is called. The countdown will continue and (possibly after |
6735 // several more GCs) CompleteInobjectSlackTracking will eventually be called. | 6755 // several more GCs) CompleteInobjectSlackTracking will eventually be called. |
6736 set_initial_map(map->heap()->raw_unchecked_undefined_value()); | 6756 Heap* heap = map->GetHeap(); |
6737 Builtins* builtins = map->heap()->isolate()->builtins(); | 6757 set_initial_map(heap->raw_unchecked_undefined_value()); |
| 6758 Builtins* builtins = heap->isolate()->builtins(); |
6738 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), | 6759 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
6739 *RawField(this, kConstructStubOffset)); | 6760 *RawField(this, kConstructStubOffset)); |
6740 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); | 6761 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
6741 // It is safe to clear the flag: it will be set again if the map is live. | 6762 // It is safe to clear the flag: it will be set again if the map is live. |
6742 set_live_objects_may_exist(false); | 6763 set_live_objects_may_exist(false); |
6743 } | 6764 } |
6744 | 6765 |
6745 | 6766 |
6746 // Called from GC, hence reinterpret_cast and unchecked accessors. | 6767 // Called from GC, hence reinterpret_cast and unchecked accessors. |
6747 void SharedFunctionInfo::AttachInitialMap(Map* map) { | 6768 void SharedFunctionInfo::AttachInitialMap(Map* map) { |
6748 map->set_bit_field2( | 6769 map->set_bit_field2( |
6749 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); | 6770 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); |
6750 | 6771 |
6751 // Resume inobject slack tracking. | 6772 // Resume inobject slack tracking. |
6752 set_initial_map(map); | 6773 set_initial_map(map); |
6753 Builtins* builtins = map->heap()->isolate()->builtins(); | 6774 Builtins* builtins = map->GetHeap()->isolate()->builtins(); |
6754 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), | 6775 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
6755 *RawField(this, kConstructStubOffset)); | 6776 *RawField(this, kConstructStubOffset)); |
6756 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); | 6777 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
6757 // The map survived the gc, so there may be objects referencing it. | 6778 // The map survived the gc, so there may be objects referencing it. |
6758 set_live_objects_may_exist(true); | 6779 set_live_objects_may_exist(true); |
6759 } | 6780 } |
6760 | 6781 |
6761 | 6782 |
6762 static void GetMinInobjectSlack(Map* map, void* data) { | 6783 static void GetMinInobjectSlack(Map* map, void* data) { |
6763 int slack = map->unused_property_fields(); | 6784 int slack = map->unused_property_fields(); |
(...skipping 11 matching lines...) Expand all Loading... |
6775 | 6796 |
6776 // Visitor id might depend on the instance size, recalculate it. | 6797 // Visitor id might depend on the instance size, recalculate it. |
6777 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); | 6798 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); |
6778 } | 6799 } |
6779 | 6800 |
6780 | 6801 |
6781 void SharedFunctionInfo::CompleteInobjectSlackTracking() { | 6802 void SharedFunctionInfo::CompleteInobjectSlackTracking() { |
6782 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); | 6803 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); |
6783 Map* map = Map::cast(initial_map()); | 6804 Map* map = Map::cast(initial_map()); |
6784 | 6805 |
6785 Heap* heap = map->heap(); | 6806 Heap* heap = map->GetHeap(); |
6786 set_initial_map(heap->undefined_value()); | 6807 set_initial_map(heap->undefined_value()); |
6787 Builtins* builtins = heap->isolate()->builtins(); | 6808 Builtins* builtins = heap->isolate()->builtins(); |
6788 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), | 6809 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
6789 construct_stub()); | 6810 construct_stub()); |
6790 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); | 6811 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
6791 | 6812 |
6792 int slack = map->unused_property_fields(); | 6813 int slack = map->unused_property_fields(); |
6793 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); | 6814 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); |
6794 if (slack != 0) { | 6815 if (slack != 0) { |
6795 // Resize the initial map and all maps in its transition tree. | 6816 // Resize the initial map and all maps in its transition tree. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6838 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 6859 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
6839 rinfo->IsPatchedDebugBreakSlotSequence())); | 6860 rinfo->IsPatchedDebugBreakSlotSequence())); |
6840 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); | 6861 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); |
6841 Object* old_target = target; | 6862 Object* old_target = target; |
6842 VisitPointer(&target); | 6863 VisitPointer(&target); |
6843 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. | 6864 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. |
6844 } | 6865 } |
6845 | 6866 |
6846 | 6867 |
6847 void Code::InvalidateRelocation() { | 6868 void Code::InvalidateRelocation() { |
6848 set_relocation_info(heap()->empty_byte_array()); | 6869 set_relocation_info(GetHeap()->empty_byte_array()); |
6849 } | 6870 } |
6850 | 6871 |
6851 | 6872 |
6852 void Code::Relocate(intptr_t delta) { | 6873 void Code::Relocate(intptr_t delta) { |
6853 for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { | 6874 for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { |
6854 it.rinfo()->apply(delta); | 6875 it.rinfo()->apply(delta); |
6855 } | 6876 } |
6856 CPU::FlushICache(instruction_start(), instruction_size()); | 6877 CPU::FlushICache(instruction_start(), instruction_size()); |
6857 } | 6878 } |
6858 | 6879 |
(...skipping 13 matching lines...) Expand all Loading... |
6872 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 6893 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
6873 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 6894 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
6874 RelocInfo::kApplyMask; | 6895 RelocInfo::kApplyMask; |
6875 Assembler* origin = desc.origin; // Needed to find target_object on X64. | 6896 Assembler* origin = desc.origin; // Needed to find target_object on X64. |
6876 for (RelocIterator it(this, mode_mask); !it.done(); it.next()) { | 6897 for (RelocIterator it(this, mode_mask); !it.done(); it.next()) { |
6877 RelocInfo::Mode mode = it.rinfo()->rmode(); | 6898 RelocInfo::Mode mode = it.rinfo()->rmode(); |
6878 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 6899 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
6879 Handle<Object> p = it.rinfo()->target_object_handle(origin); | 6900 Handle<Object> p = it.rinfo()->target_object_handle(origin); |
6880 it.rinfo()->set_target_object(*p); | 6901 it.rinfo()->set_target_object(*p); |
6881 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 6902 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
6882 Handle<JSGlobalPropertyCell> cell = it.rinfo()->target_cell_handle(); | 6903 Handle<JSGlobalPropertyCell> cell = it.rinfo()->target_cell_handle(); |
6883 it.rinfo()->set_target_cell(*cell); | 6904 it.rinfo()->set_target_cell(*cell); |
6884 } else if (RelocInfo::IsCodeTarget(mode)) { | 6905 } else if (RelocInfo::IsCodeTarget(mode)) { |
6885 // rewrite code handles in inline cache targets to direct | 6906 // rewrite code handles in inline cache targets to direct |
6886 // pointers to the first instruction in the code object | 6907 // pointers to the first instruction in the code object |
6887 Handle<Object> p = it.rinfo()->target_object_handle(origin); | 6908 Handle<Object> p = it.rinfo()->target_object_handle(origin); |
6888 Code* code = Code::cast(*p); | 6909 Code* code = Code::cast(*p); |
6889 it.rinfo()->set_target_address(code->instruction_start()); | 6910 it.rinfo()->set_target_address(code->instruction_start()); |
6890 } else { | 6911 } else { |
6891 it.rinfo()->apply(delta); | 6912 it.rinfo()->apply(delta); |
6892 } | 6913 } |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7699 int capacity = (cache->length() - header) / step; | 7720 int capacity = (cache->length() - header) / step; |
7700 | 7721 |
7701 int transitions = NumberOfProtoTransitions() + 1; | 7722 int transitions = NumberOfProtoTransitions() + 1; |
7702 | 7723 |
7703 if (transitions > capacity) { | 7724 if (transitions > capacity) { |
7704 if (capacity > kMaxCachedPrototypeTransitions) return this; | 7725 if (capacity > kMaxCachedPrototypeTransitions) return this; |
7705 | 7726 |
7706 FixedArray* new_cache; | 7727 FixedArray* new_cache; |
7707 // Grow array by factor 2 over and above what we need. | 7728 // Grow array by factor 2 over and above what we need. |
7708 { MaybeObject* maybe_cache = | 7729 { MaybeObject* maybe_cache = |
7709 heap()->AllocateFixedArray(transitions * 2 * step + header); | 7730 GetHeap()->AllocateFixedArray(transitions * 2 * step + header); |
7710 if (!maybe_cache->To<FixedArray>(&new_cache)) return maybe_cache; | 7731 if (!maybe_cache->To<FixedArray>(&new_cache)) return maybe_cache; |
7711 } | 7732 } |
7712 | 7733 |
7713 for (int i = 0; i < capacity * step; i++) { | 7734 for (int i = 0; i < capacity * step; i++) { |
7714 new_cache->set(i + header, cache->get(i + header)); | 7735 new_cache->set(i + header, cache->get(i + header)); |
7715 } | 7736 } |
7716 cache = new_cache; | 7737 cache = new_cache; |
7717 set_prototype_transitions(cache); | 7738 set_prototype_transitions(cache); |
7718 } | 7739 } |
7719 | 7740 |
(...skipping 3891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11611 if (break_point_objects()->IsUndefined()) return 0; | 11632 if (break_point_objects()->IsUndefined()) return 0; |
11612 // Single break point. | 11633 // Single break point. |
11613 if (!break_point_objects()->IsFixedArray()) return 1; | 11634 if (!break_point_objects()->IsFixedArray()) return 1; |
11614 // Multiple break points. | 11635 // Multiple break points. |
11615 return FixedArray::cast(break_point_objects())->length(); | 11636 return FixedArray::cast(break_point_objects())->length(); |
11616 } | 11637 } |
11617 #endif | 11638 #endif |
11618 | 11639 |
11619 | 11640 |
11620 } } // namespace v8::internal | 11641 } } // namespace v8::internal |
OLD | NEW |