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

Unified Diff: src/key-accumulator.cc

Issue 1612413003: Reland 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/key-accumulator.h ('k') | src/messages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/key-accumulator.cc
diff --git a/src/key-accumulator.cc b/src/key-accumulator.cc
index e7a9c3ccebccd3ba56b7a87b6cc7c1f9148deae7..c259edffe9da4b10a608d113b26d3ac74094a854 100644
--- a/src/key-accumulator.cc
+++ b/src/key-accumulator.cc
@@ -138,10 +138,11 @@
bool KeyAccumulator::AddIntegerKey(uint32_t key) {
+ if (IsKeyHidden(key)) return false;
// Make sure we do not add keys to a proxy-level (see AddKeysFromProxy).
// We mark proxy-levels with a negative length
DCHECK_LE(0, level_string_length_);
- // Binary search over all but the last level. The last one might not be
+ // Binary search over all but the last level. The last level might not be
// sorted yet.
for (size_t i = 1; i < elements_.size(); i++) {
if (AccumulatorHasKey(elements_[i - 1], key)) return false;
@@ -154,11 +155,10 @@
bool KeyAccumulator::AddStringKey(Handle<Object> key,
AddKeyConversion convert) {
+ if (IsKeyHidden(key)) return false;
if (string_properties_.is_null()) {
string_properties_ = OrderedHashSet::Allocate(isolate_, 16);
}
- // TODO(cbruni): remove this conversion once we throw the correct TypeError
- // for non-string/symbol elements returned by proxies
if (convert == PROXY_MAGIC && key->IsNumber()) {
key = isolate_->factory()->NumberToString(key);
}
@@ -175,6 +175,7 @@
bool KeyAccumulator::AddSymbolKey(Handle<Object> key) {
+ if (IsKeyHidden(key)) return false;
if (symbol_properties_.is_null()) {
symbol_properties_ = OrderedHashSet::Allocate(isolate_, 16);
}
@@ -299,6 +300,9 @@
}
+void KeyAccumulator::Prepare() { NextPrototype(); }
+
+
void KeyAccumulator::NextPrototype() {
// Store the protoLength on the first call of this method.
if (!elements_.empty()) {
@@ -311,5 +315,32 @@
}
+void KeyAccumulator::HideKey(uint32_t key) { hidden_element_keys_.insert(key); }
+
+
+void KeyAccumulator::HideKey(Object* key) {
+ HideKey(Handle<Object>(key, isolate_));
+}
+
+
+void KeyAccumulator::HideKey(Handle<Object> key) {
+ if (hidden_keys_.is_null()) {
+ hidden_keys_ = OrderedHashSet::Allocate(isolate_, 8);
+ }
+ hidden_keys_ = OrderedHashSet::Add(hidden_keys_, key);
+}
+
+
+bool KeyAccumulator::IsKeyHidden(uint32_t key) {
+ return hidden_element_keys_.count(key);
+}
+
+
+bool KeyAccumulator::IsKeyHidden(Handle<Object> key) {
+ if (hidden_keys_.is_null()) return false;
+ return OrderedHashSet::HasKey(hidden_keys_, key);
+}
+
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/key-accumulator.h ('k') | src/messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698