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 4829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7834 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ | 7845 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ |
7835 Goto(&return_result); \ | 7846 Goto(&return_result); \ |
7836 } | 7847 } |
7837 SIMD128_TYPES(SIMD128_BIND_RETURN) | 7848 SIMD128_TYPES(SIMD128_BIND_RETURN) |
7838 #undef SIMD128_BIND_RETURN | 7849 #undef SIMD128_BIND_RETURN |
7839 | 7850 |
7840 Bind(&return_result); | 7851 Bind(&return_result); |
7841 return result_var.value(); | 7852 return result_var.value(); |
7842 } | 7853 } |
7843 | 7854 |
| 7855 Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, |
| 7856 Node* context) { |
| 7857 CSA_ASSERT(this, IsJSFunction(active_function)); |
| 7858 |
| 7859 Label is_not_constructor(this, Label::kDeferred), out(this); |
| 7860 Variable result(this, MachineRepresentation::kTagged); |
| 7861 |
| 7862 Node* map = LoadMap(active_function); |
| 7863 Node* prototype = LoadMapPrototype(map); |
| 7864 Node* prototype_map = LoadMap(prototype); |
| 7865 GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor); |
| 7866 |
| 7867 result.Bind(prototype); |
| 7868 Goto(&out); |
| 7869 |
| 7870 Bind(&is_not_constructor); |
| 7871 { |
| 7872 result.Bind(CallRuntime(Runtime::kThrowNotSuperConstructor, context, |
| 7873 prototype, active_function)); |
| 7874 Goto(&out); |
| 7875 } |
| 7876 |
| 7877 Bind(&out); |
| 7878 return result.value(); |
| 7879 } |
| 7880 |
7844 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, | 7881 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, |
7845 Node* context) { | 7882 Node* context) { |
7846 Label return_runtime(this, Label::kDeferred), end(this); | 7883 Label return_runtime(this, Label::kDeferred), end(this); |
7847 Variable result(this, MachineRepresentation::kTagged); | 7884 Variable result(this, MachineRepresentation::kTagged); |
7848 | 7885 |
7849 // Check if no one installed @@hasInstance somewhere. | 7886 // Check if no one installed @@hasInstance somewhere. |
7850 GotoUnless( | 7887 GotoUnless( |
7851 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), | 7888 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), |
7852 PropertyCell::kValueOffset), | 7889 PropertyCell::kValueOffset), |
7853 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), | 7890 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8289 Heap::kUndefinedValueRootIndex); | 8326 Heap::kUndefinedValueRootIndex); |
8290 StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugNameOffset, | 8327 StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugNameOffset, |
8291 Heap::kUndefinedValueRootIndex); | 8328 Heap::kUndefinedValueRootIndex); |
8292 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, | 8329 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, |
8293 context); | 8330 context); |
8294 return result; | 8331 return result; |
8295 } | 8332 } |
8296 | 8333 |
8297 } // namespace internal | 8334 } // namespace internal |
8298 } // namespace v8 | 8335 } // namespace v8 |
OLD | NEW |