Commit c6729115 authored by whesse@chromium.org's avatar whesse@chromium.org

Changes to comments only, fixing errors and grammar.

Review URL: http://codereview.chromium.org/269050

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3047 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 57676280
......@@ -49,14 +49,14 @@ static const int kEvalContextualGenerations = 2;
static const int kRegExpGenerations = 2;
#endif
// Initial of each compilation cache table allocated.
// Initial size of each compilation cache table allocated.
static const int kInitialCacheSize = 64;
// The compilation cache consists of several generational sub-caches which uses
// this class as a base class. A sub-cache contains a compilation cache tables
// for each generation of the sub-cache. As the same source code string has
// different compiled code for scripts and evals. Internally, we use separate
// sub-caches to avoid getting the wrong kind of result when looking up.
// for each generation of the sub-cache. Since the same source code string has
// different compiled code for scripts and evals, we use separate sub-caches
// for different compilation modes, to avoid retrieving the wrong result.
class CompilationSubCache {
public:
explicit CompilationSubCache(int generations): generations_(generations) {
......
......@@ -6562,6 +6562,10 @@ class RegExpKey : public HashTableKey {
: string_(string),
flags_(Smi::FromInt(flags.value())) { }
// Rather than storing the key in the hash table, a pointer to the
// stored value is stored where the key should be. IsMatch then
// compares the search key to the found object, rather than comparing
// a key to a key.
bool IsMatch(Object* obj) {
FixedArray* val = FixedArray::cast(obj);
return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex)))
......@@ -7221,6 +7225,8 @@ Object* CompilationCacheTable::PutRegExp(String* src,
CompilationCacheTable* cache =
reinterpret_cast<CompilationCacheTable*>(obj);
int entry = cache->FindInsertionEntry(key.Hash());
// We store the value in the key slot, and compare the search key
// to the stored value with a custon IsMatch function during lookups.
cache->set(EntryToIndex(entry), value);
cache->set(EntryToIndex(entry) + 1, value);
cache->ElementAdded();
......
......@@ -2032,33 +2032,33 @@ class DescriptorArray: public FixedArray {
// // The Element size indicates number of elements per entry.
// static const int kEntrySize = ..;
// };
// table. The prefix size indicates an amount of memory in the
// The prefix size indicates an amount of memory in the
// beginning of the backing storage that can be used for non-element
// information by subclasses.
template<typename Shape, typename Key>
class HashTable: public FixedArray {
public:
// Returns the number of elements in the dictionary.
// Returns the number of elements in the hash table.
int NumberOfElements() {
return Smi::cast(get(kNumberOfElementsIndex))->value();
}
// Returns the capacity of the dictionary.
// Returns the capacity of the hash table.
int Capacity() {
return Smi::cast(get(kCapacityIndex))->value();
}
// ElementAdded should be called whenever an element is added to a
// dictionary.
// hash table.
void ElementAdded() { SetNumberOfElements(NumberOfElements() + 1); }
// ElementRemoved should be called whenever an element is removed from
// a dictionary.
// a hash table.
void ElementRemoved() { SetNumberOfElements(NumberOfElements() - 1); }
void ElementsRemoved(int n) { SetNumberOfElements(NumberOfElements() - n); }
// Returns a new array for dictionary usage. Might return Failure.
// Returns a new HashTable object. Might return Failure.
static Object* Allocate(int at_least_space_for);
// Returns the key at entry.
......@@ -2108,7 +2108,7 @@ class HashTable: public FixedArray {
return (entry * kEntrySize) + kElementsStartIndex;
}
// Update the number of elements in the dictionary.
// Update the number of elements in the hash table.
void SetNumberOfElements(int nof) {
fast_set(this, kNumberOfElementsIndex, Smi::FromInt(nof));
}
......@@ -2144,7 +2144,7 @@ class HashTableKey {
virtual uint32_t Hash() = 0;
// Returns the hash value for object.
virtual uint32_t HashForObject(Object* key) = 0;
// Returns the key object for storing into the dictionary.
// Returns the key object for storing into the hash table.
// If allocations fails a failure object is returned.
virtual Object* AsObject() = 0;
// Required.
......@@ -3575,6 +3575,7 @@ class CompilationCacheShape {
static const int kEntrySize = 2;
};
class CompilationCacheTable: public HashTable<CompilationCacheShape,
HashTableKey*> {
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment