OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3891 descriptor->Initialize( | 3891 descriptor->Initialize( |
3892 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | 3892 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
3893 } | 3893 } |
3894 | 3894 |
3895 | 3895 |
3896 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { | 3896 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { |
3897 TypeofStub stub(isolate); | 3897 TypeofStub stub(isolate); |
3898 stub.GetCode(); | 3898 stub.GetCode(); |
3899 } | 3899 } |
3900 | 3900 |
| 3901 void HasPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 3902 typedef compiler::Node Node; |
| 3903 typedef CodeStubAssembler::Label Label; |
| 3904 typedef CodeStubAssembler::Variable Variable; |
| 3905 |
| 3906 Node* key = assembler->Parameter(0); |
| 3907 Node* object = assembler->Parameter(1); |
| 3908 Node* context = assembler->Parameter(2); |
| 3909 |
| 3910 Label call_runtime(assembler), return_true(assembler), |
| 3911 return_false(assembler); |
| 3912 |
| 3913 // Ensure object is JSReceiver, otherwise call runtime to throw error. |
| 3914 Label if_objectisnotsmi(assembler); |
| 3915 assembler->Branch(assembler->WordIsSmi(object), &call_runtime, |
| 3916 &if_objectisnotsmi); |
| 3917 assembler->Bind(&if_objectisnotsmi); |
| 3918 |
| 3919 Node* map = assembler->LoadMap(object); |
| 3920 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 3921 { |
| 3922 Label if_objectisreceiver(assembler); |
| 3923 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 3924 assembler->Branch( |
| 3925 assembler->Int32GreaterThanOrEqual( |
| 3926 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), |
| 3927 &if_objectisreceiver, &call_runtime); |
| 3928 assembler->Bind(&if_objectisreceiver); |
| 3929 } |
| 3930 |
| 3931 Variable var_index(assembler, MachineRepresentation::kWord32); |
| 3932 |
| 3933 Label keyisindex(assembler), if_iskeyunique(assembler); |
| 3934 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique, |
| 3935 &call_runtime); |
| 3936 |
| 3937 assembler->Bind(&if_iskeyunique); |
| 3938 { |
| 3939 Variable var_object(assembler, MachineRepresentation::kTagged); |
| 3940 Variable var_map(assembler, MachineRepresentation::kTagged); |
| 3941 Variable var_instance_type(assembler, MachineRepresentation::kWord8); |
| 3942 |
| 3943 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type}; |
| 3944 Label loop(assembler, arraysize(merged_variables), merged_variables); |
| 3945 var_object.Bind(object); |
| 3946 var_map.Bind(map); |
| 3947 var_instance_type.Bind(instance_type); |
| 3948 assembler->Goto(&loop); |
| 3949 assembler->Bind(&loop); |
| 3950 { |
| 3951 Label next_proto(assembler); |
| 3952 assembler->TryLookupProperty(var_object.value(), var_map.value(), |
| 3953 var_instance_type.value(), key, &return_true, |
| 3954 &next_proto, &call_runtime); |
| 3955 assembler->Bind(&next_proto); |
| 3956 |
| 3957 Node* proto = assembler->LoadMapPrototype(var_map.value()); |
| 3958 |
| 3959 Label if_not_null(assembler); |
| 3960 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()), |
| 3961 &return_false, &if_not_null); |
| 3962 assembler->Bind(&if_not_null); |
| 3963 |
| 3964 Node* map = assembler->LoadMap(proto); |
| 3965 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 3966 |
| 3967 var_object.Bind(proto); |
| 3968 var_map.Bind(map); |
| 3969 var_instance_type.Bind(instance_type); |
| 3970 assembler->Goto(&loop); |
| 3971 } |
| 3972 } |
| 3973 assembler->Bind(&keyisindex); |
| 3974 { |
| 3975 Variable var_object(assembler, MachineRepresentation::kTagged); |
| 3976 Variable var_map(assembler, MachineRepresentation::kTagged); |
| 3977 Variable var_instance_type(assembler, MachineRepresentation::kWord8); |
| 3978 |
| 3979 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type}; |
| 3980 Label loop(assembler, arraysize(merged_variables), merged_variables); |
| 3981 var_object.Bind(object); |
| 3982 var_map.Bind(map); |
| 3983 var_instance_type.Bind(instance_type); |
| 3984 assembler->Goto(&loop); |
| 3985 assembler->Bind(&loop); |
| 3986 { |
| 3987 Label next_proto(assembler); |
| 3988 assembler->TryLookupElement(var_object.value(), var_map.value(), |
| 3989 var_instance_type.value(), var_index.value(), |
| 3990 &return_true, &next_proto, &call_runtime); |
| 3991 assembler->Bind(&next_proto); |
| 3992 |
| 3993 Node* proto = assembler->LoadMapPrototype(var_map.value()); |
| 3994 |
| 3995 Label if_not_null(assembler); |
| 3996 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()), |
| 3997 &return_false, &if_not_null); |
| 3998 assembler->Bind(&if_not_null); |
| 3999 |
| 4000 Node* map = assembler->LoadMap(proto); |
| 4001 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 4002 |
| 4003 var_object.Bind(proto); |
| 4004 var_map.Bind(map); |
| 4005 var_instance_type.Bind(instance_type); |
| 4006 assembler->Goto(&loop); |
| 4007 } |
| 4008 } |
| 4009 assembler->Bind(&return_true); |
| 4010 assembler->Return(assembler->BooleanConstant(true)); |
| 4011 |
| 4012 assembler->Bind(&return_false); |
| 4013 assembler->Return(assembler->BooleanConstant(false)); |
| 4014 |
| 4015 assembler->Bind(&call_runtime); |
| 4016 assembler->TailCallRuntime(Runtime::kHasProperty, context, key, object); |
| 4017 } |
3901 | 4018 |
3902 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 4019 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
3903 CreateAllocationSiteStub stub(isolate); | 4020 CreateAllocationSiteStub stub(isolate); |
3904 stub.GetCode(); | 4021 stub.GetCode(); |
3905 } | 4022 } |
3906 | 4023 |
3907 | 4024 |
3908 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { | 4025 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { |
3909 CreateWeakCellStub stub(isolate); | 4026 CreateWeakCellStub stub(isolate); |
3910 stub.GetCode(); | 4027 stub.GetCode(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 if (type->Is(Type::UntaggedPointer())) { | 4213 if (type->Is(Type::UntaggedPointer())) { |
4097 return Representation::External(); | 4214 return Representation::External(); |
4098 } | 4215 } |
4099 | 4216 |
4100 DCHECK(!type->Is(Type::Untagged())); | 4217 DCHECK(!type->Is(Type::Untagged())); |
4101 return Representation::Tagged(); | 4218 return Representation::Tagged(); |
4102 } | 4219 } |
4103 | 4220 |
4104 } // namespace internal | 4221 } // namespace internal |
4105 } // namespace v8 | 4222 } // namespace v8 |
OLD | NEW |