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 6714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6725 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); | 6725 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); |
6726 | 6726 |
6727 PretenureFlag pretenure = (context->global_context() == *context) | 6727 PretenureFlag pretenure = (context->global_context() == *context) |
6728 ? TENURED // Allocate global closures in old space. | 6728 ? TENURED // Allocate global closures in old space. |
6729 : NOT_TENURED; // Allocate local closures in new space. | 6729 : NOT_TENURED; // Allocate local closures in new space. |
6730 Handle<JSFunction> result = | 6730 Handle<JSFunction> result = |
6731 Factory::NewFunctionFromSharedFunctionInfo(shared, context, pretenure); | 6731 Factory::NewFunctionFromSharedFunctionInfo(shared, context, pretenure); |
6732 return *result; | 6732 return *result; |
6733 } | 6733 } |
6734 | 6734 |
| 6735 static Object* Runtime_NewObjectFromBound(Arguments args) { |
| 6736 HandleScope scope; |
| 6737 ASSERT(args.length() == 2); |
| 6738 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 6739 CONVERT_ARG_CHECKED(JSArray, params, 1); |
| 6740 |
| 6741 FixedArray* fixed = FixedArray::cast(params->elements()); |
| 6742 |
| 6743 bool exception = false; |
| 6744 Object*** param_data = NewArray<Object**>(fixed->length()); |
| 6745 for (int i = 0; i < fixed->length(); i++) { |
| 6746 Handle<Object> val = Handle<Object>(fixed->get(i)); |
| 6747 param_data[i] = val.location(); |
| 6748 } |
| 6749 |
| 6750 Handle<Object> result = Execution::New( |
| 6751 function, fixed->length(), param_data, &exception); |
| 6752 return *result; |
| 6753 |
| 6754 } |
| 6755 |
6735 | 6756 |
6736 static Code* ComputeConstructStub(Handle<JSFunction> function) { | 6757 static Code* ComputeConstructStub(Handle<JSFunction> function) { |
6737 Handle<Object> prototype = Factory::null_value(); | 6758 Handle<Object> prototype = Factory::null_value(); |
6738 if (function->has_instance_prototype()) { | 6759 if (function->has_instance_prototype()) { |
6739 prototype = Handle<Object>(function->instance_prototype()); | 6760 prototype = Handle<Object>(function->instance_prototype()); |
6740 } | 6761 } |
6741 if (function->shared()->CanGenerateInlineConstructor(*prototype)) { | 6762 if (function->shared()->CanGenerateInlineConstructor(*prototype)) { |
6742 ConstructStubCompiler compiler; | 6763 ConstructStubCompiler compiler; |
6743 Object* code = compiler.CompileConstructStub(function->shared()); | 6764 Object* code = compiler.CompileConstructStub(function->shared()); |
6744 if (code->IsFailure()) { | 6765 if (code->IsFailure()) { |
(...skipping 3799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10544 } else { | 10565 } else { |
10545 // Handle last resort GC and make sure to allow future allocations | 10566 // Handle last resort GC and make sure to allow future allocations |
10546 // to grow the heap without causing GCs (if possible). | 10567 // to grow the heap without causing GCs (if possible). |
10547 Counters::gc_last_resort_from_js.Increment(); | 10568 Counters::gc_last_resort_from_js.Increment(); |
10548 Heap::CollectAllGarbage(false); | 10569 Heap::CollectAllGarbage(false); |
10549 } | 10570 } |
10550 } | 10571 } |
10551 | 10572 |
10552 | 10573 |
10553 } } // namespace v8::internal | 10574 } } // namespace v8::internal |
OLD | NEW |