OLD | NEW |
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // Return whether or not {prototype} is in the prototype chain of {object}. | 607 // Return whether or not {prototype} is in the prototype chain of {object}. |
608 Maybe<bool> result = JSReceiver::HasInPrototypeChain( | 608 Maybe<bool> result = JSReceiver::HasInPrototypeChain( |
609 isolate, Handle<JSReceiver>::cast(object), prototype); | 609 isolate, Handle<JSReceiver>::cast(object), prototype); |
610 if (result.IsNothing()) return MaybeHandle<Object>(); | 610 if (result.IsNothing()) return MaybeHandle<Object>(); |
611 return isolate->factory()->ToBoolean(result.FromJust()); | 611 return isolate->factory()->ToBoolean(result.FromJust()); |
612 } | 612 } |
613 | 613 |
614 // static | 614 // static |
615 MaybeHandle<Object> Object::InstanceOf(Isolate* isolate, Handle<Object> object, | 615 MaybeHandle<Object> Object::InstanceOf(Isolate* isolate, Handle<Object> object, |
616 Handle<Object> callable) { | 616 Handle<Object> callable) { |
617 if (FLAG_harmony_instanceof) { | 617 // The {callable} must be a receiver. |
618 // The {callable} must be a receiver. | 618 if (!callable->IsJSReceiver()) { |
619 if (!callable->IsJSReceiver()) { | 619 THROW_NEW_ERROR(isolate, |
620 THROW_NEW_ERROR( | 620 NewTypeError(MessageTemplate::kNonObjectInInstanceOfCheck), |
621 isolate, NewTypeError(MessageTemplate::kNonObjectInInstanceOfCheck), | 621 Object); |
622 Object); | 622 } |
623 } | |
624 | 623 |
625 // Lookup the @@hasInstance method on {callable}. | 624 // Lookup the @@hasInstance method on {callable}. |
626 Handle<Object> inst_of_handler; | 625 Handle<Object> inst_of_handler; |
| 626 ASSIGN_RETURN_ON_EXCEPTION( |
| 627 isolate, inst_of_handler, |
| 628 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable), |
| 629 isolate->factory()->has_instance_symbol()), |
| 630 Object); |
| 631 if (!inst_of_handler->IsUndefined(isolate)) { |
| 632 // Call the {inst_of_handler} on the {callable}. |
| 633 Handle<Object> result; |
627 ASSIGN_RETURN_ON_EXCEPTION( | 634 ASSIGN_RETURN_ON_EXCEPTION( |
628 isolate, inst_of_handler, | 635 isolate, result, |
629 JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable), | 636 Execution::Call(isolate, inst_of_handler, callable, 1, &object), |
630 isolate->factory()->has_instance_symbol()), | |
631 Object); | 637 Object); |
632 if (!inst_of_handler->IsUndefined(isolate)) { | 638 return isolate->factory()->ToBoolean(result->BooleanValue()); |
633 // Call the {inst_of_handler} on the {callable}. | |
634 Handle<Object> result; | |
635 ASSIGN_RETURN_ON_EXCEPTION( | |
636 isolate, result, | |
637 Execution::Call(isolate, inst_of_handler, callable, 1, &object), | |
638 Object); | |
639 return isolate->factory()->ToBoolean(result->BooleanValue()); | |
640 } | |
641 } | 639 } |
642 | 640 |
643 // The {callable} must have a [[Call]] internal method. | 641 // The {callable} must have a [[Call]] internal method. |
644 if (!callable->IsCallable()) { | 642 if (!callable->IsCallable()) { |
645 THROW_NEW_ERROR( | 643 THROW_NEW_ERROR( |
646 isolate, NewTypeError(MessageTemplate::kNonCallableInInstanceOfCheck), | 644 isolate, NewTypeError(MessageTemplate::kNonCallableInInstanceOfCheck), |
647 Object); | 645 Object); |
648 } | 646 } |
649 | 647 |
650 // Fall back to OrdinaryHasInstance with {callable} and {object}. | 648 // Fall back to OrdinaryHasInstance with {callable} and {object}. |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 Simd128Value* b = Simd128Value::cast(other); | 1614 Simd128Value* b = Simd128Value::cast(other); |
1617 return a->map() == b->map() && a->BitwiseEquals(b); | 1615 return a->map() == b->map() && a->BitwiseEquals(b); |
1618 } | 1616 } |
1619 return false; | 1617 return false; |
1620 } | 1618 } |
1621 | 1619 |
1622 | 1620 |
1623 MaybeHandle<Object> Object::ArraySpeciesConstructor( | 1621 MaybeHandle<Object> Object::ArraySpeciesConstructor( |
1624 Isolate* isolate, Handle<Object> original_array) { | 1622 Isolate* isolate, Handle<Object> original_array) { |
1625 Handle<Object> default_species = isolate->array_function(); | 1623 Handle<Object> default_species = isolate->array_function(); |
1626 if (!FLAG_harmony_species) { | |
1627 return default_species; | |
1628 } | |
1629 if (original_array->IsJSArray() && | 1624 if (original_array->IsJSArray() && |
1630 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) && | 1625 Handle<JSArray>::cast(original_array)->HasArrayPrototype(isolate) && |
1631 isolate->IsArraySpeciesLookupChainIntact()) { | 1626 isolate->IsArraySpeciesLookupChainIntact()) { |
1632 return default_species; | 1627 return default_species; |
1633 } | 1628 } |
1634 Handle<Object> constructor = isolate->factory()->undefined_value(); | 1629 Handle<Object> constructor = isolate->factory()->undefined_value(); |
1635 Maybe<bool> is_array = Object::IsArray(original_array); | 1630 Maybe<bool> is_array = Object::IsArray(original_array); |
1636 MAYBE_RETURN_NULL(is_array); | 1631 MAYBE_RETURN_NULL(is_array); |
1637 if (is_array.FromJust()) { | 1632 if (is_array.FromJust()) { |
1638 ASSIGN_RETURN_ON_EXCEPTION( | 1633 ASSIGN_RETURN_ON_EXCEPTION( |
(...skipping 14184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15823 case 'g': | 15818 case 'g': |
15824 flag = JSRegExp::kGlobal; | 15819 flag = JSRegExp::kGlobal; |
15825 break; | 15820 break; |
15826 case 'i': | 15821 case 'i': |
15827 flag = JSRegExp::kIgnoreCase; | 15822 flag = JSRegExp::kIgnoreCase; |
15828 break; | 15823 break; |
15829 case 'm': | 15824 case 'm': |
15830 flag = JSRegExp::kMultiline; | 15825 flag = JSRegExp::kMultiline; |
15831 break; | 15826 break; |
15832 case 'u': | 15827 case 'u': |
15833 if (!FLAG_harmony_unicode_regexps) return JSRegExp::Flags(0); | |
15834 flag = JSRegExp::kUnicode; | 15828 flag = JSRegExp::kUnicode; |
15835 break; | 15829 break; |
15836 case 'y': | 15830 case 'y': |
15837 flag = JSRegExp::kSticky; | 15831 flag = JSRegExp::kSticky; |
15838 break; | 15832 break; |
15839 default: | 15833 default: |
15840 return JSRegExp::Flags(0); | 15834 return JSRegExp::Flags(0); |
15841 } | 15835 } |
15842 // Duplicate flag. | 15836 // Duplicate flag. |
15843 if (value & flag) return JSRegExp::Flags(0); | 15837 if (value & flag) return JSRegExp::Flags(0); |
(...skipping 3014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18858 } else { | 18852 } else { |
18859 // Old-style generators. | 18853 // Old-style generators. |
18860 int offset = continuation(); | 18854 int offset = continuation(); |
18861 CHECK(0 <= offset && offset < function()->code()->instruction_size()); | 18855 CHECK(0 <= offset && offset < function()->code()->instruction_size()); |
18862 return function()->code()->SourcePosition(offset); | 18856 return function()->code()->SourcePosition(offset); |
18863 } | 18857 } |
18864 } | 18858 } |
18865 | 18859 |
18866 } // namespace internal | 18860 } // namespace internal |
18867 } // namespace v8 | 18861 } // namespace v8 |
OLD | NEW |