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

Side by Side Diff: src/scopeinfo.cc

Issue 2816006: [Isolates] KeyedLookupCache / DescriptorLookupCache / ContextSlotCache moved to Isolate. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « src/scopeinfo.h ('k') | no next file » | 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 return -1; 425 return -1;
426 } 426 }
427 427
428 428
429 template<class Allocator> 429 template<class Allocator>
430 int ScopeInfo<Allocator>::ContextSlotIndex(Code* code, 430 int ScopeInfo<Allocator>::ContextSlotIndex(Code* code,
431 String* name, 431 String* name,
432 Variable::Mode* mode) { 432 Variable::Mode* mode) {
433 ASSERT(name->IsSymbol()); 433 ASSERT(name->IsSymbol());
434 int result = ContextSlotCache::Lookup(code, name, mode); 434 Isolate* isolate = Isolate::Current();
435 int result = isolate->context_slot_cache()->Lookup(code, name, mode);
435 if (result != ContextSlotCache::kNotFound) return result; 436 if (result != ContextSlotCache::kNotFound) return result;
436 if (code->sinfo_size() > 0) { 437 if (code->sinfo_size() > 0) {
437 // Loop below depends on the NULL sentinel after the context slot names. 438 // Loop below depends on the NULL sentinel after the context slot names.
438 ASSERT(NumberOfContextSlots(code) >= Context::MIN_CONTEXT_SLOTS || 439 ASSERT(NumberOfContextSlots(code) >= Context::MIN_CONTEXT_SLOTS ||
439 *(ContextEntriesAddr(code) + 1) == NULL); 440 *(ContextEntriesAddr(code) + 1) == NULL);
440 441
441 // slots start after length entry 442 // slots start after length entry
442 Object** p0 = ContextEntriesAddr(code) + 1; 443 Object** p0 = ContextEntriesAddr(code) + 1;
443 Object** p = p0; 444 Object** p = p0;
444 // contexts may have no variable slots (in the presence of eval()). 445 // contexts may have no variable slots (in the presence of eval()).
445 while (*p != NULL) { 446 while (*p != NULL) {
446 if (*p == name) { 447 if (*p == name) {
447 ASSERT(((p - p0) & 1) == 0); 448 ASSERT(((p - p0) & 1) == 0);
448 int v; 449 int v;
449 ReadInt(p + 1, &v); 450 ReadInt(p + 1, &v);
450 Variable::Mode mode_value = static_cast<Variable::Mode>(v); 451 Variable::Mode mode_value = static_cast<Variable::Mode>(v);
451 if (mode != NULL) *mode = mode_value; 452 if (mode != NULL) *mode = mode_value;
452 result = static_cast<int>((p - p0) >> 1) + Context::MIN_CONTEXT_SLOTS; 453 result = static_cast<int>((p - p0) >> 1) + Context::MIN_CONTEXT_SLOTS;
453 ContextSlotCache::Update(code, name, mode_value, result); 454 isolate->context_slot_cache()->Update(code, name, mode_value, result);
454 return result; 455 return result;
455 } 456 }
456 p += 2; 457 p += 2;
457 } 458 }
458 } 459 }
459 ContextSlotCache::Update(code, name, Variable::INTERNAL, -1); 460 isolate->context_slot_cache()->Update(code, name, Variable::INTERNAL, -1);
460 return -1; 461 return -1;
461 } 462 }
462 463
463 464
464 template<class Allocator> 465 template<class Allocator>
465 int ScopeInfo<Allocator>::ParameterIndex(Code* code, String* name) { 466 int ScopeInfo<Allocator>::ParameterIndex(Code* code, String* name) {
466 ASSERT(name->IsSymbol()); 467 ASSERT(name->IsSymbol());
467 if (code->sinfo_size() > 0) { 468 if (code->sinfo_size() > 0) {
468 // We must read parameters from the end since for 469 // We must read parameters from the end since for
469 // multiply declared parameters the value of the 470 // multiply declared parameters the value of the
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 #endif 573 #endif
573 } 574 }
574 } 575 }
575 576
576 577
577 void ContextSlotCache::Clear() { 578 void ContextSlotCache::Clear() {
578 for (int index = 0; index < kLength; index++) keys_[index].code = NULL; 579 for (int index = 0; index < kLength; index++) keys_[index].code = NULL;
579 } 580 }
580 581
581 582
582 ContextSlotCache::Key ContextSlotCache::keys_[ContextSlotCache::kLength];
583
584
585 uint32_t ContextSlotCache::values_[ContextSlotCache::kLength];
586
587
588 #ifdef DEBUG 583 #ifdef DEBUG
589 584
590 void ContextSlotCache::ValidateEntry(Code* code, 585 void ContextSlotCache::ValidateEntry(Code* code,
591 String* name, 586 String* name,
592 Variable::Mode mode, 587 Variable::Mode mode,
593 int slot_index) { 588 int slot_index) {
594 String* symbol; 589 String* symbol;
595 if (HEAP->LookupSymbolIfExists(name, &symbol)) { 590 if (HEAP->LookupSymbolIfExists(name, &symbol)) {
596 int index = Hash(code, name); 591 int index = Hash(code, name);
597 Key& key = keys_[index]; 592 Key& key = keys_[index];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 635 }
641 #endif // DEBUG 636 #endif // DEBUG
642 637
643 638
644 // Make sure the classes get instantiated by the template system. 639 // Make sure the classes get instantiated by the template system.
645 template class ScopeInfo<FreeStoreAllocationPolicy>; 640 template class ScopeInfo<FreeStoreAllocationPolicy>;
646 template class ScopeInfo<PreallocatedStorage>; 641 template class ScopeInfo<PreallocatedStorage>;
647 template class ScopeInfo<ZoneListAllocationPolicy>; 642 template class ScopeInfo<ZoneListAllocationPolicy>;
648 643
649 } } // namespace v8::internal 644 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698