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

Side by Side Diff: src/contexts.cc

Issue 2233673003: Remove CONST_LEGACY VariableMode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 3 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
« no previous file with comments | « src/compiler/js-global-object-specialization.cc ('k') | src/crankshaft/hydrogen.cc » ('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 // 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/contexts.h" 5 #include "src/contexts.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 171 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
172 isolate, blacklist, 172 isolate, blacklist,
173 JSReceiver::GetProperty(Handle<JSReceiver>::cast(unscopables), 173 JSReceiver::GetProperty(Handle<JSReceiver>::cast(unscopables),
174 it->name()), 174 it->name()),
175 Nothing<bool>()); 175 Nothing<bool>());
176 return Just(!blacklist->BooleanValue()); 176 return Just(!blacklist->BooleanValue());
177 } 177 }
178 178
179 static PropertyAttributes GetAttributesForMode(VariableMode mode) { 179 static PropertyAttributes GetAttributesForMode(VariableMode mode) {
180 DCHECK(IsDeclaredVariableMode(mode)); 180 DCHECK(IsDeclaredVariableMode(mode));
181 return IsImmutableVariableMode(mode) ? READ_ONLY : NONE; 181 return mode == CONST ? READ_ONLY : NONE;
182 } 182 }
183 183
184 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, 184 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
185 int* index, PropertyAttributes* attributes, 185 int* index, PropertyAttributes* attributes,
186 InitializationFlag* init_flag, 186 InitializationFlag* init_flag,
187 VariableMode* variable_mode) { 187 VariableMode* variable_mode) {
188 Isolate* isolate = GetIsolate(); 188 Isolate* isolate = GetIsolate();
189 Handle<Context> context(this, isolate); 189 Handle<Context> context(this, isolate);
190 190
191 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; 191 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 slot_index, mode); 300 slot_index, mode);
301 } 301 }
302 *index = slot_index; 302 *index = slot_index;
303 *variable_mode = mode; 303 *variable_mode = mode;
304 *init_flag = flag; 304 *init_flag = flag;
305 *attributes = GetAttributesForMode(mode); 305 *attributes = GetAttributesForMode(mode);
306 return context; 306 return context;
307 } 307 }
308 308
309 // Check the slot corresponding to the intermediate context holding 309 // Check the slot corresponding to the intermediate context holding
310 // only the function name variable. 310 // only the function name variable. It's conceptually (and spec-wise)
311 if (follow_context_chain && context->IsFunctionContext()) { 311 // in an outer scope of the function's declaration scope.
312 VariableMode mode; 312 if (follow_context_chain && (flags & STOP_AT_DECLARATION_SCOPE) == 0 &&
313 int function_index = scope_info->FunctionContextSlotIndex(*name, &mode); 313 context->IsFunctionContext()) {
314 int function_index = scope_info->FunctionContextSlotIndex(*name);
314 if (function_index >= 0) { 315 if (function_index >= 0) {
315 if (FLAG_trace_contexts) { 316 if (FLAG_trace_contexts) {
316 PrintF("=> found intermediate function in context slot %d\n", 317 PrintF("=> found intermediate function in context slot %d\n",
317 function_index); 318 function_index);
318 } 319 }
319 *index = function_index; 320 *index = function_index;
320 *attributes = READ_ONLY; 321 *attributes = READ_ONLY;
321 DCHECK(mode == CONST_LEGACY || mode == CONST);
322 *init_flag = kCreatedInitialized; 322 *init_flag = kCreatedInitialized;
323 *variable_mode = mode; 323 *variable_mode = CONST;
324 return context; 324 return context;
325 } 325 }
326 } 326 }
327 327
328 } else if (context->IsCatchContext()) { 328 } else if (context->IsCatchContext()) {
329 // Catch contexts have the variable name in the extension slot. 329 // Catch contexts have the variable name in the extension slot.
330 if (String::Equals(name, handle(context->catch_name()))) { 330 if (String::Equals(name, handle(context->catch_name()))) {
331 if (FLAG_trace_contexts) { 331 if (FLAG_trace_contexts) {
332 PrintF("=> found in catch context\n"); 332 PrintF("=> found in catch context\n");
333 } 333 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 int previous_value = errors_thrown()->value(); 556 int previous_value = errors_thrown()->value();
557 set_errors_thrown(Smi::FromInt(previous_value + 1)); 557 set_errors_thrown(Smi::FromInt(previous_value + 1));
558 } 558 }
559 559
560 560
561 int Context::GetErrorsThrown() { return errors_thrown()->value(); } 561 int Context::GetErrorsThrown() { return errors_thrown()->value(); }
562 562
563 } // namespace internal 563 } // namespace internal
564 } // namespace v8 564 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-global-object-specialization.cc ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698