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 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 Int32Constant(0)); | 2889 Int32Constant(0)); |
2890 } | 2890 } |
2891 | 2891 |
2892 Node* CodeStubAssembler::IsCallableMap(Node* map) { | 2892 Node* CodeStubAssembler::IsCallableMap(Node* map) { |
2893 CSA_ASSERT(this, IsMap(map)); | 2893 CSA_ASSERT(this, IsMap(map)); |
2894 return Word32NotEqual( | 2894 return Word32NotEqual( |
2895 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), | 2895 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), |
2896 Int32Constant(0)); | 2896 Int32Constant(0)); |
2897 } | 2897 } |
2898 | 2898 |
| 2899 Node* CodeStubAssembler::IsConstructorMap(Node* map) { |
| 2900 CSA_ASSERT(this, IsMap(map)); |
| 2901 return Word32NotEqual( |
| 2902 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsConstructor)), |
| 2903 Int32Constant(0)); |
| 2904 } |
| 2905 |
2899 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { | 2906 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { |
2900 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); | 2907 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); |
2901 return Int32LessThanOrEqual(instance_type, | 2908 return Int32LessThanOrEqual(instance_type, |
2902 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); | 2909 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); |
2903 } | 2910 } |
2904 | 2911 |
2905 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { | 2912 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { |
2906 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); | 2913 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); |
2907 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); | 2914 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); |
2908 } | 2915 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2985 | 2992 |
2986 Node* CodeStubAssembler::IsDictionary(Node* object) { | 2993 Node* CodeStubAssembler::IsDictionary(Node* object) { |
2987 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object)); | 2994 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object)); |
2988 } | 2995 } |
2989 | 2996 |
2990 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) { | 2997 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) { |
2991 return WordEqual(LoadMap(object), | 2998 return WordEqual(LoadMap(object), |
2992 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); | 2999 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); |
2993 } | 3000 } |
2994 | 3001 |
| 3002 Node* CodeStubAssembler::IsJSFunction(Node* object) { |
| 3003 return HasInstanceType(object, JS_FUNCTION_TYPE); |
| 3004 } |
| 3005 |
2995 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { | 3006 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
2996 CSA_ASSERT(this, IsString(string)); | 3007 CSA_ASSERT(this, IsString(string)); |
2997 // Translate the {index} into a Word. | 3008 // Translate the {index} into a Word. |
2998 index = SmiToWord(index); | 3009 index = SmiToWord(index); |
2999 | 3010 |
3000 // We may need to loop in case of cons or sliced strings. | 3011 // We may need to loop in case of cons or sliced strings. |
3001 Variable var_index(this, MachineType::PointerRepresentation()); | 3012 Variable var_index(this, MachineType::PointerRepresentation()); |
3002 Variable var_result(this, MachineRepresentation::kWord32); | 3013 Variable var_result(this, MachineRepresentation::kWord32); |
3003 Variable var_string(this, MachineRepresentation::kTagged); | 3014 Variable var_string(this, MachineRepresentation::kTagged); |
3004 Variable* loop_vars[] = {&var_index, &var_string}; | 3015 Variable* loop_vars[] = {&var_index, &var_string}; |
(...skipping 4834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7839 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ | 7850 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ |
7840 Goto(&return_result); \ | 7851 Goto(&return_result); \ |
7841 } | 7852 } |
7842 SIMD128_TYPES(SIMD128_BIND_RETURN) | 7853 SIMD128_TYPES(SIMD128_BIND_RETURN) |
7843 #undef SIMD128_BIND_RETURN | 7854 #undef SIMD128_BIND_RETURN |
7844 | 7855 |
7845 Bind(&return_result); | 7856 Bind(&return_result); |
7846 return result_var.value(); | 7857 return result_var.value(); |
7847 } | 7858 } |
7848 | 7859 |
| 7860 Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, |
| 7861 Node* context) { |
| 7862 CSA_ASSERT(this, IsJSFunction(active_function)); |
| 7863 |
| 7864 Label is_not_constructor(this, Label::kDeferred), out(this); |
| 7865 Variable result(this, MachineRepresentation::kTagged); |
| 7866 |
| 7867 Node* map = LoadMap(active_function); |
| 7868 Node* prototype = LoadMapPrototype(map); |
| 7869 Node* prototype_map = LoadMap(prototype); |
| 7870 GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor); |
| 7871 |
| 7872 result.Bind(prototype); |
| 7873 Goto(&out); |
| 7874 |
| 7875 Bind(&is_not_constructor); |
| 7876 { |
| 7877 result.Bind(CallRuntime(Runtime::kThrowNotSuperConstructor, context, |
| 7878 prototype, active_function)); |
| 7879 Goto(&out); |
| 7880 } |
| 7881 |
| 7882 Bind(&out); |
| 7883 return result.value(); |
| 7884 } |
| 7885 |
7849 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, | 7886 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, |
7850 Node* context) { | 7887 Node* context) { |
7851 Label return_runtime(this, Label::kDeferred), end(this); | 7888 Label return_runtime(this, Label::kDeferred), end(this); |
7852 Variable result(this, MachineRepresentation::kTagged); | 7889 Variable result(this, MachineRepresentation::kTagged); |
7853 | 7890 |
7854 // Check if no one installed @@hasInstance somewhere. | 7891 // Check if no one installed @@hasInstance somewhere. |
7855 GotoUnless( | 7892 GotoUnless( |
7856 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), | 7893 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), |
7857 PropertyCell::kValueOffset), | 7894 PropertyCell::kValueOffset), |
7858 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), | 7895 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8293 Heap::kUndefinedValueRootIndex); | 8330 Heap::kUndefinedValueRootIndex); |
8294 StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugNameOffset, | 8331 StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugNameOffset, |
8295 Heap::kUndefinedValueRootIndex); | 8332 Heap::kUndefinedValueRootIndex); |
8296 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, | 8333 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, |
8297 context); | 8334 context); |
8298 return result; | 8335 return result; |
8299 } | 8336 } |
8300 | 8337 |
8301 } // namespace internal | 8338 } // namespace internal |
8302 } // namespace v8 | 8339 } // namespace v8 |
OLD | NEW |