| OLD | NEW |
| 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 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3051 for (int i = 0; i < number_of_descriptors; ++i) { | 3051 for (int i = 0; i < number_of_descriptors; ++i) { |
| 3052 new_descriptors->CopyFrom(i, *descriptors, i, witness); | 3052 new_descriptors->CopyFrom(i, *descriptors, i, witness); |
| 3053 } | 3053 } |
| 3054 | 3054 |
| 3055 map->set_instance_descriptors(*new_descriptors); | 3055 map->set_instance_descriptors(*new_descriptors); |
| 3056 } | 3056 } |
| 3057 | 3057 |
| 3058 | 3058 |
| 3059 void Map::AppendCallbackDescriptors(Handle<Map> map, | 3059 void Map::AppendCallbackDescriptors(Handle<Map> map, |
| 3060 Handle<Object> descriptors) { | 3060 Handle<Object> descriptors) { |
| 3061 Isolate* isolate = map->GetIsolate(); | 3061 int nof = map->NumberOfOwnDescriptors(); |
| 3062 Handle<DescriptorArray> array(map->instance_descriptors()); | 3062 Handle<DescriptorArray> array(map->instance_descriptors()); |
| 3063 NeanderArray callbacks(descriptors); | 3063 nof = DescriptorArray::AppendDescriptors(array, nof, descriptors); |
| 3064 int nof_callbacks = callbacks.length(); | |
| 3065 | |
| 3066 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks); | |
| 3067 | |
| 3068 // Ensure the keys are unique names before writing them into the | |
| 3069 // instance descriptor. Since it may cause a GC, it has to be done before we | |
| 3070 // temporarily put the heap in an invalid state while appending descriptors. | |
| 3071 for (int i = 0; i < nof_callbacks; ++i) { | |
| 3072 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks.get(i))); | |
| 3073 if (!entry->name()->IsUniqueName()) { | |
| 3074 Handle<String> key = | |
| 3075 isolate->factory()->InternalizedStringFromString( | |
| 3076 Handle<String>(String::cast(entry->name()))); | |
| 3077 entry->set_name(*key); | |
| 3078 } | |
| 3079 } | |
| 3080 | |
| 3081 int nof = map->NumberOfOwnDescriptors(); | |
| 3082 | |
| 3083 // Fill in new callback descriptors. Process the callbacks from | |
| 3084 // back to front so that the last callback with a given name takes | |
| 3085 // precedence over previously added callbacks with that name. | |
| 3086 for (int i = nof_callbacks - 1; i >= 0; i--) { | |
| 3087 AccessorInfo* entry = AccessorInfo::cast(callbacks.get(i)); | |
| 3088 Name* key = Name::cast(entry->name()); | |
| 3089 // Check if a descriptor with this name already exists before writing. | |
| 3090 if (array->Search(key, nof) == DescriptorArray::kNotFound) { | |
| 3091 CallbacksDescriptor desc(key, entry, entry->property_attributes()); | |
| 3092 array->Append(&desc); | |
| 3093 nof += 1; | |
| 3094 } | |
| 3095 } | |
| 3096 | |
| 3097 map->SetNumberOfOwnDescriptors(nof); | 3064 map->SetNumberOfOwnDescriptors(nof); |
| 3098 } | 3065 } |
| 3099 | 3066 |
| 3100 | 3067 |
| 3101 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { | 3068 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { |
| 3102 ASSERT(!map.is_null()); | 3069 ASSERT(!map.is_null()); |
| 3103 for (int i = 0; i < maps->length(); ++i) { | 3070 for (int i = 0; i < maps->length(); ++i) { |
| 3104 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true; | 3071 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true; |
| 3105 } | 3072 } |
| 3106 return false; | 3073 return false; |
| (...skipping 4636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7743 ASSERT(!IsEmpty()); | 7710 ASSERT(!IsEmpty()); |
| 7744 ASSERT(!HasEnumCache() || new_cache->length() > GetEnumCache()->length()); | 7711 ASSERT(!HasEnumCache() || new_cache->length() > GetEnumCache()->length()); |
| 7745 FixedArray::cast(bridge_storage)-> | 7712 FixedArray::cast(bridge_storage)-> |
| 7746 set(kEnumCacheBridgeCacheIndex, new_cache); | 7713 set(kEnumCacheBridgeCacheIndex, new_cache); |
| 7747 FixedArray::cast(bridge_storage)-> | 7714 FixedArray::cast(bridge_storage)-> |
| 7748 set(kEnumCacheBridgeIndicesCacheIndex, new_index_cache); | 7715 set(kEnumCacheBridgeIndicesCacheIndex, new_index_cache); |
| 7749 set(kEnumCacheIndex, bridge_storage); | 7716 set(kEnumCacheIndex, bridge_storage); |
| 7750 } | 7717 } |
| 7751 | 7718 |
| 7752 | 7719 |
| 7720 int DescriptorArray::AppendDescriptors(Handle<DescriptorArray> array, |
| 7721 int valid_descriptors, |
| 7722 Handle<Object> descriptors) { |
| 7723 NeanderArray callbacks(descriptors); |
| 7724 int nof_callbacks = callbacks.length(); |
| 7725 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks); |
| 7726 |
| 7727 Isolate* isolate = array->GetIsolate(); |
| 7728 // Ensure the keys are unique names before writing them into the |
| 7729 // instance descriptor. Since it may cause a GC, it has to be done before we |
| 7730 // temporarily put the heap in an invalid state while appending descriptors. |
| 7731 for (int i = 0; i < nof_callbacks; ++i) { |
| 7732 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks.get(i))); |
| 7733 if (entry->name()->IsUniqueName()) continue; |
| 7734 Handle<String> key = |
| 7735 isolate->factory()->InternalizedStringFromString( |
| 7736 Handle<String>(String::cast(entry->name()))); |
| 7737 entry->set_name(*key); |
| 7738 } |
| 7739 |
| 7740 // Fill in new callback descriptors. Process the callbacks from |
| 7741 // back to front so that the last callback with a given name takes |
| 7742 // precedence over previously added callbacks with that name. |
| 7743 for (int i = nof_callbacks - 1; i >= 0; i--) { |
| 7744 AccessorInfo* entry = AccessorInfo::cast(callbacks.get(i)); |
| 7745 Name* key = Name::cast(entry->name()); |
| 7746 // Check if a descriptor with this name already exists before writing. |
| 7747 if (array->Search(key, valid_descriptors) != DescriptorArray::kNotFound) { |
| 7748 continue; |
| 7749 } |
| 7750 CallbacksDescriptor desc(key, entry, entry->property_attributes()); |
| 7751 array->Append(&desc); |
| 7752 valid_descriptors += 1; |
| 7753 } |
| 7754 |
| 7755 return valid_descriptors; |
| 7756 } |
| 7757 |
| 7758 |
| 7753 void DescriptorArray::CopyFrom(int dst_index, | 7759 void DescriptorArray::CopyFrom(int dst_index, |
| 7754 DescriptorArray* src, | 7760 DescriptorArray* src, |
| 7755 int src_index, | 7761 int src_index, |
| 7756 const WhitenessWitness& witness) { | 7762 const WhitenessWitness& witness) { |
| 7757 Object* value = src->GetValue(src_index); | 7763 Object* value = src->GetValue(src_index); |
| 7758 PropertyDetails details = src->GetDetails(src_index); | 7764 PropertyDetails details = src->GetDetails(src_index); |
| 7759 Descriptor desc(src->GetKey(src_index), value, details); | 7765 Descriptor desc(src->GetKey(src_index), value, details); |
| 7760 Set(dst_index, &desc, witness); | 7766 Set(dst_index, &desc, witness); |
| 7761 } | 7767 } |
| 7762 | 7768 |
| (...skipping 8214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15977 #define ERROR_MESSAGES_TEXTS(C, T) T, | 15983 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 15978 static const char* error_messages_[] = { | 15984 static const char* error_messages_[] = { |
| 15979 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 15985 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 15980 }; | 15986 }; |
| 15981 #undef ERROR_MESSAGES_TEXTS | 15987 #undef ERROR_MESSAGES_TEXTS |
| 15982 return error_messages_[reason]; | 15988 return error_messages_[reason]; |
| 15983 } | 15989 } |
| 15984 | 15990 |
| 15985 | 15991 |
| 15986 } } // namespace v8::internal | 15992 } } // namespace v8::internal |
| OLD | NEW |