Chromium Code Reviews

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: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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 if (IsElement()) return;
147 if (isolate_->bootstrapper()->IsActive()) return;
148 if (!isolate_->IsArraySpeciesLookupChainIntact()) return;
149
150 if (*name_ == *isolate_->factory()->constructor_string()) {
151 // Setting the constructor property could change an instance's @@species
152 if (holder_->IsJSArray()) {
153 isolate_->CountUsage(
154 v8::Isolate::UseCounterFeature::kArrayInstanceConstructorModified);
155 isolate_->InvalidateArraySpeciesProtector();
156 } else if (holder_->map()->is_prototype_map()) {
157 // Setting the constructor of Array.prototype of any realm also needs
158 // to invalidate the species protector
159 Object* context = heap()->native_contexts_list();
adamk 2016/02/19 00:01:17 The use of raw pointers instead of handles looks a
Dan Ehrenberg 2016/02/19 00:15:37 I was following the way contexts are used by the a
adamk 2016/02/19 01:06:01 I agree that I don't see any problematic code here
Camillo Bruni 2016/02/22 15:29:34 right, I think the other code forgot to add Disall
160 while (!context->IsUndefined()) {
161 Context* current_context = Context::cast(context);
162 if (current_context->initial_array_prototype() == *holder_) {
163 isolate_->CountUsage(v8::Isolate::UseCounterFeature::
164 kArrayPrototypeConstructorModified);
165 isolate_->InvalidateArraySpeciesProtector();
166 break;
167 }
168 context = current_context->get(Context::NEXT_CONTEXT_LINK);
169 }
170 }
171 } else if (FLAG_harmony_species &&
172 *name_ == *isolate_->factory()->species_symbol()) {
173 // Setting the Symbol.species property of any Array constructor invalidates
174 // the species protector
175 Object* context = heap()->native_contexts_list();
176 while (!context->IsUndefined()) {
177 Context* current_context = Context::cast(context);
178 if (current_context->array_function() == *holder_) {
179 isolate_->CountUsage(
180 v8::Isolate::UseCounterFeature::kArraySpeciesModified);
181 isolate_->InvalidateArraySpeciesProtector();
182 break;
183 }
184 context = current_context->get(Context::NEXT_CONTEXT_LINK);
185 }
186 }
187 }
145 188
146 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { 189 void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
147 DCHECK(state_ == DATA || state_ == ACCESSOR); 190 DCHECK(state_ == DATA || state_ == ACCESSOR);
148 DCHECK(HolderIsReceiverOrHiddenPrototype()); 191 DCHECK(HolderIsReceiverOrHiddenPrototype());
149 192
150 Handle<JSObject> holder = GetHolder<JSObject>(); 193 Handle<JSObject> holder = GetHolder<JSObject>();
151 194
152 if (IsElement()) { 195 if (IsElement()) {
153 ElementsKind kind = holder->GetElementsKind(); 196 ElementsKind kind = holder->GetElementsKind();
154 ElementsKind to = value->OptimalElementsKind(); 197 ElementsKind to = value->OptimalElementsKind();
(...skipping 519 matching lines...)
674 // Fall through. 717 // Fall through.
675 default: 718 default:
676 return NOT_FOUND; 719 return NOT_FOUND;
677 } 720 }
678 UNREACHABLE(); 721 UNREACHABLE();
679 return state_; 722 return state_;
680 } 723 }
681 724
682 } // namespace internal 725 } // namespace internal
683 } // namespace v8 726 } // namespace v8
OLDNEW
« src/isolate.cc ('K') | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine