From 4f932a4821ec7e144065ee21d63adf07815268e3 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Tue, 12 Aug 2014 11:07:20 -0500 Subject: [PATCH] Bug 1052491 - Simplify IdToTypeId and add support for symbol-keyed properties. r=bhackett. --HG-- extra : rebase_source : ee5bfd8e415aa9570e773662889d815c91636f57 --- js/src/jsinferinlines.h | 42 +++-------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/js/src/jsinferinlines.h b/js/src/jsinferinlines.h index 5290bf748848..bf35bfed013f 100644 --- a/js/src/jsinferinlines.h +++ b/js/src/jsinferinlines.h @@ -194,28 +194,6 @@ TypeFlagPrimitive(TypeFlags flags) } } -/* - * Check for numeric strings, as in js_StringIsIndex, but allow negative - * and overflowing integers. - */ -template -inline bool -IdIsNumericTypeId(Range cp) -{ - if (cp.length() == 0) - return false; - - if (!JS7_ISDEC(cp[0]) && cp[0] != '-') - return false; - - for (size_t i = 1; i < cp.length(); ++i) { - if (!JS7_ISDEC(cp[i])) - return false; - } - - return true; -} - /* * Get the canonical representation of an id to use when doing inference. This * maintains the constraint that if two different jsids map to the same property @@ -226,23 +204,9 @@ IdToTypeId(jsid id) { JS_ASSERT(!JSID_IS_EMPTY(id)); - /* - * All integers must map to the aggregate property for index types, including - * negative integers. - */ - if (JSID_IS_INT(id)) - return JSID_VOID; - - if (JSID_IS_STRING(id)) { - JSAtom *atom = JSID_TO_ATOM(id); - JS::AutoCheckCannotGC nogc; - bool isNumeric = atom->hasLatin1Chars() - ? IdIsNumericTypeId(atom->latin1Range(nogc)) - : IdIsNumericTypeId(atom->twoByteRange(nogc)); - return isNumeric ? JSID_VOID : id; - } - - return JSID_VOID; + // All properties which can be stored in an object's dense elements must + // map to the aggregate property for index types. + return JSID_IS_INT(id) ? JSID_VOID : id; } const char * TypeIdStringImpl(jsid id);