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

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: slim down, improve tests 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
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 4424 matching lines...) Expand 10 before | Expand all | Expand 10 after
6213 if (IsJSObjectFieldAccessor()) return IsLoad(); 6217 if (IsJSObjectFieldAccessor()) return IsLoad();
6214 if (IsJSArrayBufferViewFieldAccessor()) return IsLoad(); 6218 if (IsJSArrayBufferViewFieldAccessor()) return IsLoad();
6215 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() && 6219 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() &&
6216 name_.is_identical_to(isolate()->factory()->prototype_string())) { 6220 name_.is_identical_to(isolate()->factory()->prototype_string())) {
6217 return IsLoad(); 6221 return IsLoad();
6218 } 6222 }
6219 if (!LookupDescriptor()) return false; 6223 if (!LookupDescriptor()) return false;
6220 if (IsFound()) return IsLoad() || !IsReadOnly(); 6224 if (IsFound()) return IsLoad() || !IsReadOnly();
6221 if (IsIntegerIndexedExotic()) return false; 6225 if (IsIntegerIndexedExotic()) return false;
6222 if (!LookupInPrototypes()) return false; 6226 if (!LookupInPrototypes()) return false;
6223 if (IsLoad()) return true; 6227 if (IsLoad()) return !is_strong(builder_->function_language_mode());
6224 6228
6225 if (IsAccessorConstant()) return true; 6229 if (IsAccessorConstant()) return true;
6226 LookupTransition(*map_, *name_, NONE); 6230 LookupTransition(*map_, *name_, NONE);
6227 if (IsTransitionToData() && map_->unused_property_fields() > 0) { 6231 if (IsTransitionToData() && map_->unused_property_fields() > 0) {
6228 // Construct the object field access. 6232 // Construct the object field access.
6229 int descriptor = transition()->LastAdded(); 6233 int descriptor = transition()->LastAdded();
6230 int index = 6234 int index =
6231 transition()->instance_descriptors()->GetFieldIndex(descriptor) - 6235 transition()->instance_descriptors()->GetFieldIndex(descriptor) -
6232 map_->inobject_properties(); 6236 map_->inobject_properties();
6233 PropertyDetails details = 6237 PropertyDetails details =
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
7031 Handle<TypeFeedbackVector> vector = 7035 Handle<TypeFeedbackVector> vector =
7032 handle(current_feedback_vector(), isolate()); 7036 handle(current_feedback_vector(), isolate());
7033 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); 7037 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
7034 7038
7035 if (!expr->AsProperty()->key()->IsPropertyName()) { 7039 if (!expr->AsProperty()->key()->IsPropertyName()) {
7036 // It's possible that a keyed load of a constant string was converted 7040 // It's possible that a keyed load of a constant string was converted
7037 // to a named load. Here, at the last minute, we need to make sure to 7041 // to a named load. Here, at the last minute, we need to make sure to
7038 // use a generic Keyed Load if we are using the type vector, because 7042 // use a generic Keyed Load if we are using the type vector, because
7039 // it has to share information with full code. 7043 // it has to share information with full code.
7040 HConstant* key = Add<HConstant>(name); 7044 HConstant* key = Add<HConstant>(name);
7041 HLoadKeyedGeneric* result = 7045 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(
7042 New<HLoadKeyedGeneric>(object, key, PREMONOMORPHIC); 7046 object, key, function_language_mode(), PREMONOMORPHIC);
7043 result->SetVectorAndSlot(vector, slot); 7047 result->SetVectorAndSlot(vector, slot);
7044 return result; 7048 return result;
7045 } 7049 }
7046 7050
7047 HLoadNamedGeneric* result = 7051 HLoadNamedGeneric* result = New<HLoadNamedGeneric>(
7048 New<HLoadNamedGeneric>(object, name, PREMONOMORPHIC); 7052 object, name, function_language_mode(), PREMONOMORPHIC);
7049 result->SetVectorAndSlot(vector, slot); 7053 result->SetVectorAndSlot(vector, slot);
7050 return result; 7054 return result;
7051 } else { 7055 } else {
7052 return New<HStoreNamedGeneric>(object, name, value, 7056 return New<HStoreNamedGeneric>(object, name, value,
7053 function_language_mode(), PREMONOMORPHIC); 7057 function_language_mode(), PREMONOMORPHIC);
7054 } 7058 }
7055 } 7059 }
7056 7060
7057 7061
7058 7062
7059 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( 7063 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric(
7060 PropertyAccessType access_type, 7064 PropertyAccessType access_type,
7061 Expression* expr, 7065 Expression* expr,
7062 HValue* object, 7066 HValue* object,
7063 HValue* key, 7067 HValue* key,
7064 HValue* value) { 7068 HValue* value) {
7065 if (access_type == LOAD) { 7069 if (access_type == LOAD) {
7066 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState(); 7070 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState();
7067 HLoadKeyedGeneric* result = 7071 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(
7068 New<HLoadKeyedGeneric>(object, key, initial_state); 7072 object, key, function_language_mode(), initial_state);
7069 // HLoadKeyedGeneric with vector ics benefits from being encoded as 7073 // HLoadKeyedGeneric with vector ics benefits from being encoded as
7070 // MEGAMORPHIC because the vector/slot combo becomes unnecessary. 7074 // MEGAMORPHIC because the vector/slot combo becomes unnecessary.
7071 if (initial_state != MEGAMORPHIC) { 7075 if (initial_state != MEGAMORPHIC) {
7072 // We need to pass vector information. 7076 // We need to pass vector information.
7073 Handle<TypeFeedbackVector> vector = 7077 Handle<TypeFeedbackVector> vector =
7074 handle(current_feedback_vector(), isolate()); 7078 handle(current_feedback_vector(), isolate());
7075 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); 7079 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
7076 result->SetVectorAndSlot(vector, slot); 7080 result->SetVectorAndSlot(vector, slot);
7077 } 7081 }
7078 return result; 7082 return result;
(...skipping 6096 matching lines...) Expand 10 before | Expand all | Expand 10 after
13175 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13179 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13176 } 13180 }
13177 13181
13178 #ifdef DEBUG 13182 #ifdef DEBUG
13179 graph_->Verify(false); // No full verify. 13183 graph_->Verify(false); // No full verify.
13180 #endif 13184 #endif
13181 } 13185 }
13182 13186
13183 } // namespace internal 13187 } // namespace internal
13184 } // namespace v8 13188 } // namespace v8
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/lookup.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698