Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: src/factory.cc

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: Clean up test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); 2790 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map));
2780 iterator->set_initial_next(*next); 2791 iterator->set_initial_next(*next);
2781 iterator->set_array(*array); 2792 iterator->set_array(*array);
2782 iterator->set_index(0); 2793 iterator->set_index(0);
2783 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); 2794 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next);
2784 return iterator; 2795 return iterator;
2785 } 2796 }
2786 2797
2787 } // namespace internal 2798 } // namespace internal
2788 } // namespace v8 2799 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698