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

Unified Diff: src/api-natives.cc

Issue 1741623003: [api] Speed up template instantiation cache a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 10 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
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index 60b930374139df0c66b77130efc7f81f1c9938fd..56ee7374e5f67cf5552957e254de6fd0c8c876dc 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -269,15 +269,20 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
void CacheTemplateInstantiation(Isolate* isolate, Handle<Smi> serial_number,
Handle<JSObject> object) {
auto cache = isolate->template_instantiations_cache();
- auto new_cache = ObjectHashTable::Put(cache, serial_number, object);
+ auto new_cache = UnseededNumberDictionary::AtNumberPut(
+ cache, static_cast<uint32_t>(serial_number->value()), object);
isolate->native_context()->set_template_instantiations_cache(*new_cache);
}
void UncacheTemplateInstantiation(Isolate* isolate, Handle<Smi> serial_number) {
auto cache = isolate->template_instantiations_cache();
- bool was_present = false;
- auto new_cache = ObjectHashTable::Remove(cache, serial_number, &was_present);
- DCHECK(was_present);
+ int entry = cache->FindEntry(static_cast<uint32_t>(serial_number->value()));
+ DCHECK(entry != UnseededNumberDictionary::kNotFound);
+ Handle<Object> result =
+ UnseededNumberDictionary::DeleteProperty(cache, entry);
+ USE(result);
+ DCHECK(result->IsTrue());
+ auto new_cache = UnseededNumberDictionary::Shrink(cache, entry);
isolate->native_context()->set_template_instantiations_cache(*new_cache);
}
@@ -301,8 +306,9 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
if (serial_number->value()) {
// Probe cache.
auto cache = isolate->template_instantiations_cache();
- Object* boilerplate = cache->Lookup(serial_number);
- if (boilerplate->IsJSObject()) {
+ int entry = cache->FindEntry(static_cast<uint32_t>(serial_number->value()));
+ if (entry != UnseededNumberDictionary::kNotFound) {
+ Object* boilerplate = cache->ValueAt(entry);
result = handle(JSObject::cast(boilerplate), isolate);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result, JSObject::DeepCopyApiBoilerplate(result), JSObject);
@@ -333,8 +339,9 @@ MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
if (serial_number->value()) {
// Probe cache.
auto cache = isolate->template_instantiations_cache();
- Object* element = cache->Lookup(serial_number);
- if (element->IsJSFunction()) {
+ int entry = cache->FindEntry(static_cast<uint32_t>(serial_number->value()));
+ if (entry != UnseededNumberDictionary::kNotFound) {
+ Object* element = cache->ValueAt(entry);
return handle(JSFunction::cast(element), isolate);
}
}
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698