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

Unified Diff: src/lookup.cc

Issue 1689733002: Optimize @@species based on a global 'protector' cell (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove blank lines 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 | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index 910d8f1c864f55c183d92729013ee51242124cb5..bad5a20df51222151cc7e135583e16671c6ee390 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -142,6 +142,52 @@ void LookupIterator::ReloadPropertyInformation() {
DCHECK(IsFound() || !holder_->HasFastProperties());
}
+bool LookupIterator::HolderIsInContextIndex(uint32_t index) const {
+ DisallowHeapAllocation no_gc;
+
+ Object* context = heap()->native_contexts_list();
+ while (!context->IsUndefined()) {
+ Context* current_context = Context::cast(context);
+ if (current_context->get(index) == *holder_) {
+ return true;
+ }
+ context = current_context->get(Context::NEXT_CONTEXT_LINK);
+ }
+ return false;
+}
+
+void LookupIterator::UpdateProtector() {
+ if (!FLAG_harmony_species) return;
+
+ if (IsElement()) return;
+ if (isolate_->bootstrapper()->IsActive()) return;
+ if (!isolate_->IsArraySpeciesLookupChainIntact()) return;
+
+ if (*name_ == *isolate_->factory()->constructor_string()) {
+ // Setting the constructor property could change an instance's @@species
+ if (holder_->IsJSArray()) {
+ isolate_->CountUsage(
+ v8::Isolate::UseCounterFeature::kArrayInstanceConstructorModified);
+ isolate_->InvalidateArraySpeciesProtector();
+ } else if (holder_->map()->is_prototype_map()) {
+ // Setting the constructor of Array.prototype of any realm also needs
+ // to invalidate the species protector
+ if (HolderIsInContextIndex(Context::INITIAL_ARRAY_PROTOTYPE_INDEX)) {
+ isolate_->CountUsage(v8::Isolate::UseCounterFeature::
+ kArrayPrototypeConstructorModified);
+ isolate_->InvalidateArraySpeciesProtector();
+ }
+ }
+ } else if (*name_ == *isolate_->factory()->species_symbol()) {
+ // Setting the Symbol.species property of any Array constructor invalidates
+ // the species protector
+ if (HolderIsInContextIndex(Context::ARRAY_FUNCTION_INDEX)) {
+ isolate_->CountUsage(
+ v8::Isolate::UseCounterFeature::kArraySpeciesModified);
+ isolate_->InvalidateArraySpeciesProtector();
+ }
+ }
+}
void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
DCHECK(state_ == DATA || state_ == ACCESSOR);
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698