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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopeinfo.h ('k') | src/serialize.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopeinfo.cc
===================================================================
--- src/scopeinfo.cc (revision 3427)
+++ src/scopeinfo.cc (working copy)
@@ -536,7 +536,7 @@
// Uses only lower 32 bits if pointers are larger.
uintptr_t addr_hash =
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(code)) >> 2;
- return (addr_hash ^ name->Hash()) % kLength;
+ return (addr_hash ^ name->Hash()) % ContextSlotCacheData::kLength;
}
@@ -544,9 +544,10 @@
String* name,
Variable::Mode* mode) {
int index = Hash(code, name);
- Key& key = keys_[index];
+ ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
+ ContextSlotCacheData::Key& key = data.keys_[index];
if ((key.code == code) && key.name->Equals(name)) {
- Value result(values_[index]);
+ Value result(data.values_[index]);
if (mode != NULL) *mode = result.mode();
return result.index() + kNotFound;
}
@@ -562,11 +563,12 @@
ASSERT(slot_index > kNotFound);
if (Heap::LookupSymbolIfExists(name, &symbol)) {
int index = Hash(code, symbol);
- Key& key = keys_[index];
+ ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
+ ContextSlotCacheData::Key& key = data.keys_[index];
key.code = code;
key.name = symbol;
// Please note value only takes a uint as index.
- values_[index] = Value(mode, slot_index - kNotFound).raw();
+ data.values_[index] = Value(mode, slot_index - kNotFound).raw();
#ifdef DEBUG
ValidateEntry(code, name, mode, slot_index);
#endif
@@ -575,16 +577,19 @@
void ContextSlotCache::Clear() {
- for (int index = 0; index < kLength; index++) keys_[index].code = NULL;
+ ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
+ for (int index = 0; index < ContextSlotCacheData::kLength; index++)
+ data.keys_[index].code = NULL;
}
+ContextSlotCacheData::ContextSlotCacheData() {
+ for (int i = 0; i < ContextSlotCacheData::kLength; ++i) {
+ keys_[i].code = NULL;
+ keys_[i].name = NULL;
+ values_[i] = 0;
+ }
+}
-ContextSlotCache::Key ContextSlotCache::keys_[ContextSlotCache::kLength];
-
-
-uint32_t ContextSlotCache::values_[ContextSlotCache::kLength];
-
-
#ifdef DEBUG
void ContextSlotCache::ValidateEntry(Code* code,
@@ -594,10 +599,11 @@
String* symbol;
if (Heap::LookupSymbolIfExists(name, &symbol)) {
int index = Hash(code, name);
- Key& key = keys_[index];
+ ContextSlotCacheData& data = v8_context()->context_slot_cache_data_;
+ ContextSlotCacheData::Key& key = data.keys_[index];
ASSERT(key.code == code);
ASSERT(key.name->Equals(name));
- Value result(values_[index]);
+ Value result(data.values_[index]);
ASSERT(result.mode() == mode);
ASSERT(result.index() + kNotFound == slot_index);
}
« 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