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

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: Rebasing Created 4 years, 5 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
« no previous file with comments | « src/code-stubs.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4282 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 compiler::Node* key, 4293 compiler::Node* key,
4294 compiler::Node* object, 4294 compiler::Node* object,
4295 compiler::Node* context) { 4295 compiler::Node* context) {
4296 typedef compiler::Node Node; 4296 typedef compiler::Node Node;
4297 typedef CodeStubAssembler::Label Label; 4297 typedef CodeStubAssembler::Label Label;
4298 typedef CodeStubAssembler::Variable Variable; 4298 typedef CodeStubAssembler::Variable Variable;
4299 4299
4300 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), 4300 Label call_runtime(assembler, Label::kDeferred), return_true(assembler),
4301 return_false(assembler), end(assembler); 4301 return_false(assembler), end(assembler);
4302 4302
4303 // Ensure object is JSReceiver, otherwise call runtime to throw error. 4303 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
4304 Label if_objectisnotsmi(assembler); 4304 [assembler, &return_true](Node* receiver, Node* holder, Node* holder_map,
4305 assembler->Branch(assembler->WordIsSmi(object), &call_runtime, 4305 Node* holder_instance_type, Node* unique_name,
4306 &if_objectisnotsmi); 4306 Label* next_holder, Label* if_bailout) {
4307 assembler->Bind(&if_objectisnotsmi); 4307 assembler->TryHasOwnProperty(holder, holder_map, holder_instance_type,
4308 unique_name, &return_true, next_holder,
4309 if_bailout);
4310 };
4308 4311
4309 Node* map = assembler->LoadMap(object); 4312 CodeStubAssembler::LookupInHolder lookup_element_in_holder =
4310 Node* instance_type = assembler->LoadMapInstanceType(map); 4313 [assembler, &return_true](Node* receiver, Node* holder, Node* holder_map,
4311 { 4314 Node* holder_instance_type, Node* index,
4312 Label if_objectisreceiver(assembler); 4315 Label* next_holder, Label* if_bailout) {
4313 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); 4316 assembler->TryLookupElement(holder, holder_map, holder_instance_type,
4314 assembler->Branch( 4317 index, &return_true, next_holder,
4315 assembler->Int32GreaterThanOrEqual( 4318 if_bailout);
4316 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), 4319 };
4317 &if_objectisreceiver, &call_runtime);
4318 assembler->Bind(&if_objectisreceiver);
4319 }
4320 4320
4321 Variable var_index(assembler, MachineRepresentation::kWord32); 4321 assembler->TryPrototypeChainLookup(object, key, lookup_property_in_holder,
4322 4322 lookup_element_in_holder, &return_false,
4323 Label keyisindex(assembler), if_iskeyunique(assembler); 4323 &call_runtime);
4324 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique,
4325 &call_runtime);
4326
4327 assembler->Bind(&if_iskeyunique);
4328 {
4329 Variable var_object(assembler, MachineRepresentation::kTagged);
4330 Variable var_map(assembler, MachineRepresentation::kTagged);
4331 Variable var_instance_type(assembler, MachineRepresentation::kWord8);
4332
4333 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type};
4334 Label loop(assembler, arraysize(merged_variables), merged_variables);
4335 var_object.Bind(object);
4336 var_map.Bind(map);
4337 var_instance_type.Bind(instance_type);
4338 assembler->Goto(&loop);
4339 assembler->Bind(&loop);
4340 {
4341 Label next_proto(assembler);
4342 assembler->TryHasOwnProperty(var_object.value(), var_map.value(),
4343 var_instance_type.value(), key, &return_true,
4344 &next_proto, &call_runtime);
4345 assembler->Bind(&next_proto);
4346
4347 Node* proto = assembler->LoadMapPrototype(var_map.value());
4348
4349 Label if_not_null(assembler);
4350 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()),
4351 &return_false, &if_not_null);
4352 assembler->Bind(&if_not_null);
4353
4354 Node* map = assembler->LoadMap(proto);
4355 Node* instance_type = assembler->LoadMapInstanceType(map);
4356
4357 var_object.Bind(proto);
4358 var_map.Bind(map);
4359 var_instance_type.Bind(instance_type);
4360 assembler->Goto(&loop);
4361 }
4362 }
4363 assembler->Bind(&keyisindex);
4364 {
4365 Variable var_object(assembler, MachineRepresentation::kTagged);
4366 Variable var_map(assembler, MachineRepresentation::kTagged);
4367 Variable var_instance_type(assembler, MachineRepresentation::kWord8);
4368
4369 Variable* merged_variables[] = {&var_object, &var_map, &var_instance_type};
4370 Label loop(assembler, arraysize(merged_variables), merged_variables);
4371 var_object.Bind(object);
4372 var_map.Bind(map);
4373 var_instance_type.Bind(instance_type);
4374 assembler->Goto(&loop);
4375 assembler->Bind(&loop);
4376 {
4377 Label next_proto(assembler);
4378 assembler->TryLookupElement(var_object.value(), var_map.value(),
4379 var_instance_type.value(), var_index.value(),
4380 &return_true, &next_proto, &call_runtime);
4381 assembler->Bind(&next_proto);
4382
4383 Node* proto = assembler->LoadMapPrototype(var_map.value());
4384
4385 Label if_not_null(assembler);
4386 assembler->Branch(assembler->WordEqual(proto, assembler->NullConstant()),
4387 &return_false, &if_not_null);
4388 assembler->Bind(&if_not_null);
4389
4390 Node* map = assembler->LoadMap(proto);
4391 Node* instance_type = assembler->LoadMapInstanceType(map);
4392
4393 var_object.Bind(proto);
4394 var_map.Bind(map);
4395 var_instance_type.Bind(instance_type);
4396 assembler->Goto(&loop);
4397 }
4398 }
4399 4324
4400 Variable result(assembler, MachineRepresentation::kTagged); 4325 Variable result(assembler, MachineRepresentation::kTagged);
4401 assembler->Bind(&return_true); 4326 assembler->Bind(&return_true);
4402 { 4327 {
4403 result.Bind(assembler->BooleanConstant(true)); 4328 result.Bind(assembler->BooleanConstant(true));
4404 assembler->Goto(&end); 4329 assembler->Goto(&end);
4405 } 4330 }
4406 4331
4407 assembler->Bind(&return_false); 4332 assembler->Bind(&return_false);
4408 { 4333 {
4409 result.Bind(assembler->BooleanConstant(false)); 4334 result.Bind(assembler->BooleanConstant(false));
4410 assembler->Goto(&end); 4335 assembler->Goto(&end);
4411 } 4336 }
4412 4337
4413 assembler->Bind(&call_runtime); 4338 assembler->Bind(&call_runtime);
4414 { 4339 {
4415 result.Bind( 4340 result.Bind(
4416 assembler->CallRuntime(Runtime::kHasProperty, context, key, object)); 4341 assembler->CallRuntime(Runtime::kHasProperty, context, key, object));
4417 assembler->Goto(&end); 4342 assembler->Goto(&end);
4418 } 4343 }
4419 4344
4420 assembler->Bind(&end); 4345 assembler->Bind(&end);
4421 return result.value(); 4346 return result.value();
4422 } 4347 }
4423 4348
4349 void GetPropertyStub::GenerateAssembly(CodeStubAssembler* assembler) const {
4350 typedef compiler::Node Node;
4351 typedef CodeStubAssembler::Label Label;
4352 typedef CodeStubAssembler::Variable Variable;
4353
4354 Label call_runtime(assembler, Label::kDeferred), return_undefined(assembler),
4355 end(assembler);
4356
4357 Node* object = assembler->Parameter(0);
4358 Node* key = assembler->Parameter(1);
4359 Node* context = assembler->Parameter(2);
4360 Variable var_result(assembler, MachineRepresentation::kTagged);
4361
4362 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
4363 [assembler, context, &var_result, &end](
4364 Node* receiver, Node* holder, Node* holder_map,
4365 Node* holder_instance_type, Node* unique_name, Label* next_holder,
4366 Label* if_bailout) {
4367 Variable var_value(assembler, MachineRepresentation::kTagged);
4368 Label if_found(assembler);
4369 assembler->TryGetOwnProperty(
4370 context, receiver, holder, holder_map, holder_instance_type,
4371 unique_name, &if_found, &var_value, next_holder, if_bailout);
4372 assembler->Bind(&if_found);
4373 {
4374 var_result.Bind(var_value.value());
4375 assembler->Goto(&end);
4376 }
4377 };
4378
4379 CodeStubAssembler::LookupInHolder lookup_element_in_holder =
4380 [assembler, context, &var_result, &end](
4381 Node* receiver, Node* holder, Node* holder_map,
4382 Node* holder_instance_type, Node* index, Label* next_holder,
4383 Label* if_bailout) {
4384 // Not supported yet.
4385 assembler->Use(next_holder);
4386 assembler->Goto(if_bailout);
4387 };
4388
4389 assembler->TryPrototypeChainLookup(object, key, lookup_property_in_holder,
4390 lookup_element_in_holder,
4391 &return_undefined, &call_runtime);
4392
4393 assembler->Bind(&return_undefined);
4394 {
4395 var_result.Bind(assembler->UndefinedConstant());
4396 assembler->Goto(&end);
4397 }
4398
4399 assembler->Bind(&call_runtime);
4400 {
4401 var_result.Bind(
4402 assembler->CallRuntime(Runtime::kGetProperty, context, object, key));
4403 assembler->Goto(&end);
4404 }
4405
4406 assembler->Bind(&end);
4407 assembler->Return(var_result.value());
4408 }
4409
4424 // static 4410 // static
4425 compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler, 4411 compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
4426 compiler::Node* shared_info, 4412 compiler::Node* shared_info,
4427 compiler::Node* context) { 4413 compiler::Node* context) {
4428 typedef compiler::Node Node; 4414 typedef compiler::Node Node;
4429 typedef compiler::CodeAssembler::Label Label; 4415 typedef compiler::CodeAssembler::Label Label;
4430 typedef compiler::CodeAssembler::Variable Variable; 4416 typedef compiler::CodeAssembler::Variable Variable;
4431 4417
4432 Isolate* isolate = assembler->isolate(); 4418 Isolate* isolate = assembler->isolate();
4433 Factory* factory = assembler->isolate()->factory(); 4419 Factory* factory = assembler->isolate()->factory();
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
4874 if (type->Is(Type::UntaggedPointer())) { 4860 if (type->Is(Type::UntaggedPointer())) {
4875 return Representation::External(); 4861 return Representation::External();
4876 } 4862 }
4877 4863
4878 DCHECK(!type->Is(Type::Untagged())); 4864 DCHECK(!type->Is(Type::Untagged()));
4879 return Representation::Tagged(); 4865 return Representation::Tagged();
4880 } 4866 }
4881 4867
4882 } // namespace internal 4868 } // namespace internal
4883 } // namespace v8 4869 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698