Chromium Code Reviews| 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/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 array->set_map_no_write_barrier(*module_context_map()); | 869 array->set_map_no_write_barrier(*module_context_map()); |
| 870 Handle<Context> context = Handle<Context>::cast(array); | 870 Handle<Context> context = Handle<Context>::cast(array); |
| 871 context->set_closure(*function); | 871 context->set_closure(*function); |
| 872 context->set_previous(function->context()); | 872 context->set_previous(function->context()); |
| 873 context->set_extension(*module); | 873 context->set_extension(*module); |
| 874 context->set_native_context(function->native_context()); | 874 context->set_native_context(function->native_context()); |
| 875 DCHECK(context->IsModuleContext()); | 875 DCHECK(context->IsModuleContext()); |
| 876 return context; | 876 return context; |
| 877 } | 877 } |
| 878 | 878 |
| 879 | |
| 880 Handle<Context> Factory::NewFunctionContext(int length, | 879 Handle<Context> Factory::NewFunctionContext(int length, |
| 881 Handle<JSFunction> function) { | 880 Handle<JSFunction> function) { |
| 882 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | 881 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); |
| 883 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | 882 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); |
| 884 Handle<FixedArray> array = NewFixedArray(length); | 883 Handle<FixedArray> array = NewFixedArray(length); |
| 885 array->set_map_no_write_barrier(*function_context_map()); | 884 array->set_map_no_write_barrier(*function_context_map()); |
| 886 Handle<Context> context = Handle<Context>::cast(array); | 885 Handle<Context> context = Handle<Context>::cast(array); |
| 887 context->set_closure(*function); | 886 context->set_closure(*function); |
| 888 context->set_previous(function->context()); | 887 context->set_previous(function->context()); |
| 889 context->set_extension(*the_hole_value()); | 888 context->set_extension(*the_hole_value()); |
| 890 context->set_native_context(function->native_context()); | 889 context->set_native_context(function->native_context()); |
| 891 return context; | 890 return context; |
| 892 } | 891 } |
| 893 | 892 |
| 893 Handle<Context> Factory::NewEvalContext(int length, | |
| 894 Handle<JSFunction> function) { | |
| 895 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | |
|
adamk
2016/11/12 00:26:05
I would have expected this DCHECK to fail...should
Dan Ehrenberg
2016/12/07 05:41:26
Fixed the DCHECK. Added a new test which triggers
| |
| 896 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | |
| 897 Handle<FixedArray> array = NewFixedArray(length); | |
| 898 array->set_map_no_write_barrier(*eval_context_map()); | |
| 899 Handle<Context> context = Handle<Context>::cast(array); | |
| 900 context->set_closure(*function); | |
| 901 context->set_previous(function->context()); | |
| 902 context->set_extension(*the_hole_value()); | |
| 903 context->set_native_context(function->native_context()); | |
| 904 return context; | |
| 905 } | |
| 906 | |
| 894 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, | 907 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, |
| 895 Handle<Context> previous, | 908 Handle<Context> previous, |
| 896 Handle<ScopeInfo> scope_info, | 909 Handle<ScopeInfo> scope_info, |
| 897 Handle<String> name, | 910 Handle<String> name, |
| 898 Handle<Object> thrown_object) { | 911 Handle<Object> thrown_object) { |
| 899 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); | 912 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); |
| 900 Handle<ContextExtension> extension = NewContextExtension(scope_info, name); | 913 Handle<ContextExtension> extension = NewContextExtension(scope_info, name); |
| 901 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1); | 914 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1); |
| 902 array->set_map_no_write_barrier(*catch_context_map()); | 915 array->set_map_no_write_barrier(*catch_context_map()); |
| 903 Handle<Context> context = Handle<Context>::cast(array); | 916 Handle<Context> context = Handle<Context>::cast(array); |
| (...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2707 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); | 2720 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
| 2708 iterator->set_initial_next(*next); | 2721 iterator->set_initial_next(*next); |
| 2709 iterator->set_array(*array); | 2722 iterator->set_array(*array); |
| 2710 iterator->set_index(0); | 2723 iterator->set_index(0); |
| 2711 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); | 2724 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
| 2712 return iterator; | 2725 return iterator; |
| 2713 } | 2726 } |
| 2714 | 2727 |
| 2715 } // namespace internal | 2728 } // namespace internal |
| 2716 } // namespace v8 | 2729 } // namespace v8 |
| OLD | NEW |