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

Side by Side Diff: src/objects.cc

Issue 1409123003: [runtime] Avoid @@isConcatSpreadable lookup for fast path Array.prototype.concat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: merging with master Created 4 years, 7 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.cc ('k') | test/cctest/heap/test-heap.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 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 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 Simd128Value* a = Simd128Value::cast(this); 1554 Simd128Value* a = Simd128Value::cast(this);
1555 Simd128Value* b = Simd128Value::cast(other); 1555 Simd128Value* b = Simd128Value::cast(other);
1556 return a->map() == b->map() && a->BitwiseEquals(b); 1556 return a->map() == b->map() && a->BitwiseEquals(b);
1557 } 1557 }
1558 return false; 1558 return false;
1559 } 1559 }
1560 1560
1561 1561
1562 MaybeHandle<Object> Object::ArraySpeciesConstructor( 1562 MaybeHandle<Object> Object::ArraySpeciesConstructor(
1563 Isolate* isolate, Handle<Object> original_array) { 1563 Isolate* isolate, Handle<Object> original_array) {
1564 Handle<Context> native_context = isolate->native_context();
1565 Handle<Object> default_species = isolate->array_function(); 1564 Handle<Object> default_species = isolate->array_function();
1566 if (!FLAG_harmony_species) { 1565 if (!FLAG_harmony_species) {
1567 return default_species; 1566 return default_species;
1568 } 1567 }
1569 if (original_array->IsJSArray() && 1568 if (original_array->IsJSArray() &&
1570 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) && 1569 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) &&
1571 isolate->IsArraySpeciesLookupChainIntact()) { 1570 isolate->IsArraySpeciesLookupChainIntact()) {
1572 return default_species; 1571 return default_species;
1573 } 1572 }
1574 Handle<Object> constructor = isolate->factory()->undefined_value(); 1573 Handle<Object> constructor = isolate->factory()->undefined_value();
1575 Maybe<bool> is_array = Object::IsArray(original_array); 1574 Maybe<bool> is_array = Object::IsArray(original_array);
1576 MAYBE_RETURN_NULL(is_array); 1575 MAYBE_RETURN_NULL(is_array);
1577 if (is_array.FromJust()) { 1576 if (is_array.FromJust()) {
1578 ASSIGN_RETURN_ON_EXCEPTION( 1577 ASSIGN_RETURN_ON_EXCEPTION(
1579 isolate, constructor, 1578 isolate, constructor,
1580 Object::GetProperty(original_array, 1579 Object::GetProperty(original_array,
1581 isolate->factory()->constructor_string()), 1580 isolate->factory()->constructor_string()),
1582 Object); 1581 Object);
1583 if (constructor->IsConstructor()) { 1582 if (constructor->IsConstructor()) {
1584 Handle<Context> constructor_context; 1583 Handle<Context> constructor_context;
1585 ASSIGN_RETURN_ON_EXCEPTION( 1584 ASSIGN_RETURN_ON_EXCEPTION(
1586 isolate, constructor_context, 1585 isolate, constructor_context,
1587 JSReceiver::GetFunctionRealm(Handle<JSReceiver>::cast(constructor)), 1586 JSReceiver::GetFunctionRealm(Handle<JSReceiver>::cast(constructor)),
1588 Object); 1587 Object);
1589 if (*constructor_context != *native_context && 1588 if (*constructor_context != *isolate->native_context() &&
1590 *constructor == constructor_context->array_function()) { 1589 *constructor == constructor_context->array_function()) {
1591 constructor = isolate->factory()->undefined_value(); 1590 constructor = isolate->factory()->undefined_value();
1592 } 1591 }
1593 } 1592 }
1594 if (constructor->IsJSReceiver()) { 1593 if (constructor->IsJSReceiver()) {
1595 ASSIGN_RETURN_ON_EXCEPTION( 1594 ASSIGN_RETURN_ON_EXCEPTION(
1596 isolate, constructor, 1595 isolate, constructor,
1597 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor), 1596 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor),
1598 isolate->factory()->species_symbol()), 1597 isolate->factory()->species_symbol()),
1599 Object); 1598 Object);
(...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode)); 4146 MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
4148 return value; 4147 return value;
4149 } 4148 }
4150 4149
4151 4150
4152 Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, 4151 Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
4153 Handle<Object> value, 4152 Handle<Object> value,
4154 LanguageMode language_mode, 4153 LanguageMode language_mode,
4155 StoreFromKeyed store_mode, 4154 StoreFromKeyed store_mode,
4156 bool* found) { 4155 bool* found) {
4156 it->UpdateProtector();
4157 DCHECK(it->IsFound()); 4157 DCHECK(it->IsFound());
4158 ShouldThrow should_throw = 4158 ShouldThrow should_throw =
4159 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4159 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4160 4160
4161 // Make sure that the top context does not change when doing callbacks or 4161 // Make sure that the top context does not change when doing callbacks or
4162 // interceptor calls. 4162 // interceptor calls.
4163 AssertNoContextChange ncc(it->isolate()); 4163 AssertNoContextChange ncc(it->isolate());
4164 4164
4165 do { 4165 do {
4166 switch (it->state()) { 4166 switch (it->state()) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4229 } while (it->IsFound()); 4229 } while (it->IsFound());
4230 4230
4231 *found = false; 4231 *found = false;
4232 return Nothing<bool>(); 4232 return Nothing<bool>();
4233 } 4233 }
4234 4234
4235 4235
4236 Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value, 4236 Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
4237 LanguageMode language_mode, 4237 LanguageMode language_mode,
4238 StoreFromKeyed store_mode) { 4238 StoreFromKeyed store_mode) {
4239 it->UpdateProtector();
4240 if (it->IsFound()) { 4239 if (it->IsFound()) {
4241 bool found = true; 4240 bool found = true;
4242 Maybe<bool> result = 4241 Maybe<bool> result =
4243 SetPropertyInternal(it, value, language_mode, store_mode, &found); 4242 SetPropertyInternal(it, value, language_mode, store_mode, &found);
4244 if (found) return result; 4243 if (found) return result;
4245 } 4244 }
4246 4245
4247 // If the receiver is the JSGlobalObject, the store was contextual. In case 4246 // If the receiver is the JSGlobalObject, the store was contextual. In case
4248 // the property did not exist yet on the global object itself, we have to 4247 // the property did not exist yet on the global object itself, we have to
4249 // throw a reference error in strict mode. In sloppy mode, we continue. 4248 // throw a reference error in strict mode. In sloppy mode, we continue.
4250 if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) { 4249 if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) {
4251 it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError( 4250 it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError(
4252 MessageTemplate::kNotDefined, it->name())); 4251 MessageTemplate::kNotDefined, it->name()));
4253 return Nothing<bool>(); 4252 return Nothing<bool>();
4254 } 4253 }
4255 4254
4256 ShouldThrow should_throw = 4255 ShouldThrow should_throw =
4257 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4256 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4258 return AddDataProperty(it, value, NONE, should_throw, store_mode); 4257 return AddDataProperty(it, value, NONE, should_throw, store_mode);
4259 } 4258 }
4260 4259
4261 4260
4262 Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, 4261 Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
4263 LanguageMode language_mode, 4262 LanguageMode language_mode,
4264 StoreFromKeyed store_mode) { 4263 StoreFromKeyed store_mode) {
4265 Isolate* isolate = it->isolate(); 4264 Isolate* isolate = it->isolate();
4266 4265
4267 it->UpdateProtector();
4268 if (it->IsFound()) { 4266 if (it->IsFound()) {
4269 bool found = true; 4267 bool found = true;
4270 Maybe<bool> result = 4268 Maybe<bool> result =
4271 SetPropertyInternal(it, value, language_mode, store_mode, &found); 4269 SetPropertyInternal(it, value, language_mode, store_mode, &found);
4272 if (found) return result; 4270 if (found) return result;
4273 } 4271 }
4274 4272
4273 it->UpdateProtector();
4274
4275 // The property either doesn't exist on the holder or exists there as a data 4275 // The property either doesn't exist on the holder or exists there as a data
4276 // property. 4276 // property.
4277 4277
4278 ShouldThrow should_throw = 4278 ShouldThrow should_throw =
4279 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4279 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4280 4280
4281 if (!it->GetReceiver()->IsJSReceiver()) { 4281 if (!it->GetReceiver()->IsJSReceiver()) {
4282 return WriteToReadOnlyProperty(it, value, should_throw); 4282 return WriteToReadOnlyProperty(it, value, should_throw);
4283 } 4283 }
4284 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver()); 4284 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 if (FLAG_trace_js_array_abuse && !array->HasFixedTypedArrayElements()) { 4485 if (FLAG_trace_js_array_abuse && !array->HasFixedTypedArrayElements()) {
4486 CheckArrayAbuse(array, "elements write", it->index(), false); 4486 CheckArrayAbuse(array, "elements write", it->index(), false);
4487 } 4487 }
4488 } 4488 }
4489 4489
4490 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value, 4490 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value,
4491 attributes, should_throw); 4491 attributes, should_throw);
4492 JSObject::ValidateElements(receiver); 4492 JSObject::ValidateElements(receiver);
4493 return result; 4493 return result;
4494 } else { 4494 } else {
4495 it->UpdateProtector();
4495 // Migrate to the most up-to-date map that will be able to store |value| 4496 // Migrate to the most up-to-date map that will be able to store |value|
4496 // under it->name() with |attributes|. 4497 // under it->name() with |attributes|.
4497 it->PrepareTransitionToDataProperty(receiver, value, attributes, 4498 it->PrepareTransitionToDataProperty(receiver, value, attributes,
4498 store_mode); 4499 store_mode);
4499 DCHECK_EQ(LookupIterator::TRANSITION, it->state()); 4500 DCHECK_EQ(LookupIterator::TRANSITION, it->state());
4500 it->ApplyTransitionToDataProperty(receiver); 4501 it->ApplyTransitionToDataProperty(receiver);
4501 4502
4502 // TODO(verwaest): Encapsulate dictionary handling better. 4503 // TODO(verwaest): Encapsulate dictionary handling better.
4503 if (receiver->map()->is_dictionary_map()) { 4504 if (receiver->map()->is_dictionary_map()) {
4504 // TODO(dcarney): just populate TransitionPropertyCell here? 4505 // TODO(dcarney): just populate TransitionPropertyCell here?
(...skipping 13768 matching lines...) Expand 10 before | Expand all | Expand 10 after
18273 if (cell->value() != *new_value) { 18274 if (cell->value() != *new_value) {
18274 cell->set_value(*new_value); 18275 cell->set_value(*new_value);
18275 Isolate* isolate = cell->GetIsolate(); 18276 Isolate* isolate = cell->GetIsolate();
18276 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18277 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18277 isolate, DependentCode::kPropertyCellChangedGroup); 18278 isolate, DependentCode::kPropertyCellChangedGroup);
18278 } 18279 }
18279 } 18280 }
18280 18281
18281 } // namespace internal 18282 } // namespace internal
18282 } // namespace v8 18283 } // namespace v8
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698