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

Side by Side Diff: src/scopeinfo.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/scopeinfo.h ('k') | src/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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/scopeinfo.h" 9 #include "src/scopeinfo.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone* zone) { 16 Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone* zone) {
17 // Collect stack and context locals. 17 // Collect stack and context locals.
18 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); 18 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone);
19 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); 19 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone);
20 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); 20 scope->CollectStackAndContextLocals(&stack_locals, &context_locals);
21 const int stack_local_count = stack_locals.length(); 21 const int stack_local_count = stack_locals.length();
22 const int context_local_count = context_locals.length(); 22 const int context_local_count = context_locals.length();
23 // Make sure we allocate the correct amount. 23 // Make sure we allocate the correct amount.
24 ASSERT(scope->StackLocalCount() == stack_local_count); 24 DCHECK(scope->StackLocalCount() == stack_local_count);
25 ASSERT(scope->ContextLocalCount() == context_local_count); 25 DCHECK(scope->ContextLocalCount() == context_local_count);
26 26
27 // Determine use and location of the function variable if it is present. 27 // Determine use and location of the function variable if it is present.
28 FunctionVariableInfo function_name_info; 28 FunctionVariableInfo function_name_info;
29 VariableMode function_variable_mode; 29 VariableMode function_variable_mode;
30 if (scope->is_function_scope() && scope->function() != NULL) { 30 if (scope->is_function_scope() && scope->function() != NULL) {
31 Variable* var = scope->function()->proxy()->var(); 31 Variable* var = scope->function()->proxy()->var();
32 if (!var->is_used()) { 32 if (!var->is_used()) {
33 function_name_info = UNUSED; 33 function_name_info = UNUSED;
34 } else if (var->IsContextSlot()) { 34 } else if (var->IsContextSlot()) {
35 function_name_info = CONTEXT; 35 function_name_info = CONTEXT;
36 } else { 36 } else {
37 ASSERT(var->IsStackLocal()); 37 DCHECK(var->IsStackLocal());
38 function_name_info = STACK; 38 function_name_info = STACK;
39 } 39 }
40 function_variable_mode = var->mode(); 40 function_variable_mode = var->mode();
41 } else { 41 } else {
42 function_name_info = NONE; 42 function_name_info = NONE;
43 function_variable_mode = VAR; 43 function_variable_mode = VAR;
44 } 44 }
45 45
46 const bool has_function_name = function_name_info != NONE; 46 const bool has_function_name = function_name_info != NONE;
47 const int parameter_count = scope->num_parameters(); 47 const int parameter_count = scope->num_parameters();
(...skipping 10 matching lines...) Expand all
58 StrictModeField::encode(scope->strict_mode()) | 58 StrictModeField::encode(scope->strict_mode()) |
59 FunctionVariableField::encode(function_name_info) | 59 FunctionVariableField::encode(function_name_info) |
60 FunctionVariableMode::encode(function_variable_mode); 60 FunctionVariableMode::encode(function_variable_mode);
61 scope_info->SetFlags(flags); 61 scope_info->SetFlags(flags);
62 scope_info->SetParameterCount(parameter_count); 62 scope_info->SetParameterCount(parameter_count);
63 scope_info->SetStackLocalCount(stack_local_count); 63 scope_info->SetStackLocalCount(stack_local_count);
64 scope_info->SetContextLocalCount(context_local_count); 64 scope_info->SetContextLocalCount(context_local_count);
65 65
66 int index = kVariablePartIndex; 66 int index = kVariablePartIndex;
67 // Add parameters. 67 // Add parameters.
68 ASSERT(index == scope_info->ParameterEntriesIndex()); 68 DCHECK(index == scope_info->ParameterEntriesIndex());
69 for (int i = 0; i < parameter_count; ++i) { 69 for (int i = 0; i < parameter_count; ++i) {
70 scope_info->set(index++, *scope->parameter(i)->name()); 70 scope_info->set(index++, *scope->parameter(i)->name());
71 } 71 }
72 72
73 // Add stack locals' names. We are assuming that the stack locals' 73 // Add stack locals' names. We are assuming that the stack locals'
74 // slots are allocated in increasing order, so we can simply add 74 // slots are allocated in increasing order, so we can simply add
75 // them to the ScopeInfo object. 75 // them to the ScopeInfo object.
76 ASSERT(index == scope_info->StackLocalEntriesIndex()); 76 DCHECK(index == scope_info->StackLocalEntriesIndex());
77 for (int i = 0; i < stack_local_count; ++i) { 77 for (int i = 0; i < stack_local_count; ++i) {
78 ASSERT(stack_locals[i]->index() == i); 78 DCHECK(stack_locals[i]->index() == i);
79 scope_info->set(index++, *stack_locals[i]->name()); 79 scope_info->set(index++, *stack_locals[i]->name());
80 } 80 }
81 81
82 // Due to usage analysis, context-allocated locals are not necessarily in 82 // Due to usage analysis, context-allocated locals are not necessarily in
83 // increasing order: Some of them may be parameters which are allocated before 83 // increasing order: Some of them may be parameters which are allocated before
84 // the non-parameter locals. When the non-parameter locals are sorted 84 // the non-parameter locals. When the non-parameter locals are sorted
85 // according to usage, the allocated slot indices may not be in increasing 85 // according to usage, the allocated slot indices may not be in increasing
86 // order with the variable list anymore. Thus, we first need to sort them by 86 // order with the variable list anymore. Thus, we first need to sort them by
87 // context slot index before adding them to the ScopeInfo object. 87 // context slot index before adding them to the ScopeInfo object.
88 context_locals.Sort(&Variable::CompareIndex); 88 context_locals.Sort(&Variable::CompareIndex);
89 89
90 // Add context locals' names. 90 // Add context locals' names.
91 ASSERT(index == scope_info->ContextLocalNameEntriesIndex()); 91 DCHECK(index == scope_info->ContextLocalNameEntriesIndex());
92 for (int i = 0; i < context_local_count; ++i) { 92 for (int i = 0; i < context_local_count; ++i) {
93 scope_info->set(index++, *context_locals[i]->name()); 93 scope_info->set(index++, *context_locals[i]->name());
94 } 94 }
95 95
96 // Add context locals' info. 96 // Add context locals' info.
97 ASSERT(index == scope_info->ContextLocalInfoEntriesIndex()); 97 DCHECK(index == scope_info->ContextLocalInfoEntriesIndex());
98 for (int i = 0; i < context_local_count; ++i) { 98 for (int i = 0; i < context_local_count; ++i) {
99 Variable* var = context_locals[i]; 99 Variable* var = context_locals[i];
100 uint32_t value = 100 uint32_t value =
101 ContextLocalMode::encode(var->mode()) | 101 ContextLocalMode::encode(var->mode()) |
102 ContextLocalInitFlag::encode(var->initialization_flag()) | 102 ContextLocalInitFlag::encode(var->initialization_flag()) |
103 ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned()); 103 ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned());
104 scope_info->set(index++, Smi::FromInt(value)); 104 scope_info->set(index++, Smi::FromInt(value));
105 } 105 }
106 106
107 // If present, add the function variable name and its index. 107 // If present, add the function variable name and its index.
108 ASSERT(index == scope_info->FunctionNameEntryIndex()); 108 DCHECK(index == scope_info->FunctionNameEntryIndex());
109 if (has_function_name) { 109 if (has_function_name) {
110 int var_index = scope->function()->proxy()->var()->index(); 110 int var_index = scope->function()->proxy()->var()->index();
111 scope_info->set(index++, *scope->function()->proxy()->name()); 111 scope_info->set(index++, *scope->function()->proxy()->name());
112 scope_info->set(index++, Smi::FromInt(var_index)); 112 scope_info->set(index++, Smi::FromInt(var_index));
113 ASSERT(function_name_info != STACK || 113 DCHECK(function_name_info != STACK ||
114 (var_index == scope_info->StackLocalCount() && 114 (var_index == scope_info->StackLocalCount() &&
115 var_index == scope_info->StackSlotCount() - 1)); 115 var_index == scope_info->StackSlotCount() - 1));
116 ASSERT(function_name_info != CONTEXT || 116 DCHECK(function_name_info != CONTEXT ||
117 var_index == scope_info->ContextLength() - 1); 117 var_index == scope_info->ContextLength() - 1);
118 } 118 }
119 119
120 ASSERT(index == scope_info->length()); 120 DCHECK(index == scope_info->length());
121 ASSERT(scope->num_parameters() == scope_info->ParameterCount()); 121 DCHECK(scope->num_parameters() == scope_info->ParameterCount());
122 ASSERT(scope->num_stack_slots() == scope_info->StackSlotCount()); 122 DCHECK(scope->num_stack_slots() == scope_info->StackSlotCount());
123 ASSERT(scope->num_heap_slots() == scope_info->ContextLength() || 123 DCHECK(scope->num_heap_slots() == scope_info->ContextLength() ||
124 (scope->num_heap_slots() == kVariablePartIndex && 124 (scope->num_heap_slots() == kVariablePartIndex &&
125 scope_info->ContextLength() == 0)); 125 scope_info->ContextLength() == 0));
126 return scope_info; 126 return scope_info;
127 } 127 }
128 128
129 129
130 ScopeInfo* ScopeInfo::Empty(Isolate* isolate) { 130 ScopeInfo* ScopeInfo::Empty(Isolate* isolate) {
131 return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array()); 131 return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array());
132 } 132 }
133 133
134 134
135 ScopeType ScopeInfo::scope_type() { 135 ScopeType ScopeInfo::scope_type() {
136 ASSERT(length() > 0); 136 DCHECK(length() > 0);
137 return ScopeTypeField::decode(Flags()); 137 return ScopeTypeField::decode(Flags());
138 } 138 }
139 139
140 140
141 bool ScopeInfo::CallsEval() { 141 bool ScopeInfo::CallsEval() {
142 return length() > 0 && CallsEvalField::decode(Flags()); 142 return length() > 0 && CallsEvalField::decode(Flags());
143 } 143 }
144 144
145 145
146 StrictMode ScopeInfo::strict_mode() { 146 StrictMode ScopeInfo::strict_mode() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 } 200 }
201 201
202 202
203 bool ScopeInfo::HasContext() { 203 bool ScopeInfo::HasContext() {
204 return ContextLength() > 0; 204 return ContextLength() > 0;
205 } 205 }
206 206
207 207
208 String* ScopeInfo::FunctionName() { 208 String* ScopeInfo::FunctionName() {
209 ASSERT(HasFunctionName()); 209 DCHECK(HasFunctionName());
210 return String::cast(get(FunctionNameEntryIndex())); 210 return String::cast(get(FunctionNameEntryIndex()));
211 } 211 }
212 212
213 213
214 String* ScopeInfo::ParameterName(int var) { 214 String* ScopeInfo::ParameterName(int var) {
215 ASSERT(0 <= var && var < ParameterCount()); 215 DCHECK(0 <= var && var < ParameterCount());
216 int info_index = ParameterEntriesIndex() + var; 216 int info_index = ParameterEntriesIndex() + var;
217 return String::cast(get(info_index)); 217 return String::cast(get(info_index));
218 } 218 }
219 219
220 220
221 String* ScopeInfo::LocalName(int var) { 221 String* ScopeInfo::LocalName(int var) {
222 ASSERT(0 <= var && var < LocalCount()); 222 DCHECK(0 <= var && var < LocalCount());
223 ASSERT(StackLocalEntriesIndex() + StackLocalCount() == 223 DCHECK(StackLocalEntriesIndex() + StackLocalCount() ==
224 ContextLocalNameEntriesIndex()); 224 ContextLocalNameEntriesIndex());
225 int info_index = StackLocalEntriesIndex() + var; 225 int info_index = StackLocalEntriesIndex() + var;
226 return String::cast(get(info_index)); 226 return String::cast(get(info_index));
227 } 227 }
228 228
229 229
230 String* ScopeInfo::StackLocalName(int var) { 230 String* ScopeInfo::StackLocalName(int var) {
231 ASSERT(0 <= var && var < StackLocalCount()); 231 DCHECK(0 <= var && var < StackLocalCount());
232 int info_index = StackLocalEntriesIndex() + var; 232 int info_index = StackLocalEntriesIndex() + var;
233 return String::cast(get(info_index)); 233 return String::cast(get(info_index));
234 } 234 }
235 235
236 236
237 String* ScopeInfo::ContextLocalName(int var) { 237 String* ScopeInfo::ContextLocalName(int var) {
238 ASSERT(0 <= var && var < ContextLocalCount()); 238 DCHECK(0 <= var && var < ContextLocalCount());
239 int info_index = ContextLocalNameEntriesIndex() + var; 239 int info_index = ContextLocalNameEntriesIndex() + var;
240 return String::cast(get(info_index)); 240 return String::cast(get(info_index));
241 } 241 }
242 242
243 243
244 VariableMode ScopeInfo::ContextLocalMode(int var) { 244 VariableMode ScopeInfo::ContextLocalMode(int var) {
245 ASSERT(0 <= var && var < ContextLocalCount()); 245 DCHECK(0 <= var && var < ContextLocalCount());
246 int info_index = ContextLocalInfoEntriesIndex() + var; 246 int info_index = ContextLocalInfoEntriesIndex() + var;
247 int value = Smi::cast(get(info_index))->value(); 247 int value = Smi::cast(get(info_index))->value();
248 return ContextLocalMode::decode(value); 248 return ContextLocalMode::decode(value);
249 } 249 }
250 250
251 251
252 InitializationFlag ScopeInfo::ContextLocalInitFlag(int var) { 252 InitializationFlag ScopeInfo::ContextLocalInitFlag(int var) {
253 ASSERT(0 <= var && var < ContextLocalCount()); 253 DCHECK(0 <= var && var < ContextLocalCount());
254 int info_index = ContextLocalInfoEntriesIndex() + var; 254 int info_index = ContextLocalInfoEntriesIndex() + var;
255 int value = Smi::cast(get(info_index))->value(); 255 int value = Smi::cast(get(info_index))->value();
256 return ContextLocalInitFlag::decode(value); 256 return ContextLocalInitFlag::decode(value);
257 } 257 }
258 258
259 259
260 MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) { 260 MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) {
261 ASSERT(0 <= var && var < ContextLocalCount()); 261 DCHECK(0 <= var && var < ContextLocalCount());
262 int info_index = ContextLocalInfoEntriesIndex() + var; 262 int info_index = ContextLocalInfoEntriesIndex() + var;
263 int value = Smi::cast(get(info_index))->value(); 263 int value = Smi::cast(get(info_index))->value();
264 return ContextLocalMaybeAssignedFlag::decode(value); 264 return ContextLocalMaybeAssignedFlag::decode(value);
265 } 265 }
266 266
267 267
268 bool ScopeInfo::LocalIsSynthetic(int var) { 268 bool ScopeInfo::LocalIsSynthetic(int var) {
269 ASSERT(0 <= var && var < LocalCount()); 269 DCHECK(0 <= var && var < LocalCount());
270 // There's currently no flag stored on the ScopeInfo to indicate that a 270 // There's currently no flag stored on the ScopeInfo to indicate that a
271 // variable is a compiler-introduced temporary. However, to avoid conflict 271 // variable is a compiler-introduced temporary. However, to avoid conflict
272 // with user declarations, the current temporaries like .generator_object and 272 // with user declarations, the current temporaries like .generator_object and
273 // .result start with a dot, so we can use that as a flag. It's a hack! 273 // .result start with a dot, so we can use that as a flag. It's a hack!
274 Handle<String> name(LocalName(var)); 274 Handle<String> name(LocalName(var));
275 return name->length() > 0 && name->Get(0) == '.'; 275 return name->length() > 0 && name->Get(0) == '.';
276 } 276 }
277 277
278 278
279 int ScopeInfo::StackSlotIndex(String* name) { 279 int ScopeInfo::StackSlotIndex(String* name) {
280 ASSERT(name->IsInternalizedString()); 280 DCHECK(name->IsInternalizedString());
281 if (length() > 0) { 281 if (length() > 0) {
282 int start = StackLocalEntriesIndex(); 282 int start = StackLocalEntriesIndex();
283 int end = StackLocalEntriesIndex() + StackLocalCount(); 283 int end = StackLocalEntriesIndex() + StackLocalCount();
284 for (int i = start; i < end; ++i) { 284 for (int i = start; i < end; ++i) {
285 if (name == get(i)) { 285 if (name == get(i)) {
286 return i - start; 286 return i - start;
287 } 287 }
288 } 288 }
289 } 289 }
290 return -1; 290 return -1;
291 } 291 }
292 292
293 293
294 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info, 294 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
295 Handle<String> name, VariableMode* mode, 295 Handle<String> name, VariableMode* mode,
296 InitializationFlag* init_flag, 296 InitializationFlag* init_flag,
297 MaybeAssignedFlag* maybe_assigned_flag) { 297 MaybeAssignedFlag* maybe_assigned_flag) {
298 ASSERT(name->IsInternalizedString()); 298 DCHECK(name->IsInternalizedString());
299 ASSERT(mode != NULL); 299 DCHECK(mode != NULL);
300 ASSERT(init_flag != NULL); 300 DCHECK(init_flag != NULL);
301 if (scope_info->length() > 0) { 301 if (scope_info->length() > 0) {
302 ContextSlotCache* context_slot_cache = 302 ContextSlotCache* context_slot_cache =
303 scope_info->GetIsolate()->context_slot_cache(); 303 scope_info->GetIsolate()->context_slot_cache();
304 int result = context_slot_cache->Lookup(*scope_info, *name, mode, init_flag, 304 int result = context_slot_cache->Lookup(*scope_info, *name, mode, init_flag,
305 maybe_assigned_flag); 305 maybe_assigned_flag);
306 if (result != ContextSlotCache::kNotFound) { 306 if (result != ContextSlotCache::kNotFound) {
307 ASSERT(result < scope_info->ContextLength()); 307 DCHECK(result < scope_info->ContextLength());
308 return result; 308 return result;
309 } 309 }
310 310
311 int start = scope_info->ContextLocalNameEntriesIndex(); 311 int start = scope_info->ContextLocalNameEntriesIndex();
312 int end = scope_info->ContextLocalNameEntriesIndex() + 312 int end = scope_info->ContextLocalNameEntriesIndex() +
313 scope_info->ContextLocalCount(); 313 scope_info->ContextLocalCount();
314 for (int i = start; i < end; ++i) { 314 for (int i = start; i < end; ++i) {
315 if (*name == scope_info->get(i)) { 315 if (*name == scope_info->get(i)) {
316 int var = i - start; 316 int var = i - start;
317 *mode = scope_info->ContextLocalMode(var); 317 *mode = scope_info->ContextLocalMode(var);
318 *init_flag = scope_info->ContextLocalInitFlag(var); 318 *init_flag = scope_info->ContextLocalInitFlag(var);
319 *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var); 319 *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var);
320 result = Context::MIN_CONTEXT_SLOTS + var; 320 result = Context::MIN_CONTEXT_SLOTS + var;
321 context_slot_cache->Update(scope_info, name, *mode, *init_flag, 321 context_slot_cache->Update(scope_info, name, *mode, *init_flag,
322 *maybe_assigned_flag, result); 322 *maybe_assigned_flag, result);
323 ASSERT(result < scope_info->ContextLength()); 323 DCHECK(result < scope_info->ContextLength());
324 return result; 324 return result;
325 } 325 }
326 } 326 }
327 // Cache as not found. Mode, init flag and maybe assigned flag don't matter. 327 // Cache as not found. Mode, init flag and maybe assigned flag don't matter.
328 context_slot_cache->Update(scope_info, name, INTERNAL, kNeedsInitialization, 328 context_slot_cache->Update(scope_info, name, INTERNAL, kNeedsInitialization,
329 kNotAssigned, -1); 329 kNotAssigned, -1);
330 } 330 }
331 return -1; 331 return -1;
332 } 332 }
333 333
334 334
335 int ScopeInfo::ParameterIndex(String* name) { 335 int ScopeInfo::ParameterIndex(String* name) {
336 ASSERT(name->IsInternalizedString()); 336 DCHECK(name->IsInternalizedString());
337 if (length() > 0) { 337 if (length() > 0) {
338 // We must read parameters from the end since for 338 // We must read parameters from the end since for
339 // multiply declared parameters the value of the 339 // multiply declared parameters the value of the
340 // last declaration of that parameter is used 340 // last declaration of that parameter is used
341 // inside a function (and thus we need to look 341 // inside a function (and thus we need to look
342 // at the last index). Was bug# 1110337. 342 // at the last index). Was bug# 1110337.
343 int start = ParameterEntriesIndex(); 343 int start = ParameterEntriesIndex();
344 int end = ParameterEntriesIndex() + ParameterCount(); 344 int end = ParameterEntriesIndex() + ParameterCount();
345 for (int i = end - 1; i >= start; --i) { 345 for (int i = end - 1; i >= start; --i) {
346 if (name == get(i)) { 346 if (name == get(i)) {
347 return i - start; 347 return i - start;
348 } 348 }
349 } 349 }
350 } 350 }
351 return -1; 351 return -1;
352 } 352 }
353 353
354 354
355 int ScopeInfo::FunctionContextSlotIndex(String* name, VariableMode* mode) { 355 int ScopeInfo::FunctionContextSlotIndex(String* name, VariableMode* mode) {
356 ASSERT(name->IsInternalizedString()); 356 DCHECK(name->IsInternalizedString());
357 ASSERT(mode != NULL); 357 DCHECK(mode != NULL);
358 if (length() > 0) { 358 if (length() > 0) {
359 if (FunctionVariableField::decode(Flags()) == CONTEXT && 359 if (FunctionVariableField::decode(Flags()) == CONTEXT &&
360 FunctionName() == name) { 360 FunctionName() == name) {
361 *mode = FunctionVariableMode::decode(Flags()); 361 *mode = FunctionVariableMode::decode(Flags());
362 return Smi::cast(get(FunctionNameEntryIndex() + 1))->value(); 362 return Smi::cast(get(FunctionNameEntryIndex() + 1))->value();
363 } 363 }
364 } 364 }
365 return -1; 365 return -1;
366 } 366 }
367 367
(...skipping 17 matching lines...) Expand all
385 Handle<String>(String::cast(scope_info->get(i + start))), 385 Handle<String>(String::cast(scope_info->get(i + start))),
386 Handle<Object>(context->get(context_index), isolate), 386 Handle<Object>(context->get(context_index), isolate),
387 ::NONE), 387 ::NONE),
388 false); 388 false);
389 } 389 }
390 return true; 390 return true;
391 } 391 }
392 392
393 393
394 int ScopeInfo::ParameterEntriesIndex() { 394 int ScopeInfo::ParameterEntriesIndex() {
395 ASSERT(length() > 0); 395 DCHECK(length() > 0);
396 return kVariablePartIndex; 396 return kVariablePartIndex;
397 } 397 }
398 398
399 399
400 int ScopeInfo::StackLocalEntriesIndex() { 400 int ScopeInfo::StackLocalEntriesIndex() {
401 return ParameterEntriesIndex() + ParameterCount(); 401 return ParameterEntriesIndex() + ParameterCount();
402 } 402 }
403 403
404 404
405 int ScopeInfo::ContextLocalNameEntriesIndex() { 405 int ScopeInfo::ContextLocalNameEntriesIndex() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return kNotFound; 441 return kNotFound;
442 } 442 }
443 443
444 444
445 void ContextSlotCache::Update(Handle<Object> data, Handle<String> name, 445 void ContextSlotCache::Update(Handle<Object> data, Handle<String> name,
446 VariableMode mode, InitializationFlag init_flag, 446 VariableMode mode, InitializationFlag init_flag,
447 MaybeAssignedFlag maybe_assigned_flag, 447 MaybeAssignedFlag maybe_assigned_flag,
448 int slot_index) { 448 int slot_index) {
449 DisallowHeapAllocation no_gc; 449 DisallowHeapAllocation no_gc;
450 Handle<String> internalized_name; 450 Handle<String> internalized_name;
451 ASSERT(slot_index > kNotFound); 451 DCHECK(slot_index > kNotFound);
452 if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name). 452 if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name).
453 ToHandle(&internalized_name)) { 453 ToHandle(&internalized_name)) {
454 int index = Hash(*data, *internalized_name); 454 int index = Hash(*data, *internalized_name);
455 Key& key = keys_[index]; 455 Key& key = keys_[index];
456 key.data = *data; 456 key.data = *data;
457 key.name = *internalized_name; 457 key.name = *internalized_name;
458 // Please note value only takes a uint as index. 458 // Please note value only takes a uint as index.
459 values_[index] = Value(mode, init_flag, maybe_assigned_flag, 459 values_[index] = Value(mode, init_flag, maybe_assigned_flag,
460 slot_index - kNotFound).raw(); 460 slot_index - kNotFound).raw();
461 #ifdef DEBUG 461 #ifdef DEBUG
(...skipping 14 matching lines...) Expand all
476 VariableMode mode, 476 VariableMode mode,
477 InitializationFlag init_flag, 477 InitializationFlag init_flag,
478 MaybeAssignedFlag maybe_assigned_flag, 478 MaybeAssignedFlag maybe_assigned_flag,
479 int slot_index) { 479 int slot_index) {
480 DisallowHeapAllocation no_gc; 480 DisallowHeapAllocation no_gc;
481 Handle<String> internalized_name; 481 Handle<String> internalized_name;
482 if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name). 482 if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name).
483 ToHandle(&internalized_name)) { 483 ToHandle(&internalized_name)) {
484 int index = Hash(*data, *name); 484 int index = Hash(*data, *name);
485 Key& key = keys_[index]; 485 Key& key = keys_[index];
486 ASSERT(key.data == *data); 486 DCHECK(key.data == *data);
487 ASSERT(key.name->Equals(*name)); 487 DCHECK(key.name->Equals(*name));
488 Value result(values_[index]); 488 Value result(values_[index]);
489 ASSERT(result.mode() == mode); 489 DCHECK(result.mode() == mode);
490 ASSERT(result.initialization_flag() == init_flag); 490 DCHECK(result.initialization_flag() == init_flag);
491 ASSERT(result.maybe_assigned_flag() == maybe_assigned_flag); 491 DCHECK(result.maybe_assigned_flag() == maybe_assigned_flag);
492 ASSERT(result.index() + kNotFound == slot_index); 492 DCHECK(result.index() + kNotFound == slot_index);
493 } 493 }
494 } 494 }
495 495
496 496
497 static void PrintList(const char* list_name, 497 static void PrintList(const char* list_name,
498 int nof_internal_slots, 498 int nof_internal_slots,
499 int start, 499 int start,
500 int end, 500 int end,
501 ScopeInfo* scope_info) { 501 ScopeInfo* scope_info) {
502 if (start < end) { 502 if (start < end) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 Handle<ModuleInfo> ModuleInfo::Create( 547 Handle<ModuleInfo> ModuleInfo::Create(
548 Isolate* isolate, Interface* interface, Scope* scope) { 548 Isolate* isolate, Interface* interface, Scope* scope) {
549 Handle<ModuleInfo> info = Allocate(isolate, interface->Length()); 549 Handle<ModuleInfo> info = Allocate(isolate, interface->Length());
550 info->set_host_index(interface->Index()); 550 info->set_host_index(interface->Index());
551 int i = 0; 551 int i = 0;
552 for (Interface::Iterator it = interface->iterator(); 552 for (Interface::Iterator it = interface->iterator();
553 !it.done(); it.Advance(), ++i) { 553 !it.done(); it.Advance(), ++i) {
554 Variable* var = scope->LookupLocal(it.name()); 554 Variable* var = scope->LookupLocal(it.name());
555 info->set_name(i, *(it.name()->string())); 555 info->set_name(i, *(it.name()->string()));
556 info->set_mode(i, var->mode()); 556 info->set_mode(i, var->mode());
557 ASSERT((var->mode() == MODULE) == (it.interface()->IsModule())); 557 DCHECK((var->mode() == MODULE) == (it.interface()->IsModule()));
558 if (var->mode() == MODULE) { 558 if (var->mode() == MODULE) {
559 ASSERT(it.interface()->IsFrozen()); 559 DCHECK(it.interface()->IsFrozen());
560 ASSERT(it.interface()->Index() >= 0); 560 DCHECK(it.interface()->Index() >= 0);
561 info->set_index(i, it.interface()->Index()); 561 info->set_index(i, it.interface()->Index());
562 } else { 562 } else {
563 ASSERT(var->index() >= 0); 563 DCHECK(var->index() >= 0);
564 info->set_index(i, var->index()); 564 info->set_index(i, var->index());
565 } 565 }
566 } 566 }
567 ASSERT(i == info->length()); 567 DCHECK(i == info->length());
568 return info; 568 return info;
569 } 569 }
570 570
571 } } // namespace v8::internal 571 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.h ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698