Reviewers: Sven Panne,
Description:
Fix issue with storing 31-bit bitfield as Smi.
[email protected]
Please review this at https://codereview.chromium.org/428183003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+10, -5 lines):
M include/v8.h
M src/code-stubs.h
M src/objects.h
M src/objects-inl.h
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
46d4fc96d3ba1304a9f71f24419d0c520044fe8d..9d70766baf1e7f3e619052d25b9a8c1a4a2a352f
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5525,7 +5525,7 @@ template <> struct SmiTagging<4> {
V8_INLINE static int SmiToInt(const internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign
extending).
- return static_cast<int>(reinterpret_cast<intptr_t>(value)) >>
shift_bits;
+ return static_cast<int>(reinterpret_cast<intptr_t>(value) >>
shift_bits);
}
V8_INLINE static internal::Object* IntToSmi(int value) {
return internal::IntToSmi<kSmiShiftSize>(value);
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
f50abda45ff23227cc6d03723b62dde3d5748cfc..2c569021ad291c869777273c6869e308bcb60036
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -1665,7 +1665,9 @@ class CallFunctionStub: public PlatformCodeStub {
// Minor key encoding in 32 bits with Bitfield <Type, shift, size>.
class FlagBits: public BitField<CallFunctionFlags, 0, 2> {};
- class ArgcBits: public BitField<unsigned, 2, 32 - 2> {};
+ class ArgcBits : public BitField<unsigned, 2, Code::kArgumentsBits> {};
+
+ STATIC_ASSERT(Code::kArgumentsBits + 2 <= kStubMinorKeyBits);
Major MajorKey() const { return CallFunction; }
int MinorKey() const {
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
36e7eb1758769709f12c17d6abf609f422dd9359..b403ec4a62a99277e469109693026c3a2a3b15d2
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -6131,13 +6131,14 @@ void Code::set_type_feedback_info(Object* value,
WriteBarrierMode mode) {
uint32_t Code::stub_key() {
ASSERT(IsCodeStubOrIC());
- return Smi::cast(raw_type_feedback_info())->value() - Smi::kMinValue;
+ Smi* smi_key = Smi::cast(raw_type_feedback_info());
+ return static_cast<uint32_t>(smi_key->value());
}
void Code::set_stub_key(uint32_t key) {
ASSERT(IsCodeStubOrIC());
- set_raw_type_feedback_info(Smi::FromInt(key + Smi::kMinValue));
+ set_raw_type_feedback_info(Smi::FromInt(key));
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
e32b51d2ff06cff2fb9a5fbb9f0704fdf094fb58..037a337a2da05a17539bf70a0f676d48183a4a9d
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -304,8 +304,10 @@ static const ExtraICState kNoExtraICState = 0;
// Instance size sentinel for objects of variable size.
const int kVariableSizeSentinel = 0;
+// We may store the unsigned bit field as signed Smi value and do not
+// use the sign bit.
const int kStubMajorKeyBits = 7;
-const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize -
kStubMajorKeyBits;
+const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
// All Maps have a field instance_type containing a InstanceType.
// It describes the type of the instances.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.