OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5044 | 5044 |
5045 result->SetNumberOfOwnDescriptors(new_descriptors->number_of_descriptors()); | 5045 result->SetNumberOfOwnDescriptors(new_descriptors->number_of_descriptors()); |
5046 ASSERT(result->NumberOfOwnDescriptors() == NumberOfOwnDescriptors() + 1); | 5046 ASSERT(result->NumberOfOwnDescriptors() == NumberOfOwnDescriptors() + 1); |
5047 | 5047 |
5048 return result; | 5048 return result; |
5049 } | 5049 } |
5050 | 5050 |
5051 | 5051 |
5052 MaybeObject* Map::CopyReplaceDescriptors(DescriptorArray* descriptors, | 5052 MaybeObject* Map::CopyReplaceDescriptors(DescriptorArray* descriptors, |
5053 String* name, | 5053 String* name, |
5054 TransitionFlag flag) { | 5054 TransitionFlag flag, |
5055 int descriptor_index) { | |
5055 ASSERT(descriptors->IsSortedNoDuplicates()); | 5056 ASSERT(descriptors->IsSortedNoDuplicates()); |
5056 | 5057 |
5057 Map* result; | 5058 Map* result; |
5058 MaybeObject* maybe_result = CopyDropDescriptors(); | 5059 MaybeObject* maybe_result = CopyDropDescriptors(); |
5059 if (!maybe_result->To(&result)) return maybe_result; | 5060 if (!maybe_result->To(&result)) return maybe_result; |
5060 | 5061 |
5061 // Unless we are creating a map with no descriptors and no back pointer, we | 5062 // Unless we are creating a map with no descriptors and no back pointer, we |
5062 // insert the descriptor array locally. | 5063 // insert the descriptor array locally. |
5063 if (!descriptors->IsEmpty()) { | 5064 if (!descriptors->IsEmpty()) { |
5064 MaybeObject* maybe_failure = result->SetDescriptors(descriptors); | 5065 MaybeObject* maybe_failure = result->SetDescriptors(descriptors); |
5065 if (maybe_failure->IsFailure()) return maybe_failure; | 5066 if (maybe_failure->IsFailure()) return maybe_failure; |
5066 result->SetNumberOfOwnDescriptors(descriptors->number_of_descriptors()); | 5067 result->SetNumberOfOwnDescriptors(descriptors->number_of_descriptors()); |
5067 } | 5068 } |
5068 | 5069 |
5069 if (flag == INSERT_TRANSITION && CanHaveMoreTransitions()) { | 5070 if (flag == INSERT_TRANSITION && CanHaveMoreTransitions()) { |
5070 TransitionArray* transitions; | 5071 TransitionArray* transitions; |
5071 MaybeObject* maybe_transitions = AddTransition(name, result); | 5072 SimpleTransitionFlag simple_flag = |
5073 (descriptor_index == descriptors->number_of_descriptors() - 1) | |
5074 ? SIMPLE_TRANSITION | |
5075 : FULL_TRANSITION; | |
5076 MaybeObject* maybe_transitions = AddTransition(name, result, simple_flag); | |
5072 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 5077 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
5073 | 5078 |
5074 if (descriptors->IsEmpty()) { | 5079 if (descriptors->IsEmpty()) { |
5075 if (owns_descriptors()) { | 5080 if (owns_descriptors()) { |
5076 // If the copied map has no added fields, and the parent map owns its | 5081 // If the copied map has no added fields, and the parent map owns its |
5077 // descriptors, those descriptors have to be empty. In that case, | 5082 // descriptors, those descriptors have to be empty. In that case, |
5078 // transfer ownership of the descriptors to the new child. | 5083 // transfer ownership of the descriptors to the new child. |
5079 ASSERT(instance_descriptors()->IsEmpty()); | 5084 ASSERT(instance_descriptors()->IsEmpty()); |
5080 set_owns_descriptors(false); | 5085 set_owns_descriptors(false); |
5081 } else { | 5086 } else { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5297 if (i == insertion_index) { | 5302 if (i == insertion_index) { |
5298 new_descriptors->Set(i, descriptor, witness); | 5303 new_descriptors->Set(i, descriptor, witness); |
5299 } else { | 5304 } else { |
5300 new_descriptors->CopyFrom(i, descriptors, i, witness); | 5305 new_descriptors->CopyFrom(i, descriptors, i, witness); |
5301 } | 5306 } |
5302 } | 5307 } |
5303 | 5308 |
5304 // Re-sort if descriptors were removed. | 5309 // Re-sort if descriptors were removed. |
5305 if (new_size != descriptors->length()) new_descriptors->Sort(); | 5310 if (new_size != descriptors->length()) new_descriptors->Sort(); |
5306 | 5311 |
5307 return CopyReplaceDescriptors(new_descriptors, key, flag); | 5312 return CopyReplaceDescriptors(new_descriptors, key, flag, insertion_index); |
5308 } | 5313 } |
5309 | 5314 |
5310 | 5315 |
5311 void Map::UpdateCodeCache(Handle<Map> map, | 5316 void Map::UpdateCodeCache(Handle<Map> map, |
5312 Handle<String> name, | 5317 Handle<String> name, |
5313 Handle<Code> code) { | 5318 Handle<Code> code) { |
5314 Isolate* isolate = map->GetIsolate(); | 5319 Isolate* isolate = map->GetIsolate(); |
5315 CALL_HEAP_FUNCTION_VOID(isolate, | 5320 CALL_HEAP_FUNCTION_VOID(isolate, |
5316 map->UpdateCodeCache(*name, *code)); | 5321 map->UpdateCodeCache(*name, *code)); |
5317 } | 5322 } |
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7547 if (transition_index == 0 && | 7552 if (transition_index == 0 && |
7548 !t->HasElementsTransition() && | 7553 !t->HasElementsTransition() && |
7549 !t->HasPrototypeTransitions() && | 7554 !t->HasPrototypeTransitions() && |
7550 number_of_own_descriptors == 0) { | 7555 number_of_own_descriptors == 0) { |
7551 ASSERT(owns_descriptors()); | 7556 ASSERT(owns_descriptors()); |
7552 return ClearTransitions(heap); | 7557 return ClearTransitions(heap); |
7553 } | 7558 } |
7554 | 7559 |
7555 int trim = t->number_of_transitions() - transition_index; | 7560 int trim = t->number_of_transitions() - transition_index; |
7556 if (trim > 0) { | 7561 if (trim > 0) { |
7557 RightTrimFixedArray<FROM_GC>( | 7562 if (!t->IsSimpleTransition()) trim *= TransitionArray::kTransitionSize; |
7558 heap, t, trim * TransitionArray::kTransitionSize); | 7563 RightTrimFixedArray<FROM_GC>(heap, t, trim); |
Michael Starzinger
2012/09/19 09:34:55
Can we use "t->IsSimpleTransition() ? trim : trim
Toon Verwaest
2012/09/19 09:53:23
Done.
| |
7559 } | 7564 } |
7560 } | 7565 } |
7561 | 7566 |
7562 | 7567 |
7563 int Map::Hash() { | 7568 int Map::Hash() { |
7564 // For performance reasons we only hash the 3 most variable fields of a map: | 7569 // For performance reasons we only hash the 3 most variable fields of a map: |
7565 // constructor, prototype and bit_field2. | 7570 // constructor, prototype and bit_field2. |
7566 | 7571 |
7567 // Shift away the tag. | 7572 // Shift away the tag. |
7568 int hash = (static_cast<uint32_t>( | 7573 int hash = (static_cast<uint32_t>( |
(...skipping 5952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13521 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13526 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13522 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13527 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13523 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13528 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13524 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13529 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13525 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13530 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13526 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13531 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13527 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13532 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13528 } | 13533 } |
13529 | 13534 |
13530 } } // namespace v8::internal | 13535 } } // namespace v8::internal |
OLD | NEW |