| 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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 int size = this->Size(); // Byte size of the original string. | 954 int size = this->Size(); // Byte size of the original string. |
| 955 if (size < ExternalString::kShortSize) { | 955 if (size < ExternalString::kShortSize) { |
| 956 return false; | 956 return false; |
| 957 } | 957 } |
| 958 bool is_ascii = this->IsAsciiRepresentation(); | 958 bool is_ascii = this->IsAsciiRepresentation(); |
| 959 bool is_symbol = this->IsSymbol(); | 959 bool is_symbol = this->IsSymbol(); |
| 960 | 960 |
| 961 // Morph the object to an external string by adjusting the map and | 961 // Morph the object to an external string by adjusting the map and |
| 962 // reinitializing the fields. | 962 // reinitializing the fields. |
| 963 if (size >= ExternalString::kSize) { | 963 if (size >= ExternalString::kSize) { |
| 964 this->set_map( | 964 this->set_map_no_wb( |
| 965 is_symbol | 965 is_symbol |
| 966 ? (is_ascii ? heap->external_symbol_with_ascii_data_map() | 966 ? (is_ascii ? heap->external_symbol_with_ascii_data_map() |
| 967 : heap->external_symbol_map()) | 967 : heap->external_symbol_map()) |
| 968 : (is_ascii ? heap->external_string_with_ascii_data_map() | 968 : (is_ascii ? heap->external_string_with_ascii_data_map() |
| 969 : heap->external_string_map())); | 969 : heap->external_string_map())); |
| 970 } else { | 970 } else { |
| 971 this->set_map( | 971 this->set_map_no_wb( |
| 972 is_symbol | 972 is_symbol |
| 973 ? (is_ascii ? heap->short_external_symbol_with_ascii_data_map() | 973 ? (is_ascii ? heap->short_external_symbol_with_ascii_data_map() |
| 974 : heap->short_external_symbol_map()) | 974 : heap->short_external_symbol_map()) |
| 975 : (is_ascii ? heap->short_external_string_with_ascii_data_map() | 975 : (is_ascii ? heap->short_external_string_with_ascii_data_map() |
| 976 : heap->short_external_string_map())); | 976 : heap->short_external_string_map())); |
| 977 } | 977 } |
| 978 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); | 978 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); |
| 979 self->set_resource(resource); | 979 self->set_resource(resource); |
| 980 if (is_symbol) self->Hash(); // Force regeneration of the hash value. | 980 if (is_symbol) self->Hash(); // Force regeneration of the hash value. |
| 981 | 981 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1004 Heap* heap = GetHeap(); | 1004 Heap* heap = GetHeap(); |
| 1005 int size = this->Size(); // Byte size of the original string. | 1005 int size = this->Size(); // Byte size of the original string. |
| 1006 if (size < ExternalString::kShortSize) { | 1006 if (size < ExternalString::kShortSize) { |
| 1007 return false; | 1007 return false; |
| 1008 } | 1008 } |
| 1009 bool is_symbol = this->IsSymbol(); | 1009 bool is_symbol = this->IsSymbol(); |
| 1010 | 1010 |
| 1011 // Morph the object to an external string by adjusting the map and | 1011 // Morph the object to an external string by adjusting the map and |
| 1012 // reinitializing the fields. Use short version if space is limited. | 1012 // reinitializing the fields. Use short version if space is limited. |
| 1013 if (size >= ExternalString::kSize) { | 1013 if (size >= ExternalString::kSize) { |
| 1014 this->set_map(is_symbol ? heap->external_ascii_symbol_map() | 1014 this->set_map_no_wb(is_symbol ? heap->external_ascii_symbol_map() |
| 1015 : heap->external_ascii_string_map()); | 1015 : heap->external_ascii_string_map()); |
| 1016 } else { | 1016 } else { |
| 1017 this->set_map(is_symbol ? heap->short_external_ascii_symbol_map() | 1017 this->set_map_no_wb(is_symbol ? heap->short_external_ascii_symbol_map() |
| 1018 : heap->short_external_ascii_string_map()); | 1018 : heap->short_external_ascii_string_map()); |
| 1019 } | 1019 } |
| 1020 ExternalAsciiString* self = ExternalAsciiString::cast(this); | 1020 ExternalAsciiString* self = ExternalAsciiString::cast(this); |
| 1021 self->set_resource(resource); | 1021 self->set_resource(resource); |
| 1022 if (is_symbol) self->Hash(); // Force regeneration of the hash value. | 1022 if (is_symbol) self->Hash(); // Force regeneration of the hash value. |
| 1023 | 1023 |
| 1024 // Fill the remainder of the string with dead wood. | 1024 // Fill the remainder of the string with dead wood. |
| 1025 int new_size = this->Size(); // Byte size of the external String object. | 1025 int new_size = this->Size(); // Byte size of the external String object. |
| 1026 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1026 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
| 1027 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { | 1027 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { |
| 1028 MemoryChunk::IncrementLiveBytes(this->address(), new_size - size); | 1028 MemoryChunk::IncrementLiveBytes(this->address(), new_size - size); |
| (...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4845 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; | 4845 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; |
| 4846 i < contents->length(); | 4846 i < contents->length(); |
| 4847 i += 2) { | 4847 i += 2) { |
| 4848 PropertyDetails details(Smi::cast(contents->get(i + 1))); | 4848 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
| 4849 if (details.IsTransition()) { | 4849 if (details.IsTransition()) { |
| 4850 // Found a map in the transition array. We record our progress in | 4850 // Found a map in the transition array. We record our progress in |
| 4851 // the transition array by recording the current map in the map field | 4851 // the transition array by recording the current map in the map field |
| 4852 // of the next map and recording the index in the transition array in | 4852 // of the next map and recording the index in the transition array in |
| 4853 // the map field of the array. | 4853 // the map field of the array. |
| 4854 Map* next = Map::cast(contents->get(i)); | 4854 Map* next = Map::cast(contents->get(i)); |
| 4855 next->set_map_unsafe(current); | 4855 next->set_map_no_wb(current); |
| 4856 *map_or_index_field = Smi::FromInt(i + 2); | 4856 *map_or_index_field = Smi::FromInt(i + 2); |
| 4857 current = next; | 4857 current = next; |
| 4858 map_done = false; | 4858 map_done = false; |
| 4859 break; | 4859 break; |
| 4860 } | 4860 } |
| 4861 } | 4861 } |
| 4862 if (!map_done) continue; | 4862 if (!map_done) continue; |
| 4863 } else { | 4863 } else { |
| 4864 map_or_index_field = NULL; | 4864 map_or_index_field = NULL; |
| 4865 } | 4865 } |
| 4866 // That was the regular transitions, now for the prototype transitions. | 4866 // That was the regular transitions, now for the prototype transitions. |
| 4867 FixedArray* prototype_transitions = | 4867 FixedArray* prototype_transitions = |
| 4868 current->unchecked_prototype_transitions(); | 4868 current->unchecked_prototype_transitions(); |
| 4869 Object** proto_map_or_index_field = | 4869 Object** proto_map_or_index_field = |
| 4870 RawField(prototype_transitions, HeapObject::kMapOffset); | 4870 RawField(prototype_transitions, HeapObject::kMapOffset); |
| 4871 Object* map_or_index = *proto_map_or_index_field; | 4871 Object* map_or_index = *proto_map_or_index_field; |
| 4872 const int start = kProtoTransitionHeaderSize + kProtoTransitionMapOffset; | 4872 const int start = kProtoTransitionHeaderSize + kProtoTransitionMapOffset; |
| 4873 int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : start; | 4873 int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : start; |
| 4874 if (i < prototype_transitions->length()) { | 4874 if (i < prototype_transitions->length()) { |
| 4875 // Found a map in the prototype transition array. Record progress in | 4875 // Found a map in the prototype transition array. Record progress in |
| 4876 // an analogous way to the regular transitions array above. | 4876 // an analogous way to the regular transitions array above. |
| 4877 Object* perhaps_map = prototype_transitions->get(i); | 4877 Object* perhaps_map = prototype_transitions->get(i); |
| 4878 if (perhaps_map->IsMap()) { | 4878 if (perhaps_map->IsMap()) { |
| 4879 Map* next = Map::cast(perhaps_map); | 4879 Map* next = Map::cast(perhaps_map); |
| 4880 next->set_map_unsafe(current); | 4880 next->set_map_no_wb(current); |
| 4881 *proto_map_or_index_field = | 4881 *proto_map_or_index_field = |
| 4882 Smi::FromInt(i + kProtoTransitionElementsPerEntry); | 4882 Smi::FromInt(i + kProtoTransitionElementsPerEntry); |
| 4883 current = next; | 4883 current = next; |
| 4884 continue; | 4884 continue; |
| 4885 } | 4885 } |
| 4886 } | 4886 } |
| 4887 *proto_map_or_index_field = GetHeap()->fixed_array_map(); | 4887 *proto_map_or_index_field = GetHeap()->fixed_array_map(); |
| 4888 if (map_or_index_field != NULL) { | 4888 if (map_or_index_field != NULL) { |
| 4889 *map_or_index_field = GetHeap()->fixed_array_map(); | 4889 *map_or_index_field = GetHeap()->fixed_array_map(); |
| 4890 } | 4890 } |
| 4891 | 4891 |
| 4892 // The callback expects a map to have a real map as its map, so we save | 4892 // The callback expects a map to have a real map as its map, so we save |
| 4893 // the map field, which is being used to track the traversal and put the | 4893 // the map field, which is being used to track the traversal and put the |
| 4894 // correct map (the meta_map) in place while we do the callback. | 4894 // correct map (the meta_map) in place while we do the callback. |
| 4895 Map* prev = current->map(); | 4895 Map* prev = current->map(); |
| 4896 current->set_map_unsafe(meta_map); | 4896 current->set_map_no_wb(meta_map); |
| 4897 callback(current, data); | 4897 callback(current, data); |
| 4898 current = prev; | 4898 current = prev; |
| 4899 } | 4899 } |
| 4900 } | 4900 } |
| 4901 | 4901 |
| 4902 | 4902 |
| 4903 MaybeObject* CodeCache::Update(String* name, Code* code) { | 4903 MaybeObject* CodeCache::Update(String* name, Code* code) { |
| 4904 // The number of monomorphic stubs for normal load/store/call IC's can grow to | 4904 // The number of monomorphic stubs for normal load/store/call IC's can grow to |
| 4905 // a large number and therefore they need to go into a hash table. They are | 4905 // a large number and therefore they need to go into a hash table. They are |
| 4906 // used to load global properties from cells. | 4906 // used to load global properties from cells. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5387 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length); | 5387 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length); |
| 5388 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 5388 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 5389 } | 5389 } |
| 5390 FixedArray* result = FixedArray::cast(obj); | 5390 FixedArray* result = FixedArray::cast(obj); |
| 5391 // Copy the content | 5391 // Copy the content |
| 5392 AssertNoAllocation no_gc; | 5392 AssertNoAllocation no_gc; |
| 5393 int len = length(); | 5393 int len = length(); |
| 5394 if (new_length < len) len = new_length; | 5394 if (new_length < len) len = new_length; |
| 5395 // We are taking the map from the old fixed array so the map is sure to | 5395 // We are taking the map from the old fixed array so the map is sure to |
| 5396 // be an immortal immutable object. | 5396 // be an immortal immutable object. |
| 5397 result->set_map_unsafe(map()); | 5397 result->set_map_no_wb(map()); |
| 5398 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 5398 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| 5399 for (int i = 0; i < len; i++) { | 5399 for (int i = 0; i < len; i++) { |
| 5400 result->set(i, get(i), mode); | 5400 result->set(i, get(i), mode); |
| 5401 } | 5401 } |
| 5402 return result; | 5402 return result; |
| 5403 } | 5403 } |
| 5404 | 5404 |
| 5405 | 5405 |
| 5406 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { | 5406 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { |
| 5407 AssertNoAllocation no_gc; | 5407 AssertNoAllocation no_gc; |
| (...skipping 5193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10601 } | 10601 } |
| 10602 | 10602 |
| 10603 MaybeObject* AsObject() { | 10603 MaybeObject* AsObject() { |
| 10604 // Attempt to flatten the string, so that symbols will most often | 10604 // Attempt to flatten the string, so that symbols will most often |
| 10605 // be flat strings. | 10605 // be flat strings. |
| 10606 string_ = string_->TryFlattenGetString(); | 10606 string_ = string_->TryFlattenGetString(); |
| 10607 Heap* heap = string_->GetHeap(); | 10607 Heap* heap = string_->GetHeap(); |
| 10608 // Transform string to symbol if possible. | 10608 // Transform string to symbol if possible. |
| 10609 Map* map = heap->SymbolMapForString(string_); | 10609 Map* map = heap->SymbolMapForString(string_); |
| 10610 if (map != NULL) { | 10610 if (map != NULL) { |
| 10611 string_->set_map(map); | 10611 string_->set_map_no_wb(map); |
| 10612 ASSERT(string_->IsSymbol()); | 10612 ASSERT(string_->IsSymbol()); |
| 10613 return string_; | 10613 return string_; |
| 10614 } | 10614 } |
| 10615 // Otherwise allocate a new symbol. | 10615 // Otherwise allocate a new symbol. |
| 10616 StringInputBuffer buffer(string_); | 10616 StringInputBuffer buffer(string_); |
| 10617 return heap->AllocateInternalSymbol(&buffer, | 10617 return heap->AllocateInternalSymbol(&buffer, |
| 10618 string_->length(), | 10618 string_->length(), |
| 10619 string_->hash_field()); | 10619 string_->hash_field()); |
| 10620 } | 10620 } |
| 10621 | 10621 |
| (...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12522 if (break_point_objects()->IsUndefined()) return 0; | 12522 if (break_point_objects()->IsUndefined()) return 0; |
| 12523 // Single break point. | 12523 // Single break point. |
| 12524 if (!break_point_objects()->IsFixedArray()) return 1; | 12524 if (!break_point_objects()->IsFixedArray()) return 1; |
| 12525 // Multiple break points. | 12525 // Multiple break points. |
| 12526 return FixedArray::cast(break_point_objects())->length(); | 12526 return FixedArray::cast(break_point_objects())->length(); |
| 12527 } | 12527 } |
| 12528 #endif // ENABLE_DEBUGGER_SUPPORT | 12528 #endif // ENABLE_DEBUGGER_SUPPORT |
| 12529 | 12529 |
| 12530 | 12530 |
| 12531 } } // namespace v8::internal | 12531 } } // namespace v8::internal |
| OLD | NEW |