| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
| 5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2687 Goto(&if_valueisstring); | 2687 Goto(&if_valueisstring); |
| 2688 } | 2688 } |
| 2689 } | 2689 } |
| 2690 | 2690 |
| 2691 Bind(&if_valueisnullorundefined); | 2691 Bind(&if_valueisnullorundefined); |
| 2692 { | 2692 { |
| 2693 // The {value} is either null or undefined. | 2693 // The {value} is either null or undefined. |
| 2694 CallRuntime(Runtime::kThrowCalledOnNullOrUndefined, context, | 2694 CallRuntime(Runtime::kThrowCalledOnNullOrUndefined, context, |
| 2695 HeapConstant(factory()->NewStringFromAsciiChecked( | 2695 HeapConstant(factory()->NewStringFromAsciiChecked( |
| 2696 method_name, TENURED))); | 2696 method_name, TENURED))); |
| 2697 Goto(&if_valueisstring); // Never reached. | 2697 Unreachable(); |
| 2698 } | 2698 } |
| 2699 } | 2699 } |
| 2700 } | 2700 } |
| 2701 Bind(&if_valueissmi); | 2701 Bind(&if_valueissmi); |
| 2702 { | 2702 { |
| 2703 // The {value} is a Smi, convert it to a String. | 2703 // The {value} is a Smi, convert it to a String. |
| 2704 Callable callable = CodeFactory::NumberToString(isolate()); | 2704 Callable callable = CodeFactory::NumberToString(isolate()); |
| 2705 var_value.Bind(CallStub(callable, context, value)); | 2705 var_value.Bind(CallStub(callable, context, value)); |
| 2706 Goto(&if_valueisstring); | 2706 Goto(&if_valueisstring); |
| 2707 } | 2707 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2786 Goto(&done_throw); | 2786 Goto(&done_throw); |
| 2787 } | 2787 } |
| 2788 } | 2788 } |
| 2789 | 2789 |
| 2790 Bind(&done_throw); | 2790 Bind(&done_throw); |
| 2791 { | 2791 { |
| 2792 // The {value} is not a compatible receiver for this method. | 2792 // The {value} is not a compatible receiver for this method. |
| 2793 CallRuntime(Runtime::kThrowNotGeneric, context, | 2793 CallRuntime(Runtime::kThrowNotGeneric, context, |
| 2794 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, | 2794 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, |
| 2795 TENURED))); | 2795 TENURED))); |
| 2796 Goto(&done_loop); // Never reached. | 2796 Unreachable(); |
| 2797 } | 2797 } |
| 2798 | 2798 |
| 2799 Bind(&done_loop); | 2799 Bind(&done_loop); |
| 2800 return var_value.value(); | 2800 return var_value.value(); |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 Node* CodeStubAssembler::ThrowIfNotInstanceType(Node* context, Node* value, | 2803 Node* CodeStubAssembler::ThrowIfNotInstanceType(Node* context, Node* value, |
| 2804 InstanceType instance_type, | 2804 InstanceType instance_type, |
| 2805 char const* method_name) { | 2805 char const* method_name) { |
| 2806 Label out(this), throw_exception(this, Label::kDeferred); | 2806 Label out(this), throw_exception(this, Label::kDeferred); |
| 2807 Variable var_value_map(this, MachineRepresentation::kTagged); | 2807 Variable var_value_map(this, MachineRepresentation::kTagged); |
| 2808 | 2808 |
| 2809 GotoIf(TaggedIsSmi(value), &throw_exception); | 2809 GotoIf(TaggedIsSmi(value), &throw_exception); |
| 2810 | 2810 |
| 2811 // Load the instance type of the {value}. | 2811 // Load the instance type of the {value}. |
| 2812 var_value_map.Bind(LoadMap(value)); | 2812 var_value_map.Bind(LoadMap(value)); |
| 2813 Node* const value_instance_type = LoadMapInstanceType(var_value_map.value()); | 2813 Node* const value_instance_type = LoadMapInstanceType(var_value_map.value()); |
| 2814 | 2814 |
| 2815 Branch(Word32Equal(value_instance_type, Int32Constant(instance_type)), &out, | 2815 Branch(Word32Equal(value_instance_type, Int32Constant(instance_type)), &out, |
| 2816 &throw_exception); | 2816 &throw_exception); |
| 2817 | 2817 |
| 2818 // The {value} is not a compatible receiver for this method. | 2818 // The {value} is not a compatible receiver for this method. |
| 2819 Bind(&throw_exception); | 2819 Bind(&throw_exception); |
| 2820 CallRuntime( | 2820 CallRuntime( |
| 2821 Runtime::kThrowIncompatibleMethodReceiver, context, | 2821 Runtime::kThrowIncompatibleMethodReceiver, context, |
| 2822 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)), | 2822 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)), |
| 2823 value); | 2823 value); |
| 2824 var_value_map.Bind(UndefinedConstant()); | 2824 Unreachable(); |
| 2825 Goto(&out); // Never reached. | |
| 2826 | 2825 |
| 2827 Bind(&out); | 2826 Bind(&out); |
| 2828 return var_value_map.value(); | 2827 return var_value_map.value(); |
| 2829 } | 2828 } |
| 2830 | 2829 |
| 2831 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { | 2830 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { |
| 2832 return Word32Equal(instance_type, Int32Constant(type)); | 2831 return Word32Equal(instance_type, Int32Constant(type)); |
| 2833 } | 2832 } |
| 2834 | 2833 |
| 2835 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { | 2834 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { |
| (...skipping 4966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7802 Node* map = LoadMap(active_function); | 7801 Node* map = LoadMap(active_function); |
| 7803 Node* prototype = LoadMapPrototype(map); | 7802 Node* prototype = LoadMapPrototype(map); |
| 7804 Node* prototype_map = LoadMap(prototype); | 7803 Node* prototype_map = LoadMap(prototype); |
| 7805 GotoIfNot(IsConstructorMap(prototype_map), &is_not_constructor); | 7804 GotoIfNot(IsConstructorMap(prototype_map), &is_not_constructor); |
| 7806 | 7805 |
| 7807 result.Bind(prototype); | 7806 result.Bind(prototype); |
| 7808 Goto(&out); | 7807 Goto(&out); |
| 7809 | 7808 |
| 7810 Bind(&is_not_constructor); | 7809 Bind(&is_not_constructor); |
| 7811 { | 7810 { |
| 7812 result.Bind(CallRuntime(Runtime::kThrowNotSuperConstructor, context, | 7811 CallRuntime(Runtime::kThrowNotSuperConstructor, context, prototype, |
| 7813 prototype, active_function)); | 7812 active_function); |
| 7814 Goto(&out); | 7813 Unreachable(); |
| 7815 } | 7814 } |
| 7816 | 7815 |
| 7817 Bind(&out); | 7816 Bind(&out); |
| 7818 return result.value(); | 7817 return result.value(); |
| 7819 } | 7818 } |
| 7820 | 7819 |
| 7821 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, | 7820 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, |
| 7822 Node* context) { | 7821 Node* context) { |
| 7823 Variable var_result(this, MachineRepresentation::kTagged); | 7822 Variable var_result(this, MachineRepresentation::kTagged); |
| 7824 Label if_notcallable(this, Label::kDeferred), | 7823 Label if_notcallable(this, Label::kDeferred), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7873 | 7872 |
| 7874 // Use the OrdinaryHasInstance algorithm. | 7873 // Use the OrdinaryHasInstance algorithm. |
| 7875 Node* result = CallStub(CodeFactory::OrdinaryHasInstance(isolate()), | 7874 Node* result = CallStub(CodeFactory::OrdinaryHasInstance(isolate()), |
| 7876 context, callable, object); | 7875 context, callable, object); |
| 7877 var_result.Bind(result); | 7876 var_result.Bind(result); |
| 7878 Goto(&return_result); | 7877 Goto(&return_result); |
| 7879 } | 7878 } |
| 7880 | 7879 |
| 7881 Bind(&if_notcallable); | 7880 Bind(&if_notcallable); |
| 7882 { | 7881 { |
| 7883 Node* result = | 7882 CallRuntime(Runtime::kThrowNonCallableInInstanceOfCheck, context); |
| 7884 CallRuntime(Runtime::kThrowNonCallableInInstanceOfCheck, context); | 7883 Unreachable(); |
| 7885 var_result.Bind(result); | |
| 7886 Goto(&return_result); | |
| 7887 } | 7884 } |
| 7888 | 7885 |
| 7889 Bind(&if_notreceiver); | 7886 Bind(&if_notreceiver); |
| 7890 { | 7887 { |
| 7891 Node* result = | 7888 CallRuntime(Runtime::kThrowNonObjectInInstanceOfCheck, context); |
| 7892 CallRuntime(Runtime::kThrowNonObjectInInstanceOfCheck, context); | 7889 Unreachable(); |
| 7893 var_result.Bind(result); | |
| 7894 Goto(&return_result); | |
| 7895 } | 7890 } |
| 7896 | 7891 |
| 7897 Bind(&return_true); | 7892 Bind(&return_true); |
| 7898 var_result.Bind(TrueConstant()); | 7893 var_result.Bind(TrueConstant()); |
| 7899 Goto(&return_result); | 7894 Goto(&return_result); |
| 7900 | 7895 |
| 7901 Bind(&return_false); | 7896 Bind(&return_false); |
| 7902 var_result.Bind(FalseConstant()); | 7897 var_result.Bind(FalseConstant()); |
| 7903 Goto(&return_result); | 7898 Goto(&return_result); |
| 7904 | 7899 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8377 formatted.c_str(), TENURED); | 8372 formatted.c_str(), TENURED); |
| 8378 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8373 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
| 8379 HeapConstant(string)); | 8374 HeapConstant(string)); |
| 8380 } | 8375 } |
| 8381 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 8376 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
| 8382 #endif | 8377 #endif |
| 8383 } | 8378 } |
| 8384 | 8379 |
| 8385 } // namespace internal | 8380 } // namespace internal |
| 8386 } // namespace v8 | 8381 } // namespace v8 |
| OLD | NEW |