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

Side by Side Diff: src/objects.cc

Issue 1756883002: Avoid SetPropertyInternal if the LookupIterator is NotFound (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 4113 matching lines...) Expand 10 before | Expand all | Expand 10 after
4124 MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode)); 4124 MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
4125 return value; 4125 return value;
4126 } 4126 }
4127 4127
4128 4128
4129 Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, 4129 Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
4130 Handle<Object> value, 4130 Handle<Object> value,
4131 LanguageMode language_mode, 4131 LanguageMode language_mode,
4132 StoreFromKeyed store_mode, 4132 StoreFromKeyed store_mode,
4133 bool* found) { 4133 bool* found) {
4134 it->UpdateProtector(); 4134 DCHECK(it->IsFound());
4135 ShouldThrow should_throw = 4135 ShouldThrow should_throw =
4136 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4136 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4137 4137
4138 // Make sure that the top context does not change when doing callbacks or 4138 // Make sure that the top context does not change when doing callbacks or
4139 // interceptor calls. 4139 // interceptor calls.
4140 AssertNoContextChange ncc(it->isolate()); 4140 AssertNoContextChange ncc(it->isolate());
4141 4141
4142 for (; it->IsFound(); it->Next()) { 4142 do {
4143 switch (it->state()) { 4143 switch (it->state()) {
4144 case LookupIterator::NOT_FOUND: 4144 case LookupIterator::NOT_FOUND:
4145 UNREACHABLE(); 4145 UNREACHABLE();
4146 4146
4147 case LookupIterator::ACCESS_CHECK: 4147 case LookupIterator::ACCESS_CHECK:
4148 if (it->HasAccess()) break; 4148 if (it->HasAccess()) break;
4149 // Check whether it makes sense to reuse the lookup iterator. Here it 4149 // Check whether it makes sense to reuse the lookup iterator. Here it
4150 // might still call into setters up the prototype chain. 4150 // might still call into setters up the prototype chain.
4151 return JSObject::SetPropertyWithFailedAccessCheck(it, value, 4151 return JSObject::SetPropertyWithFailedAccessCheck(it, value,
4152 should_throw); 4152 should_throw);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 return WriteToReadOnlyProperty(it, value, should_throw); 4195 return WriteToReadOnlyProperty(it, value, should_throw);
4196 } 4196 }
4197 if (it->HolderIsReceiverOrHiddenPrototype()) { 4197 if (it->HolderIsReceiverOrHiddenPrototype()) {
4198 return SetDataProperty(it, value); 4198 return SetDataProperty(it, value);
4199 } 4199 }
4200 // Fall through. 4200 // Fall through.
4201 case LookupIterator::TRANSITION: 4201 case LookupIterator::TRANSITION:
4202 *found = false; 4202 *found = false;
4203 return Nothing<bool>(); 4203 return Nothing<bool>();
4204 } 4204 }
4205 } 4205 it->Next();
4206 } while (it->IsFound());
4206 4207
4207 *found = false; 4208 *found = false;
4208 return Nothing<bool>(); 4209 return Nothing<bool>();
4209 } 4210 }
4210 4211
4211 4212
4212 Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value, 4213 Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
4213 LanguageMode language_mode, 4214 LanguageMode language_mode,
4214 StoreFromKeyed store_mode) { 4215 StoreFromKeyed store_mode) {
4215 bool found = true; 4216 it->UpdateProtector();
4216 Maybe<bool> result = 4217 if (it->IsFound()) {
4217 SetPropertyInternal(it, value, language_mode, store_mode, &found); 4218 bool found = true;
4218 if (found) return result; 4219 Maybe<bool> result =
4220 SetPropertyInternal(it, value, language_mode, store_mode, &found);
4221 if (found) return result;
4222 }
4219 4223
4220 // If the receiver is the JSGlobalObject, the store was contextual. In case 4224 // If the receiver is the JSGlobalObject, the store was contextual. In case
4221 // the property did not exist yet on the global object itself, we have to 4225 // the property did not exist yet on the global object itself, we have to
4222 // throw a reference error in strict mode. In sloppy mode, we continue. 4226 // throw a reference error in strict mode. In sloppy mode, we continue.
4223 if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) { 4227 if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) {
4224 it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError( 4228 it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError(
4225 MessageTemplate::kNotDefined, it->name())); 4229 MessageTemplate::kNotDefined, it->name()));
4226 return Nothing<bool>(); 4230 return Nothing<bool>();
4227 } 4231 }
4228 4232
4229 ShouldThrow should_throw = 4233 ShouldThrow should_throw =
4230 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4234 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4231 return AddDataProperty(it, value, NONE, should_throw, store_mode); 4235 return AddDataProperty(it, value, NONE, should_throw, store_mode);
4232 } 4236 }
4233 4237
4234 4238
4235 Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, 4239 Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
4236 LanguageMode language_mode, 4240 LanguageMode language_mode,
4237 StoreFromKeyed store_mode) { 4241 StoreFromKeyed store_mode) {
4238 Isolate* isolate = it->isolate(); 4242 Isolate* isolate = it->isolate();
4239 4243
4240 bool found = true; 4244 it->UpdateProtector();
4241 Maybe<bool> result = 4245 if (it->IsFound()) {
4242 SetPropertyInternal(it, value, language_mode, store_mode, &found); 4246 bool found = true;
4243 if (found) return result; 4247 Maybe<bool> result =
4248 SetPropertyInternal(it, value, language_mode, store_mode, &found);
4249 if (found) return result;
4250 }
4244 4251
4245 // The property either doesn't exist on the holder or exists there as a data 4252 // The property either doesn't exist on the holder or exists there as a data
4246 // property. 4253 // property.
4247 4254
4248 ShouldThrow should_throw = 4255 ShouldThrow should_throw =
4249 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4256 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4250 4257
4251 if (!it->GetReceiver()->IsJSReceiver()) { 4258 if (!it->GetReceiver()->IsJSReceiver()) {
4252 return WriteToReadOnlyProperty(it, value, should_throw); 4259 return WriteToReadOnlyProperty(it, value, should_throw);
4253 } 4260 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(), 4315 return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(),
4309 &value_desc, should_throw); 4316 &value_desc, should_throw);
4310 } 4317 }
4311 4318
4312 case LookupIterator::NOT_FOUND: 4319 case LookupIterator::NOT_FOUND:
4313 case LookupIterator::TRANSITION: 4320 case LookupIterator::TRANSITION:
4314 UNREACHABLE(); 4321 UNREACHABLE();
4315 } 4322 }
4316 } 4323 }
4317 4324
4318 return JSObject::AddDataProperty(&own_lookup, value, NONE, should_throw, 4325 return AddDataProperty(&own_lookup, value, NONE, should_throw, store_mode);
4319 store_mode);
4320 } 4326 }
4321 4327
4322 MaybeHandle<Object> Object::ReadAbsentProperty(LookupIterator* it) { 4328 MaybeHandle<Object> Object::ReadAbsentProperty(LookupIterator* it) {
4323 return it->isolate()->factory()->undefined_value(); 4329 return it->isolate()->factory()->undefined_value();
4324 } 4330 }
4325 4331
4326 MaybeHandle<Object> Object::ReadAbsentProperty(Isolate* isolate, 4332 MaybeHandle<Object> Object::ReadAbsentProperty(Isolate* isolate,
4327 Handle<Object> receiver, 4333 Handle<Object> receiver,
4328 Handle<Object> name) { 4334 Handle<Object> name) {
4329 return isolate->factory()->undefined_value(); 4335 return isolate->factory()->undefined_value();
(...skipping 15435 matching lines...) Expand 10 before | Expand all | Expand 10 after
19765 if (cell->value() != *new_value) { 19771 if (cell->value() != *new_value) {
19766 cell->set_value(*new_value); 19772 cell->set_value(*new_value);
19767 Isolate* isolate = cell->GetIsolate(); 19773 Isolate* isolate = cell->GetIsolate();
19768 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19774 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19769 isolate, DependentCode::kPropertyCellChangedGroup); 19775 isolate, DependentCode::kPropertyCellChangedGroup);
19770 } 19776 }
19771 } 19777 }
19772 19778
19773 } // namespace internal 19779 } // namespace internal
19774 } // namespace v8 19780 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698