Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index a5da88a0b3b2e0b5e44b17e0918d17655ea38e09..38eda1fb68061d5cfd6f3b5bdcf2752e5427fcde 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -15742,10 +15742,12 @@ void Symbol::SymbolShortPrint(std::ostream& os) { |
| class StringSharedKey : public HashTableKey { |
| public: |
| StringSharedKey(Handle<String> source, Handle<SharedFunctionInfo> shared, |
| - LanguageMode language_mode, int scope_position) |
| + LanguageMode language_mode, bool is_module, |
| + int scope_position) |
| : source_(source), |
| shared_(shared), |
| language_mode_(language_mode), |
| + is_module_(is_module), |
| scope_position_(scope_position) {} |
| bool IsMatch(Object* other) override { |
| @@ -15762,7 +15764,9 @@ class StringSharedKey : public HashTableKey { |
| DCHECK(is_valid_language_mode(language_unchecked)); |
| LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); |
| if (language_mode != language_mode_) return false; |
| - int scope_position = Smi::cast(other_array->get(3))->value(); |
| + bool is_module = Smi::cast(other_array->get(3))->value() == 1; |
| + if (is_module != is_module_) return false; |
| + int scope_position = Smi::cast(other_array->get(4))->value(); |
| if (scope_position != scope_position_) return false; |
| String* source = String::cast(other_array->get(1)); |
| return source->Equals(*source_); |
| @@ -15771,7 +15775,7 @@ class StringSharedKey : public HashTableKey { |
| static uint32_t StringSharedHashHelper(String* source, |
| SharedFunctionInfo* shared, |
| LanguageMode language_mode, |
| - int scope_position) { |
| + bool is_module, int scope_position) { |
| uint32_t hash = source->Hash(); |
| if (shared->HasSourceCode()) { |
| // Instead of using the SharedFunctionInfo pointer in the hash |
| @@ -15783,6 +15787,7 @@ class StringSharedKey : public HashTableKey { |
| hash ^= String::cast(script->source())->Hash(); |
| STATIC_ASSERT(LANGUAGE_END == 3); |
| if (is_strict(language_mode)) hash ^= 0x8000; |
| + if (is_module) hash ^= 0x4000; |
|
adamk
2016/06/28 17:03:53
Curious how you decided to tweak the hash code her
mike3
2016/07/02 22:17:59
I just needed a place to store this bit, so I foll
|
| hash += scope_position; |
| } |
| return hash; |
| @@ -15790,7 +15795,7 @@ class StringSharedKey : public HashTableKey { |
| uint32_t Hash() override { |
| return StringSharedHashHelper(*source_, *shared_, language_mode_, |
| - scope_position_); |
| + is_module_, scope_position_); |
| } |
| uint32_t HashForObject(Object* obj) override { |
| @@ -15804,18 +15809,21 @@ class StringSharedKey : public HashTableKey { |
| int language_unchecked = Smi::cast(other_array->get(2))->value(); |
| DCHECK(is_valid_language_mode(language_unchecked)); |
| LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); |
| - int scope_position = Smi::cast(other_array->get(3))->value(); |
| - return StringSharedHashHelper(source, shared, language_mode, |
| + bool is_module = |
| + Smi::cast(other_array->get(3))->value() == 1 ? true : false; |
|
vogelheim
2016/06/28 16:41:27
Please also drop "? true : false" here.
mike3
2016/07/02 22:17:59
Acknowledged.
|
| + int scope_position = Smi::cast(other_array->get(4))->value(); |
| + return StringSharedHashHelper(source, shared, language_mode, is_module, |
| scope_position); |
| } |
| Handle<Object> AsHandle(Isolate* isolate) override { |
| - Handle<FixedArray> array = isolate->factory()->NewFixedArray(4); |
| + Handle<FixedArray> array = isolate->factory()->NewFixedArray(5); |
| array->set(0, *shared_); |
| array->set(1, *source_); |
| array->set(2, Smi::FromInt(language_mode_)); |
| - array->set(3, Smi::FromInt(scope_position_)); |
| + array->set(3, Smi::FromInt(is_module_ ? 1 : 0)); |
| + array->set(4, Smi::FromInt(scope_position_)); |
| return array; |
| } |
| @@ -15823,6 +15831,7 @@ class StringSharedKey : public HashTableKey { |
| Handle<String> source_; |
| Handle<SharedFunctionInfo> shared_; |
| LanguageMode language_mode_; |
| + bool is_module_; |
| int scope_position_; |
| }; |
| @@ -17045,10 +17054,12 @@ bool StringSet::Has(Handle<String> name) { |
| Handle<Object> CompilationCacheTable::Lookup(Handle<String> src, |
| Handle<Context> context, |
| - LanguageMode language_mode) { |
| + LanguageMode language_mode, |
| + bool is_module) { |
| Isolate* isolate = GetIsolate(); |
| Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
| - StringSharedKey key(src, shared, language_mode, RelocInfo::kNoPosition); |
| + StringSharedKey key(src, shared, language_mode, is_module, |
| + RelocInfo::kNoPosition); |
| int entry = FindEntry(&key); |
| if (entry == kNotFound) return isolate->factory()->undefined_value(); |
| int index = EntryToIndex(entry); |
| @@ -17063,7 +17074,7 @@ Handle<Object> CompilationCacheTable::LookupEval( |
| Isolate* isolate = GetIsolate(); |
| // Cache key is the tuple (source, outer shared function info, scope position) |
| // to unambiguously identify the context chain the cached eval code assumes. |
| - StringSharedKey key(src, outer_info, language_mode, scope_position); |
| + StringSharedKey key(src, outer_info, language_mode, false, scope_position); |
| int entry = FindEntry(&key); |
| if (entry == kNotFound) return isolate->factory()->undefined_value(); |
| int index = EntryToIndex(entry); |
| @@ -17082,13 +17093,14 @@ Handle<Object> CompilationCacheTable::LookupRegExp(Handle<String> src, |
| return Handle<Object>(get(EntryToIndex(entry) + 1), isolate); |
| } |
| - |
| Handle<CompilationCacheTable> CompilationCacheTable::Put( |
| Handle<CompilationCacheTable> cache, Handle<String> src, |
| - Handle<Context> context, LanguageMode language_mode, Handle<Object> value) { |
| + Handle<Context> context, LanguageMode language_mode, bool is_module, |
| + Handle<Object> value) { |
| Isolate* isolate = cache->GetIsolate(); |
| Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
| - StringSharedKey key(src, shared, language_mode, RelocInfo::kNoPosition); |
| + StringSharedKey key(src, shared, language_mode, is_module, |
| + RelocInfo::kNoPosition); |
| Handle<Object> k = key.AsHandle(isolate); |
| cache = EnsureCapacity(cache, 1, &key); |
| int entry = cache->FindInsertionEntry(key.Hash()); |
| @@ -17104,7 +17116,8 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutEval( |
| Handle<SharedFunctionInfo> outer_info, Handle<SharedFunctionInfo> value, |
| int scope_position) { |
| Isolate* isolate = cache->GetIsolate(); |
| - StringSharedKey key(src, outer_info, value->language_mode(), scope_position); |
| + StringSharedKey key(src, outer_info, value->language_mode(), false, |
| + scope_position); |
| { |
| Handle<Object> k = key.AsHandle(isolate); |
| DisallowHeapAllocation no_allocation_scope; |