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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/lookup.h" 5 #include "src/lookup.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/deoptimizer.h" 8 #include "src/deoptimizer.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/field-type.h" 10 #include "src/field-type.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 137
138 void LookupIterator::ReloadPropertyInformation() { 138 void LookupIterator::ReloadPropertyInformation() {
139 state_ = BEFORE_PROPERTY; 139 state_ = BEFORE_PROPERTY;
140 interceptor_state_ = InterceptorState::kUninitialized; 140 interceptor_state_ = InterceptorState::kUninitialized;
141 state_ = LookupInHolder(holder_->map(), *holder_); 141 state_ = LookupInHolder(holder_->map(), *holder_);
142 DCHECK(IsFound() || !holder_->HasFastProperties()); 142 DCHECK(IsFound() || !holder_->HasFastProperties());
143 } 143 }
144 144
145 void LookupIterator::UpdateProtector() {
146 DisallowHeapAllocation no_gc;
147 if (IsElement()) return;
148 if (isolate_->bootstrapper()->IsActive()) return;
149 if (!isolate_->IsArraySpeciesLookupChainIntact()) return;
150
151 if (*name_ == *isolate_->factory()->constructor_string()) {
152 // Setting the constructor property could change an instance's @@species
153 if (holder_->IsJSArray()) {
154 isolate_->CountUsage(
155 v8::Isolate::UseCounterFeature::kArrayInstanceConstructorModified);
156 isolate_->InvalidateArraySpeciesProtector();
157 } else if (holder_->map()->is_prototype_map()) {
158 // Setting the constructor of Array.prototype of any realm also needs
159 // to invalidate the species protector
160 Object* context = heap()->native_contexts_list();
161 while (!context->IsUndefined()) {
162 Context* current_context = Context::cast(context);
163 if (current_context->initial_array_prototype() == *holder_) {
164 isolate_->CountUsage(v8::Isolate::UseCounterFeature::
165 kArrayPrototypeConstructorModified);
166 isolate_->InvalidateArraySpeciesProtector();
167 break;
168 }
169 context = current_context->get(Context::NEXT_CONTEXT_LINK);
170 }
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
171 }
172 } else if (FLAG_harmony_species &&
173 *name_ == *isolate_->factory()->species_symbol()) {
174 // Setting the Symbol.species property of any Array constructor invalidates
175 // the species protector
176 Object* context = heap()->native_contexts_list();
177 while (!context->IsUndefined()) {
178 Context* current_context = Context::cast(context);
179 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
180 isolate_->CountUsage(
181 v8::Isolate::UseCounterFeature::kArraySpeciesModified);
182 isolate_->InvalidateArraySpeciesProtector();
183 break;
184 }
185 context = current_context->get(Context::NEXT_CONTEXT_LINK);
186 }
187 }
188 }
145 189
146 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { 190 void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
147 DCHECK(state_ == DATA || state_ == ACCESSOR); 191 DCHECK(state_ == DATA || state_ == ACCESSOR);
148 DCHECK(HolderIsReceiverOrHiddenPrototype()); 192 DCHECK(HolderIsReceiverOrHiddenPrototype());
149 193
150 Handle<JSObject> holder = GetHolder<JSObject>(); 194 Handle<JSObject> holder = GetHolder<JSObject>();
151 195
152 if (IsElement()) { 196 if (IsElement()) {
153 ElementsKind kind = holder->GetElementsKind(); 197 ElementsKind kind = holder->GetElementsKind();
154 ElementsKind to = value->OptimalElementsKind(); 198 ElementsKind to = value->OptimalElementsKind();
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // Fall through. 718 // Fall through.
675 default: 719 default:
676 return NOT_FOUND; 720 return NOT_FOUND;
677 } 721 }
678 UNREACHABLE(); 722 UNREACHABLE();
679 return state_; 723 return state_;
680 } 724 }
681 725
682 } // namespace internal 726 } // namespace internal
683 } // namespace v8 727 } // namespace v8
OLDNEW
« 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