Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: src/code-stubs.cc

Issue 2087863002: [stubs] GetPropertyStub added. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@get-prop-stub
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4286 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 compiler::Node* key, 4297 compiler::Node* key,
4298 compiler::Node* object, 4298 compiler::Node* object,
4299 compiler::Node* context) { 4299 compiler::Node* context) {
4300 typedef compiler::Node Node; 4300 typedef compiler::Node Node;
4301 typedef CodeStubAssembler::Label Label; 4301 typedef CodeStubAssembler::Label Label;
4302 typedef CodeStubAssembler::Variable Variable; 4302 typedef CodeStubAssembler::Variable Variable;
4303 4303
4304 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), 4304 Label call_runtime(assembler, Label::kDeferred), return_true(assembler),
4305 return_false(assembler), end(assembler); 4305 return_false(assembler), end(assembler);
4306 4306
4307 // Ensure object is JSReceiver, otherwise call runtime to throw error. 4307 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
4308 Label if_objectisnotsmi(assembler); 4308 [assembler, &return_true](Node* receiver, Node* holder, Node* holder_map,
4309 assembler->Branch(assembler->WordIsSmi(object), &call_runtime, 4309 Node* holder_instance_type, Node* unique_name,
4310 &if_objectisnotsmi); 4310 Label* next_holder, Label* if_bailout) {
4311 assembler->Bind(&if_objectisnotsmi); 4311 assembler->TryHasOwnProperty(holder, holder_map, holder_instance_type,
4312 unique_name, &return_true, next_holder,
4313 if_bailout);
4314 };
4312 4315
4313 Node* map = assembler->LoadMap(object); 4316 CodeStubAssembler::LookupInHolder lookup_element_in_holder =
4314 Node* instance_type = assembler->LoadMapInstanceType(map); 4317 [assembler, &return_true](Node* receiver, Node* holder, Node* holder_map,
4315 { 4318 Node* holder_instance_type, Node* index,
4316 Label if_objectisreceiver(assembler); 4319 Label* next_holder, Label* if_bailout) {
4317 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); 4320 assembler->TryLookupElement(holder, holder_map, holder_instance_type,
4318 assembler->Branch( 4321 index, &return_true, next_holder,
4319 assembler->Int32GreaterThanOrEqual( 4322 if_bailout);
4320 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), 4323 };
4321 &if_objectisreceiver, &call_runtime);
4322 assembler->Bind(&if_objectisreceiver);
4323 }
4324 4324
4325 Variable var_index(assembler, MachineRepresentation::kWord32); 4325 assembler->TryPrototypeChainLookup(object, key, lookup_property_in_holder,
4326 4326 lookup_element_in_holder, &return_false,
4327 Label keyisindex(assembler), if_iskeyunique(assembler); 4327 &call_runtime);
4328 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique,
4329 &call_runtime);
4330
4331 assembler->Bind(&if_iskeyunique);
4332 {
4333 Variable var_object(assembler, MachineRepresentation::kTagged);
4334 Variable var_map(assembler, MachineRepresentation::kTagged);
4335 Variable var_instance_type(assembler, MachineRepresentation::kWord8);
4336
4337 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type};
4338 Label loop(assembler, arraysize(merged_variables), merged_variables);
4339 var_object.Bind(object);
4340 var_map.Bind(map);
4341 var_instance_type.Bind(instance_type);
4342 assembler->Goto(&loop);
4343 assembler->Bind(&loop);
4344 {
4345 Label next_proto(assembler);
4346 assembler->TryHasOwnProperty(var_object.value(), var_map.value(),
4347 var_instance_type.value(), key, &return_true,
4348 &next_proto, &call_runtime);
4349 assembler->Bind(&next_proto);
4350
4351 Node* proto = assembler->LoadMapPrototype(var_map.value());
4352
4353 Label if_not_null(assembler);
4354 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()),
4355 &return_false, &if_not_null);
4356 assembler->Bind(&if_not_null);
4357
4358 Node* map = assembler->LoadMap(proto);
4359 Node* instance_type = assembler->LoadMapInstanceType(map);
4360
4361 var_object.Bind(proto);
4362 var_map.Bind(map);
4363 var_instance_type.Bind(instance_type);
4364 assembler->Goto(&loop);
4365 }
4366 }
4367 assembler->Bind(&keyisindex);
4368 {
4369 Variable var_object(assembler, MachineRepresentation::kTagged);
4370 Variable var_map(assembler, MachineRepresentation::kTagged);
4371 Variable var_instance_type(assembler, MachineRepresentation::kWord8);
4372
4373 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type};
4374 Label loop(assembler, arraysize(merged_variables), merged_variables);
4375 var_object.Bind(object);
4376 var_map.Bind(map);
4377 var_instance_type.Bind(instance_type);
4378 assembler->Goto(&loop);
4379 assembler->Bind(&loop);
4380 {
4381 Label next_proto(assembler);
4382 assembler->TryLookupElement(var_object.value(), var_map.value(),
4383 var_instance_type.value(), var_index.value(),
4384 &return_true, &next_proto, &call_runtime);
4385 assembler->Bind(&next_proto);
4386
4387 Node* proto = assembler->LoadMapPrototype(var_map.value());
4388
4389 Label if_not_null(assembler);
4390 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()),
4391 &return_false, &if_not_null);
4392 assembler->Bind(&if_not_null);
4393
4394 Node* map = assembler->LoadMap(proto);
4395 Node* instance_type = assembler->LoadMapInstanceType(map);
4396
4397 var_object.Bind(proto);
4398 var_map.Bind(map);
4399 var_instance_type.Bind(instance_type);
4400 assembler->Goto(&loop);
4401 }
4402 }
4403 4328
4404 Variable result(assembler, MachineRepresentation::kTagged); 4329 Variable result(assembler, MachineRepresentation::kTagged);
4405 assembler->Bind(&return_true); 4330 assembler->Bind(&return_true);
4406 { 4331 {
4407 result.Bind(assembler->BooleanConstant(true)); 4332 result.Bind(assembler->BooleanConstant(true));
4408 assembler->Goto(&end); 4333 assembler->Goto(&end);
4409 } 4334 }
4410 4335
4411 assembler->Bind(&return_false); 4336 assembler->Bind(&return_false);
4412 { 4337 {
4413 result.Bind(assembler->BooleanConstant(false)); 4338 result.Bind(assembler->BooleanConstant(false));
4414 assembler->Goto(&end); 4339 assembler->Goto(&end);
4415 } 4340 }
4416 4341
4417 assembler->Bind(&call_runtime); 4342 assembler->Bind(&call_runtime);
4418 { 4343 {
4419 result.Bind( 4344 result.Bind(
4420 assembler->CallRuntime(Runtime::kHasProperty, context, key, object)); 4345 assembler->CallRuntime(Runtime::kHasProperty, context, key, object));
4421 assembler->Goto(&end); 4346 assembler->Goto(&end);
4422 } 4347 }
4423 4348
4424 assembler->Bind(&end); 4349 assembler->Bind(&end);
4425 return result.value(); 4350 return result.value();
4426 } 4351 }
4427 4352
4353 void GetPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
4354 typedef compiler::Node Node;
4355 typedef CodeStubAssembler::Label Label;
4356 typedef CodeStubAssembler::Variable Variable;
4357
4358 Label call_runtime(assembler, Label::kDeferred), return_undefined(assembler),
4359 end(assembler);
4360
4361 Node* object = assembler->Parameter(0);
4362 Node* key = assembler->Parameter(1);
4363 Node* context = assembler->Parameter(2);
4364 Variable var_result(assembler, MachineRepresentation::kTagged);
4365
4366 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
4367 [assembler, context, &var_result, &end](
4368 Node* receiver, Node* holder, Node* holder_map,
4369 Node* holder_instance_type, Node* unique_name, Label* next_holder,
4370 Label* if_bailout) {
4371 Variable var_value(assembler, MachineRepresentation::kTagged);
4372 Label if_found(assembler);
4373 assembler->TryGetOwnProperty(
4374 context, receiver, holder, holder_map, holder_instance_type,
4375 unique_name, &if_found, &var_value, next_holder, if_bailout);
4376 assembler->Bind(&if_found);
4377 {
4378 var_result.Bind(var_value.value());
4379 assembler->Goto(&end);
4380 }
4381 };
4382
4383 CodeStubAssembler::LookupInHolder lookup_element_in_holder =
4384 [assembler, context, &var_result, &end](
4385 Node* receiver, Node* holder, Node* holder_map,
4386 Node* holder_instance_type, Node* index, Label* next_holder,
4387 Label* if_bailout) {
4388 // Not supported yet.
4389 assembler->Use(next_holder);
4390 assembler->Goto(if_bailout);
4391 };
4392
4393 assembler->TryPrototypeChainLookup(object, key, lookup_property_in_holder,
4394 lookup_element_in_holder,
4395 &return_undefined, &call_runtime);
4396
4397 assembler->Bind(&return_undefined);
4398 {
4399 var_result.Bind(assembler->UndefinedConstant());
4400 assembler->Goto(&end);
4401 }
4402
4403 assembler->Bind(&call_runtime);
4404 {
4405 var_result.Bind(
4406 assembler->CallRuntime(Runtime::kGetProperty, context, object, key));
4407 assembler->Goto(&end);
4408 }
4409
4410 assembler->Bind(&end);
4411 assembler->Return(var_result.value());
4412 }
4413
4428 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { 4414 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
4429 CreateAllocationSiteStub stub(isolate); 4415 CreateAllocationSiteStub stub(isolate);
4430 stub.GetCode(); 4416 stub.GetCode();
4431 } 4417 }
4432 4418
4433 4419
4434 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { 4420 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) {
4435 CreateWeakCellStub stub(isolate); 4421 CreateWeakCellStub stub(isolate);
4436 stub.GetCode(); 4422 stub.GetCode();
4437 } 4423 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4730 if (type->Is(Type::UntaggedPointer())) { 4716 if (type->Is(Type::UntaggedPointer())) {
4731 return Representation::External(); 4717 return Representation::External();
4732 } 4718 }
4733 4719
4734 DCHECK(!type->Is(Type::Untagged())); 4720 DCHECK(!type->Is(Type::Untagged()));
4735 return Representation::Tagged(); 4721 return Representation::Tagged();
4736 } 4722 }
4737 4723
4738 } // namespace internal 4724 } // namespace internal
4739 } // namespace v8 4725 } // namespace v8
OLDNEW
« src/code-stub-assembler.cc ('K') | « src/code-stubs.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698