OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4361 static Object* Runtime_NewArgumentsFast(Arguments args) { | 4361 static Object* Runtime_NewArgumentsFast(Arguments args) { |
4362 NoHandleAllocation ha; | 4362 NoHandleAllocation ha; |
4363 ASSERT(args.length() == 3); | 4363 ASSERT(args.length() == 3); |
4364 | 4364 |
4365 JSFunction* callee = JSFunction::cast(args[0]); | 4365 JSFunction* callee = JSFunction::cast(args[0]); |
4366 Object** parameters = reinterpret_cast<Object**>(args[1]); | 4366 Object** parameters = reinterpret_cast<Object**>(args[1]); |
4367 const int length = Smi::cast(args[2])->value(); | 4367 const int length = Smi::cast(args[2])->value(); |
4368 | 4368 |
4369 Object* result = Heap::AllocateArgumentsObject(callee, length); | 4369 Object* result = Heap::AllocateArgumentsObject(callee, length); |
4370 if (result->IsFailure()) return result; | 4370 if (result->IsFailure()) return result; |
4371 ASSERT(Heap::InNewSpace(result)); | |
4372 | |
4373 // Allocate the elements if needed. | 4371 // Allocate the elements if needed. |
4374 if (length > 0) { | 4372 if (length > 0) { |
4375 // Allocate the fixed array. | 4373 // Allocate the fixed array. |
4376 Object* obj = Heap::AllocateRawFixedArray(length); | 4374 Object* obj = Heap::AllocateRawFixedArray(length); |
4377 if (obj->IsFailure()) return obj; | 4375 if (obj->IsFailure()) return obj; |
4378 reinterpret_cast<Array*>(obj)->set_map(Heap::fixed_array_map()); | 4376 reinterpret_cast<Array*>(obj)->set_map(Heap::fixed_array_map()); |
4379 FixedArray* array = FixedArray::cast(obj); | 4377 FixedArray* array = FixedArray::cast(obj); |
4380 array->set_length(length); | 4378 array->set_length(length); |
4381 WriteBarrierMode mode = array->GetWriteBarrierMode(); | 4379 WriteBarrierMode mode = array->GetWriteBarrierMode(); |
4382 for (int i = 0; i < length; i++) { | 4380 for (int i = 0; i < length; i++) { |
4383 array->set(i, *--parameters, mode); | 4381 array->set(i, *--parameters, mode); |
4384 } | 4382 } |
4385 JSObject::cast(result)->set_elements(FixedArray::cast(obj), | 4383 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
4386 SKIP_WRITE_BARRIER); | |
4387 } | 4384 } |
4388 return result; | 4385 return result; |
4389 } | 4386 } |
4390 | 4387 |
4391 | 4388 |
4392 static Object* Runtime_NewClosure(Arguments args) { | 4389 static Object* Runtime_NewClosure(Arguments args) { |
4393 HandleScope scope; | 4390 HandleScope scope; |
4394 ASSERT(args.length() == 2); | 4391 ASSERT(args.length() == 2); |
4395 CONVERT_ARG_CHECKED(Context, context, 0); | 4392 CONVERT_ARG_CHECKED(Context, context, 0); |
4396 CONVERT_ARG_CHECKED(JSFunction, boilerplate, 1); | 4393 CONVERT_ARG_CHECKED(JSFunction, boilerplate, 1); |
(...skipping 3508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7905 } else { | 7902 } else { |
7906 // Handle last resort GC and make sure to allow future allocations | 7903 // Handle last resort GC and make sure to allow future allocations |
7907 // to grow the heap without causing GCs (if possible). | 7904 // to grow the heap without causing GCs (if possible). |
7908 Counters::gc_last_resort_from_js.Increment(); | 7905 Counters::gc_last_resort_from_js.Increment(); |
7909 Heap::CollectAllGarbage(false); | 7906 Heap::CollectAllGarbage(false); |
7910 } | 7907 } |
7911 } | 7908 } |
7912 | 7909 |
7913 | 7910 |
7914 } } // namespace v8::internal | 7911 } } // namespace v8::internal |
OLD | NEW |