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

Side by Side Diff: src/scopeinfo.cc

Issue 2918001: Move serialized scope info from Code object to SharedFunctionInfo. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 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/stub-cache.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 context_slots_.length()); 141 context_slots_.length());
142 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS == 142 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
143 context_modes_.length()); 143 context_modes_.length());
144 context_slots_.Add(Factory::empty_symbol()); 144 context_slots_.Add(Factory::empty_symbol());
145 context_modes_.Add(Variable::INTERNAL); 145 context_modes_.Add(Variable::INTERNAL);
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 150
151 // Encoding format in the Code object: 151 // Encoding format in a FixedArray object:
152 // 152 //
153 // - function name 153 // - function name
154 // 154 //
155 // - number of variables in the context object (smi) (= function context 155 // - number of variables in the context object (smi) (= function context
156 // slot index + 1) 156 // slot index + 1)
157 // - list of pairs (name, Var mode) of context-allocated variables (starting 157 // - list of pairs (name, Var mode) of context-allocated variables (starting
158 // with context slot 0) 158 // with context slot 0)
159 // - NULL (sentinel) 159 // - NULL (sentinel)
160 // 160 //
161 // - number of parameters (smi) 161 // - number of parameters (smi)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 p = ReadSymbol(p, &s); 237 p = ReadSymbol(p, &s);
238 p = ReadInt(p, &m); 238 p = ReadInt(p, &m);
239 list->Add(s); 239 list->Add(s);
240 modes->Add(static_cast<Variable::Mode>(m)); 240 modes->Add(static_cast<Variable::Mode>(m));
241 } 241 }
242 return ReadSentinel(p); 242 return ReadSentinel(p);
243 } 243 }
244 244
245 245
246 template<class Allocator> 246 template<class Allocator>
247 ScopeInfo<Allocator>::ScopeInfo(Code* code) 247 Handle<Object> ScopeInfo<Allocator>::CreateHeapObject(Scope* scope) {
248 ScopeInfo<ZoneListAllocationPolicy> sinfo(scope);
249 return sinfo.Serialize();
250 }
251
252
253 template<class Allocator>
254 Object* ScopeInfo<Allocator>::EmptyHeapObject() {
255 return Heap::empty_fixed_array();
256 }
257
258
259 inline bool IsNotEmpty(Object* data) {
260 return FixedArray::cast(data)->length() != 0;
261 }
262
263
264 inline Object** GetDataStart(Object* data) {
265 return FixedArray::cast(data)->data_start();
266 }
267
268
269 template<class Allocator>
270 ScopeInfo<Allocator>::ScopeInfo(Object* data)
248 : function_name_(Factory::empty_symbol()), 271 : function_name_(Factory::empty_symbol()),
249 parameters_(4), 272 parameters_(4),
250 stack_slots_(8), 273 stack_slots_(8),
251 context_slots_(8), 274 context_slots_(8),
252 context_modes_(8) { 275 context_modes_(8) {
253 if (code == NULL || code->sinfo_size() == 0) return; 276 if (IsNotEmpty(data)) {
254 277 Object** p0 = GetDataStart(data);
255 Object** p0 = &Memory::Object_at(code->sinfo_start()); 278 Object** p = p0;
256 Object** p = p0; 279 p = ReadSymbol(p, &function_name_);
257 p = ReadSymbol(p, &function_name_); 280 p = ReadBool(p, &calls_eval_);
258 p = ReadBool(p, &calls_eval_); 281 p = ReadList<Allocator>(p, &context_slots_, &context_modes_);
259 p = ReadList<Allocator>(p, &context_slots_, &context_modes_); 282 p = ReadList<Allocator>(p, &parameters_);
260 p = ReadList<Allocator>(p, &parameters_); 283 p = ReadList<Allocator>(p, &stack_slots_);
261 p = ReadList<Allocator>(p, &stack_slots_); 284 ASSERT((p - p0) == FixedArray::cast(data)->length());
262 ASSERT((p - p0) * kPointerSize == code->sinfo_size()); 285 }
263 } 286 }
264 287
265 288
266 static inline Object** WriteInt(Object** p, int x) { 289 static inline Object** WriteInt(Object** p, int x) {
267 *p++ = Smi::FromInt(x); 290 *p++ = Smi::FromInt(x);
268 return p; 291 return p;
269 } 292 }
270 293
271 294
272 static inline Object** WriteBool(Object** p, bool b) { 295 static inline Object** WriteBool(Object** p, bool b) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 p = WriteInt(p, n); 329 p = WriteInt(p, n);
307 for (int i = 0; i < n; i++) { 330 for (int i = 0; i < n; i++) {
308 p = WriteSymbol(p, list->at(i)); 331 p = WriteSymbol(p, list->at(i));
309 p = WriteInt(p, modes->at(i)); 332 p = WriteInt(p, modes->at(i));
310 } 333 }
311 return WriteSentinel(p); 334 return WriteSentinel(p);
312 } 335 }
313 336
314 337
315 template<class Allocator> 338 template<class Allocator>
316 int ScopeInfo<Allocator>::Serialize(Code* code) { 339 Handle<Object> ScopeInfo<Allocator>::Serialize() {
317 // function name, calls eval, length & sentinel for 3 tables: 340 // function name, calls eval, length & sentinel for 3 tables:
318 const int extra_slots = 1 + 1 + 2 * 3; 341 const int extra_slots = 1 + 1 + 2 * 3;
319 int size = (extra_slots + 342 int length = extra_slots +
320 context_slots_.length() * 2 + 343 context_slots_.length() * 2 +
321 parameters_.length() + 344 parameters_.length() +
322 stack_slots_.length()) * kPointerSize; 345 stack_slots_.length();
323 346
324 if (code != NULL) { 347 Handle<Object> data(Factory::NewFixedArray(length, TENURED));
325 CHECK(code->sinfo_size() == size); 348 AssertNoAllocation nogc;
326 Object** p0 = &Memory::Object_at(code->sinfo_start());
327 Object** p = p0;
328 p = WriteSymbol(p, function_name_);
329 p = WriteBool(p, calls_eval_);
330 p = WriteList(p, &context_slots_, &context_modes_);
331 p = WriteList(p, &parameters_);
332 p = WriteList(p, &stack_slots_);
333 ASSERT((p - p0) * kPointerSize == size);
334 }
335 349
336 return size; 350 Object** p0 = GetDataStart(*data);
351 Object** p = p0;
352 p = WriteSymbol(p, function_name_);
353 p = WriteBool(p, calls_eval_);
354 p = WriteList(p, &context_slots_, &context_modes_);
355 p = WriteList(p, &parameters_);
356 p = WriteList(p, &stack_slots_);
357 ASSERT((p - p0) == length);
358
359 return data;
337 } 360 }
338 361
339 362
340 template<class Allocator> 363 static Object** ContextEntriesAddr(Object* data) {
341 void ScopeInfo<Allocator>::IterateScopeInfo(Code* code, ObjectVisitor* v) { 364 ASSERT(IsNotEmpty(data));
342 Object** start = &Memory::Object_at(code->sinfo_start()); 365 // +2 for function name and calls eval:
343 Object** end = &Memory::Object_at(code->sinfo_start() + code->sinfo_size()); 366 return GetDataStart(data) + 2;
344 v->VisitPointers(start, end);
345 } 367 }
346 368
347 369
348 static Object** ContextEntriesAddr(Code* code) { 370 static Object** ParameterEntriesAddr(Object* data) {
349 ASSERT(code->sinfo_size() > 0); 371 ASSERT(IsNotEmpty(data));
350 // +2 for function name and calls eval: 372 Object** p = ContextEntriesAddr(data);
351 return &Memory::Object_at(code->sinfo_start()) + 2;
352 }
353
354
355 static Object** ParameterEntriesAddr(Code* code) {
356 ASSERT(code->sinfo_size() > 0);
357 Object** p = ContextEntriesAddr(code);
358 int n; // number of context slots; 373 int n; // number of context slots;
359 p = ReadInt(p, &n); 374 p = ReadInt(p, &n);
360 return p + n*2 + 1; // *2 for pairs, +1 for sentinel 375 return p + n*2 + 1; // *2 for pairs, +1 for sentinel
361 } 376 }
362 377
363 378
364 static Object** StackSlotEntriesAddr(Code* code) { 379 static Object** StackSlotEntriesAddr(Object* data) {
365 ASSERT(code->sinfo_size() > 0); 380 ASSERT(IsNotEmpty(data));
366 Object** p = ParameterEntriesAddr(code); 381 Object** p = ParameterEntriesAddr(data);
367 int n; // number of parameter slots; 382 int n; // number of parameter slots;
368 p = ReadInt(p, &n); 383 p = ReadInt(p, &n);
369 return p + n + 1; // +1 for sentinel 384 return p + n + 1; // +1 for sentinel
370 } 385 }
371 386
372 387
373 template<class Allocator> 388 template<class Allocator>
374 bool ScopeInfo<Allocator>::CallsEval(Code* code) { 389 bool ScopeInfo<Allocator>::CallsEval(Object* data) {
375 if (code->sinfo_size() > 0) { 390 if (IsNotEmpty(data)) {
376 // +1 for function name: 391 // +1 for function name:
377 Object** p = &Memory::Object_at(code->sinfo_start()) + 1; 392 Object** p = GetDataStart(data) + 1;
378 bool calls_eval; 393 bool calls_eval;
379 p = ReadBool(p, &calls_eval); 394 p = ReadBool(p, &calls_eval);
380 return calls_eval; 395 return calls_eval;
381 } 396 }
382 return true; 397 return true;
383 } 398 }
384 399
385 400
386 template<class Allocator> 401 template<class Allocator>
387 int ScopeInfo<Allocator>::NumberOfStackSlots(Code* code) { 402 int ScopeInfo<Allocator>::NumberOfStackSlots(Object* data) {
388 if (code->sinfo_size() > 0) { 403 if (IsNotEmpty(data)) {
389 Object** p = StackSlotEntriesAddr(code); 404 Object** p = StackSlotEntriesAddr(data);
390 int n; // number of stack slots; 405 int n; // number of stack slots;
391 ReadInt(p, &n); 406 ReadInt(p, &n);
392 return n; 407 return n;
393 } 408 }
394 return 0; 409 return 0;
395 } 410 }
396 411
397 412
398 template<class Allocator> 413 template<class Allocator>
399 int ScopeInfo<Allocator>::NumberOfContextSlots(Code* code) { 414 int ScopeInfo<Allocator>::NumberOfContextSlots(Object* data) {
400 if (code->sinfo_size() > 0) { 415 if (IsNotEmpty(data)) {
401 Object** p = ContextEntriesAddr(code); 416 Object** p = ContextEntriesAddr(data);
402 int n; // number of context slots; 417 int n; // number of context slots;
403 ReadInt(p, &n); 418 ReadInt(p, &n);
404 return n + Context::MIN_CONTEXT_SLOTS; 419 return n + Context::MIN_CONTEXT_SLOTS;
405 } 420 }
406 return 0; 421 return 0;
407 } 422 }
408 423
409 424
410 template<class Allocator> 425 template<class Allocator>
411 bool ScopeInfo<Allocator>::HasHeapAllocatedLocals(Code* code) { 426 bool ScopeInfo<Allocator>::HasHeapAllocatedLocals(Object* data) {
412 if (code->sinfo_size() > 0) { 427 if (IsNotEmpty(data)) {
413 Object** p = ContextEntriesAddr(code); 428 Object** p = ContextEntriesAddr(data);
414 int n; // number of context slots; 429 int n; // number of context slots;
415 ReadInt(p, &n); 430 ReadInt(p, &n);
416 return n > 0; 431 return n > 0;
417 } 432 }
418 return false; 433 return false;
419 } 434 }
420 435
421 436
422 template<class Allocator> 437 template<class Allocator>
423 int ScopeInfo<Allocator>::StackSlotIndex(Code* code, String* name) { 438 int ScopeInfo<Allocator>::StackSlotIndex(Object* data, String* name) {
424 ASSERT(name->IsSymbol()); 439 ASSERT(name->IsSymbol());
425 if (code->sinfo_size() > 0) { 440 if (IsNotEmpty(data)) {
426 // Loop below depends on the NULL sentinel after the stack slot names. 441 // Loop below depends on the NULL sentinel after the stack slot names.
427 ASSERT(NumberOfStackSlots(code) > 0 || 442 ASSERT(NumberOfStackSlots(data) > 0 ||
428 *(StackSlotEntriesAddr(code) + 1) == NULL); 443 *(StackSlotEntriesAddr(data) + 1) == NULL);
429 // slots start after length entry 444 // slots start after length entry
430 Object** p0 = StackSlotEntriesAddr(code) + 1; 445 Object** p0 = StackSlotEntriesAddr(data) + 1;
431 Object** p = p0; 446 Object** p = p0;
432 while (*p != NULL) { 447 while (*p != NULL) {
433 if (*p == name) return static_cast<int>(p - p0); 448 if (*p == name) return static_cast<int>(p - p0);
434 p++; 449 p++;
435 } 450 }
436 } 451 }
437 return -1; 452 return -1;
438 } 453 }
439 454
440 455
441 template<class Allocator> 456 template<class Allocator>
442 int ScopeInfo<Allocator>::ContextSlotIndex(Code* code, 457 int ScopeInfo<Allocator>::ContextSlotIndex(Object* data,
443 String* name, 458 String* name,
444 Variable::Mode* mode) { 459 Variable::Mode* mode) {
445 ASSERT(name->IsSymbol()); 460 ASSERT(name->IsSymbol());
446 int result = ContextSlotCache::Lookup(code, name, mode); 461 int result = ContextSlotCache::Lookup(data, name, mode);
447 if (result != ContextSlotCache::kNotFound) return result; 462 if (result != ContextSlotCache::kNotFound) return result;
448 if (code->sinfo_size() > 0) { 463 if (IsNotEmpty(data)) {
449 // Loop below depends on the NULL sentinel after the context slot names. 464 // Loop below depends on the NULL sentinel after the context slot names.
450 ASSERT(NumberOfContextSlots(code) >= Context::MIN_CONTEXT_SLOTS || 465 ASSERT(NumberOfContextSlots(data) >= Context::MIN_CONTEXT_SLOTS ||
451 *(ContextEntriesAddr(code) + 1) == NULL); 466 *(ContextEntriesAddr(data) + 1) == NULL);
452 467
453 // slots start after length entry 468 // slots start after length entry
454 Object** p0 = ContextEntriesAddr(code) + 1; 469 Object** p0 = ContextEntriesAddr(data) + 1;
455 Object** p = p0; 470 Object** p = p0;
456 // contexts may have no variable slots (in the presence of eval()). 471 // contexts may have no variable slots (in the presence of eval()).
457 while (*p != NULL) { 472 while (*p != NULL) {
458 if (*p == name) { 473 if (*p == name) {
459 ASSERT(((p - p0) & 1) == 0); 474 ASSERT(((p - p0) & 1) == 0);
460 int v; 475 int v;
461 ReadInt(p + 1, &v); 476 ReadInt(p + 1, &v);
462 Variable::Mode mode_value = static_cast<Variable::Mode>(v); 477 Variable::Mode mode_value = static_cast<Variable::Mode>(v);
463 if (mode != NULL) *mode = mode_value; 478 if (mode != NULL) *mode = mode_value;
464 result = static_cast<int>((p - p0) >> 1) + Context::MIN_CONTEXT_SLOTS; 479 result = static_cast<int>((p - p0) >> 1) + Context::MIN_CONTEXT_SLOTS;
465 ContextSlotCache::Update(code, name, mode_value, result); 480 ContextSlotCache::Update(data, name, mode_value, result);
466 return result; 481 return result;
467 } 482 }
468 p += 2; 483 p += 2;
469 } 484 }
470 } 485 }
471 ContextSlotCache::Update(code, name, Variable::INTERNAL, -1); 486 ContextSlotCache::Update(data, name, Variable::INTERNAL, -1);
472 return -1; 487 return -1;
473 } 488 }
474 489
475 490
476 template<class Allocator> 491 template<class Allocator>
477 int ScopeInfo<Allocator>::ParameterIndex(Code* code, String* name) { 492 int ScopeInfo<Allocator>::ParameterIndex(Object* data, String* name) {
478 ASSERT(name->IsSymbol()); 493 ASSERT(name->IsSymbol());
479 if (code->sinfo_size() > 0) { 494 if (IsNotEmpty(data)) {
480 // We must read parameters from the end since for 495 // We must read parameters from the end since for
481 // multiply declared parameters the value of the 496 // multiply declared parameters the value of the
482 // last declaration of that parameter is used 497 // last declaration of that parameter is used
483 // inside a function (and thus we need to look 498 // inside a function (and thus we need to look
484 // at the last index). Was bug# 1110337. 499 // at the last index). Was bug# 1110337.
485 // 500 //
486 // Eventually, we should only register such parameters 501 // Eventually, we should only register such parameters
487 // once, with corresponding index. This requires a new 502 // once, with corresponding index. This requires a new
488 // implementation of the ScopeInfo code. See also other 503 // implementation of the ScopeInfo code. See also other
489 // comments in this file regarding this. 504 // comments in this file regarding this.
490 Object** p = ParameterEntriesAddr(code); 505 Object** p = ParameterEntriesAddr(data);
491 int n; // number of parameters 506 int n; // number of parameters
492 Object** p0 = ReadInt(p, &n); 507 Object** p0 = ReadInt(p, &n);
493 p = p0 + n; 508 p = p0 + n;
494 while (p > p0) { 509 while (p > p0) {
495 p--; 510 p--;
496 if (*p == name) return static_cast<int>(p - p0); 511 if (*p == name) return static_cast<int>(p - p0);
497 } 512 }
498 } 513 }
499 return -1; 514 return -1;
500 } 515 }
501 516
502 517
503 template<class Allocator> 518 template<class Allocator>
504 int ScopeInfo<Allocator>::FunctionContextSlotIndex(Code* code, String* name) { 519 int ScopeInfo<Allocator>::FunctionContextSlotIndex(Object* data, String* name) {
505 ASSERT(name->IsSymbol()); 520 ASSERT(name->IsSymbol());
506 if (code->sinfo_size() > 0) { 521 if (IsNotEmpty(data)) {
507 Object** p = &Memory::Object_at(code->sinfo_start()); 522 Object** p = GetDataStart(data);
508 if (*p == name) { 523 if (*p == name) {
509 p = ContextEntriesAddr(code); 524 p = ContextEntriesAddr(data);
510 int n; // number of context slots 525 int n; // number of context slots
511 ReadInt(p, &n); 526 ReadInt(p, &n);
512 ASSERT(n != 0); 527 ASSERT(n != 0);
513 // The function context slot is the last entry. 528 // The function context slot is the last entry.
514 return n + Context::MIN_CONTEXT_SLOTS - 1; 529 return n + Context::MIN_CONTEXT_SLOTS - 1;
515 } 530 }
516 } 531 }
517 return -1; 532 return -1;
518 } 533 }
519 534
(...skipping 17 matching lines...) Expand all
537 int ScopeInfo<Allocator>::NumberOfLocals() const { 552 int ScopeInfo<Allocator>::NumberOfLocals() const {
538 int number_of_locals = number_of_stack_slots(); 553 int number_of_locals = number_of_stack_slots();
539 if (number_of_context_slots() > 0) { 554 if (number_of_context_slots() > 0) {
540 ASSERT(number_of_context_slots() >= Context::MIN_CONTEXT_SLOTS); 555 ASSERT(number_of_context_slots() >= Context::MIN_CONTEXT_SLOTS);
541 number_of_locals += number_of_context_slots() - Context::MIN_CONTEXT_SLOTS; 556 number_of_locals += number_of_context_slots() - Context::MIN_CONTEXT_SLOTS;
542 } 557 }
543 return number_of_locals; 558 return number_of_locals;
544 } 559 }
545 560
546 561
547 int ContextSlotCache::Hash(Code* code, String* name) { 562 int ContextSlotCache::Hash(Object* data, String* name) {
548 // Uses only lower 32 bits if pointers are larger. 563 // Uses only lower 32 bits if pointers are larger.
549 uintptr_t addr_hash = 564 uintptr_t addr_hash =
550 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(code)) >> 2; 565 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(data)) >> 2;
551 return static_cast<int>((addr_hash ^ name->Hash()) % kLength); 566 return static_cast<int>((addr_hash ^ name->Hash()) % kLength);
552 } 567 }
553 568
554 569
555 int ContextSlotCache::Lookup(Code* code, 570 int ContextSlotCache::Lookup(Object* data,
556 String* name, 571 String* name,
557 Variable::Mode* mode) { 572 Variable::Mode* mode) {
558 int index = Hash(code, name); 573 int index = Hash(data, name);
559 Key& key = keys_[index]; 574 Key& key = keys_[index];
560 if ((key.code == code) && key.name->Equals(name)) { 575 if ((key.data == data) && key.name->Equals(name)) {
561 Value result(values_[index]); 576 Value result(values_[index]);
562 if (mode != NULL) *mode = result.mode(); 577 if (mode != NULL) *mode = result.mode();
563 return result.index() + kNotFound; 578 return result.index() + kNotFound;
564 } 579 }
565 return kNotFound; 580 return kNotFound;
566 } 581 }
567 582
568 583
569 void ContextSlotCache::Update(Code* code, 584 void ContextSlotCache::Update(Object* data,
570 String* name, 585 String* name,
571 Variable::Mode mode, 586 Variable::Mode mode,
572 int slot_index) { 587 int slot_index) {
573 String* symbol; 588 String* symbol;
574 ASSERT(slot_index > kNotFound); 589 ASSERT(slot_index > kNotFound);
575 if (Heap::LookupSymbolIfExists(name, &symbol)) { 590 if (Heap::LookupSymbolIfExists(name, &symbol)) {
576 int index = Hash(code, symbol); 591 int index = Hash(data, symbol);
577 Key& key = keys_[index]; 592 Key& key = keys_[index];
578 key.code = code; 593 key.data = data;
579 key.name = symbol; 594 key.name = symbol;
580 // Please note value only takes a uint as index. 595 // Please note value only takes a uint as index.
581 values_[index] = Value(mode, slot_index - kNotFound).raw(); 596 values_[index] = Value(mode, slot_index - kNotFound).raw();
582 #ifdef DEBUG 597 #ifdef DEBUG
583 ValidateEntry(code, name, mode, slot_index); 598 ValidateEntry(data, name, mode, slot_index);
584 #endif 599 #endif
585 } 600 }
586 } 601 }
587 602
588 603
589 void ContextSlotCache::Clear() { 604 void ContextSlotCache::Clear() {
590 for (int index = 0; index < kLength; index++) keys_[index].code = NULL; 605 for (int index = 0; index < kLength; index++) keys_[index].data = NULL;
591 } 606 }
592 607
593 608
594 ContextSlotCache::Key ContextSlotCache::keys_[ContextSlotCache::kLength]; 609 ContextSlotCache::Key ContextSlotCache::keys_[ContextSlotCache::kLength];
595 610
596 611
597 uint32_t ContextSlotCache::values_[ContextSlotCache::kLength]; 612 uint32_t ContextSlotCache::values_[ContextSlotCache::kLength];
598 613
599 614
600 #ifdef DEBUG 615 #ifdef DEBUG
601 616
602 void ContextSlotCache::ValidateEntry(Code* code, 617 void ContextSlotCache::ValidateEntry(Object* data,
603 String* name, 618 String* name,
604 Variable::Mode mode, 619 Variable::Mode mode,
605 int slot_index) { 620 int slot_index) {
606 String* symbol; 621 String* symbol;
607 if (Heap::LookupSymbolIfExists(name, &symbol)) { 622 if (Heap::LookupSymbolIfExists(name, &symbol)) {
608 int index = Hash(code, name); 623 int index = Hash(data, name);
609 Key& key = keys_[index]; 624 Key& key = keys_[index];
610 ASSERT(key.code == code); 625 ASSERT(key.data == data);
611 ASSERT(key.name->Equals(name)); 626 ASSERT(key.name->Equals(name));
612 Value result(values_[index]); 627 Value result(values_[index]);
613 ASSERT(result.mode() == mode); 628 ASSERT(result.mode() == mode);
614 ASSERT(result.index() + kNotFound == slot_index); 629 ASSERT(result.index() + kNotFound == slot_index);
615 } 630 }
616 } 631 }
617 632
618 633
619 template <class Allocator> 634 template <class Allocator>
620 static void PrintList(const char* list_name, 635 static void PrintList(const char* list_name,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 667 }
653 #endif // DEBUG 668 #endif // DEBUG
654 669
655 670
656 // Make sure the classes get instantiated by the template system. 671 // Make sure the classes get instantiated by the template system.
657 template class ScopeInfo<FreeStoreAllocationPolicy>; 672 template class ScopeInfo<FreeStoreAllocationPolicy>;
658 template class ScopeInfo<PreallocatedStorage>; 673 template class ScopeInfo<PreallocatedStorage>;
659 template class ScopeInfo<ZoneListAllocationPolicy>; 674 template class ScopeInfo<ZoneListAllocationPolicy>;
660 675
661 } } // namespace v8::internal 676 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698