| 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 14673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14684 if (maybe_array->IsFailure()) return maybe_array; | 14684 if (maybe_array->IsFailure()) return maybe_array; |
| 14685 maybe_array = ArrayConstructInitializeElements(array, caller_args); | 14685 maybe_array = ArrayConstructInitializeElements(array, caller_args); |
| 14686 if (maybe_array->IsFailure()) return maybe_array; | 14686 if (maybe_array->IsFailure()) return maybe_array; |
| 14687 return array; | 14687 return array; |
| 14688 } | 14688 } |
| 14689 | 14689 |
| 14690 | 14690 |
| 14691 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) { | 14691 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) { |
| 14692 HandleScope scope(isolate); | 14692 HandleScope scope(isolate); |
| 14693 // If we get 2 arguments then they are the stub parameters (constructor, type | 14693 // If we get 2 arguments then they are the stub parameters (constructor, type |
| 14694 // info). If we get 3, then the first one is a pointer to the arguments | 14694 // info). If we get 4, then the first one is a pointer to the arguments |
| 14695 // passed by the caller. | 14695 // passed by the caller, and the last one is the length of the arguments |
| 14696 // passed to the caller (redundant, but useful to check on the deoptimizer |
| 14697 // with an assert). |
| 14696 Arguments empty_args(0, NULL); | 14698 Arguments empty_args(0, NULL); |
| 14697 bool no_caller_args = args.length() == 2; | 14699 bool no_caller_args = args.length() == 2; |
| 14698 ASSERT(no_caller_args || args.length() == 3); | 14700 ASSERT(no_caller_args || args.length() == 4); |
| 14699 int parameters_start = no_caller_args ? 0 : 1; | 14701 int parameters_start = no_caller_args ? 0 : 1; |
| 14700 Arguments* caller_args = no_caller_args | 14702 Arguments* caller_args = no_caller_args |
| 14701 ? &empty_args | 14703 ? &empty_args |
| 14702 : reinterpret_cast<Arguments*>(args[0]); | 14704 : reinterpret_cast<Arguments*>(args[0]); |
| 14703 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 14705 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
| 14704 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); | 14706 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); |
| 14705 | 14707 #ifdef DEBUG |
| 14708 if (!no_caller_args) { |
| 14709 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2); |
| 14710 ASSERT(arg_count == caller_args->length()); |
| 14711 } |
| 14712 #endif |
| 14706 return ArrayConstructorCommon(isolate, | 14713 return ArrayConstructorCommon(isolate, |
| 14707 constructor, | 14714 constructor, |
| 14708 type_info, | 14715 type_info, |
| 14709 caller_args); | 14716 caller_args); |
| 14710 } | 14717 } |
| 14711 | 14718 |
| 14712 | 14719 |
| 14713 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) { | 14720 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) { |
| 14714 HandleScope scope(isolate); | 14721 HandleScope scope(isolate); |
| 14715 Arguments empty_args(0, NULL); | 14722 Arguments empty_args(0, NULL); |
| 14716 bool no_caller_args = args.length() == 1; | 14723 bool no_caller_args = args.length() == 1; |
| 14717 ASSERT(no_caller_args || args.length() == 2); | 14724 ASSERT(no_caller_args || args.length() == 3); |
| 14718 int parameters_start = no_caller_args ? 0 : 1; | 14725 int parameters_start = no_caller_args ? 0 : 1; |
| 14719 Arguments* caller_args = no_caller_args | 14726 Arguments* caller_args = no_caller_args |
| 14720 ? &empty_args | 14727 ? &empty_args |
| 14721 : reinterpret_cast<Arguments*>(args[0]); | 14728 : reinterpret_cast<Arguments*>(args[0]); |
| 14722 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 14729 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
| 14723 | 14730 #ifdef DEBUG |
| 14731 if (!no_caller_args) { |
| 14732 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); |
| 14733 ASSERT(arg_count == caller_args->length()); |
| 14734 } |
| 14735 #endif |
| 14724 return ArrayConstructorCommon(isolate, | 14736 return ArrayConstructorCommon(isolate, |
| 14725 constructor, | 14737 constructor, |
| 14726 Handle<Object>::null(), | 14738 Handle<Object>::null(), |
| 14727 caller_args); | 14739 caller_args); |
| 14728 } | 14740 } |
| 14729 | 14741 |
| 14730 | 14742 |
| 14731 // ---------------------------------------------------------------------------- | 14743 // ---------------------------------------------------------------------------- |
| 14732 // Implementation of Runtime | 14744 // Implementation of Runtime |
| 14733 | 14745 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14805 // Handle last resort GC and make sure to allow future allocations | 14817 // Handle last resort GC and make sure to allow future allocations |
| 14806 // to grow the heap without causing GCs (if possible). | 14818 // to grow the heap without causing GCs (if possible). |
| 14807 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14819 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14808 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14820 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14809 "Runtime::PerformGC"); | 14821 "Runtime::PerformGC"); |
| 14810 } | 14822 } |
| 14811 } | 14823 } |
| 14812 | 14824 |
| 14813 | 14825 |
| 14814 } } // namespace v8::internal | 14826 } } // namespace v8::internal |
| OLD | NEW |