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 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5287 Node* callable_map = LoadMap(callable); | 5294 Node* callable_map = LoadMap(callable); |
5288 | 5295 |
5289 // Goto runtime if {callable} is not a JSFunction. | 5296 // Goto runtime if {callable} is not a JSFunction. |
5290 Node* callable_instance_type = LoadMapInstanceType(callable_map); | 5297 Node* callable_instance_type = LoadMapInstanceType(callable_map); |
5291 GotoUnless( | 5298 GotoUnless( |
5292 Word32Equal(callable_instance_type, Int32Constant(JS_FUNCTION_TYPE)), | 5299 Word32Equal(callable_instance_type, Int32Constant(JS_FUNCTION_TYPE)), |
5293 &return_runtime); | 5300 &return_runtime); |
5294 | 5301 |
5295 // Goto runtime if {callable} is not a constructor or has | 5302 // Goto runtime if {callable} is not a constructor or has |
5296 // a non-instance "prototype". | 5303 // a non-instance "prototype". |
5297 Node* callable_bitfield = LoadMapBitField(callable_map); | 5304 GotoUnless(IsConstructorMap(callable_map), &return_runtime); |
Benedikt Meurer
2016/12/08 18:42:24
This is not correct, as the original code also tes
Henrique Ferreiro
2016/12/09 13:24:28
Sorry, I should have double-checked. Anyway, is it
Benedikt Meurer
2016/12/09 18:30:28
Better do a separate CL for those. Unrelated chang
| |
5298 GotoUnless( | |
5299 Word32Equal(Word32And(callable_bitfield, | |
5300 Int32Constant((1 << Map::kHasNonInstancePrototype) | | |
5301 (1 << Map::kIsConstructor))), | |
5302 Int32Constant(1 << Map::kIsConstructor)), | |
5303 &return_runtime); | |
5304 | 5305 |
5305 // Get the "prototype" (or initial map) of the {callable}. | 5306 // Get the "prototype" (or initial map) of the {callable}. |
5306 Node* callable_prototype = | 5307 Node* callable_prototype = |
5307 LoadObjectField(callable, JSFunction::kPrototypeOrInitialMapOffset); | 5308 LoadObjectField(callable, JSFunction::kPrototypeOrInitialMapOffset); |
5308 { | 5309 { |
5309 Variable var_callable_prototype(this, MachineRepresentation::kTagged); | 5310 Variable var_callable_prototype(this, MachineRepresentation::kTagged); |
5310 Label callable_prototype_valid(this); | 5311 Label callable_prototype_valid(this); |
5311 var_callable_prototype.Bind(callable_prototype); | 5312 var_callable_prototype.Bind(callable_prototype); |
5312 | 5313 |
5313 // Resolve the "prototype" if the {callable} has an initial map. Afterwards | 5314 // Resolve the "prototype" if the {callable} has an initial map. Afterwards |
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7811 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ | 7812 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ |
7812 Goto(&return_result); \ | 7813 Goto(&return_result); \ |
7813 } | 7814 } |
7814 SIMD128_TYPES(SIMD128_BIND_RETURN) | 7815 SIMD128_TYPES(SIMD128_BIND_RETURN) |
7815 #undef SIMD128_BIND_RETURN | 7816 #undef SIMD128_BIND_RETURN |
7816 | 7817 |
7817 Bind(&return_result); | 7818 Bind(&return_result); |
7818 return result_var.value(); | 7819 return result_var.value(); |
7819 } | 7820 } |
7820 | 7821 |
7822 Node* CodeStubAssembler::GetSuperConstructor(Node* active_function, | |
7823 Node* context) { | |
7824 Label is_not_object(this, Label::kDeferred), | |
7825 is_not_constructor(this, Label::kDeferred), out(this); | |
7826 Variable result(this, MachineRepresentation::kTagged); | |
7827 | |
7828 Node* map = LoadMap(active_function); | |
7829 Node* prototype = LoadMapPrototype(map); | |
7830 GotoIf(TaggedIsSmi(active_function), &is_not_object); | |
7831 | |
7832 Node* prototype_map = LoadMap(prototype); | |
7833 GotoUnless(IsConstructorMap(prototype_map), &is_not_constructor); | |
7834 | |
7835 result.Bind(prototype); | |
7836 Goto(&out); | |
7837 | |
7838 Bind(&is_not_object); | |
7839 { | |
7840 CallRuntime(Runtime::kThrowTypeError, context, | |
7841 SmiConstant(MessageTemplate::kMethodCalledOnWrongObject), | |
7842 HeapConstant(factory()->NewStringFromStaticChars("super"))); | |
7843 result.Bind(UndefinedConstant()); // Never reached. | |
7844 Goto(&out); | |
7845 } | |
7846 | |
7847 Bind(&is_not_constructor); | |
7848 { | |
7849 CallRuntime(Runtime::kThrowNotSuperConstructor, context, prototype, | |
7850 active_function); | |
7851 result.Bind(UndefinedConstant()); // Never reached. | |
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 |