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

Unified Diff: src/macros.py

Issue 947683002: Reimplement Maps and Sets in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable one more test Created 5 years, 10 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
Index: src/macros.py
diff --git a/src/macros.py b/src/macros.py
index 93a5563c19ddaa7e0afcea891993afd722c753ba..a462f804a0a4adc43d6f1cff6911fd0d2db19e1e 100644
--- a/src/macros.py
+++ b/src/macros.py
@@ -272,6 +272,26 @@ const ITERATOR_KIND_KEYS = 1;
const ITERATOR_KIND_VALUES = 2;
const ITERATOR_KIND_ENTRIES = 3;
+# Needs prefixing
+const NUMBER_OF_BUCKETS_INDEX = 0;
+const NUMBER_OF_ELEMENTS_INDEX = 1;
+const NUMBER_OF_DELETED_ELEMENTS_INDEX = 2;
+const HASH_TABLE_START_INDEX = 3;
+const NOT_FOUND = -1;
+# For sets
+const SET_CHAIN_OFFSET = 1;
+const MAP_CHAIN_OFFSET = 2;
+
+macro SET_ENTRY_TO_INDEX(entry, numBuckets) = (3 + numBuckets + (entry << 1));
+macro SET_KEY_AT(table, entry, numBuckets) = (%_FixedArrayGet(table, SET_ENTRY_TO_INDEX(entry, numBuckets)));
+macro SET_CHAIN_AT(table, entry, numBuckets) = (%_FixedArrayGet(table, SET_ENTRY_TO_INDEX(entry, numBuckets) + 1));
+
+# TODO(adamk): Need to make multiplications not create HeapNumbers
+macro MAP_ENTRY_TO_INDEX(entry, numBuckets) = (3 + numBuckets + ((entry * 3) | 0));
+macro MAP_KEY_AT(table, entry, numBuckets) = (%_FixedArrayGet(table, MAP_ENTRY_TO_INDEX(entry, numBuckets)));
+macro MAP_VALUE_AT(table, entry, numBuckets) = (%_FixedArrayGet(table, MAP_ENTRY_TO_INDEX(entry, numBuckets) + 1));
+macro MAP_CHAIN_AT(table, entry, numBuckets) = (%_FixedArrayGet(table, MAP_ENTRY_TO_INDEX(entry, numBuckets) + 2));
+
# Check whether debug is active.
const DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
macro DEBUG_IS_STEPPING(function) = (%_DebugIsActive() != 0 && %DebugCallbackSupportsStepping(function));

Powered by Google App Engine
This is Rietveld 408576698