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 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 FixedArray* result = FixedArray::cast(obj); | 2286 FixedArray* result = FixedArray::cast(obj); |
2287 result->set_length(len); | 2287 result->set_length(len); |
2288 // Copy the content | 2288 // Copy the content |
2289 WriteBarrierMode mode = result->GetWriteBarrierMode(); | 2289 WriteBarrierMode mode = result->GetWriteBarrierMode(); |
2290 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); | 2290 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
2291 return result; | 2291 return result; |
2292 } | 2292 } |
2293 | 2293 |
2294 | 2294 |
2295 Object* Heap::AllocateFixedArray(int length) { | 2295 Object* Heap::AllocateFixedArray(int length) { |
| 2296 if (length == 0) return empty_fixed_array(); |
2296 Object* result = AllocateRawFixedArray(length); | 2297 Object* result = AllocateRawFixedArray(length); |
2297 if (!result->IsFailure()) { | 2298 if (!result->IsFailure()) { |
2298 // Initialize header. | 2299 // Initialize header. |
2299 reinterpret_cast<Array*>(result)->set_map(fixed_array_map()); | 2300 reinterpret_cast<Array*>(result)->set_map(fixed_array_map()); |
2300 FixedArray* array = FixedArray::cast(result); | 2301 FixedArray* array = FixedArray::cast(result); |
2301 array->set_length(length); | 2302 array->set_length(length); |
2302 Object* value = undefined_value(); | 2303 Object* value = undefined_value(); |
2303 // Initialize body. | 2304 // Initialize body. |
2304 for (int index = 0; index < length; index++) { | 2305 for (int index = 0; index < length; index++) { |
2305 array->set(index, value, SKIP_WRITE_BARRIER); | 2306 array->set(index, value, SKIP_WRITE_BARRIER); |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 #ifdef DEBUG | 3357 #ifdef DEBUG |
3357 bool Heap::GarbageCollectionGreedyCheck() { | 3358 bool Heap::GarbageCollectionGreedyCheck() { |
3358 ASSERT(FLAG_gc_greedy); | 3359 ASSERT(FLAG_gc_greedy); |
3359 if (Bootstrapper::IsActive()) return true; | 3360 if (Bootstrapper::IsActive()) return true; |
3360 if (disallow_allocation_failure()) return true; | 3361 if (disallow_allocation_failure()) return true; |
3361 return CollectGarbage(0, NEW_SPACE); | 3362 return CollectGarbage(0, NEW_SPACE); |
3362 } | 3363 } |
3363 #endif | 3364 #endif |
3364 | 3365 |
3365 } } // namespace v8::internal | 3366 } } // namespace v8::internal |
OLD | NEW |