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

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: Moved more to JS Created 5 years, 9 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 c3a7888db0eace8534494b7e359147a594b08d1d..5ca15b0bad18678a7edac180c73349b008d6642f 100644
--- a/src/macros.py
+++ b/src/macros.py
@@ -271,6 +271,28 @@ 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;
+const HASH_NOT_COMPUTED_MASK = 1;
+const STRING_HASH_SHIFT = 2;
+# 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));
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.h » ('j') | src/runtime/runtime-collections.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698