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

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: Some fixes 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
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> originalArray) {
adamk 2016/01/06 00:10:12 original_array
Dan Ehrenberg 2016/01/07 00:42:58 Done
1610 Context* native_context = isolate->context()->native_context();
adamk 2016/01/06 00:10:12 Please stuff this in a handle immediately; raw poi
Dan Ehrenberg 2016/01/07 00:42:58 Oops, fixed (turns out the Handle API is more ergo
1611 if (!FLAG_harmony_species) {
1612 return Handle<Object>(native_context->array_function(), isolate);
1613 }
1614 Handle<Object> constructor(isolate->heap()->undefined_value(), isolate);
adamk 2016/01/06 00:10:12 isolate->factory()->undefined_value() will hand yo
Dan Ehrenberg 2016/01/07 00:42:58 Done
1615 Maybe<bool> is_array = Object::IsArray(originalArray);
1616 MAYBE_RETURN_NULL(is_array);
1617 if (is_array.FromJust()) {
1618 ASSIGN_RETURN_ON_EXCEPTION(
1619 isolate, constructor,
1620 Object::GetProperty(isolate, originalArray, "constructor", STRICT),
adamk 2016/01/06 00:10:12 You can make this slightly faster by using a diffe
Dan Ehrenberg 2016/01/07 00:42:58 Done
1621 Object);
1622 if (constructor->IsConstructor()) {
1623 Context* constructor_context =
adamk 2016/01/06 00:10:12 Again, please store in a handle.
Dan Ehrenberg 2016/01/07 00:42:58 Done
1624 JSFunction::cast(*constructor)->context()->native_context();
1625 if (constructor_context != native_context &&
1626 *constructor == constructor_context->array_function()) {
1627 constructor =
1628 Handle<Object>(isolate->heap()->undefined_value(), isolate);
adamk 2016/01/06 00:10:12 isolate->factory()->undefined_value()
Dan Ehrenberg 2016/01/07 00:42:58 Done
1629 }
1630 }
1631 if (constructor->IsJSReceiver()) {
1632 ASSIGN_RETURN_ON_EXCEPTION(
1633 isolate, constructor,
1634 Object::GetProperty(constructor,
1635 Handle<Name>(isolate->heap()->species_symbol())),
adamk 2016/01/06 00:10:12 isolate->factory()->species_symbol()
Dan Ehrenberg 2016/01/07 00:42:58 Done
1636 Object);
1637 if (constructor->IsNull()) {
1638 constructor =
1639 Handle<Object>(isolate->heap()->undefined_value(), isolate);
adamk 2016/01/06 00:10:12 factory version
Dan Ehrenberg 2016/01/07 00:42:58 Done
1640 }
1641 }
1642 }
1643 if (constructor->IsUndefined()) {
1644 return Handle<Object>(native_context->array_function(), isolate);
1645 } else {
1646 if (!constructor->IsConstructor()) {
1647 isolate->Throw(*isolate->factory()->NewTypeError(
adamk 2016/01/06 00:10:12 I think you want to return what Throw() returns. A
Dan Ehrenberg 2016/01/07 00:42:57 Fixed
1648 MessageTemplate::kSpeciesNotConstructor));
1649 return MaybeHandle<Object>();
1650 }
1651 return constructor;
1652 }
1653 }
1654
1655
1608 void Object::ShortPrint(FILE* out) { 1656 void Object::ShortPrint(FILE* out) {
1609 OFStream os(out); 1657 OFStream os(out);
1610 os << Brief(this); 1658 os << Brief(this);
1611 } 1659 }
1612 1660
1613 1661
1614 void Object::ShortPrint(StringStream* accumulator) { 1662 void Object::ShortPrint(StringStream* accumulator) {
1615 std::ostringstream os; 1663 std::ostringstream os;
1616 os << Brief(this); 1664 os << Brief(this);
1617 accumulator->Add(os.str().c_str()); 1665 accumulator->Add(os.str().c_str());
(...skipping 17927 matching lines...) Expand 10 before | Expand all | Expand 10 after
19545 if (cell->value() != *new_value) { 19593 if (cell->value() != *new_value) {
19546 cell->set_value(*new_value); 19594 cell->set_value(*new_value);
19547 Isolate* isolate = cell->GetIsolate(); 19595 Isolate* isolate = cell->GetIsolate();
19548 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19596 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19549 isolate, DependentCode::kPropertyCellChangedGroup); 19597 isolate, DependentCode::kPropertyCellChangedGroup);
19550 } 19598 }
19551 } 19599 }
19552 19600
19553 } // namespace internal 19601 } // namespace internal
19554 } // namespace v8 19602 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698