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

Side by Side Diff: src/objects.cc

Issue 1560763002: Add Array support for @@species and subclassing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Last couple comments Created 4 years, 11 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/objects.h ('k') | src/runtime/runtime.h » ('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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 Simd128Value* a = Simd128Value::cast(this); 1598 Simd128Value* a = Simd128Value::cast(this);
1599 Simd128Value* b = Simd128Value::cast(other); 1599 Simd128Value* b = Simd128Value::cast(other);
1600 return a->map()->instance_type() == b->map()->instance_type() && 1600 return a->map()->instance_type() == b->map()->instance_type() &&
1601 a->BitwiseEquals(b); 1601 a->BitwiseEquals(b);
1602 } 1602 }
1603 } 1603 }
1604 return false; 1604 return false;
1605 } 1605 }
1606 1606
1607 1607
1608 MaybeHandle<Object> Object::ArraySpeciesConstructor(
1609 Isolate* isolate, Handle<Object> original_array) {
1610 Handle<Context> native_context = isolate->native_context();
1611 if (!FLAG_harmony_species) {
1612 return Handle<Object>(native_context->array_function(), isolate);
1613 }
1614 Handle<Object> constructor = isolate->factory()->undefined_value();
1615 Maybe<bool> is_array = Object::IsArray(original_array);
1616 MAYBE_RETURN_NULL(is_array);
1617 if (is_array.FromJust()) {
1618 ASSIGN_RETURN_ON_EXCEPTION(
1619 isolate, constructor,
1620 Object::GetProperty(original_array,
1621 isolate->factory()->constructor_string()),
1622 Object);
1623 if (constructor->IsConstructor()) {
1624 Handle<Context> constructor_context;
1625 ASSIGN_RETURN_ON_EXCEPTION(
1626 isolate, constructor_context,
1627 JSReceiver::GetFunctionRealm(Handle<JSReceiver>::cast(constructor)),
1628 Object);
1629 if (*constructor_context != *native_context &&
1630 *constructor == constructor_context->array_function()) {
1631 constructor = isolate->factory()->undefined_value();
1632 }
1633 }
1634 if (constructor->IsJSReceiver()) {
1635 ASSIGN_RETURN_ON_EXCEPTION(
1636 isolate, constructor,
1637 Object::GetProperty(constructor,
1638 isolate->factory()->species_symbol()),
1639 Object);
1640 if (constructor->IsNull()) {
1641 constructor = isolate->factory()->undefined_value();
1642 }
1643 }
1644 }
1645 if (constructor->IsUndefined()) {
1646 return Handle<Object>(native_context->array_function(), isolate);
1647 } else {
1648 if (!constructor->IsConstructor()) {
1649 THROW_NEW_ERROR(isolate,
1650 NewTypeError(MessageTemplate::kSpeciesNotConstructor),
1651 Object);
1652 }
1653 return constructor;
1654 }
1655 }
1656
1657
1608 void Object::ShortPrint(FILE* out) { 1658 void Object::ShortPrint(FILE* out) {
1609 OFStream os(out); 1659 OFStream os(out);
1610 os << Brief(this); 1660 os << Brief(this);
1611 } 1661 }
1612 1662
1613 1663
1614 void Object::ShortPrint(StringStream* accumulator) { 1664 void Object::ShortPrint(StringStream* accumulator) {
1615 std::ostringstream os; 1665 std::ostringstream os;
1616 os << Brief(this); 1666 os << Brief(this);
1617 accumulator->Add(os.str().c_str()); 1667 accumulator->Add(os.str().c_str());
(...skipping 17936 matching lines...) Expand 10 before | Expand all | Expand 10 after
19554 if (cell->value() != *new_value) { 19604 if (cell->value() != *new_value) {
19555 cell->set_value(*new_value); 19605 cell->set_value(*new_value);
19556 Isolate* isolate = cell->GetIsolate(); 19606 Isolate* isolate = cell->GetIsolate();
19557 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19607 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19558 isolate, DependentCode::kPropertyCellChangedGroup); 19608 isolate, DependentCode::kPropertyCellChangedGroup);
19559 } 19609 }
19560 } 19610 }
19561 19611
19562 } // namespace internal 19612 } // namespace internal
19563 } // namespace v8 19613 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698