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 } | |
5451 | 5456 |
5452 HOptimizedGraphBuilder::GlobalPropertyAccess | 5457 bool HOptimizedGraphBuilder::CanInlineGlobalPropertyAccess( |
5453 HOptimizedGraphBuilder::LookupGlobalProperty(Variable* var, LookupIterator* it, | 5458 LookupIterator* it, PropertyAccessType access_type) { |
5454 PropertyAccessType access_type) { | 5459 if (!current_info()->has_global_object()) { |
5455 if (var->is_this() || !current_info()->has_global_object()) { | 5460 return false; |
5456 return kUseGeneric; | |
5457 } | 5461 } |
5458 | 5462 |
5459 switch (it->state()) { | 5463 switch (it->state()) { |
5460 case LookupIterator::ACCESSOR: | 5464 case LookupIterator::ACCESSOR: |
5461 case LookupIterator::ACCESS_CHECK: | 5465 case LookupIterator::ACCESS_CHECK: |
5462 case LookupIterator::INTERCEPTOR: | 5466 case LookupIterator::INTERCEPTOR: |
5463 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 5467 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
5464 case LookupIterator::NOT_FOUND: | 5468 case LookupIterator::NOT_FOUND: |
5465 return kUseGeneric; | 5469 return false; |
5466 case LookupIterator::DATA: | 5470 case LookupIterator::DATA: |
5467 if (access_type == STORE && it->IsReadOnly()) return kUseGeneric; | 5471 if (access_type == STORE && it->IsReadOnly()) return false; |
5468 if (!it->GetHolder<JSObject>()->IsJSGlobalObject()) return kUseGeneric; | 5472 if (!it->GetHolder<JSObject>()->IsJSGlobalObject()) return false; |
5469 return kUseCell; | 5473 return true; |
5470 case LookupIterator::JSPROXY: | 5474 case LookupIterator::JSPROXY: |
5471 case LookupIterator::TRANSITION: | 5475 case LookupIterator::TRANSITION: |
5472 UNREACHABLE(); | 5476 UNREACHABLE(); |
5473 } | 5477 } |
5474 UNREACHABLE(); | 5478 UNREACHABLE(); |
5475 return kUseGeneric; | 5479 return false; |
5476 } | 5480 } |
5477 | 5481 |
5478 | 5482 |
5479 HValue* HOptimizedGraphBuilder::BuildContextChainWalk(Variable* var) { | 5483 HValue* HOptimizedGraphBuilder::BuildContextChainWalk(Variable* var) { |
5480 DCHECK(var->IsContextSlot()); | 5484 DCHECK(var->IsContextSlot()); |
5481 HValue* context = environment()->context(); | 5485 HValue* context = environment()->context(); |
5482 int length = scope()->ContextChainLength(var->scope()); | 5486 int length = scope()->ContextChainLength(var->scope()); |
5483 while (length-- > 0) { | 5487 while (length-- > 0) { |
5484 context = Add<HLoadNamedField>( | 5488 context = Add<HLoadNamedField>( |
5485 context, nullptr, | 5489 context, nullptr, |
5486 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); | 5490 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); |
5487 } | 5491 } |
5488 return context; | 5492 return context; |
5489 } | 5493 } |
5490 | 5494 |
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 } | |
5491 | 5544 |
5492 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 5545 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
5493 DCHECK(!HasStackOverflow()); | 5546 DCHECK(!HasStackOverflow()); |
5494 DCHECK(current_block() != NULL); | 5547 DCHECK(current_block() != NULL); |
5495 DCHECK(current_block()->HasPredecessor()); | 5548 DCHECK(current_block()->HasPredecessor()); |
5496 Variable* variable = expr->var(); | 5549 Variable* variable = expr->var(); |
5497 switch (variable->location()) { | 5550 switch (variable->location()) { |
5498 case VariableLocation::UNALLOCATED: { | 5551 case VariableLocation::UNALLOCATED: { |
5499 if (IsLexicalVariableMode(variable->mode())) { | 5552 if (IsLexicalVariableMode(variable->mode())) { |
5500 // TODO(rossberg): should this be an DCHECK? | 5553 // TODO(rossberg): should this be an DCHECK? |
(...skipping 28 matching lines...) Expand all Loading... | |
5529 return Bailout(kReferenceToUninitializedVariable); | 5582 return Bailout(kReferenceToUninitializedVariable); |
5530 } | 5583 } |
5531 HInstruction* result = New<HLoadNamedField>( | 5584 HInstruction* result = New<HLoadNamedField>( |
5532 Add<HConstant>(script_context), nullptr, | 5585 Add<HConstant>(script_context), nullptr, |
5533 HObjectAccess::ForContextSlot(lookup.slot_index)); | 5586 HObjectAccess::ForContextSlot(lookup.slot_index)); |
5534 return ast_context()->ReturnInstruction(result, expr->id()); | 5587 return ast_context()->ReturnInstruction(result, expr->id()); |
5535 } | 5588 } |
5536 } | 5589 } |
5537 | 5590 |
5538 LookupIterator it(global, variable->name(), LookupIterator::OWN); | 5591 LookupIterator it(global, variable->name(), LookupIterator::OWN); |
5539 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); | 5592 if (CanInlineGlobalPropertyAccess(variable, &it, LOAD)) { |
5540 | 5593 InlineGlobalPropertyLoad(&it, expr->id()); |
5541 if (type == kUseCell) { | 5594 return; |
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 } | |
5590 } else { | 5595 } else { |
5591 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); | 5596 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
5592 | 5597 |
5593 HValue* vector_value = Add<HConstant>(vector); | 5598 HValue* vector_value = Add<HConstant>(vector); |
5594 HValue* slot_value = | 5599 HValue* slot_value = |
5595 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); | 5600 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); |
5596 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( | 5601 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( |
5597 isolate(), ast_context()->typeof_mode()); | 5602 isolate(), ast_context()->typeof_mode()); |
5598 HValue* stub = Add<HConstant>(callable.code()); | 5603 HValue* stub = Add<HConstant>(callable.code()); |
5599 HValue* values[] = {slot_value, vector_value}; | 5604 HValue* values[] = {slot_value, vector_value}; |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6683 DCHECK(prop != NULL); | 6688 DCHECK(prop != NULL); |
6684 CHECK_ALIVE(VisitForValue(prop->obj())); | 6689 CHECK_ALIVE(VisitForValue(prop->obj())); |
6685 if (!prop->key()->IsPropertyName()) { | 6690 if (!prop->key()->IsPropertyName()) { |
6686 CHECK_ALIVE(VisitForValue(prop->key())); | 6691 CHECK_ALIVE(VisitForValue(prop->key())); |
6687 } | 6692 } |
6688 CHECK_ALIVE(VisitForValue(expr->value())); | 6693 CHECK_ALIVE(VisitForValue(expr->value())); |
6689 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), | 6694 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), |
6690 expr->AssignmentId(), expr->IsUninitialized()); | 6695 expr->AssignmentId(), expr->IsUninitialized()); |
6691 } | 6696 } |
6692 | 6697 |
6698 void HOptimizedGraphBuilder::InlineGlobalPropertyStore(LookupIterator* it, | |
6699 HValue* value, | |
6700 BailoutId ast_id) { | |
6701 Handle<PropertyCell> cell = it->GetPropertyCell(); | |
6702 top_info()->dependencies()->AssumePropertyCell(cell); | |
6703 auto cell_type = it->property_details().cell_type(); | |
6704 if (cell_type == PropertyCellType::kConstant || | |
6705 cell_type == PropertyCellType::kUndefined) { | |
6706 Handle<Object> constant(cell->value(), isolate()); | |
6707 if (value->IsConstant()) { | |
6708 HConstant* c_value = HConstant::cast(value); | |
6709 if (!constant.is_identical_to(c_value->handle(isolate()))) { | |
6710 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, | |
6711 Deoptimizer::EAGER); | |
6712 } | |
6713 } else { | |
6714 HValue* c_constant = Add<HConstant>(constant); | |
6715 IfBuilder builder(this); | |
6716 if (constant->IsNumber()) { | |
6717 builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ); | |
6718 } else { | |
6719 builder.If<HCompareObjectEqAndBranch>(value, c_constant); | |
6720 } | |
6721 builder.Then(); | |
6722 builder.Else(); | |
6723 Add<HDeoptimize>(DeoptimizeReason::kConstantGlobalVariableAssignment, | |
6724 Deoptimizer::EAGER); | |
6725 builder.End(); | |
6726 } | |
6727 } | |
6728 HConstant* cell_constant = Add<HConstant>(cell); | |
6729 auto access = HObjectAccess::ForPropertyCellValue(); | |
6730 if (cell_type == PropertyCellType::kConstantType) { | |
6731 switch (cell->GetConstantType()) { | |
6732 case PropertyCellConstantType::kSmi: | |
6733 access = access.WithRepresentation(Representation::Smi()); | |
6734 break; | |
6735 case PropertyCellConstantType::kStableMap: { | |
6736 // The map may no longer be stable, deopt if it's ever different from | |
6737 // what is currently there, which will allow for restablization. | |
6738 Handle<Map> map(HeapObject::cast(cell->value())->map()); | |
6739 Add<HCheckHeapObject>(value); | |
6740 value = Add<HCheckMaps>(value, map); | |
6741 access = access.WithRepresentation(Representation::HeapObject()); | |
6742 break; | |
6743 } | |
6744 } | |
6745 } | |
6746 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value); | |
6747 instr->ClearChangesFlag(kInobjectFields); | |
6748 instr->SetChangesFlag(kGlobalVars); | |
6749 if (instr->HasObservableSideEffects()) { | |
6750 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | |
6751 } | |
6752 } | |
6693 | 6753 |
6694 // Because not every expression has a position and there is not common | 6754 // Because not every expression has a position and there is not common |
6695 // superclass of Assignment and CountOperation, we cannot just pass the | 6755 // superclass of Assignment and CountOperation, we cannot just pass the |
6696 // owning expression instead of position and ast_id separately. | 6756 // owning expression instead of position and ast_id separately. |
6697 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6757 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
6698 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { | 6758 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { |
6699 Handle<JSGlobalObject> global(current_info()->global_object()); | 6759 Handle<JSGlobalObject> global(current_info()->global_object()); |
6700 | 6760 |
6701 // Lookup in script contexts. | 6761 // Lookup in script contexts. |
6702 { | 6762 { |
(...skipping 20 matching lines...) Expand all Loading... | |
6723 Add<HConstant>(script_context), | 6783 Add<HConstant>(script_context), |
6724 HObjectAccess::ForContextSlot(lookup.slot_index), value); | 6784 HObjectAccess::ForContextSlot(lookup.slot_index), value); |
6725 USE(instr); | 6785 USE(instr); |
6726 DCHECK(instr->HasObservableSideEffects()); | 6786 DCHECK(instr->HasObservableSideEffects()); |
6727 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6787 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6728 return; | 6788 return; |
6729 } | 6789 } |
6730 } | 6790 } |
6731 | 6791 |
6732 LookupIterator it(global, var->name(), LookupIterator::OWN); | 6792 LookupIterator it(global, var->name(), LookupIterator::OWN); |
6733 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); | 6793 if (CanInlineGlobalPropertyAccess(var, &it, STORE)) { |
6734 if (type == kUseCell) { | 6794 InlineGlobalPropertyStore(&it, value, ast_id); |
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); | |
6783 if (instr->HasObservableSideEffects()) { | |
6784 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | |
6785 } | |
6786 } else { | 6795 } else { |
6787 HValue* global_object = Add<HLoadNamedField>( | 6796 HValue* global_object = Add<HLoadNamedField>( |
6788 BuildGetNativeContext(), nullptr, | 6797 BuildGetNativeContext(), nullptr, |
6789 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); | 6798 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); |
6790 Handle<TypeFeedbackVector> vector = | 6799 Handle<TypeFeedbackVector> vector = |
6791 handle(current_feedback_vector(), isolate()); | 6800 handle(current_feedback_vector(), isolate()); |
6792 HValue* name = Add<HConstant>(var->name()); | 6801 HValue* name = Add<HConstant>(var->name()); |
6793 HValue* vector_value = Add<HConstant>(vector); | 6802 HValue* vector_value = Add<HConstant>(vector); |
6794 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); | 6803 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); |
6795 Callable callable = CodeFactory::StoreICInOptimizedCode( | 6804 Callable callable = CodeFactory::StoreICInOptimizedCode( |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7695 | 7704 |
7696 HValue* HOptimizedGraphBuilder::BuildNamedAccess( | 7705 HValue* HOptimizedGraphBuilder::BuildNamedAccess( |
7697 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, | 7706 PropertyAccessType access, BailoutId ast_id, BailoutId return_id, |
7698 Expression* expr, FeedbackVectorSlot slot, HValue* object, | 7707 Expression* expr, FeedbackVectorSlot slot, HValue* object, |
7699 Handle<Name> name, HValue* value, bool is_uninitialized) { | 7708 Handle<Name> name, HValue* value, bool is_uninitialized) { |
7700 SmallMapList* maps; | 7709 SmallMapList* maps; |
7701 ComputeReceiverTypes(expr, object, &maps, this); | 7710 ComputeReceiverTypes(expr, object, &maps, this); |
7702 DCHECK(maps != NULL); | 7711 DCHECK(maps != NULL); |
7703 | 7712 |
7704 if (maps->length() > 0) { | 7713 if (maps->length() > 0) { |
7714 Handle<JSGlobalObject> global_object(current_info()->global_object()); | |
7715 Handle<Context> current_context(current_info()->context()); | |
7716 Handle<JSObject> global_proxy(current_context->global_proxy()); | |
7717 | |
7718 // Check for special case: Access via a single map to the global proxy | |
7719 // can also be handled monomorphically. | |
7720 Handle<Object> map_constructor = | |
7721 handle(maps->first()->GetConstructor(), isolate()); | |
7722 if (map_constructor->IsJSFunction()) { | |
7723 Handle<Context> map_context = | |
7724 handle(Handle<JSFunction>::cast(map_constructor)->context()); | |
7725 bool is_global_proxy_access = | |
7726 maps->length() == 1 && // More than one map, fallback to polymorphic? | |
7727 maps->first()->IsJSGlobalProxyMap() && | |
7728 isolate()->MayAccess(map_context, global_proxy); | |
7729 | |
7730 if (is_global_proxy_access) { | |
7731 LookupIterator it(global_object, name, LookupIterator::OWN); | |
7732 if (CanInlineGlobalPropertyAccess(&it, access)) { | |
7733 BuildCheckHeapObject(object); | |
7734 Add<HCheckMaps>(object, maps); | |
7735 if (access == LOAD) { | |
7736 InlineGlobalPropertyLoad(&it, expr->id()); | |
7737 } else { | |
7738 InlineGlobalPropertyStore(&it, value, expr->id()); | |
7739 ast_context()->ReturnValue(value); | |
7740 } | |
Toon Verwaest
2016/10/14 08:15:32
You do this since the previous inline call already
vogelheim
2016/10/14 08:50:49
Well, sort of.
The InlineGlobalPropertyStore adds
| |
7741 return nullptr; | |
7742 } | |
7743 } | |
7744 } | |
7745 | |
7705 PropertyAccessInfo info(this, access, maps->first(), name); | 7746 PropertyAccessInfo info(this, access, maps->first(), name); |
7706 if (!info.CanAccessAsMonomorphic(maps)) { | 7747 if (!info.CanAccessAsMonomorphic(maps)) { |
7707 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, | 7748 HandlePolymorphicNamedFieldAccess(access, expr, slot, ast_id, return_id, |
7708 object, value, maps, name); | 7749 object, value, maps, name); |
7709 return NULL; | 7750 return NULL; |
7710 } | 7751 } |
7711 | 7752 |
7712 HValue* checked_object; | 7753 HValue* checked_object; |
7713 // AstType::Number() is only supported by polymorphic load/call handling. | 7754 // AstType::Number() is only supported by polymorphic load/call handling. |
7714 DCHECK(!info.IsNumberType()); | 7755 DCHECK(!info.IsNumberType()); |
(...skipping 5572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13287 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13328 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13288 } | 13329 } |
13289 | 13330 |
13290 #ifdef DEBUG | 13331 #ifdef DEBUG |
13291 graph_->Verify(false); // No full verify. | 13332 graph_->Verify(false); // No full verify. |
13292 #endif | 13333 #endif |
13293 } | 13334 } |
13294 | 13335 |
13295 } // namespace internal | 13336 } // namespace internal |
13296 } // namespace v8 | 13337 } // namespace v8 |
OLD | NEW |