Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from fenghaitao/master
Browse files Browse the repository at this point in the history
Implement SIMD APIs with C++ runtime functions and Float32x4Array and Int32x4Array element load and store for IA32 port
  • Loading branch information
fenghaitao committed Feb 28, 2014
2 parents 6af2070 + df89019 commit 68a92e4
Show file tree
Hide file tree
Showing 66 changed files with 5,162 additions and 88 deletions.
62 changes: 58 additions & 4 deletions include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,18 @@ class V8_EXPORT Value : public Data {
*/
bool IsFloat32Array() const;

/**
* Returns true if this value is a Float32x4Array.
* This is an experimental feature.
*/
bool IsFloat32x4Array() const;

/**
* Returns true if this value is a Int32x4Array.
* This is an experimental feature.
*/
bool IsInt32x4Array() const;

/**
* Returns true if this value is a Float64Array.
* This is an experimental feature.
Expand Down Expand Up @@ -2005,8 +2017,10 @@ enum ExternalArrayType {
kExternalInt16Array,
kExternalUint16Array,
kExternalInt32Array,
kExternalInt32x4Array,
kExternalUint32Array,
kExternalFloat32Array,
kExternalFloat32x4Array,
kExternalFloat64Array,
kExternalUint8ClampedArray,

Expand Down Expand Up @@ -2850,6 +2864,30 @@ class V8_EXPORT Float32Array : public TypedArray {
};


class V8_EXPORT Float32x4Array : public TypedArray {
public:
static Local<Float32x4Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Float32x4Array* Cast(Value* obj);

private:
Float32x4Array();
static void CheckCast(Value* obj);
};


class V8_EXPORT Int32x4Array : public TypedArray {
public:
static Local<Int32x4Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE static Int32x4Array* Cast(Value* obj);

private:
Int32x4Array();
static void CheckCast(Value* obj);
};


/**
* An instance of Float64Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly.
Expand Down Expand Up @@ -5386,7 +5424,7 @@ class Internals {
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 65;
static const int kContextEmbedderDataIndex = 72;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
Expand All @@ -5398,7 +5436,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
static const int kEmptyStringRootIndex = 145;
static const int kEmptyStringRootIndex = 153;

static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
Expand All @@ -5409,10 +5447,10 @@ class Internals {
static const int kNodeIsIndependentShift = 4;
static const int kNodeIsPartiallyDependentShift = 5;

static const int kJSObjectType = 0xbb;
static const int kJSObjectType = 0xc1;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
static const int kForeignType = 0x89;

static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3;
Expand Down Expand Up @@ -6251,6 +6289,22 @@ Float32Array* Float32Array::Cast(v8::Value* value) {
}


Float32x4Array* Float32x4Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Float32x4Array*>(value);
}


Int32x4Array* Int32x4Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Int32x4Array*>(value);
}


Float64Array* Float64Array::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
Expand Down
6 changes: 6 additions & 0 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class RegisteredExtension {
V(Uint32Array, JSTypedArray) \
V(Int32Array, JSTypedArray) \
V(Float32Array, JSTypedArray) \
V(Float32x4Array, JSTypedArray) \
V(Int32x4Array, JSTypedArray) \
V(Float64Array, JSTypedArray) \
V(DataView, JSDataView) \
V(String, String) \
Expand Down Expand Up @@ -246,6 +248,10 @@ class Utils {
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<Float32Array> ToLocalFloat32Array(
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<Float32x4Array> ToLocalFloat32x4Array(
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<Int32x4Array> ToLocalInt32x4Array(
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<Float64Array> ToLocalFloat64Array(
v8::internal::Handle<v8::internal::JSTypedArray> obj);

Expand Down
8 changes: 8 additions & 0 deletions src/arm/full-codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4515,6 +4515,14 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
__ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
__ cmp(r0, ip);
Split(eq, if_true, if_false, fall_through);
} else if (check->Equals(isolate()->heap()->float32x4_string())) {
__ JumpIfSmi(r0, if_false);
__ CompareObjectType(r0, r0, r1, FLOAT32x4_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (check->Equals(isolate()->heap()->int32x4_string())) {
__ JumpIfSmi(r0, if_false);
__ CompareObjectType(r0, r0, r1, INT32x4_TYPE);
Split(eq, if_true, if_false, fall_through);
} else if (check->Equals(isolate()->heap()->string_string())) {
__ JumpIfSmi(r0, if_false);
// Check for undetectable objects => false.
Expand Down
33 changes: 26 additions & 7 deletions src/arm/lithium-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,10 @@ LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
ASSERT(instr->key()->representation().IsSmiOrInteger32());
ElementsKind elements_kind = instr->elements_kind();
LOperand* key = UseRegisterOrConstantAtStart(instr->key());
bool load_128bits_without_neon = IsSIMD128ElementsKind(elements_kind);
LOperand* key = load_128bits_without_neon
? UseRegisterOrConstant(instr->key())
: UseRegisterOrConstantAtStart(instr->key());
LLoadKeyed* result = NULL;

if (!instr->is_typed_elements()) {
Expand All @@ -2090,15 +2093,24 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
ASSERT(instr->representation().IsSmiOrTagged());
obj = UseRegisterAtStart(instr->elements());
}
result = new(zone()) LLoadKeyed(obj, key);
result = new(zone()) LLoadKeyed(obj, key, NULL, NULL);
} else {
ASSERT(
(instr->representation().IsInteger32() &&
!IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
(instr->representation().IsDouble() &&
IsDoubleOrFloatElementsKind(instr->elements_kind())));
IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
(instr->representation().IsTagged() &&
(IsSIMD128ElementsKind(instr->elements_kind()))));
LOperand* backing_store = UseRegister(instr->elements());
result = new(zone()) LLoadKeyed(backing_store, key);
result = load_128bits_without_neon
? new(zone()) LLoadKeyed(backing_store, key,
TempRegister(), TempRegister())
: new(zone()) LLoadKeyed(backing_store, key, NULL, NULL);
if (load_128bits_without_neon) {
info()->MarkAsDeferredCalling();
AssignPointerMap(result);
}
}

DefineAsRegister(result);
Expand Down Expand Up @@ -2147,22 +2159,29 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
}
}

return new(zone()) LStoreKeyed(object, key, val);
return new(zone()) LStoreKeyed(object, key, val, NULL);
}

ASSERT(
(instr->value()->representation().IsInteger32() &&
!IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
(instr->value()->representation().IsDouble() &&
IsDoubleOrFloatElementsKind(instr->elements_kind())));
IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
(instr->value()->representation().IsTagged() &&
IsSIMD128ElementsKind(instr->elements_kind())));
ASSERT((instr->is_fixed_typed_array() &&
instr->elements()->representation().IsTagged()) ||
(instr->is_external() &&
instr->elements()->representation().IsExternal()));
LOperand* val = UseRegister(instr->value());
LOperand* key = UseRegisterOrConstantAtStart(instr->key());
LOperand* backing_store = UseRegister(instr->elements());
return new(zone()) LStoreKeyed(backing_store, key, val);
bool store_128bits_without_neon =
IsSIMD128ElementsKind(instr->elements_kind());
LStoreKeyed* result =
new(zone()) LStoreKeyed(backing_store, key, val,
store_128bits_without_neon ? TempRegister() : NULL);
return store_128bits_without_neon ? AssignEnvironment(result) : result;
}


Expand Down
16 changes: 12 additions & 4 deletions src/arm/lithium-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1581,15 +1581,20 @@ class LLoadExternalArrayPointer V8_FINAL
};


class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 2> {
public:
LLoadKeyed(LOperand* elements, LOperand* key) {
LLoadKeyed(LOperand* elements, LOperand* key,
LOperand* temp, LOperand* temp2) {
inputs_[0] = elements;
inputs_[1] = key;
temps_[0] = temp;
temps_[1] = temp2;
}

LOperand* elements() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
LOperand* temp2() { return temps_[1]; }
ElementsKind elements_kind() const {
return hydrogen()->elements_kind();
}
Expand Down Expand Up @@ -2203,12 +2208,14 @@ class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
};


class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 1> {
public:
LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
LOperand* temp) {
inputs_[0] = object;
inputs_[1] = key;
inputs_[2] = value;
temps_[0] = temp;
}

bool is_external() const { return hydrogen()->is_external(); }
Expand All @@ -2221,6 +2228,7 @@ class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
LOperand* elements() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* value() { return inputs_[2]; }
LOperand* temp() { return temps_[0]; }
ElementsKind elements_kind() const {
return hydrogen()->elements_kind();
}
Expand Down
Loading

0 comments on commit 68a92e4

Please sign in to comment.