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

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: DCHECK 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 83bfc79c8eefe6435b9134c33943e91f1d6bad83..dba0be0cae5480a0617888ab8296fe85562144da 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -142,6 +142,50 @@ void LookupIterator::ReloadPropertyInformation() {
DCHECK(IsFound() || !holder_->HasFastProperties());
}
+void LookupIterator::UpdateProtector() {
+ DisallowHeapAllocation no_gc;
+ 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
+ Object* context = heap()->native_contexts_list();
+ while (!context->IsUndefined()) {
+ Context* current_context = Context::cast(context);
+ if (current_context->initial_array_prototype() == *holder_) {
+ isolate_->CountUsage(v8::Isolate::UseCounterFeature::
+ kArrayPrototypeConstructorModified);
+ isolate_->InvalidateArraySpeciesProtector();
+ break;
+ }
+ context = current_context->get(Context::NEXT_CONTEXT_LINK);
+ }
Camillo Bruni 2016/02/22 12:44:47 nit: Could you copy over and adapt the helper Cont
Dan Ehrenberg 2016/02/22 20:02:00 Done
+ }
+ } else if (FLAG_harmony_species &&
+ *name_ == *isolate_->factory()->species_symbol()) {
+ // Setting the Symbol.species property of any Array constructor invalidates
+ // the species protector
+ Object* context = heap()->native_contexts_list();
+ while (!context->IsUndefined()) {
+ Context* current_context = Context::cast(context);
+ if (current_context->array_function() == *holder_) {
Camillo Bruni 2016/02/22 12:44:47 you could check that the value we set is not the a
Dan Ehrenberg 2016/02/22 20:02:00 Not really sure how I could do that. Polyfill libr
Camillo Bruni 2016/02/22 20:05:22 I guess this is fine for now. I thought of checkin
+ isolate_->CountUsage(
+ v8::Isolate::UseCounterFeature::kArraySpeciesModified);
+ isolate_->InvalidateArraySpeciesProtector();
+ break;
+ }
+ context = current_context->get(Context::NEXT_CONTEXT_LINK);
+ }
+ }
+}
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