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

Unified Diff: src/ast/scopeinfo.cc

Issue 2197973002: Move ContextSlotCache to its own file (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: src/ast/scopeinfo.cc
diff --git a/src/ast/scopeinfo.cc b/src/ast/scopeinfo.cc
index 687bd198b0d20f6c9f76d54a5afef07d2b240b6a..20d343f17aa74239f08d53004646b812e8aced68 100644
--- a/src/ast/scopeinfo.cc
+++ b/src/ast/scopeinfo.cc
@@ -6,6 +6,7 @@
#include <stdlib.h>
+#include "src/ast/context-slot-cache.h"
#include "src/ast/scopes.h"
#include "src/bootstrapper.h"
@@ -637,83 +638,7 @@ int ScopeInfo::FunctionNameEntryIndex() {
return ReceiverEntryIndex() + (HasAllocatedReceiver() ? 1 : 0);
}
-
-int ContextSlotCache::Hash(Object* data, String* name) {
- // Uses only lower 32 bits if pointers are larger.
- uintptr_t addr_hash =
- static_cast<uint32_t>(reinterpret_cast<uintptr_t>(data)) >> 2;
- return static_cast<int>((addr_hash ^ name->Hash()) % kLength);
-}
-
-
-int ContextSlotCache::Lookup(Object* data, String* name, VariableMode* mode,
- InitializationFlag* init_flag,
- MaybeAssignedFlag* maybe_assigned_flag) {
- int index = Hash(data, name);
- Key& key = keys_[index];
- if ((key.data == data) && key.name->Equals(name)) {
- Value result(values_[index]);
- if (mode != NULL) *mode = result.mode();
- if (init_flag != NULL) *init_flag = result.initialization_flag();
- if (maybe_assigned_flag != NULL)
- *maybe_assigned_flag = result.maybe_assigned_flag();
- return result.index() + kNotFound;
- }
- return kNotFound;
-}
-
-
-void ContextSlotCache::Update(Handle<Object> data, Handle<String> name,
- VariableMode mode, InitializationFlag init_flag,
- MaybeAssignedFlag maybe_assigned_flag,
- int slot_index) {
- DisallowHeapAllocation no_gc;
- Handle<String> internalized_name;
- DCHECK(slot_index > kNotFound);
- if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name).
- ToHandle(&internalized_name)) {
- int index = Hash(*data, *internalized_name);
- Key& key = keys_[index];
- key.data = *data;
- key.name = *internalized_name;
- // Please note value only takes a uint as index.
- values_[index] = Value(mode, init_flag, maybe_assigned_flag,
- slot_index - kNotFound).raw();
#ifdef DEBUG
- ValidateEntry(data, name, mode, init_flag, maybe_assigned_flag, slot_index);
-#endif
- }
-}
-
-
-void ContextSlotCache::Clear() {
- for (int index = 0; index < kLength; index++) keys_[index].data = NULL;
-}
-
-
-#ifdef DEBUG
-
-void ContextSlotCache::ValidateEntry(Handle<Object> data, Handle<String> name,
- VariableMode mode,
- InitializationFlag init_flag,
- MaybeAssignedFlag maybe_assigned_flag,
- int slot_index) {
- DisallowHeapAllocation no_gc;
- Handle<String> internalized_name;
- if (StringTable::InternalizeStringIfExists(name->GetIsolate(), name).
- ToHandle(&internalized_name)) {
- int index = Hash(*data, *name);
- Key& key = keys_[index];
- DCHECK(key.data == *data);
- DCHECK(key.name->Equals(*name));
- Value result(values_[index]);
- DCHECK(result.mode() == mode);
- DCHECK(result.initialization_flag() == init_flag);
- DCHECK(result.maybe_assigned_flag() == maybe_assigned_flag);
- DCHECK(result.index() + kNotFound == slot_index);
- }
-}
-
static void PrintList(const char* list_name,
int nof_internal_slots,
« src/ast/scopeinfo.h ('K') | « src/ast/scopeinfo.h ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698