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

Side by Side Diff: src/scopes.cc

Issue 6624085: [Isolates] Merge 7051:7083 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « src/scopes.h ('k') | src/type-info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 876
877 void Scope::AllocateHeapSlot(Variable* var) { 877 void Scope::AllocateHeapSlot(Variable* var) {
878 var->set_rewrite(new Slot(var, Slot::CONTEXT, num_heap_slots_++)); 878 var->set_rewrite(new Slot(var, Slot::CONTEXT, num_heap_slots_++));
879 } 879 }
880 880
881 881
882 void Scope::AllocateParameterLocals() { 882 void Scope::AllocateParameterLocals() {
883 ASSERT(is_function_scope()); 883 ASSERT(is_function_scope());
884 Variable* arguments = LocalLookup(FACTORY->arguments_symbol()); 884 Variable* arguments = LocalLookup(FACTORY->arguments_symbol());
885 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly 885 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly
886
887 // Parameters are rewritten to arguments[i] if 'arguments' is used in
888 // a non-strict mode function. Strict mode code doesn't alias arguments.
889 bool rewrite_parameters = false;
890
886 if (MustAllocate(arguments) && !HasArgumentsParameter()) { 891 if (MustAllocate(arguments) && !HasArgumentsParameter()) {
887 // 'arguments' is used. Unless there is also a parameter called 892 // 'arguments' is used. Unless there is also a parameter called
888 // 'arguments', we must be conservative and access all parameters via 893 // 'arguments', we must be conservative and access all parameters via
889 // the arguments object: The i'th parameter is rewritten into 894 // the arguments object: The i'th parameter is rewritten into
890 // '.arguments[i]' (*). If we have a parameter named 'arguments', a 895 // '.arguments[i]' (*). If we have a parameter named 'arguments', a
891 // (new) value is always assigned to it via the function 896 // (new) value is always assigned to it via the function
892 // invocation. Then 'arguments' denotes that specific parameter value 897 // invocation. Then 'arguments' denotes that specific parameter value
893 // and cannot be used to access the parameters, which is why we don't 898 // and cannot be used to access the parameters, which is why we don't
894 // need to rewrite in that case. 899 // need to rewrite in that case.
895 // 900 //
(...skipping 11 matching lines...) Expand all
907 // allocated. All parameters are rewritten into property accesses via 912 // allocated. All parameters are rewritten into property accesses via
908 // the '.arguments' variable. Thus, any changes to properties of 913 // the '.arguments' variable. Thus, any changes to properties of
909 // 'arguments' are reflected in the variables and vice versa. If the 914 // 'arguments' are reflected in the variables and vice versa. If the
910 // 'arguments' variable is changed, '.arguments' still points to the 915 // 'arguments' variable is changed, '.arguments' still points to the
911 // correct arguments object and the rewrites still work. 916 // correct arguments object and the rewrites still work.
912 917
913 // We are using 'arguments'. Tell the code generator that is needs to 918 // We are using 'arguments'. Tell the code generator that is needs to
914 // allocate the arguments object by setting 'arguments_'. 919 // allocate the arguments object by setting 'arguments_'.
915 arguments_ = arguments; 920 arguments_ = arguments;
916 921
922 // In strict mode 'arguments' does not alias formal parameters.
923 // Therefore in strict mode we allocate parameters as if 'arguments'
924 // were not used.
925 rewrite_parameters = !is_strict_mode();
926 }
927
928 if (rewrite_parameters) {
917 // We also need the '.arguments' shadow variable. Declare it and create 929 // We also need the '.arguments' shadow variable. Declare it and create
918 // and bind the corresponding proxy. It's ok to declare it only now 930 // and bind the corresponding proxy. It's ok to declare it only now
919 // because it's a local variable that is allocated after the parameters 931 // because it's a local variable that is allocated after the parameters
920 // have been allocated. 932 // have been allocated.
921 // 933 //
922 // Note: This is "almost" at temporary variable but we cannot use 934 // Note: This is "almost" at temporary variable but we cannot use
923 // NewTemporary() because the mode needs to be INTERNAL since this 935 // NewTemporary() because the mode needs to be INTERNAL since this
924 // variable may be allocated in the heap-allocated context (temporaries 936 // variable may be allocated in the heap-allocated context (temporaries
925 // are never allocated in the context). 937 // are never allocated in the context).
926 arguments_shadow_ = new Variable(this, 938 arguments_shadow_ = new Variable(this,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1071 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1060 !must_have_local_context) { 1072 !must_have_local_context) {
1061 num_heap_slots_ = 0; 1073 num_heap_slots_ = 0;
1062 } 1074 }
1063 1075
1064 // Allocation done. 1076 // Allocation done.
1065 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1077 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1066 } 1078 }
1067 1079
1068 } } // namespace v8::internal 1080 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698