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 4090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4101 descriptor->Initialize( | 4101 descriptor->Initialize( |
4102 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | 4102 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
4103 } | 4103 } |
4104 | 4104 |
4105 | 4105 |
4106 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { | 4106 void TypeofStub::GenerateAheadOfTime(Isolate* isolate) { |
4107 TypeofStub stub(isolate); | 4107 TypeofStub stub(isolate); |
4108 stub.GetCode(); | 4108 stub.GetCode(); |
4109 } | 4109 } |
4110 | 4110 |
| 4111 void HasPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 4112 typedef compiler::Node Node; |
| 4113 typedef CodeStubAssembler::Label Label; |
| 4114 typedef CodeStubAssembler::Variable Variable; |
| 4115 |
| 4116 Node* key = assembler->Parameter(0); |
| 4117 Node* object = assembler->Parameter(1); |
| 4118 Node* context = assembler->Parameter(2); |
| 4119 |
| 4120 Label call_runtime(assembler), return_true(assembler), |
| 4121 return_false(assembler); |
| 4122 |
| 4123 // Ensure object is JSReceiver, otherwise call runtime to throw error. |
| 4124 Label if_objectisnotsmi(assembler); |
| 4125 assembler->Branch(assembler->WordIsSmi(object), &call_runtime, |
| 4126 &if_objectisnotsmi); |
| 4127 assembler->Bind(&if_objectisnotsmi); |
| 4128 |
| 4129 Node* map = assembler->LoadMap(object); |
| 4130 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 4131 { |
| 4132 Label if_objectisreceiver(assembler); |
| 4133 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 4134 assembler->Branch( |
| 4135 assembler->Int32GreaterThanOrEqual( |
| 4136 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), |
| 4137 &if_objectisreceiver, &call_runtime); |
| 4138 assembler->Bind(&if_objectisreceiver); |
| 4139 } |
| 4140 |
| 4141 Variable var_index(assembler, MachineRepresentation::kWord32); |
| 4142 |
| 4143 Label keyisindex(assembler), if_iskeyunique(assembler); |
| 4144 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique, |
| 4145 &call_runtime); |
| 4146 |
| 4147 assembler->Bind(&if_iskeyunique); |
| 4148 { |
| 4149 Variable var_object(assembler, MachineRepresentation::kTagged); |
| 4150 Variable var_map(assembler, MachineRepresentation::kTagged); |
| 4151 Variable var_instance_type(assembler, MachineRepresentation::kWord8); |
| 4152 |
| 4153 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type}; |
| 4154 Label loop(assembler, arraysize(merged_variables), merged_variables); |
| 4155 var_object.Bind(object); |
| 4156 var_map.Bind(map); |
| 4157 var_instance_type.Bind(instance_type); |
| 4158 assembler->Goto(&loop); |
| 4159 assembler->Bind(&loop); |
| 4160 { |
| 4161 Label next_proto(assembler); |
| 4162 assembler->TryLookupProperty(var_object.value(), var_map.value(), |
| 4163 var_instance_type.value(), key, &return_true, |
| 4164 &next_proto, &call_runtime); |
| 4165 assembler->Bind(&next_proto); |
| 4166 |
| 4167 Node* proto = assembler->LoadMapPrototype(var_map.value()); |
| 4168 |
| 4169 Label if_not_null(assembler); |
| 4170 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()), |
| 4171 &return_false, &if_not_null); |
| 4172 assembler->Bind(&if_not_null); |
| 4173 |
| 4174 Node* map = assembler->LoadMap(proto); |
| 4175 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 4176 |
| 4177 var_object.Bind(proto); |
| 4178 var_map.Bind(map); |
| 4179 var_instance_type.Bind(instance_type); |
| 4180 assembler->Goto(&loop); |
| 4181 } |
| 4182 } |
| 4183 assembler->Bind(&keyisindex); |
| 4184 { |
| 4185 Variable var_object(assembler, MachineRepresentation::kTagged); |
| 4186 Variable var_map(assembler, MachineRepresentation::kTagged); |
| 4187 Variable var_instance_type(assembler, MachineRepresentation::kWord8); |
| 4188 |
| 4189 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type}; |
| 4190 Label loop(assembler, arraysize(merged_variables), merged_variables); |
| 4191 var_object.Bind(object); |
| 4192 var_map.Bind(map); |
| 4193 var_instance_type.Bind(instance_type); |
| 4194 assembler->Goto(&loop); |
| 4195 assembler->Bind(&loop); |
| 4196 { |
| 4197 Label next_proto(assembler); |
| 4198 assembler->TryLookupElement(var_object.value(), var_map.value(), |
| 4199 var_instance_type.value(), var_index.value(), |
| 4200 &return_true, &next_proto, &call_runtime); |
| 4201 assembler->Bind(&next_proto); |
| 4202 |
| 4203 Node* proto = assembler->LoadMapPrototype(var_map.value()); |
| 4204 |
| 4205 Label if_not_null(assembler); |
| 4206 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()), |
| 4207 &return_false, &if_not_null); |
| 4208 assembler->Bind(&if_not_null); |
| 4209 |
| 4210 Node* map = assembler->LoadMap(proto); |
| 4211 Node* instance_type = assembler->LoadMapInstanceType(map); |
| 4212 |
| 4213 var_object.Bind(proto); |
| 4214 var_map.Bind(map); |
| 4215 var_instance_type.Bind(instance_type); |
| 4216 assembler->Goto(&loop); |
| 4217 } |
| 4218 } |
| 4219 assembler->Bind(&return_true); |
| 4220 assembler->Return(assembler->BooleanConstant(true)); |
| 4221 |
| 4222 assembler->Bind(&return_false); |
| 4223 assembler->Return(assembler->BooleanConstant(false)); |
| 4224 |
| 4225 assembler->Bind(&call_runtime); |
| 4226 assembler->TailCallRuntime(Runtime::kHasProperty, context, key, object); |
| 4227 } |
4111 | 4228 |
4112 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 4229 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
4113 CreateAllocationSiteStub stub(isolate); | 4230 CreateAllocationSiteStub stub(isolate); |
4114 stub.GetCode(); | 4231 stub.GetCode(); |
4115 } | 4232 } |
4116 | 4233 |
4117 | 4234 |
4118 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { | 4235 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { |
4119 CreateWeakCellStub stub(isolate); | 4236 CreateWeakCellStub stub(isolate); |
4120 stub.GetCode(); | 4237 stub.GetCode(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4306 if (type->Is(Type::UntaggedPointer())) { | 4423 if (type->Is(Type::UntaggedPointer())) { |
4307 return Representation::External(); | 4424 return Representation::External(); |
4308 } | 4425 } |
4309 | 4426 |
4310 DCHECK(!type->Is(Type::Untagged())); | 4427 DCHECK(!type->Is(Type::Untagged())); |
4311 return Representation::Tagged(); | 4428 return Representation::Tagged(); |
4312 } | 4429 } |
4313 | 4430 |
4314 } // namespace internal | 4431 } // namespace internal |
4315 } // namespace v8 | 4432 } // namespace v8 |
OLD | NEW |