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

Side by Side Diff: src/scopeinfo.cc

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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/serialize.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 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 number_of_locals += number_of_context_slots() - Context::MIN_CONTEXT_SLOTS; 529 number_of_locals += number_of_context_slots() - Context::MIN_CONTEXT_SLOTS;
530 } 530 }
531 return number_of_locals; 531 return number_of_locals;
532 } 532 }
533 533
534 534
535 int ContextSlotCache::Hash(Code* code, String* name) { 535 int ContextSlotCache::Hash(Code* code, String* name) {
536 // Uses only lower 32 bits if pointers are larger. 536 // Uses only lower 32 bits if pointers are larger.
537 uintptr_t addr_hash = 537 uintptr_t addr_hash =
538 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(code)) >> 2; 538 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(code)) >> 2;
539 return (addr_hash ^ name->Hash()) % kLength; 539 return (addr_hash ^ name->Hash()) % ContextSlotCacheData::kLength;
540 } 540 }
541 541
542 542
543 int ContextSlotCache::Lookup(Code* code, 543 int ContextSlotCache::Lookup(Code* code,
544 String* name, 544 String* name,
545 Variable::Mode* mode) { 545 Variable::Mode* mode) {
546 int index = Hash(code, name); 546 int index = Hash(code, name);
547 Key& key = keys_[index]; 547 ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
548 ContextSlotCacheData::Key& key = data.keys_[index];
548 if ((key.code == code) && key.name->Equals(name)) { 549 if ((key.code == code) && key.name->Equals(name)) {
549 Value result(values_[index]); 550 Value result(data.values_[index]);
550 if (mode != NULL) *mode = result.mode(); 551 if (mode != NULL) *mode = result.mode();
551 return result.index() + kNotFound; 552 return result.index() + kNotFound;
552 } 553 }
553 return kNotFound; 554 return kNotFound;
554 } 555 }
555 556
556 557
557 void ContextSlotCache::Update(Code* code, 558 void ContextSlotCache::Update(Code* code,
558 String* name, 559 String* name,
559 Variable::Mode mode, 560 Variable::Mode mode,
560 int slot_index) { 561 int slot_index) {
561 String* symbol; 562 String* symbol;
562 ASSERT(slot_index > kNotFound); 563 ASSERT(slot_index > kNotFound);
563 if (Heap::LookupSymbolIfExists(name, &symbol)) { 564 if (Heap::LookupSymbolIfExists(name, &symbol)) {
564 int index = Hash(code, symbol); 565 int index = Hash(code, symbol);
565 Key& key = keys_[index]; 566 ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
567 ContextSlotCacheData::Key& key = data.keys_[index];
566 key.code = code; 568 key.code = code;
567 key.name = symbol; 569 key.name = symbol;
568 // Please note value only takes a uint as index. 570 // Please note value only takes a uint as index.
569 values_[index] = Value(mode, slot_index - kNotFound).raw(); 571 data.values_[index] = Value(mode, slot_index - kNotFound).raw();
570 #ifdef DEBUG 572 #ifdef DEBUG
571 ValidateEntry(code, name, mode, slot_index); 573 ValidateEntry(code, name, mode, slot_index);
572 #endif 574 #endif
573 } 575 }
574 } 576 }
575 577
576 578
577 void ContextSlotCache::Clear() { 579 void ContextSlotCache::Clear() {
578 for (int index = 0; index < kLength; index++) keys_[index].code = NULL; 580 ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
581 for (int index = 0; index < ContextSlotCacheData::kLength; index++)
582 data.keys_[index].code = NULL;
579 } 583 }
580 584
581 585 ContextSlotCacheData::ContextSlotCacheData() {
582 ContextSlotCache::Key ContextSlotCache::keys_[ContextSlotCache::kLength]; 586 for (int i = 0; i < ContextSlotCacheData::kLength; ++i) {
583 587 keys_[i].code = NULL;
584 588 keys_[i].name = NULL;
585 uint32_t ContextSlotCache::values_[ContextSlotCache::kLength]; 589 values_[i] = 0;
586 590 }
591 }
587 592
588 #ifdef DEBUG 593 #ifdef DEBUG
589 594
590 void ContextSlotCache::ValidateEntry(Code* code, 595 void ContextSlotCache::ValidateEntry(Code* code,
591 String* name, 596 String* name,
592 Variable::Mode mode, 597 Variable::Mode mode,
593 int slot_index) { 598 int slot_index) {
594 String* symbol; 599 String* symbol;
595 if (Heap::LookupSymbolIfExists(name, &symbol)) { 600 if (Heap::LookupSymbolIfExists(name, &symbol)) {
596 int index = Hash(code, name); 601 int index = Hash(code, name);
597 Key& key = keys_[index]; 602 ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
603 ContextSlotCacheData::Key& key = data.keys_[index];
598 ASSERT(key.code == code); 604 ASSERT(key.code == code);
599 ASSERT(key.name->Equals(name)); 605 ASSERT(key.name->Equals(name));
600 Value result(values_[index]); 606 Value result(data.values_[index]);
601 ASSERT(result.mode() == mode); 607 ASSERT(result.mode() == mode);
602 ASSERT(result.index() + kNotFound == slot_index); 608 ASSERT(result.index() + kNotFound == slot_index);
603 } 609 }
604 } 610 }
605 611
606 612
607 template <class Allocator> 613 template <class Allocator>
608 static void PrintList(const char* list_name, 614 static void PrintList(const char* list_name,
609 int nof_internal_slots, 615 int nof_internal_slots,
610 List<Handle<String>, Allocator>& list) { 616 List<Handle<String>, Allocator>& list) {
(...skipping 29 matching lines...) Expand all
640 } 646 }
641 #endif // DEBUG 647 #endif // DEBUG
642 648
643 649
644 // Make sure the classes get instantiated by the template system. 650 // Make sure the classes get instantiated by the template system.
645 template class ScopeInfo<FreeStoreAllocationPolicy>; 651 template class ScopeInfo<FreeStoreAllocationPolicy>;
646 template class ScopeInfo<PreallocatedStorage>; 652 template class ScopeInfo<PreallocatedStorage>;
647 template class ScopeInfo<ZoneListAllocationPolicy>; 653 template class ScopeInfo<ZoneListAllocationPolicy>;
648 654
649 } } // namespace v8::internal 655 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.h ('k') | src/serialize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698