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

Unified Diff: src/objects-inl.h

Issue 2695653005: Revert of Remove SIMD.js from V8. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 0a785e613daa604b61106d28791913190e78dfba..371bc2af73927d64f717eb49e68a9dd94e5b0cdf 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -174,6 +174,7 @@
TYPE_CHECKER(Oddball, ODDBALL_TYPE)
TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
+TYPE_CHECKER(Simd128Value, SIMD128_VALUE_TYPE)
TYPE_CHECKER(Symbol, SYMBOL_TYPE)
TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
@@ -202,6 +203,11 @@
bool HeapObject::IsExternal() const {
return map() == GetHeap()->external_map();
}
+
+#define SIMD128_TYPE_CHECKER(TYPE, Type, type, lane_count, lane_type) \
+ bool HeapObject::Is##Type() const { return map() == GetHeap()->type##_map(); }
+SIMD128_TYPES(SIMD128_TYPE_CHECKER)
+#undef SIMD128_TYPE_CHECKER
#define IS_TYPE_FUNCTION_DEF(type_) \
bool Object::Is##type_() const { \
@@ -611,6 +617,9 @@
CAST_ACCESSOR(AbstractCode)
CAST_ACCESSOR(ArrayList)
CAST_ACCESSOR(BoilerplateDescription)
+CAST_ACCESSOR(Bool16x8)
+CAST_ACCESSOR(Bool32x4)
+CAST_ACCESSOR(Bool8x16)
CAST_ACCESSOR(ByteArray)
CAST_ACCESSOR(BytecodeArray)
CAST_ACCESSOR(Cell)
@@ -629,11 +638,15 @@
CAST_ACCESSOR(FixedArrayBase)
CAST_ACCESSOR(FixedDoubleArray)
CAST_ACCESSOR(FixedTypedArrayBase)
+CAST_ACCESSOR(Float32x4)
CAST_ACCESSOR(Foreign)
CAST_ACCESSOR(FrameArray)
CAST_ACCESSOR(GlobalDictionary)
CAST_ACCESSOR(HandlerTable)
CAST_ACCESSOR(HeapObject)
+CAST_ACCESSOR(Int16x8)
+CAST_ACCESSOR(Int32x4)
+CAST_ACCESSOR(Int8x16)
CAST_ACCESSOR(JSArray)
CAST_ACCESSOR(JSArrayBuffer)
CAST_ACCESSOR(JSArrayBufferView)
@@ -684,6 +697,7 @@
CAST_ACCESSOR(SeqString)
CAST_ACCESSOR(SeqTwoByteString)
CAST_ACCESSOR(SharedFunctionInfo)
+CAST_ACCESSOR(Simd128Value)
CAST_ACCESSOR(SlicedString)
CAST_ACCESSOR(Smi)
CAST_ACCESSOR(String)
@@ -693,6 +707,9 @@
CAST_ACCESSOR(Symbol)
CAST_ACCESSOR(TemplateInfo)
CAST_ACCESSOR(ThinString)
+CAST_ACCESSOR(Uint16x8)
+CAST_ACCESSOR(Uint32x4)
+CAST_ACCESSOR(Uint8x16)
CAST_ACCESSOR(UnseededNumberDictionary)
CAST_ACCESSOR(WeakCell)
CAST_ACCESSOR(WeakFixedArray)
@@ -1557,6 +1574,110 @@
int HeapNumber::get_sign() {
return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
}
+
+
+bool Simd128Value::Equals(Simd128Value* that) {
+ // TODO(bmeurer): This doesn't match the SIMD.js specification, but it seems
+ // to be consistent with what the CompareICStub does, and what is tested in
+ // the current SIMD.js testsuite.
+ if (this == that) return true;
+#define SIMD128_VALUE(TYPE, Type, type, lane_count, lane_type) \
+ if (this->Is##Type()) { \
+ if (!that->Is##Type()) return false; \
+ return Type::cast(this)->Equals(Type::cast(that)); \
+ }
+ SIMD128_TYPES(SIMD128_VALUE)
+#undef SIMD128_VALUE
+ return false;
+}
+
+
+// static
+bool Simd128Value::Equals(Handle<Simd128Value> one, Handle<Simd128Value> two) {
+ return one->Equals(*two);
+}
+
+
+#define SIMD128_VALUE_EQUALS(TYPE, Type, type, lane_count, lane_type) \
+ bool Type::Equals(Type* that) { \
+ for (int lane = 0; lane < lane_count; ++lane) { \
+ if (this->get_lane(lane) != that->get_lane(lane)) return false; \
+ } \
+ return true; \
+ }
+SIMD128_TYPES(SIMD128_VALUE_EQUALS)
+#undef SIMD128_VALUE_EQUALS
+
+
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+#define SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \
+ lane_type value = \
+ READ_##field_type##_FIELD(this, kValueOffset + lane * field_size);
+#elif defined(V8_TARGET_BIG_ENDIAN)
+#define SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \
+ lane_type value = READ_##field_type##_FIELD( \
+ this, kValueOffset + (lane_count - lane - 1) * field_size);
+#else
+#error Unknown byte ordering
+#endif
+
+#if defined(V8_TARGET_LITTLE_ENDIAN)
+#define SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \
+ WRITE_##field_type##_FIELD(this, kValueOffset + lane * field_size, value);
+#elif defined(V8_TARGET_BIG_ENDIAN)
+#define SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \
+ WRITE_##field_type##_FIELD( \
+ this, kValueOffset + (lane_count - lane - 1) * field_size, value);
+#else
+#error Unknown byte ordering
+#endif
+
+#define SIMD128_NUMERIC_LANE_FNS(type, lane_type, lane_count, field_type, \
+ field_size) \
+ lane_type type::get_lane(int lane) const { \
+ DCHECK(lane < lane_count && lane >= 0); \
+ SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \
+ return value; \
+ } \
+ \
+ void type::set_lane(int lane, lane_type value) { \
+ DCHECK(lane < lane_count && lane >= 0); \
+ SIMD128_WRITE_LANE(lane_count, field_type, field_size, value) \
+ }
+
+SIMD128_NUMERIC_LANE_FNS(Float32x4, float, 4, FLOAT, kFloatSize)
+SIMD128_NUMERIC_LANE_FNS(Int32x4, int32_t, 4, INT32, kInt32Size)
+SIMD128_NUMERIC_LANE_FNS(Uint32x4, uint32_t, 4, UINT32, kInt32Size)
+SIMD128_NUMERIC_LANE_FNS(Int16x8, int16_t, 8, INT16, kShortSize)
+SIMD128_NUMERIC_LANE_FNS(Uint16x8, uint16_t, 8, UINT16, kShortSize)
+SIMD128_NUMERIC_LANE_FNS(Int8x16, int8_t, 16, INT8, kCharSize)
+SIMD128_NUMERIC_LANE_FNS(Uint8x16, uint8_t, 16, UINT8, kCharSize)
+#undef SIMD128_NUMERIC_LANE_FNS
+
+
+#define SIMD128_BOOLEAN_LANE_FNS(type, lane_type, lane_count, field_type, \
+ field_size) \
+ bool type::get_lane(int lane) const { \
+ DCHECK(lane < lane_count && lane >= 0); \
+ SIMD128_READ_LANE(lane_type, lane_count, field_type, field_size) \
+ DCHECK(value == 0 || value == -1); \
+ return value != 0; \
+ } \
+ \
+ void type::set_lane(int lane, bool value) { \
+ DCHECK(lane < lane_count && lane >= 0); \
+ int32_t int_val = value ? -1 : 0; \
+ SIMD128_WRITE_LANE(lane_count, field_type, field_size, int_val) \
+ }
+
+SIMD128_BOOLEAN_LANE_FNS(Bool32x4, int32_t, 4, INT32, kInt32Size)
+SIMD128_BOOLEAN_LANE_FNS(Bool16x8, int16_t, 8, INT16, kShortSize)
+SIMD128_BOOLEAN_LANE_FNS(Bool8x16, int8_t, 16, INT8, kCharSize)
+#undef SIMD128_BOOLEAN_LANE_FNS
+
+#undef SIMD128_READ_LANE
+#undef SIMD128_WRITE_LANE
+
ACCESSORS(JSReceiver, properties, FixedArray, kPropertiesOffset)
@@ -2337,8 +2458,8 @@
DCHECK(IsHeapObject());
Isolate* isolate = HeapObject::cast(this)->GetIsolate();
if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
- IsUndefined(isolate) || IsTrue(isolate) || IsFalse(isolate) ||
- IsNull(isolate))) {
+ IsSimd128Value() || IsUndefined(isolate) || IsTrue(isolate) ||
+ IsFalse(isolate) || IsNull(isolate))) {
FATAL("API call returned invalid object");
}
#endif // DEBUG
@@ -2601,6 +2722,7 @@
return kDoubleAligned;
}
if (IsHeapNumber()) return kDoubleUnaligned;
+ if (IsSimd128Value()) return kSimd128Unaligned;
#endif // V8_HOST_ARCH_32_BIT
return kWordAligned;
}
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698