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

Side by Side Diff: src/key-accumulator.h

Issue 1619803003: Revert of [runtime] Do not use the enum-cache for non-prototype objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/elements.cc ('k') | src/key-accumulator.cc » ('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 #ifndef V8_KEY_ACCUMULATOR_H_ 5 #ifndef V8_KEY_ACCUMULATOR_H_
6 #define V8_KEY_ACCUMULATOR_H_ 6 #define V8_KEY_ACCUMULATOR_H_
7 7
8 #include <set>
9
10 #include "src/isolate.h" 8 #include "src/isolate.h"
11 #include "src/objects.h" 9 #include "src/objects.h"
12 10
13 namespace v8 { 11 namespace v8 {
14 namespace internal { 12 namespace internal {
15 13
16 enum AddKeyConversion { DO_NOT_CONVERT, CONVERT_TO_ARRAY_INDEX, PROXY_MAGIC }; 14 enum AddKeyConversion { DO_NOT_CONVERT, CONVERT_TO_ARRAY_INDEX, PROXY_MAGIC };
17 15
18 // This is a helper class for JSReceiver::GetKeys which collects and sorts keys. 16 // This is a helper class for JSReceiver::GetKeys which collects and sorts keys.
19 // GetKeys needs to sort keys per prototype level, first showing the integer 17 // GetKeys needs to sort keys per prototype level, first showing the integer
(...skipping 20 matching lines...) Expand all
40 bool AddKey(uint32_t key); 38 bool AddKey(uint32_t key);
41 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); 39 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT);
42 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); 40 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT);
43 void AddKeys(Handle<FixedArray> array, 41 void AddKeys(Handle<FixedArray> array,
44 AddKeyConversion convert = DO_NOT_CONVERT); 42 AddKeyConversion convert = DO_NOT_CONVERT);
45 void AddKeys(Handle<JSObject> array, 43 void AddKeys(Handle<JSObject> array,
46 AddKeyConversion convert = DO_NOT_CONVERT); 44 AddKeyConversion convert = DO_NOT_CONVERT);
47 void AddKeysFromProxy(Handle<JSObject> array); 45 void AddKeysFromProxy(Handle<JSObject> array);
48 Maybe<bool> AddKeysFromProxy(Handle<JSProxy> proxy, Handle<FixedArray> keys); 46 Maybe<bool> AddKeysFromProxy(Handle<JSProxy> proxy, Handle<FixedArray> keys);
49 void AddElementKeysFromInterceptor(Handle<JSObject> array); 47 void AddElementKeysFromInterceptor(Handle<JSObject> array);
50 void HideKey(uint32_t key);
51 void HideKey(Object* key);
52 void HideKey(Handle<Object> key);
53 void Prepare();
54 // Jump to the next level, pushing the current |levelLength_| to 48 // Jump to the next level, pushing the current |levelLength_| to
55 // |levelLengths_| and adding a new list to |elements_|. 49 // |levelLengths_| and adding a new list to |elements_|.
56 void NextPrototype(); 50 void NextPrototype();
57 // Sort the integer indices in the last list in |elements_| 51 // Sort the integer indices in the last list in |elements_|
58 void SortCurrentElementsList(); 52 void SortCurrentElementsList();
59 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); 53 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS);
60 int length() { return length_; } 54 int length() { return length_; }
61 Isolate* isolate() { return isolate_; } 55 Isolate* isolate() { return isolate_; }
62 56
63 private: 57 private:
64 bool AddIntegerKey(uint32_t key); 58 bool AddIntegerKey(uint32_t key);
65 bool AddStringKey(Handle<Object> key, AddKeyConversion convert); 59 bool AddStringKey(Handle<Object> key, AddKeyConversion convert);
66 bool AddSymbolKey(Handle<Object> array); 60 bool AddSymbolKey(Handle<Object> array);
67 void SortCurrentElementsListRemoveDuplicates(); 61 void SortCurrentElementsListRemoveDuplicates();
68 bool IsKeyHidden(Handle<Object> key);
69 bool IsKeyHidden(uint32_t key);
70 62
71 Isolate* isolate_; 63 Isolate* isolate_;
72 PropertyFilter filter_; 64 PropertyFilter filter_;
73 // |elements_| contains the sorted element keys (indices) per level. 65 // |elements_| contains the sorted element keys (indices) per level.
74 std::vector<std::vector<uint32_t>*> elements_; 66 std::vector<std::vector<uint32_t>*> elements_;
75 // |protoLengths_| contains the total number of keys (elements + properties) 67 // |protoLengths_| contains the total number of keys (elements + properties)
76 // per level. Negative values mark counts for a level with keys from a proxy. 68 // per level. Negative values mark counts for a level with keys from a proxy.
77 std::vector<int> level_lengths_; 69 std::vector<int> level_lengths_;
78 // |string_properties_| contains the unique String property keys for all 70 // |string_properties_| contains the unique String property keys for all
79 // levels in insertion order per level. 71 // levels in insertion order per level.
80 Handle<OrderedHashSet> string_properties_; 72 Handle<OrderedHashSet> string_properties_;
81 // |symbol_properties_| contains the unique Symbol property keys for all 73 // |symbol_properties_| contains the unique Symbol property keys for all
82 // levels in insertion order per level. 74 // levels in insertion order per level.
83 Handle<OrderedHashSet> symbol_properties_; 75 Handle<OrderedHashSet> symbol_properties_;
84 // |hidden_keys_| keeps track of the non-enumerable property keys to prevent
85 // them from being added to the accumulator if they reappear higher up in the
86 // prototype-chain.
87 Handle<OrderedHashSet> hidden_keys_;
88 std::set<uint32_t> hidden_element_keys_;
89 // |length_| keeps track of the total number of all element and property keys. 76 // |length_| keeps track of the total number of all element and property keys.
90 int length_ = 0; 77 int length_ = 0;
91 // |levelLength_| keeps track of the number of String keys in the current 78 // |levelLength_| keeps track of the number of String keys in the current
92 // level. 79 // level.
93 int level_string_length_ = 0; 80 int level_string_length_ = 0;
94 // |levelSymbolLength_| keeps track of the number of Symbol keys in the 81 // |levelSymbolLength_| keeps track of the number of Symbol keys in the
95 // current level. 82 // current level.
96 int level_symbol_length_ = 0; 83 int level_symbol_length_ = 0;
97 84
98 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); 85 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
99 }; 86 };
100 87
101 88
102 } // namespace internal 89 } // namespace internal
103 } // namespace v8 90 } // namespace v8
104 91
105 92
106 #endif // V8_KEY_ACCUMULATOR_H_ 93 #endif // V8_KEY_ACCUMULATOR_H_
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/key-accumulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698