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

Side by Side Diff: src/hydrogen.cc

Issue 1168093002: [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.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 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/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 HConstant* HGraph::GetConstant1() { 676 HConstant* HGraph::GetConstant1() {
677 return GetConstant(&constant_1_, 1); 677 return GetConstant(&constant_1_, 1);
678 } 678 }
679 679
680 680
681 HConstant* HGraph::GetConstantMinus1() { 681 HConstant* HGraph::GetConstantMinus1() {
682 return GetConstant(&constant_minus1_, -1); 682 return GetConstant(&constant_minus1_, -1);
683 } 683 }
684 684
685 685
686 HConstant* HGraph::GetConstantBool(bool value) {
687 return value ? GetConstantTrue() : GetConstantFalse();
688 }
689
690
686 #define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value) \ 691 #define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value) \
687 HConstant* HGraph::GetConstant##Name() { \ 692 HConstant* HGraph::GetConstant##Name() { \
688 if (!constant_##name##_.is_set()) { \ 693 if (!constant_##name##_.is_set()) { \
689 HConstant* constant = new(zone()) HConstant( \ 694 HConstant* constant = new(zone()) HConstant( \
690 Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \ 695 Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \
691 Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \ 696 Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \
692 false, \ 697 false, \
693 Representation::Tagged(), \ 698 Representation::Tagged(), \
694 htype, \ 699 htype, \
695 true, \ 700 true, \
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 // hash = hash * 2057; 1665 // hash = hash * 2057;
1661 hash = AddUncasted<HMul>(hash, Add<HConstant>(2057)); 1666 hash = AddUncasted<HMul>(hash, Add<HConstant>(2057));
1662 hash->ClearFlag(HValue::kCanOverflow); 1667 hash->ClearFlag(HValue::kCanOverflow);
1663 1668
1664 // hash = hash ^ (hash >> 16); 1669 // hash = hash ^ (hash >> 16);
1665 shifted_hash = AddUncasted<HShr>(hash, Add<HConstant>(16)); 1670 shifted_hash = AddUncasted<HShr>(hash, Add<HConstant>(16));
1666 return AddUncasted<HBitwise>(Token::BIT_XOR, hash, shifted_hash); 1671 return AddUncasted<HBitwise>(Token::BIT_XOR, hash, shifted_hash);
1667 } 1672 }
1668 1673
1669 1674
1670 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(HValue* receiver, 1675 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(
1671 HValue* elements, 1676 HValue* receiver, HValue* elements, HValue* key, HValue* hash,
1672 HValue* key, 1677 LanguageMode language_mode) {
1673 HValue* hash) {
1674 HValue* capacity = 1678 HValue* capacity =
1675 Add<HLoadKeyed>(elements, Add<HConstant>(NameDictionary::kCapacityIndex), 1679 Add<HLoadKeyed>(elements, Add<HConstant>(NameDictionary::kCapacityIndex),
1676 nullptr, FAST_ELEMENTS); 1680 nullptr, FAST_ELEMENTS);
1677 1681
1678 HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1()); 1682 HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1());
1679 mask->ChangeRepresentation(Representation::Integer32()); 1683 mask->ChangeRepresentation(Representation::Integer32());
1680 mask->ClearFlag(HValue::kCanOverflow); 1684 mask->ClearFlag(HValue::kCanOverflow);
1681 1685
1682 HValue* entry = hash; 1686 HValue* entry = hash;
1683 HValue* count = graph()->GetConstant1(); 1687 HValue* count = graph()->GetConstant1();
(...skipping 21 matching lines...) Expand all
1705 1709
1706 HValue* candidate_key = 1710 HValue* candidate_key =
1707 Add<HLoadKeyed>(elements, key_index, nullptr, FAST_ELEMENTS); 1711 Add<HLoadKeyed>(elements, key_index, nullptr, FAST_ELEMENTS);
1708 IfBuilder if_undefined(this); 1712 IfBuilder if_undefined(this);
1709 if_undefined.If<HCompareObjectEqAndBranch>(candidate_key, 1713 if_undefined.If<HCompareObjectEqAndBranch>(candidate_key,
1710 graph()->GetConstantUndefined()); 1714 graph()->GetConstantUndefined());
1711 if_undefined.Then(); 1715 if_undefined.Then();
1712 { 1716 {
1713 // element == undefined means "not found". Call the runtime. 1717 // element == undefined means "not found". Call the runtime.
1714 // TODO(jkummerow): walk the prototype chain instead. 1718 // TODO(jkummerow): walk the prototype chain instead.
1715 Add<HPushArguments>(receiver, key); 1719 Add<HPushArguments>(receiver, key, Add<HConstant>(language_mode));
1716 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(), 1720 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(),
1717 Runtime::FunctionForId(Runtime::kKeyedGetProperty), 1721 Runtime::FunctionForId(Runtime::kKeyedGetProperty),
1718 2)); 1722 3));
1719 } 1723 }
1720 if_undefined.Else(); 1724 if_undefined.Else();
1721 { 1725 {
1722 IfBuilder if_match(this); 1726 IfBuilder if_match(this);
1723 if_match.If<HCompareObjectEqAndBranch>(candidate_key, key); 1727 if_match.If<HCompareObjectEqAndBranch>(candidate_key, key);
1724 if_match.Then(); 1728 if_match.Then();
1725 if_match.Else(); 1729 if_match.Else();
1726 1730
1727 // Update non-internalized string in the dictionary with internalized key? 1731 // Update non-internalized string in the dictionary with internalized key?
1728 IfBuilder if_update_with_internalized(this); 1732 IfBuilder if_update_with_internalized(this);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 Add<HConstant>(details_mask)); 1769 Add<HConstant>(details_mask));
1766 IfBuilder details_compare(this); 1770 IfBuilder details_compare(this);
1767 details_compare.If<HCompareNumericAndBranch>( 1771 details_compare.If<HCompareNumericAndBranch>(
1768 details, graph()->GetConstant0(), Token::EQ); 1772 details, graph()->GetConstant0(), Token::EQ);
1769 details_compare.Then(); 1773 details_compare.Then();
1770 HValue* result_index = 1774 HValue* result_index =
1771 AddUncasted<HAdd>(base_index, Add<HConstant>(start_offset + 1)); 1775 AddUncasted<HAdd>(base_index, Add<HConstant>(start_offset + 1));
1772 result_index->ClearFlag(HValue::kCanOverflow); 1776 result_index->ClearFlag(HValue::kCanOverflow);
1773 Push(Add<HLoadKeyed>(elements, result_index, nullptr, FAST_ELEMENTS)); 1777 Push(Add<HLoadKeyed>(elements, result_index, nullptr, FAST_ELEMENTS));
1774 details_compare.Else(); 1778 details_compare.Else();
1775 Add<HPushArguments>(receiver, key); 1779 Add<HPushArguments>(receiver, key, Add<HConstant>(language_mode));
1776 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(), 1780 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(),
1777 Runtime::FunctionForId(Runtime::kKeyedGetProperty), 1781 Runtime::FunctionForId(Runtime::kKeyedGetProperty),
1778 2)); 1782 3));
1779 details_compare.End(); 1783 details_compare.End();
1780 1784
1781 found_key_match.Else(); 1785 found_key_match.Else();
1782 found_key_match.JoinContinuation(&return_or_loop_continuation); 1786 found_key_match.JoinContinuation(&return_or_loop_continuation);
1783 } 1787 }
1784 if_undefined.JoinContinuation(&return_or_loop_continuation); 1788 if_undefined.JoinContinuation(&return_or_loop_continuation);
1785 1789
1786 IfBuilder return_or_loop(this, &return_or_loop_continuation); 1790 IfBuilder return_or_loop(this, &return_or_loop_continuation);
1787 return_or_loop.Then(); 1791 return_or_loop.Then();
1788 probe_loop.Break(); 1792 probe_loop.Break();
(...skipping 4427 matching lines...) Expand 10 before | Expand all | Expand 10 after
6216 if (IsJSObjectFieldAccessor()) return IsLoad(); 6220 if (IsJSObjectFieldAccessor()) return IsLoad();
6217 if (IsJSArrayBufferViewFieldAccessor()) return IsLoad(); 6221 if (IsJSArrayBufferViewFieldAccessor()) return IsLoad();
6218 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() && 6222 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() &&
6219 name_.is_identical_to(isolate()->factory()->prototype_string())) { 6223 name_.is_identical_to(isolate()->factory()->prototype_string())) {
6220 return IsLoad(); 6224 return IsLoad();
6221 } 6225 }
6222 if (!LookupDescriptor()) return false; 6226 if (!LookupDescriptor()) return false;
6223 if (IsFound()) return IsLoad() || !IsReadOnly(); 6227 if (IsFound()) return IsLoad() || !IsReadOnly();
6224 if (IsIntegerIndexedExotic()) return false; 6228 if (IsIntegerIndexedExotic()) return false;
6225 if (!LookupInPrototypes()) return false; 6229 if (!LookupInPrototypes()) return false;
6226 if (IsLoad()) return true; 6230 if (IsLoad()) return !is_strong(builder_->function_language_mode());
6227 6231
6228 if (IsAccessorConstant()) return true; 6232 if (IsAccessorConstant()) return true;
6229 LookupTransition(*map_, *name_, NONE); 6233 LookupTransition(*map_, *name_, NONE);
6230 if (IsTransitionToData() && map_->unused_property_fields() > 0) { 6234 if (IsTransitionToData() && map_->unused_property_fields() > 0) {
6231 // Construct the object field access. 6235 // Construct the object field access.
6232 int descriptor = transition()->LastAdded(); 6236 int descriptor = transition()->LastAdded();
6233 int index = 6237 int index =
6234 transition()->instance_descriptors()->GetFieldIndex(descriptor) - 6238 transition()->instance_descriptors()->GetFieldIndex(descriptor) -
6235 map_->inobject_properties(); 6239 map_->inobject_properties();
6236 PropertyDetails details = 6240 PropertyDetails details =
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
7034 Handle<TypeFeedbackVector> vector = 7038 Handle<TypeFeedbackVector> vector =
7035 handle(current_feedback_vector(), isolate()); 7039 handle(current_feedback_vector(), isolate());
7036 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); 7040 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
7037 7041
7038 if (!expr->AsProperty()->key()->IsPropertyName()) { 7042 if (!expr->AsProperty()->key()->IsPropertyName()) {
7039 // It's possible that a keyed load of a constant string was converted 7043 // It's possible that a keyed load of a constant string was converted
7040 // to a named load. Here, at the last minute, we need to make sure to 7044 // to a named load. Here, at the last minute, we need to make sure to
7041 // use a generic Keyed Load if we are using the type vector, because 7045 // use a generic Keyed Load if we are using the type vector, because
7042 // it has to share information with full code. 7046 // it has to share information with full code.
7043 HConstant* key = Add<HConstant>(name); 7047 HConstant* key = Add<HConstant>(name);
7044 HLoadKeyedGeneric* result = 7048 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(
7045 New<HLoadKeyedGeneric>(object, key, PREMONOMORPHIC); 7049 object, key, function_language_mode(), PREMONOMORPHIC);
7046 result->SetVectorAndSlot(vector, slot); 7050 result->SetVectorAndSlot(vector, slot);
7047 return result; 7051 return result;
7048 } 7052 }
7049 7053
7050 HLoadNamedGeneric* result = 7054 HLoadNamedGeneric* result = New<HLoadNamedGeneric>(
7051 New<HLoadNamedGeneric>(object, name, PREMONOMORPHIC); 7055 object, name, function_language_mode(), PREMONOMORPHIC);
7052 result->SetVectorAndSlot(vector, slot); 7056 result->SetVectorAndSlot(vector, slot);
7053 return result; 7057 return result;
7054 } else { 7058 } else {
7055 return New<HStoreNamedGeneric>(object, name, value, 7059 return New<HStoreNamedGeneric>(object, name, value,
7056 function_language_mode(), PREMONOMORPHIC); 7060 function_language_mode(), PREMONOMORPHIC);
7057 } 7061 }
7058 } 7062 }
7059 7063
7060 7064
7061 7065
7062 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( 7066 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric(
7063 PropertyAccessType access_type, 7067 PropertyAccessType access_type,
7064 Expression* expr, 7068 Expression* expr,
7065 HValue* object, 7069 HValue* object,
7066 HValue* key, 7070 HValue* key,
7067 HValue* value) { 7071 HValue* value) {
7068 if (access_type == LOAD) { 7072 if (access_type == LOAD) {
7069 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState(); 7073 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState();
7070 HLoadKeyedGeneric* result = 7074 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(
7071 New<HLoadKeyedGeneric>(object, key, initial_state); 7075 object, key, function_language_mode(), initial_state);
7072 // HLoadKeyedGeneric with vector ics benefits from being encoded as 7076 // HLoadKeyedGeneric with vector ics benefits from being encoded as
7073 // MEGAMORPHIC because the vector/slot combo becomes unnecessary. 7077 // MEGAMORPHIC because the vector/slot combo becomes unnecessary.
7074 if (initial_state != MEGAMORPHIC) { 7078 if (initial_state != MEGAMORPHIC) {
7075 // We need to pass vector information. 7079 // We need to pass vector information.
7076 Handle<TypeFeedbackVector> vector = 7080 Handle<TypeFeedbackVector> vector =
7077 handle(current_feedback_vector(), isolate()); 7081 handle(current_feedback_vector(), isolate());
7078 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); 7082 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
7079 result->SetVectorAndSlot(vector, slot); 7083 result->SetVectorAndSlot(vector, slot);
7080 } 7084 }
7081 return result; 7085 return result;
(...skipping 6118 matching lines...) Expand 10 before | Expand all | Expand 10 after
13200 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13204 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13201 } 13205 }
13202 13206
13203 #ifdef DEBUG 13207 #ifdef DEBUG
13204 graph_->Verify(false); // No full verify. 13208 graph_->Verify(false); // No full verify.
13205 #endif 13209 #endif
13206 } 13210 }
13207 13211
13208 } // namespace internal 13212 } // namespace internal
13209 } // namespace v8 13213 } // namespace v8
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698