OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 5430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5441 | 5441 |
5442 if (!ast_context()->IsTest()) { | 5442 if (!ast_context()->IsTest()) { |
5443 HBasicBlock* join = CreateJoin(cond_true, cond_false, expr->id()); | 5443 HBasicBlock* join = CreateJoin(cond_true, cond_false, expr->id()); |
5444 set_current_block(join); | 5444 set_current_block(join); |
5445 if (join != NULL && !ast_context()->IsEffect()) { | 5445 if (join != NULL && !ast_context()->IsEffect()) { |
5446 return ast_context()->ReturnValue(Pop()); | 5446 return ast_context()->ReturnValue(Pop()); |
5447 } | 5447 } |
5448 } | 5448 } |
5449 } | 5449 } |
5450 | 5450 |
5451 bool HOptimizedGraphBuilder::CanInlineGlobalPropertyAccess( | |
5452 Variable* var, LookupIterator* it, PropertyAccessType access_type) { | |
5453 if (var->is_this()) return false; | |
5454 return CanInlineGlobalPropertyAccess(it, access_type); | |
5455 } | |
5456 | 5451 |
5457 bool HOptimizedGraphBuilder::CanInlineGlobalPropertyAccess( | 5452 HOptimizedGraphBuilder::GlobalPropertyAccess |
5458 LookupIterator* it, PropertyAccessType access_type) { | 5453 HOptimizedGraphBuilder::LookupGlobalProperty(Variable* var, LookupIterator* it, |
5459 if (!current_info()->has_global_object()) { | 5454 PropertyAccessType access_type) { |
5460 return false; | 5455 if (var->is_this() || !current_info()->has_global_object()) { |
| 5456 return kUseGeneric; |
5461 } | 5457 } |
5462 | 5458 |
5463 switch (it->state()) { | 5459 switch (it->state()) { |
5464 case LookupIterator::ACCESSOR: | 5460 case LookupIterator::ACCESSOR: |
5465 case LookupIterator::ACCESS_CHECK: | 5461 case LookupIterator::ACCESS_CHECK: |
5466 case LookupIterator::INTERCEPTOR: | 5462 case LookupIterator::INTERCEPTOR: |
5467 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 5463 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
5468 case LookupIterator::NOT_FOUND: | 5464 case LookupIterator::NOT_FOUND: |
5469 return false; | 5465 return kUseGeneric; |
5470 case LookupIterator::DATA: | 5466 case LookupIterator::DATA: |
5471 if (access_type == STORE && it->IsReadOnly()) return false; | 5467 if (access_type == STORE && it->IsReadOnly()) return kUseGeneric; |
5472 if (!it->GetHolder<JSObject>()->IsJSGlobalObject()) return false; | 5468 if (!it->GetHolder<JSObject>()->IsJSGlobalObject()) return kUseGeneric; |
5473 return true; | 5469 return kUseCell; |
5474 case LookupIterator::JSPROXY: | 5470 case LookupIterator::JSPROXY: |
5475 case LookupIterator::TRANSITION: | 5471 case LookupIterator::TRANSITION: |
5476 UNREACHABLE(); | 5472 UNREACHABLE(); |
5477 } | 5473 } |
5478 UNREACHABLE(); | 5474 UNREACHABLE(); |
5479 return false; | 5475 return kUseGeneric; |
5480 } | 5476 } |
5481 | 5477 |
5482 | 5478 |
5483 HValue* HOptimizedGraphBuilder::BuildContextChainWalk(Variable* var) { | 5479 HValue* HOptimizedGraphBuilder::BuildContextChainWalk(Variable* var) { |
5484 DCHECK(var->IsContextSlot()); | 5480 DCHECK(var->IsContextSlot()); |
5485 HValue* context = environment()->context(); | 5481 HValue* context = environment()->context(); |
5486 int length = scope()->ContextChainLength(var->scope()); | 5482 int length = scope()->ContextChainLength(var->scope()); |
5487 while (length-- > 0) { | 5483 while (length-- > 0) { |
5488 context = Add<HLoadNamedField>( | 5484 context = Add<HLoadNamedField>( |
5489 context, nullptr, | 5485 context, nullptr, |
5490 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); | 5486 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); |
5491 } | 5487 } |
5492 return context; | 5488 return context; |
5493 } | 5489 } |
5494 | 5490 |
5495 void HOptimizedGraphBuilder::InlineGlobalPropertyLoad(LookupIterator* it, | |
5496 BailoutId ast_id) { | |
5497 Handle<PropertyCell> cell = it->GetPropertyCell(); | |
5498 top_info()->dependencies()->AssumePropertyCell(cell); | |
5499 auto cell_type = it->property_details().cell_type(); | |
5500 if (cell_type == PropertyCellType::kConstant || | |
5501 cell_type == PropertyCellType::kUndefined) { | |
5502 Handle<Object> constant_object(cell->value(), isolate()); | |
5503 if (constant_object->IsConsString()) { | |
5504 constant_object = String::Flatten(Handle<String>::cast(constant_object)); | |
5505 } | |
5506 HConstant* constant = New<HConstant>(constant_object); | |
5507 return ast_context()->ReturnInstruction(constant, ast_id); | |
5508 } else { | |
5509 auto access = HObjectAccess::ForPropertyCellValue(); | |
5510 UniqueSet<Map>* field_maps = nullptr; | |
5511 if (cell_type == PropertyCellType::kConstantType) { | |
5512 switch (cell->GetConstantType()) { | |
5513 case PropertyCellConstantType::kSmi: | |
5514 access = access.WithRepresentation(Representation::Smi()); | |
5515 break; | |
5516 case PropertyCellConstantType::kStableMap: { | |
5517 // Check that the map really is stable. The heap object could | |
5518 // have mutated without the cell updating state. In that case, | |
5519 // make no promises about the loaded value except that it's a | |
5520 // heap object. | |
5521 access = access.WithRepresentation(Representation::HeapObject()); | |
5522 Handle<Map> map(HeapObject::cast(cell->value())->map()); | |
5523 if (map->is_stable()) { | |
5524 field_maps = new (zone()) | |
5525 UniqueSet<Map>(Unique<Map>::CreateImmovable(map), zone()); | |
5526 } | |
5527 break; | |
5528 } | |
5529 } | |
5530 } | |
5531 HConstant* cell_constant = Add<HConstant>(cell); | |
5532 HLoadNamedField* instr; | |
5533 if (field_maps == nullptr) { | |
5534 instr = New<HLoadNamedField>(cell_constant, nullptr, access); | |
5535 } else { | |
5536 instr = New<HLoadNamedField>(cell_constant, nullptr, access, field_maps, | |
5537 HType::HeapObject()); | |
5538 } | |
5539 instr->ClearDependsOnFlag(kInobjectFields); | |
5540 instr->SetDependsOnFlag(kGlobalVars); | |
5541 return ast_context()->ReturnInstruction(instr, ast_id); | |
5542 } | |
5543 } | |
5544 | 5491 |
5545 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 5492 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
5546 DCHECK(!HasStackOverflow()); | 5493 DCHECK(!HasStackOverflow()); |
5547 DCHECK(current_block() != NULL); | 5494 DCHECK(current_block() != NULL); |
5548 DCHECK(current_block()->HasPredecessor()); | 5495 DCHECK(current_block()->HasPredecessor()); |
5549 Variable* variable = expr->var(); | 5496 Variable* variable = expr->var(); |
5550 switch (variable->location()) { | 5497 switch (variable->location()) { |
5551 case VariableLocation::UNALLOCATED: { | 5498 case VariableLocation::UNALLOCATED: { |
5552 if (IsLexicalVariableMode(variable->mode())) { | 5499 if (IsLexicalVariableMode(variable->mode())) { |
5553 // TODO(rossberg): should this be an DCHECK? | 5500 // TODO(rossberg): should this be an DCHECK? |
(...skipping 28 matching lines...) Expand all Loading... |
5582 return Bailout(kReferenceToUninitializedVariable); | 5529 return Bailout(kReferenceToUninitializedVariable); |
5583 } | 5530 } |
5584 HInstruction* result = New<HLoadNamedField>( | 5531 HInstruction* result = New<HLoadNamedField>( |
5585 Add<HConstant>(script_context), nullptr, | 5532 Add<HConstant>(script_context), nullptr, |
5586 HObjectAccess::ForContextSlot(lookup.slot_index)); | 5533 HObjectAccess::ForContextSlot(lookup.slot_index)); |
5587 return ast_context()->ReturnInstruction(result, expr->id()); | 5534 return ast_context()->ReturnInstruction(result, expr->id()); |
5588 } | 5535 } |
5589 } | 5536 } |
5590 | 5537 |
5591 LookupIterator it(global, variable->name(), LookupIterator::OWN); | 5538 LookupIterator it(global, variable->name(), LookupIterator::OWN); |
5592 if (CanInlineGlobalPropertyAccess(variable, &it, LOAD)) { | 5539 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); |
5593 InlineGlobalPropertyLoad(&it, expr->id()); | 5540 |
5594 return; | 5541 if (type == kUseCell) { |
| 5542 Handle<PropertyCell> cell = it.GetPropertyCell(); |
| 5543 top_info()->dependencies()->AssumePropertyCell(cell); |
| 5544 auto cell_type = it.property_details().cell_type(); |
| 5545 if (cell_type == PropertyCellType::kConstant || |
| 5546 cell_type == PropertyCellType::kUndefined) { |
| 5547 Handle<Object> constant_object(cell->value(), isolate()); |
| 5548 if (constant_object->IsConsString()) { |
| 5549 constant_object = |
| 5550 String::Flatten(Handle<String>::cast(constant_object)); |
| 5551 } |
| 5552 HConstant* constant = New<HConstant>(constant_object); |
| 5553 return ast_context()->ReturnInstruction(constant, expr->id()); |
| 5554 } else { |
| 5555 auto access = HObjectAccess::ForPropertyCellValue(); |
| 5556 UniqueSet<Map>* field_maps = nullptr; |
| 5557 if (cell_type == PropertyCellType::kConstantType) { |
| 5558 switch (cell->GetConstantType()) { |
| 5559 case PropertyCellConstantType::kSmi: |
| 5560 access = access.WithRepresentation(Representation::Smi()); |
| 5561 break; |
| 5562 case PropertyCellConstantType::kStableMap: { |
| 5563 // Check that the map really is stable. The heap object could |
| 5564 // have mutated without the cell updating state. In that case, |
| 5565 // make no promises about the loaded value except that it's a |
| 5566 // heap object. |
| 5567 access = |
| 5568 access.WithRepresentation(Representation::HeapObject()); |
| 5569 Handle<Map> map(HeapObject::cast(cell->value())->map()); |
| 5570 if (map->is_stable()) { |
| 5571 field_maps = new (zone()) |
| 5572 UniqueSet<Map>(Unique<Map>::CreateImmovable(map), zone()); |
| 5573 } |
| 5574 break; |
| 5575 } |
| 5576 } |
| 5577 } |
| 5578 HConstant* cell_constant = Add<HConstant>(cell); |
| 5579 HLoadNamedField* instr; |
| 5580 if (field_maps == nullptr) { |
| 5581 instr = New<HLoadNamedField>(cell_constant, nullptr, access); |
| 5582 } else { |
| 5583 instr = New<HLoadNamedField>(cell_constant, nullptr, access, |
| 5584 field_maps, HType::HeapObject()); |
| 5585 } |
| 5586 instr->ClearDependsOnFlag(kInobjectFields); |
| 5587 instr->SetDependsOnFlag(kGlobalVars); |
| 5588 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5589 } |
5595 } else { | 5590 } else { |
5596 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); | 5591 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
5597 | 5592 |
5598 HValue* vector_value = Add<HConstant>(vector); | 5593 HValue* vector_value = Add<HConstant>(vector); |
5599 HValue* slot_value = | 5594 HValue* slot_value = |
5600 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); | 5595 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); |
5601 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( | 5596 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( |
5602 isolate(), ast_context()->typeof_mode()); | 5597 isolate(), ast_context()->typeof_mode()); |
5603 HValue* stub = Add<HConstant>(callable.code()); | 5598 HValue* stub = Add<HConstant>(callable.code()); |
5604 HValue* values[] = {slot_value, vector_value}; | 5599 HValue* values[] = {slot_value, vector_value}; |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6688 DCHECK(prop != NULL); | 6683 DCHECK(prop != NULL); |
6689 CHECK_ALIVE(VisitForValue(prop->obj())); | 6684 CHECK_ALIVE(VisitForValue(prop->obj())); |
6690 if (!prop->key()->IsPropertyName()) { | 6685 if (!prop->key()->IsPropertyName()) { |
6691 CHECK_ALIVE(VisitForValue(prop->key())); | 6686 CHECK_ALIVE(VisitForValue(prop->key())); |
6692 } | 6687 } |
6693 CHECK_ALIVE(VisitForValue(expr->value())); | 6688 CHECK_ALIVE(VisitForValue(expr->value())); |
6694 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), | 6689 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), |
6695 expr->AssignmentId(), expr->IsUninitialized()); | 6690 expr->AssignmentId(), expr->IsUninitialized()); |
6696 } | 6691 } |
6697 | 6692 |
6698 HInstruction* HOptimizedGraphBuilder::InlineGlobalPropertyStore( | |
6699 LookupIterator* it, HValue* value, BailoutId ast_id) { | |
6700 Handle<PropertyCell> cell = it->GetPropertyCell(); | |
6701 top_info()->dependencies()->AssumePropertyCell(cell); | |
6702 auto cell_type = it->property_details().cell_type(); | |
6703 if (cell_type == PropertyCellType::kConstant || | |
6704 cell_type == PropertyCellType::kUndefined) { | |
6705 Handle<Object> constant(cell->value(), isolate()); | |
6706 if (value->IsConstant()) { | |
6707 HConstant* c_value = HConstant::cast(value); | |
6708 if (!constant.is_identical_to(c_value->handle(isolate()))) { | |
6709 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, | |
6710 Deoptimizer::EAGER); | |
6711 } | |
6712 } else { | |
6713 HValue* c_constant = Add<HConstant>(constant); | |
6714 IfBuilder builder(this); | |
6715 if (constant->IsNumber()) { | |
6716 builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ); | |
6717 } else { | |
6718 builder.If<HCompareObjectEqAndBranch>(value, c_constant); | |
6719 } | |
6720 builder.Then(); | |
6721 builder.Else(); | |
6722 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, | |
6723 Deoptimizer::EAGER); | |
6724 builder.End(); | |
6725 } | |
6726 } | |
6727 HConstant* cell_constant = Add<HConstant>(cell); | |
6728 auto access = HObjectAccess::ForPropertyCellValue(); | |
6729 if (cell_type == PropertyCellType::kConstantType) { | |
6730 switch (cell->GetConstantType()) { | |
6731 case PropertyCellConstantType::kSmi: | |
6732 access = access.WithRepresentation(Representation::Smi()); | |
6733 break; | |
6734 case PropertyCellConstantType::kStableMap: { | |
6735 // The map may no longer be stable, deopt if it's ever different from | |
6736 // what is currently there, which will allow for restablization. | |
6737 Handle<Map> map(HeapObject::cast(cell->value())->map()); | |
6738 Add<HCheckHeapObject>(value); | |
6739 value = Add<HCheckMaps>(value, map); | |
6740 access = access.WithRepresentation(Representation::HeapObject()); | |
6741 break; | |
6742 } | |
6743 } | |
6744 } | |
6745 HInstruction* instr = New<HStoreNamedField>(cell_constant, access, value); | |
6746 instr->ClearChangesFlag(kInobjectFields); | |
6747 instr->SetChangesFlag(kGlobalVars); | |
6748 return instr; | |
6749 } | |
6750 | 6693 |
6751 // Because not every expression has a position and there is not common | 6694 // Because not every expression has a position and there is not common |
6752 // superclass of Assignment and CountOperation, we cannot just pass the | 6695 // superclass of Assignment and CountOperation, we cannot just pass the |
6753 // owning expression instead of position and ast_id separately. | 6696 // owning expression instead of position and ast_id separately. |
6754 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6697 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
6755 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { | 6698 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { |
6756 Handle<JSGlobalObject> global(current_info()->global_object()); | 6699 Handle<JSGlobalObject> global(current_info()->global_object()); |
6757 | 6700 |
6758 // Lookup in script contexts. | 6701 // Lookup in script contexts. |
6759 { | 6702 { |
(...skipping 20 matching lines...) Expand all Loading... |
6780 Add<HConstant>(script_context), | 6723 Add<HConstant>(script_context), |
6781 HObjectAccess::ForContextSlot(lookup.slot_index), value); | 6724 HObjectAccess::ForContextSlot(lookup.slot_index), value); |
6782 USE(instr); | 6725 USE(instr); |
6783 DCHECK(instr->HasObservableSideEffects()); | 6726 DCHECK(instr->HasObservableSideEffects()); |
6784 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6727 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6785 return; | 6728 return; |
6786 } | 6729 } |
6787 } | 6730 } |
6788 | 6731 |
6789 LookupIterator it(global, var->name(), LookupIterator::OWN); | 6732 LookupIterator it(global, var->name(), LookupIterator::OWN); |
6790 if (CanInlineGlobalPropertyAccess(var, &it, STORE)) { | 6733 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); |
6791 HInstruction* instr = InlineGlobalPropertyStore(&it, value, ast_id); | 6734 if (type == kUseCell) { |
6792 AddInstruction(instr); | 6735 Handle<PropertyCell> cell = it.GetPropertyCell(); |
| 6736 top_info()->dependencies()->AssumePropertyCell(cell); |
| 6737 auto cell_type = it.property_details().cell_type(); |
| 6738 if (cell_type == PropertyCellType::kConstant || |
| 6739 cell_type == PropertyCellType::kUndefined) { |
| 6740 Handle<Object> constant(cell->value(), isolate()); |
| 6741 if (value->IsConstant()) { |
| 6742 HConstant* c_value = HConstant::cast(value); |
| 6743 if (!constant.is_identical_to(c_value->handle(isolate()))) { |
| 6744 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, |
| 6745 Deoptimizer::EAGER); |
| 6746 } |
| 6747 } else { |
| 6748 HValue* c_constant = Add<HConstant>(constant); |
| 6749 IfBuilder builder(this); |
| 6750 if (constant->IsNumber()) { |
| 6751 builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ); |
| 6752 } else { |
| 6753 builder.If<HCompareObjectEqAndBranch>(value, c_constant); |
| 6754 } |
| 6755 builder.Then(); |
| 6756 builder.Else(); |
| 6757 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, |
| 6758 Deoptimizer::EAGER); |
| 6759 builder.End(); |
| 6760 } |
| 6761 } |
| 6762 HConstant* cell_constant = Add<HConstant>(cell); |
| 6763 auto access = HObjectAccess::ForPropertyCellValue(); |
| 6764 if (cell_type == PropertyCellType::kConstantType) { |
| 6765 switch (cell->GetConstantType()) { |
| 6766 case PropertyCellConstantType::kSmi: |
| 6767 access = access.WithRepresentation(Representation::Smi()); |
| 6768 break; |
| 6769 case PropertyCellConstantType::kStableMap: { |
| 6770 // The map may no longer be stable, deopt if it's ever different from |
| 6771 // what is currently there, which will allow for restablization. |
| 6772 Handle<Map> map(HeapObject::cast(cell->value())->map()); |
| 6773 Add<HCheckHeapObject>(value); |
| 6774 value = Add<HCheckMaps>(value, map); |
| 6775 access = access.WithRepresentation(Representation::HeapObject()); |
| 6776 break; |
| 6777 } |
| 6778 } |
| 6779 } |
| 6780 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value); |
| 6781 instr->ClearChangesFlag(kInobjectFields); |
| 6782 instr->SetChangesFlag(kGlobalVars); |
6793 if (instr->HasObservableSideEffects()) { | 6783 if (instr->HasObservableSideEffects()) { |
6794 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6784 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6795 } | 6785 } |
6796 } else { | 6786 } else { |
6797 HValue* global_object = Add<HLoadNamedField>( | 6787 HValue* global_object = Add<HLoadNamedField>( |
6798 BuildGetNativeContext(), nullptr, | 6788 BuildGetNativeContext(), nullptr, |
6799 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); | 6789 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); |
6800 Handle<TypeFeedbackVector> vector = | 6790 Handle<TypeFeedbackVector> vector = |
6801 handle(current_feedback_vector(), isolate()); | 6791 handle(current_feedback_vector(), isolate()); |
6802 HValue* name = Add<HConstant>(var->name()); | 6792 HValue* name = Add<HConstant>(var->name()); |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7705 | 7695 |
7706 HValue* HOptimizedGraphBuilder::BuildNamedAccess( | 7696 HValue* HOptimizedGraphBuilder::BuildNamedAccess( |
7707 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, | 7697 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, |
7708 Expression* expr, FeedbackVectorSlot slot, HValue* object, | 7698 Expression* expr, FeedbackVectorSlot slot, HValue* object, |
7709 Handle<Name> name, HValue* value, bool is_uninitialized) { | 7699 Handle<Name> name, HValue* value, bool is_uninitialized) { |
7710 SmallMapList* maps; | 7700 SmallMapList* maps; |
7711 ComputeReceiverTypes(expr, object, &maps, this); | 7701 ComputeReceiverTypes(expr, object, &maps, this); |
7712 DCHECK(maps != NULL); | 7702 DCHECK(maps != NULL); |
7713 | 7703 |
7714 if (maps->length() > 0) { | 7704 if (maps->length() > 0) { |
7715 Handle<JSGlobalObject> global_object(current_info()->global_object()); | |
7716 Handle<Context> current_context(current_info()->context()); | |
7717 Handle<JSObject> global_proxy(current_context->global_proxy()); | |
7718 | |
7719 // Check for special case: Access via a single map to the global proxy | |
7720 // can also be handled monomorphically. | |
7721 Handle<Object> map_constructor = | |
7722 handle(maps->first()->GetConstructor(), isolate()); | |
7723 if (map_constructor->IsJSFunction()) { | |
7724 Handle<Context> map_context = | |
7725 handle(Handle<JSFunction>::cast(map_constructor)->context()); | |
7726 bool is_global_proxy_access = | |
7727 maps->length() == 1 && // More than one map, fallback to polymorphic? | |
7728 maps->first()->IsJSGlobalProxyMap() && | |
7729 isolate()->MayAccess(map_context, global_proxy); | |
7730 | |
7731 if (is_global_proxy_access) { | |
7732 LookupIterator it(global_object, name, LookupIterator::OWN); | |
7733 if (CanInlineGlobalPropertyAccess(&it, access)) { | |
7734 BuildCheckHeapObject(object); | |
7735 Add<HCheckMaps>(object, maps); | |
7736 if (access == LOAD) { | |
7737 InlineGlobalPropertyLoad(&it, expr->id()); | |
7738 return nullptr; | |
7739 } else { | |
7740 return InlineGlobalPropertyStore(&it, value, expr->id()); | |
7741 } | |
7742 } | |
7743 } | |
7744 } | |
7745 | |
7746 PropertyAccessInfo info(this, access, maps->first(), name); | 7705 PropertyAccessInfo info(this, access, maps->first(), name); |
7747 if (!info.CanAccessAsMonomorphic(maps)) { | 7706 if (!info.CanAccessAsMonomorphic(maps)) { |
7748 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, | 7707 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, |
7749 object, value, maps, name); | 7708 object, value, maps, name); |
7750 return NULL; | 7709 return NULL; |
7751 } | 7710 } |
7752 | 7711 |
7753 HValue* checked_object; | 7712 HValue* checked_object; |
7754 // AstType::Number() is only supported by polymorphic load/call handling. | 7713 // AstType::Number() is only supported by polymorphic load/call handling. |
7755 DCHECK(!info.IsNumberType()); | 7714 DCHECK(!info.IsNumberType()); |
(...skipping 5572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13328 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13287 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13329 } | 13288 } |
13330 | 13289 |
13331 #ifdef DEBUG | 13290 #ifdef DEBUG |
13332 graph_->Verify(false); // No full verify. | 13291 graph_->Verify(false); // No full verify. |
13333 #endif | 13292 #endif |
13334 } | 13293 } |
13335 | 13294 |
13336 } // namespace internal | 13295 } // namespace internal |
13337 } // namespace v8 | 13296 } // namespace v8 |
OLD | NEW |