Chromium Code Reviews| 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 2862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2873 Int32Constant(0)); | 2873 Int32Constant(0)); |
| 2874 } | 2874 } |
| 2875 | 2875 |
| 2876 Node* CodeStubAssembler::IsCallableMap(Node* map) { | 2876 Node* CodeStubAssembler::IsCallableMap(Node* map) { |
| 2877 CSA_ASSERT(this, IsMap(map)); | 2877 CSA_ASSERT(this, IsMap(map)); |
| 2878 return Word32NotEqual( | 2878 return Word32NotEqual( |
| 2879 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), | 2879 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), |
| 2880 Int32Constant(0)); | 2880 Int32Constant(0)); |
| 2881 } | 2881 } |
| 2882 | 2882 |
| 2883 Node* CodeStubAssembler::IsConstructorMap(Node* map) { | |
| 2884 CSA_ASSERT(this, IsMap(map)); | |
| 2885 return Word32NotEqual( | |
| 2886 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsConstructor)), | |
| 2887 Int32Constant(0)); | |
| 2888 } | |
| 2889 | |
| 2883 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { | 2890 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { |
| 2884 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); | 2891 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); |
| 2885 return Int32LessThanOrEqual(instance_type, | 2892 return Int32LessThanOrEqual(instance_type, |
| 2886 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); | 2893 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); |
| 2887 } | 2894 } |
| 2888 | 2895 |
| 2889 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { | 2896 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { |
| 2890 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); | 2897 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); |
| 2891 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); | 2898 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); |
| 2892 } | 2899 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2953 | 2960 |
| 2954 Node* CodeStubAssembler::IsDictionary(Node* object) { | 2961 Node* CodeStubAssembler::IsDictionary(Node* object) { |
| 2955 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object)); | 2962 return Word32Or(IsHashTable(object), IsUnseededNumberDictionary(object)); |
| 2956 } | 2963 } |
| 2957 | 2964 |
| 2958 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) { | 2965 Node* CodeStubAssembler::IsUnseededNumberDictionary(Node* object) { |
| 2959 return WordEqual(LoadMap(object), | 2966 return WordEqual(LoadMap(object), |
| 2960 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); | 2967 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); |
| 2961 } | 2968 } |
| 2962 | 2969 |
| 2970 Node* CodeStubAssembler::IsJSFunction(Node* object) { | |
| 2971 return HasInstanceType(object, JS_FUNCTION_TYPE); | |
| 2972 } | |
| 2973 | |
| 2963 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { | 2974 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
| 2964 CSA_ASSERT(this, IsString(string)); | 2975 CSA_ASSERT(this, IsString(string)); |
| 2965 // Translate the {index} into a Word. | 2976 // Translate the {index} into a Word. |
| 2966 index = SmiToWord(index); | 2977 index = SmiToWord(index); |
| 2967 | 2978 |
| 2968 // We may need to loop in case of cons or sliced strings. | 2979 // We may need to loop in case of cons or sliced strings. |
| 2969 Variable var_index(this, MachineType::PointerRepresentation()); | 2980 Variable var_index(this, MachineType::PointerRepresentation()); |
| 2970 Variable var_result(this, MachineRepresentation::kWord32); | 2981 Variable var_result(this, MachineRepresentation::kWord32); |
| 2971 Variable var_string(this, MachineRepresentation::kTagged); | 2982 Variable var_string(this, MachineRepresentation::kTagged); |
| 2972 Variable* loop_vars[] = {&var_index, &var_string}; | 2983 Variable* loop_vars[] = {&var_index, &var_string}; |
| (...skipping 4838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7811 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ | 7822 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ |
| 7812 Goto(&return_result); \ | 7823 Goto(&return_result); \ |
| 7813 } | 7824 } |
| 7814 SIMD128_TYPES(SIMD128_BIND_RETURN) | 7825 SIMD128_TYPES(SIMD128_BIND_RETURN) |
| 7815 #undef SIMD128_BIND_RETURN | 7826 #undef SIMD128_BIND_RETURN |
| 7816 | 7827 |
| 7817 Bind(&return_result); | 7828 Bind(&return_result); |
| 7818 return result_var.value(); | 7829 return result_var.value(); |
| 7819 } | 7830 } |
| 7820 | 7831 |
| 7832 Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, | |
| 7833 Node* context) { | |
| 7834 CSA_ASSERT(this, IsJSFunction(active_function)); | |
| 7835 | |
| 7836 Label is_not_constructor(this, Label::kDeferred), out(this); | |
| 7837 Variable result(this, MachineRepresentation::kTagged); | |
| 7838 | |
| 7839 Node* map = LoadMap(active_function); | |
| 7840 Node* prototype = LoadMapPrototype(map); | |
| 7841 Node* prototype_map = LoadMap(prototype); | |
| 7842 GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor); | |
| 7843 | |
| 7844 result.Bind(prototype); | |
| 7845 Goto(&out); | |
| 7846 | |
| 7847 Bind(&is_not_constructor); | |
| 7848 { | |
| 7849 CallRuntime(Runtime::kThrowNotSuperConstructor, context, prototype, | |
| 7850 active_function); | |
| 7851 result.Bind(UndefinedConstant()); // Never reached. | |
|
Benedikt Meurer
2016/12/12 18:18:19
Nit: you could just bind the result of the runtime
| |
| 7852 Goto(&out); | |
| 7853 } | |
| 7854 | |
| 7855 Bind(&out); | |
| 7856 return result.value(); | |
| 7857 } | |
| 7858 | |
| 7821 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, | 7859 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable, |
| 7822 Node* context) { | 7860 Node* context) { |
| 7823 Label return_runtime(this, Label::kDeferred), end(this); | 7861 Label return_runtime(this, Label::kDeferred), end(this); |
| 7824 Variable result(this, MachineRepresentation::kTagged); | 7862 Variable result(this, MachineRepresentation::kTagged); |
| 7825 | 7863 |
| 7826 // Check if no one installed @@hasInstance somewhere. | 7864 // Check if no one installed @@hasInstance somewhere. |
| 7827 GotoUnless( | 7865 GotoUnless( |
| 7828 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), | 7866 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), |
| 7829 PropertyCell::kValueOffset), | 7867 PropertyCell::kValueOffset), |
| 7830 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), | 7868 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8222 | 8260 |
| 8223 Node* CodeStubAssembler::IsDebugActive() { | 8261 Node* CodeStubAssembler::IsDebugActive() { |
| 8224 Node* is_debug_active = Load( | 8262 Node* is_debug_active = Load( |
| 8225 MachineType::Uint8(), | 8263 MachineType::Uint8(), |
| 8226 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); | 8264 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); |
| 8227 return WordNotEqual(is_debug_active, Int32Constant(0)); | 8265 return WordNotEqual(is_debug_active, Int32Constant(0)); |
| 8228 } | 8266 } |
| 8229 | 8267 |
| 8230 } // namespace internal | 8268 } // namespace internal |
| 8231 } // namespace v8 | 8269 } // namespace v8 |
| OLD | NEW |