OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 int extra = 0; | 2573 int extra = 0; |
2574 for (int y = 0; y < len1; y++) { | 2574 for (int y = 0; y < len1; y++) { |
2575 if (!HasKey(this, other->get(y))) extra++; | 2575 if (!HasKey(this, other->get(y))) extra++; |
2576 } | 2576 } |
2577 | 2577 |
2578 // Allocate the result | 2578 // Allocate the result |
2579 Object* obj = Heap::AllocateFixedArray(len0 + extra); | 2579 Object* obj = Heap::AllocateFixedArray(len0 + extra); |
2580 if (obj->IsFailure()) return obj; | 2580 if (obj->IsFailure()) return obj; |
2581 // Fill in the content | 2581 // Fill in the content |
2582 FixedArray* result = FixedArray::cast(obj); | 2582 FixedArray* result = FixedArray::cast(obj); |
| 2583 WriteBarrierMode mode = result->GetWriteBarrierMode(); |
2583 for (int i = 0; i < len0; i++) { | 2584 for (int i = 0; i < len0; i++) { |
2584 result->set(i, get(i)); | 2585 result->set(i, get(i), mode); |
2585 } | 2586 } |
2586 // Fill in the extra keys. | 2587 // Fill in the extra keys. |
2587 int index = 0; | 2588 int index = 0; |
2588 for (int y = 0; y < len1; y++) { | 2589 for (int y = 0; y < len1; y++) { |
2589 if (!HasKey(this, other->get(y))) { | 2590 if (!HasKey(this, other->get(y))) { |
2590 result->set(len0 + index, other->get(y)); | 2591 result->set(len0 + index, other->get(y), mode); |
2591 index++; | 2592 index++; |
2592 } | 2593 } |
2593 } | 2594 } |
2594 ASSERT(extra == index); | 2595 ASSERT(extra == index); |
2595 return result; | 2596 return result; |
2596 } | 2597 } |
2597 | 2598 |
2598 | 2599 |
2599 Object* FixedArray::CopySize(int new_length) { | 2600 Object* FixedArray::CopySize(int new_length) { |
2600 if (new_length == 0) return Heap::empty_fixed_array(); | 2601 if (new_length == 0) return Heap::empty_fixed_array(); |
2601 Object* obj = Heap::AllocateFixedArray(new_length); | 2602 Object* obj = Heap::AllocateFixedArray(new_length); |
2602 if (obj->IsFailure()) return obj; | 2603 if (obj->IsFailure()) return obj; |
2603 FixedArray* result = FixedArray::cast(obj); | 2604 FixedArray* result = FixedArray::cast(obj); |
2604 WriteBarrierMode mode = result->GetWriteBarrierMode(); | |
2605 // Copy the content | 2605 // Copy the content |
2606 int len = length(); | 2606 int len = length(); |
2607 if (new_length < len) len = new_length; | 2607 if (new_length < len) len = new_length; |
| 2608 result->set_map(map()); |
| 2609 WriteBarrierMode mode = result->GetWriteBarrierMode(); |
2608 for (int i = 0; i < len; i++) { | 2610 for (int i = 0; i < len; i++) { |
2609 result->set(i, get(i), mode); | 2611 result->set(i, get(i), mode); |
2610 } | 2612 } |
2611 result->set_map(map()); | |
2612 return result; | 2613 return result; |
2613 } | 2614 } |
2614 | 2615 |
2615 | 2616 |
2616 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { | 2617 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { |
2617 WriteBarrierMode mode = dest->GetWriteBarrierMode(); | 2618 WriteBarrierMode mode = dest->GetWriteBarrierMode(); |
2618 for (int index = 0; index < len; index++) { | 2619 for (int index = 0; index < len; index++) { |
2619 dest->set(dest_pos+index, get(pos+index), mode); | 2620 dest->set(dest_pos+index, get(pos+index), mode); |
2620 } | 2621 } |
2621 } | 2622 } |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4040 } | 4041 } |
4041 } | 4042 } |
4042 | 4043 |
4043 | 4044 |
4044 void Map::MapIterateBody(ObjectVisitor* v) { | 4045 void Map::MapIterateBody(ObjectVisitor* v) { |
4045 // Assumes all Object* members are contiguously allocated! | 4046 // Assumes all Object* members are contiguously allocated! |
4046 IteratePointers(v, kPrototypeOffset, kCodeCacheOffset + kPointerSize); | 4047 IteratePointers(v, kPrototypeOffset, kCodeCacheOffset + kPointerSize); |
4047 } | 4048 } |
4048 | 4049 |
4049 | 4050 |
4050 int JSFunction::NumberOfLiterals() { | |
4051 return literals()->length(); | |
4052 } | |
4053 | |
4054 | |
4055 Object* JSFunction::SetInstancePrototype(Object* value) { | 4051 Object* JSFunction::SetInstancePrototype(Object* value) { |
4056 ASSERT(value->IsJSObject()); | 4052 ASSERT(value->IsJSObject()); |
4057 | 4053 |
4058 if (has_initial_map()) { | 4054 if (has_initial_map()) { |
4059 initial_map()->set_prototype(value); | 4055 initial_map()->set_prototype(value); |
4060 } else { | 4056 } else { |
4061 // Put the value in the initial map field until an initial map is | 4057 // Put the value in the initial map field until an initial map is |
4062 // needed. At that point, a new initial map is created and the | 4058 // needed. At that point, a new initial map is created and the |
4063 // prototype is put into the initial map where it belongs. | 4059 // prototype is put into the initial map where it belongs. |
4064 set_prototype_or_initial_map(value); | 4060 set_prototype_or_initial_map(value); |
(...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5967 MapNameKey key(map, name); | 5963 MapNameKey key(map, name); |
5968 Object* obj = EnsureCapacity(1, &key); | 5964 Object* obj = EnsureCapacity(1, &key); |
5969 if (obj->IsFailure()) return obj; | 5965 if (obj->IsFailure()) return obj; |
5970 Object* k = key.GetObject(); | 5966 Object* k = key.GetObject(); |
5971 if (k->IsFailure()) return k; | 5967 if (k->IsFailure()) return k; |
5972 | 5968 |
5973 LookupCache* cache = reinterpret_cast<LookupCache*>(obj); | 5969 LookupCache* cache = reinterpret_cast<LookupCache*>(obj); |
5974 int entry = cache->FindInsertionEntry(k, key.Hash()); | 5970 int entry = cache->FindInsertionEntry(k, key.Hash()); |
5975 int index = EntryToIndex(entry); | 5971 int index = EntryToIndex(entry); |
5976 cache->set(index, k); | 5972 cache->set(index, k); |
5977 cache->set(index + 1, Smi::FromInt(value)); | 5973 cache->set(index + 1, Smi::FromInt(value), SKIP_WRITE_BARRIER); |
5978 cache->ElementAdded(); | 5974 cache->ElementAdded(); |
5979 return cache; | 5975 return cache; |
5980 } | 5976 } |
5981 | 5977 |
5982 | 5978 |
5983 Object* Dictionary::Allocate(int at_least_space_for) { | 5979 Object* Dictionary::Allocate(int at_least_space_for) { |
5984 Object* obj = DictionaryBase::Allocate(at_least_space_for); | 5980 Object* obj = DictionaryBase::Allocate(at_least_space_for); |
5985 // Initialize the next enumeration index. | 5981 // Initialize the next enumeration index. |
5986 if (!obj->IsFailure()) { | 5982 if (!obj->IsFailure()) { |
5987 Dictionary::cast(obj)-> | 5983 Dictionary::cast(obj)-> |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6652 // No break point. | 6648 // No break point. |
6653 if (break_point_objects()->IsUndefined()) return 0; | 6649 if (break_point_objects()->IsUndefined()) return 0; |
6654 // Single beak point. | 6650 // Single beak point. |
6655 if (!break_point_objects()->IsFixedArray()) return 1; | 6651 if (!break_point_objects()->IsFixedArray()) return 1; |
6656 // Multiple break points. | 6652 // Multiple break points. |
6657 return FixedArray::cast(break_point_objects())->length(); | 6653 return FixedArray::cast(break_point_objects())->length(); |
6658 } | 6654 } |
6659 | 6655 |
6660 | 6656 |
6661 } } // namespace v8::internal | 6657 } } // namespace v8::internal |
OLD | NEW |