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

Side by Side Diff: src/ast/scopeinfo.cc

Issue 2232633002: Function name variable does not need a VariableDeclaration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 4 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 | « no previous file | src/ast/scopes.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 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/ast/scopeinfo.h" 5 #include "src/ast/scopeinfo.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "src/ast/context-slot-cache.h" 9 #include "src/ast/context-slot-cache.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 bool has_new_target = 50 bool has_new_target =
51 scope->is_declaration_scope() && 51 scope->is_declaration_scope() &&
52 scope->AsDeclarationScope()->new_target_var() != nullptr; 52 scope->AsDeclarationScope()->new_target_var() != nullptr;
53 53
54 // Determine use and location of the function variable if it is present. 54 // Determine use and location of the function variable if it is present.
55 VariableAllocationInfo function_name_info; 55 VariableAllocationInfo function_name_info;
56 VariableMode function_variable_mode; 56 VariableMode function_variable_mode;
57 if (scope->is_function_scope() && 57 if (scope->is_function_scope() &&
58 scope->AsDeclarationScope()->function() != nullptr) { 58 scope->AsDeclarationScope()->function_var() != nullptr) {
59 Variable* var = scope->AsDeclarationScope()->function()->proxy()->var(); 59 Variable* var = scope->AsDeclarationScope()->function_var();
60 if (!var->is_used()) { 60 if (!var->is_used()) {
61 function_name_info = UNUSED; 61 function_name_info = UNUSED;
62 } else if (var->IsContextSlot()) { 62 } else if (var->IsContextSlot()) {
63 function_name_info = CONTEXT; 63 function_name_info = CONTEXT;
64 } else { 64 } else {
65 DCHECK(var->IsStackLocal()); 65 DCHECK(var->IsStackLocal());
66 function_name_info = STACK; 66 function_name_info = STACK;
67 } 67 }
68 function_variable_mode = var->mode(); 68 function_variable_mode = var->mode();
69 } else { 69 } else {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (has_receiver) { 185 if (has_receiver) {
186 int var_index = scope->AsDeclarationScope()->receiver()->index(); 186 int var_index = scope->AsDeclarationScope()->receiver()->index();
187 scope_info->set(index++, Smi::FromInt(var_index)); 187 scope_info->set(index++, Smi::FromInt(var_index));
188 // ?? DCHECK(receiver_info != CONTEXT || var_index == 188 // ?? DCHECK(receiver_info != CONTEXT || var_index ==
189 // scope_info->ContextLength() - 1); 189 // scope_info->ContextLength() - 1);
190 } 190 }
191 191
192 // If present, add the function variable name and its index. 192 // If present, add the function variable name and its index.
193 DCHECK(index == scope_info->FunctionNameEntryIndex()); 193 DCHECK(index == scope_info->FunctionNameEntryIndex());
194 if (has_function_name) { 194 if (has_function_name) {
195 int var_index = 195 int var_index = scope->AsDeclarationScope()->function_var()->index();
196 scope->AsDeclarationScope()->function()->proxy()->var()->index();
197 scope_info->set(index++, 196 scope_info->set(index++,
198 *scope->AsDeclarationScope()->function()->proxy()->name()); 197 *scope->AsDeclarationScope()->function_var()->name());
199 scope_info->set(index++, Smi::FromInt(var_index)); 198 scope_info->set(index++, Smi::FromInt(var_index));
200 DCHECK(function_name_info != CONTEXT || 199 DCHECK(function_name_info != CONTEXT ||
201 var_index == scope_info->ContextLength() - 1); 200 var_index == scope_info->ContextLength() - 1);
202 } 201 }
203 202
204 DCHECK(index == scope_info->length()); 203 DCHECK(index == scope_info->length());
205 DCHECK(scope->num_parameters() == scope_info->ParameterCount()); 204 DCHECK(scope->num_parameters() == scope_info->ParameterCount());
206 DCHECK(scope->num_heap_slots() == scope_info->ContextLength() || 205 DCHECK(scope->num_heap_slots() == scope_info->ContextLength() ||
207 (scope->num_heap_slots() == kVariablePartIndex && 206 (scope->num_heap_slots() == kVariablePartIndex &&
208 scope_info->ContextLength() == 0)); 207 scope_info->ContextLength() == 0));
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 ContextLocalNameEntriesIndex() + ContextLocalCount(), this); 691 ContextLocalNameEntriesIndex() + ContextLocalCount(), this);
693 } 692 }
694 693
695 PrintF("}\n"); 694 PrintF("}\n");
696 } 695 }
697 #endif // DEBUG 696 #endif // DEBUG
698 697
699 698
700 } // namespace internal 699 } // namespace internal
701 } // namespace v8 700 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698