| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/factory.h" | 5 #include "src/factory.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 array->set_map_no_write_barrier(*module_context_map()); | 882 array->set_map_no_write_barrier(*module_context_map()); |
| 883 Handle<Context> context = Handle<Context>::cast(array); | 883 Handle<Context> context = Handle<Context>::cast(array); |
| 884 context->set_closure(*function); | 884 context->set_closure(*function); |
| 885 context->set_previous(function->context()); | 885 context->set_previous(function->context()); |
| 886 context->set_extension(*module); | 886 context->set_extension(*module); |
| 887 context->set_native_context(function->native_context()); | 887 context->set_native_context(function->native_context()); |
| 888 DCHECK(context->IsModuleContext()); | 888 DCHECK(context->IsModuleContext()); |
| 889 return context; | 889 return context; |
| 890 } | 890 } |
| 891 | 891 |
| 892 | |
| 893 Handle<Context> Factory::NewFunctionContext(int length, | 892 Handle<Context> Factory::NewFunctionContext(int length, |
| 894 Handle<JSFunction> function) { | 893 Handle<JSFunction> function, |
| 895 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | 894 ScopeType scope_type) { |
| 895 DCHECK(function->shared()->scope_info()->scope_type() == scope_type); |
| 896 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | 896 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); |
| 897 Handle<FixedArray> array = NewFixedArray(length); | 897 Handle<FixedArray> array = NewFixedArray(length); |
| 898 array->set_map_no_write_barrier(*function_context_map()); | 898 Handle<Map> map; |
| 899 switch (scope_type) { |
| 900 case EVAL_SCOPE: |
| 901 map = eval_context_map(); |
| 902 break; |
| 903 case FUNCTION_SCOPE: |
| 904 map = function_context_map(); |
| 905 break; |
| 906 default: |
| 907 UNREACHABLE(); |
| 908 } |
| 909 array->set_map_no_write_barrier(*map); |
| 899 Handle<Context> context = Handle<Context>::cast(array); | 910 Handle<Context> context = Handle<Context>::cast(array); |
| 900 context->set_closure(*function); | 911 context->set_closure(*function); |
| 901 context->set_previous(function->context()); | 912 context->set_previous(function->context()); |
| 902 context->set_extension(*the_hole_value()); | 913 context->set_extension(*the_hole_value()); |
| 903 context->set_native_context(function->native_context()); | 914 context->set_native_context(function->native_context()); |
| 904 return context; | 915 return context; |
| 905 } | 916 } |
| 906 | 917 |
| 907 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, | 918 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, |
| 908 Handle<Context> previous, | 919 Handle<Context> previous, |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); | 2791 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
| 2781 iterator->set_initial_next(*next); | 2792 iterator->set_initial_next(*next); |
| 2782 iterator->set_array(*array); | 2793 iterator->set_array(*array); |
| 2783 iterator->set_index(0); | 2794 iterator->set_index(0); |
| 2784 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); | 2795 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
| 2785 return iterator; | 2796 return iterator; |
| 2786 } | 2797 } |
| 2787 | 2798 |
| 2788 } // namespace internal | 2799 } // namespace internal |
| 2789 } // namespace v8 | 2800 } // namespace v8 |
| OLD | NEW |