Bug 645416, part 1 - Add an enum for symbols to JSValueType. r=nbp.

JSVAL_TYPE_SYMBOL is inserted between STRING and NULL, rather than added at the
end, in order to preserve all the inequality relations on JSValueTypes used
throughout Value.h. (Search the header for the operators < > <= >=.)

Otherwise, this pretty much just works. Some details of Ion snapshot layout
had to change to accommodate 4-bit types.

--HG--
extra : rebase_source : e3141e6a9ee32ef563dab43a4942a9e67d234865
This commit is contained in:
Jason Orendorff 2014-06-23 10:55:51 -05:00
parent 61e163f753
commit c3317f9be6
4 changed files with 13 additions and 8 deletions

View File

@ -76,8 +76,9 @@ JS_ENUM_HEADER(JSValueType, uint8_t)
JSVAL_TYPE_BOOLEAN = 0x03,
JSVAL_TYPE_MAGIC = 0x04,
JSVAL_TYPE_STRING = 0x05,
JSVAL_TYPE_NULL = 0x06,
JSVAL_TYPE_OBJECT = 0x07,
JSVAL_TYPE_SYMBOL = 0x06,
JSVAL_TYPE_NULL = 0x07,
JSVAL_TYPE_OBJECT = 0x08,
/* These never appear in a jsval; they are only provided as an out-of-band value. */
JSVAL_TYPE_UNKNOWN = 0x20,

View File

@ -289,8 +289,8 @@ RValueAllocation::readPayload(CompactBufferReader &reader, PayloadType type,
p->fpu = FloatRegister::FromCode(reader.readByte());
break;
case PAYLOAD_PACKED_TAG:
p->type = JSValueType(*mode & 0x07);
*mode = *mode & ~0x07;
p->type = JSValueType(*mode & PACKED_TAG_MASK);
*mode = *mode & ~PACKED_TAG_MASK;
break;
}
}
@ -335,7 +335,7 @@ RValueAllocation::writePayload(CompactBufferWriter &writer, PayloadType type,
// writeByte of the mode.
MOZ_ASSERT(writer.length());
uint8_t *mode = writer.buffer() + (writer.length() - 1);
MOZ_ASSERT((*mode & 0x07) == 0 && (p.type & ~0x07) == 0);
MOZ_ASSERT((*mode & PACKED_TAG_MASK) == 0 && (p.type & ~PACKED_TAG_MASK) == 0);
*mode = *mode | p.type;
break;
}

View File

@ -58,17 +58,19 @@ class RValueAllocation
// The JSValueType is packed in the Mode.
TYPED_REG_MIN = 0x10,
TYPED_REG_MAX = 0x17,
TYPED_REG_MAX = 0x1f,
TYPED_REG = TYPED_REG_MIN,
// The JSValueType is packed in the Mode.
TYPED_STACK_MIN = 0x18,
TYPED_STACK_MAX = 0x1f,
TYPED_STACK_MIN = 0x20,
TYPED_STACK_MAX = 0x2f,
TYPED_STACK = TYPED_STACK_MIN,
INVALID = 0x100,
};
enum { PACKED_TAG_MASK = 0x0f };
// See Payload encoding in Snapshots.cpp
enum PayloadType {
PAYLOAD_NONE,

View File

@ -73,6 +73,7 @@ BEGIN_TEST(testJitRValueAlloc_TypedReg)
_(JSVAL_TYPE_BOOLEAN) \
/* _(JSVAL_TYPE_MAGIC) */ \
_(JSVAL_TYPE_STRING) \
_(JSVAL_TYPE_SYMBOL) \
/* _(JSVAL_TYPE_NULL) */ \
_(JSVAL_TYPE_OBJECT)
@ -100,6 +101,7 @@ BEGIN_TEST(testJitRValueAlloc_TypedStack)
_(JSVAL_TYPE_BOOLEAN) \
/* _(JSVAL_TYPE_MAGIC) */ \
_(JSVAL_TYPE_STRING) \
_(JSVAL_TYPE_SYMBOL) \
/* _(JSVAL_TYPE_NULL) */ \
_(JSVAL_TYPE_OBJECT)