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

Side by Side Diff: src/contexts.cc

Issue 7187007: Merge arguments branch to bleeding edge (second try). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Undelete external-array test. Created 9 years, 6 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/contexts.h ('k') | src/extensions/experimental/i18n.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 JSObject* Context::global_proxy() { 68 JSObject* Context::global_proxy() {
69 return global_context()->global_proxy_object(); 69 return global_context()->global_proxy_object();
70 } 70 }
71 71
72 void Context::set_global_proxy(JSObject* object) { 72 void Context::set_global_proxy(JSObject* object) {
73 global_context()->set_global_proxy_object(object); 73 global_context()->set_global_proxy_object(object);
74 } 74 }
75 75
76 76
77 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, 77 Handle<Object> Context::Lookup(Handle<String> name,
78 int* index_, PropertyAttributes* attributes) { 78 ContextLookupFlags flags,
79 int* index_,
80 PropertyAttributes* attributes) {
79 Isolate* isolate = GetIsolate(); 81 Isolate* isolate = GetIsolate();
80 Handle<Context> context(this, isolate); 82 Handle<Context> context(this, isolate);
81 83
82 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; 84 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
83 *index_ = -1; 85 *index_ = -1;
84 *attributes = ABSENT; 86 *attributes = ABSENT;
85 87
86 if (FLAG_trace_contexts) { 88 if (FLAG_trace_contexts) {
87 PrintF("Context::Lookup("); 89 PrintF("Context::Lookup(");
88 name->ShortPrint(); 90 name->ShortPrint();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 PrintF("=> found property in context object %p\n", 130 PrintF("=> found property in context object %p\n",
129 reinterpret_cast<void*>(*extension)); 131 reinterpret_cast<void*>(*extension));
130 } 132 }
131 return extension; 133 return extension;
132 } 134 }
133 } 135 }
134 } 136 }
135 137
136 // Only functions can have locals, parameters, and a function name. 138 // Only functions can have locals, parameters, and a function name.
137 if (context->IsFunctionContext()) { 139 if (context->IsFunctionContext()) {
138 // we have context-local slots 140 // We may have context-local slots. Check locals in the context.
139
140 // check non-parameter locals in context
141 Handle<SerializedScopeInfo> scope_info( 141 Handle<SerializedScopeInfo> scope_info(
142 context->closure()->shared()->scope_info(), isolate); 142 context->closure()->shared()->scope_info(), isolate);
143 Variable::Mode mode; 143 Variable::Mode mode;
144 int index = scope_info->ContextSlotIndex(*name, &mode); 144 int index = scope_info->ContextSlotIndex(*name, &mode);
145 ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS); 145 ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS);
146 if (index >= 0) { 146 if (index >= 0) {
147 // slot found
148 if (FLAG_trace_contexts) { 147 if (FLAG_trace_contexts) {
149 PrintF("=> found local in context slot %d (mode = %d)\n", 148 PrintF("=> found local in context slot %d (mode = %d)\n",
150 index, mode); 149 index, mode);
151 } 150 }
152 *index_ = index; 151 *index_ = index;
153 // Note: Fixed context slots are statically allocated by the compiler. 152 // Note: Fixed context slots are statically allocated by the compiler.
154 // Statically allocated variables always have a statically known mode, 153 // Statically allocated variables always have a statically known mode,
155 // which is the mode with which they were declared when added to the 154 // which is the mode with which they were declared when added to the
156 // scope. Thus, the DYNAMIC mode (which corresponds to dynamically 155 // scope. Thus, the DYNAMIC mode (which corresponds to dynamically
157 // declared variables that were introduced through declaration nodes) 156 // declared variables that were introduced through declaration nodes)
158 // must not appear here. 157 // must not appear here.
159 switch (mode) { 158 switch (mode) {
160 case Variable::INTERNAL: // fall through 159 case Variable::INTERNAL: // Fall through.
161 case Variable::VAR: *attributes = NONE; break; 160 case Variable::VAR:
162 case Variable::CONST: *attributes = READ_ONLY; break; 161 *attributes = NONE;
163 case Variable::DYNAMIC: UNREACHABLE(); break; 162 break;
164 case Variable::DYNAMIC_GLOBAL: UNREACHABLE(); break; 163 case Variable::CONST:
165 case Variable::DYNAMIC_LOCAL: UNREACHABLE(); break; 164 *attributes = READ_ONLY;
166 case Variable::TEMPORARY: UNREACHABLE(); break; 165 break;
166 case Variable::DYNAMIC:
167 case Variable::DYNAMIC_GLOBAL:
168 case Variable::DYNAMIC_LOCAL:
169 case Variable::TEMPORARY:
170 UNREACHABLE();
171 break;
167 } 172 }
168 return context; 173 return context;
169 } 174 }
170 175
171 // check parameter locals in context 176 // Check the slot corresponding to the intermediate context holding
172 int param_index = scope_info->ParameterIndex(*name); 177 // only the function name variable.
173 if (param_index >= 0) {
174 // slot found.
175 int index = scope_info->ContextSlotIndex(
176 isolate->heap()->arguments_shadow_symbol(), NULL);
177 ASSERT(index >= 0); // arguments must exist and be in the heap context
178 Handle<JSObject> arguments(JSObject::cast(context->get(index)),
179 isolate);
180 if (FLAG_trace_contexts) {
181 PrintF("=> found parameter %d in arguments object\n", param_index);
182 }
183 *index_ = param_index;
184 *attributes = NONE;
185 return arguments;
186 }
187
188 // check intermediate context (holding only the function name variable)
189 if (follow_context_chain) { 178 if (follow_context_chain) {
190 int index = scope_info->FunctionContextSlotIndex(*name); 179 int index = scope_info->FunctionContextSlotIndex(*name);
191 if (index >= 0) { 180 if (index >= 0) {
192 // slot found
193 if (FLAG_trace_contexts) { 181 if (FLAG_trace_contexts) {
194 PrintF("=> found intermediate function in context slot %d\n", 182 PrintF("=> found intermediate function in context slot %d\n",
195 index); 183 index);
196 } 184 }
197 *index_ = index; 185 *index_ = index;
198 *attributes = READ_ONLY; 186 *attributes = READ_ONLY;
199 return context; 187 return context;
200 } 188 }
201 } 189 }
202 } 190 }
203 191
204 // Proceed with the previous context. 192 // Proceed with the previous context.
205 if (context->IsGlobalContext()) { 193 if (context->IsGlobalContext()) {
206 follow_context_chain = false; 194 follow_context_chain = false;
207 } else { 195 } else {
208 context = Handle<Context>(context->previous(), isolate); 196 context = Handle<Context>(context->previous(), isolate);
209 } 197 }
210 } while (follow_context_chain); 198 } while (follow_context_chain);
211 199
212 // slot not found
213 if (FLAG_trace_contexts) { 200 if (FLAG_trace_contexts) {
214 PrintF("=> no property/slot found\n"); 201 PrintF("=> no property/slot found\n");
215 } 202 }
216 return Handle<Object>::null(); 203 return Handle<Object>::null();
217 } 204 }
218 205
219 206
220 bool Context::GlobalIfNotShadowedByEval(Handle<String> name) { 207 bool Context::GlobalIfNotShadowedByEval(Handle<String> name) {
221 Context* context = this; 208 Context* context = this;
222 209
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // During bootstrapping we allow all objects to pass as global 339 // During bootstrapping we allow all objects to pass as global
353 // objects. This is necessary to fix circular dependencies. 340 // objects. This is necessary to fix circular dependencies.
354 Isolate* isolate = Isolate::Current(); 341 Isolate* isolate = Isolate::Current();
355 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || 342 return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
356 isolate->bootstrapper()->IsActive() || 343 isolate->bootstrapper()->IsActive() ||
357 object->IsGlobalObject(); 344 object->IsGlobalObject();
358 } 345 }
359 #endif 346 #endif
360 347
361 } } // namespace v8::internal 348 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/extensions/experimental/i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698