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

M54 simd rebase #169

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/arm/assembler-arm-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace internal {
bool CpuFeatures::SupportsCrankshaft() { return IsSupported(VFP3); }

bool CpuFeatures::SupportsSimd128() { return false; }
bool CpuFeatures::SupportsSIMD128InCrankshaft() { return false; }

int DoubleRegister::NumRegisters() {
return CpuFeatures::IsSupported(VFP32DREGS) ? 32 : 16;
Expand Down
29 changes: 29 additions & 0 deletions src/arm/assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,34 @@ struct QwNeonRegister {
return r;
}

static int ToAllocationIndex(QwNeonRegister reg) {
DCHECK(reg.code() < kMaxNumRegisters);
return reg.code();
}

static const char* AllocationIndexToString(int index) {
DCHECK(index >= 0 && index < kMaxNumRegisters);
const char* const names[] = {
"q0",
"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",
"q9",
"q10",
"q11",
"q12",
"q13",
"q14",
"q15",
};
return names[index];
}

bool is_valid() const {
return (0 <= reg_code) && (reg_code < kMaxNumRegisters);
}
Expand All @@ -308,6 +336,7 @@ struct QwNeonRegister {


typedef QwNeonRegister QuadRegister;
typedef QwNeonRegister SIMD128Register;

typedef QwNeonRegister Simd128Register;

Expand Down
39 changes: 33 additions & 6 deletions src/arm/deoptimizer-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ void Deoptimizer::SetPlatformCompiledStubRegisters(
output_frame->SetRegister(r1.code(), handler);
}

void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {}

void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
void Deoptimizer::CopySIMD128Registers(FrameDescription* output_frame) {
for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) {
double double_value = input_->GetDoubleRegister(i);
output_frame->SetDoubleRegister(i, double_value);
Expand Down Expand Up @@ -185,12 +186,11 @@ void Deoptimizer::TableEntryGenerator::Generate() {

// Copy VFP registers to
// double_registers_[DoubleRegister::kMaxNumAllocatableRegisters]
int double_regs_offset = FrameDescription::double_registers_offset();
int double_regs_offset = FrameDescription::simd128_registers_offset();
const RegisterConfiguration* config = RegisterConfiguration::Crankshaft();
for (int i = 0; i < config->num_allocatable_double_registers(); ++i) {
int code = config->GetAllocatableDoubleCode(i);
int dst_offset = code * kDoubleSize + double_regs_offset;
int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize;
for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) {
int dst_offset = i * kDoubleSize + double_regs_offset;
int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize;
__ vldr(d0, sp, src_offset);
__ vstr(d0, r1, dst_offset);
}
Expand Down Expand Up @@ -366,6 +366,33 @@ void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) {
SetFrameSlot(offset, value);
}

double RegisterValues::GetDoubleRegister(unsigned n) const {
DCHECK(n < 2 * arraysize(simd128_registers_));
return simd128_registers_[n / 2].d[n % 2];
}

void RegisterValues::SetDoubleRegister(unsigned n, double value) {
DCHECK(n < 2 * arraysize(simd128_registers_));
simd128_registers_[n / 2].d[n % 2] = value;
}

simd128_value_t RegisterValues::GetSIMD128Register(unsigned n) const {
DCHECK(n < arraysize(simd128_registers_));
return simd128_registers_[n];
}

void RegisterValues::SetSIMD128Register(unsigned n, simd128_value_t value) {
DCHECK(n < arraysize(simd128_registers_));
simd128_registers_[n] = value;
}

int FrameDescription::double_registers_offset() {
return OFFSET_OF(FrameDescription, register_values_.simd128_registers_);
}

int FrameDescription::simd128_registers_offset() {
return OFFSET_OF(FrameDescription, register_values_.simd128_registers_);
}

#undef __

Expand Down
1 change: 1 addition & 0 deletions src/arm64/assembler-arm64-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace internal {
bool CpuFeatures::SupportsCrankshaft() { return true; }

bool CpuFeatures::SupportsSimd128() { return false; }
bool CpuFeatures::SupportsSIMD128InCrankshaft() { return false; }

void RelocInfo::apply(intptr_t delta) {
// On arm64 only internal references need extra work.
Expand Down
24 changes: 24 additions & 0 deletions src/arm64/assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,30 @@ struct FPRegister : public CPURegister {
// End of V8 compatibility section -----------------------
};

struct SIMD128Register {
static const int kMaxNumRegisters = 0;

static int ToAllocationIndex(SIMD128Register reg) {
UNIMPLEMENTED();
return -1;
}

static const char* AllocationIndexToString(int index) {
UNIMPLEMENTED();
return NULL;
}

static SIMD128Register from_code(int code) {
UNIMPLEMENTED();
SIMD128Register result = {-1};
return result;
}
int code() const {
UNIMPLEMENTED();
return -1;
}
int code_;
};

STATIC_ASSERT(sizeof(CPURegister) == sizeof(Register));
STATIC_ASSERT(sizeof(CPURegister) == sizeof(FPRegister));
Expand Down
30 changes: 29 additions & 1 deletion src/arm64/deoptimizer-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
}
}


void Deoptimizer::CopySIMD128Registers(FrameDescription* output_frame) {}

#define __ masm()->

Expand Down Expand Up @@ -341,6 +341,34 @@ void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) {
UNREACHABLE();
}

double RegisterValues::GetDoubleRegister(unsigned n) const {
DCHECK(n < arraysize(double_registers_));
return double_registers_[n];
}

void RegisterValues::SetDoubleRegister(unsigned n, double value) {
DCHECK(n < arraysize(double_registers_));
double_registers_[n] = value;
}

simd128_value_t RegisterValues::GetSIMD128Register(unsigned n) const {
UNREACHABLE();
simd128_value_t value;
return value;
}

void RegisterValues::SetSIMD128Register(unsigned n, simd128_value_t value) {
UNREACHABLE();
}

int FrameDescription::double_registers_offset() {
return OFFSET_OF(FrameDescription, register_values_.double_registers_);
}

int FrameDescription::simd128_registers_offset() {
UNREACHABLE();
return -1;
}

#undef __

Expand Down
1 change: 1 addition & 0 deletions src/assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class CpuFeatures : public AllStatic {
}

static inline bool SupportsCrankshaft();
static inline bool SupportsSIMD128InCrankshaft();

static inline bool SupportsSimd128();

Expand Down
2 changes: 1 addition & 1 deletion src/ast/scopes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
void Scope::ResolveTo(ParseInfo* info, BindingKind binding_kind,
VariableProxy* proxy, Variable* var) {
#ifdef DEBUG
if (info->script_is_native()) {
if (info->script_is_native() && var != 0x0) {
// To avoid polluting the global object in native scripts
// - Variables must not be allocated to the global scope.
CHECK_NOT_NULL(outer_scope());
Expand Down
68 changes: 68 additions & 0 deletions src/bootstrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class Genesis BASE_EMBEDDED {
bool InstallDebuggerNatives();
void InstallBuiltinFunctionIds();
void InstallExperimentalBuiltinFunctionIds();
void InstallExperimentalSIMDBuiltinFunctionIds();
void InitializeNormalizedMapCaches();

enum ExtensionTraversalState {
Expand Down Expand Up @@ -3376,6 +3377,9 @@ bool Genesis::InstallExperimentalNatives() {
if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \
return false; \
} \
if (id##_natives[j] == "native harmony-simd.js") { \
InstallExperimentalSIMDBuiltinFunctionIds(); \
} \
} \
} \
}
Expand Down Expand Up @@ -3427,6 +3431,32 @@ bool Genesis::InstallDebuggerNatives() {
return CallUtilsFunction(isolate(), "PostDebug");
}

static Handle<JSObject> ResolveBuiltinSIMDIdHolder(
Handle<Context> native_context, const char* holder_expr) {
Isolate* isolate = native_context->GetIsolate();
Factory* factory = isolate->factory();
Handle<JSGlobalObject> global(native_context->global_object());
Handle<Object> holder = global;
char* name = const_cast<char*>(holder_expr);
char* period_pos = strchr(name, '.');
while (period_pos != NULL) {
Vector<const char> property(name, static_cast<int>(period_pos - name));
Handle<String> property_string = factory->InternalizeUtf8String(property);
DCHECK(!property_string.is_null());
holder = Object::GetProperty(holder, property_string).ToHandleChecked();
if (strcmp(".prototype", period_pos) == 0) {
Handle<JSFunction> function = Handle<JSFunction>::cast(holder);
return Handle<JSObject>(JSObject::cast(function->prototype()));
} else {
name = period_pos + 1;
period_pos = strchr(name, '.');
}
}

return Handle<JSObject>::cast(
Object::GetPropertyOrElement(holder, factory->InternalizeUtf8String(name))
.ToHandleChecked());
}

static void InstallBuiltinFunctionId(Handle<JSObject> holder,
const char* function_name,
Expand Down Expand Up @@ -3485,6 +3515,44 @@ void Genesis::InstallExperimentalBuiltinFunctionIds() {

#undef INSTALL_BUILTIN_ID

void Genesis::InstallExperimentalSIMDBuiltinFunctionIds() {
HandleScope scope(isolate());
#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
{ \
Handle<JSObject> holder = \
ResolveBuiltinSIMDIdHolder(native_context(), #holder_expr); \
BuiltinFunctionId id = k##name; \
InstallBuiltinFunctionId(holder, #fun_name, id); \
}
TYPED_ARRAYS_SIMD_LOAD_OPERATIONS(INSTALL_BUILTIN_ID)
TYPED_ARRAYS_SIMD_STORE_OPERATIONS(INSTALL_BUILTIN_ID)
#define INSTALL_SIMD_UNARY_FUNCTION_ID(p1, p2, p3, p4, p5) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_UNARY_OPERATIONS(INSTALL_SIMD_UNARY_FUNCTION_ID)
#undef INSTALL_SIMD_UNARY_FUNCTION_ID
#define INSTALL_SIMD_BINARY_FUNCTION_ID(p1, p2, p3, p4, p5, p6) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_BINARY_OPERATIONS(INSTALL_SIMD_BINARY_FUNCTION_ID)
#undef INSTALL_SIMD_BINARY_FUNCTION_ID
#define INSTALL_SIMD_TERNARY_FUNCTION_ID(p1, p2, p3, p4, p5, p6, p7) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_TERNARY_OPERATIONS(INSTALL_SIMD_TERNARY_FUNCTION_ID)
#undef INSTALL_SIMD_TERNARY_FUNCTION_ID
#define INSTALL_SIMD_QUARTERNARY_FUNCTION_ID(p1, p2, p3, p4, p5, p6, p7, p8) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_QUARTERNARY_OPERATIONS(INSTALL_SIMD_QUARTERNARY_FUNCTION_ID)
#undef INSTALL_SIMD_QUARTERNARY_FUNCTION_ID
#define INSTALL_SIMD_QUINARY_FUNCTION_ID(p1, p2, p3, p4, p5, p6, p7, p8, p9) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_QUINARY_OPERATIONS(INSTALL_SIMD_QUINARY_FUNCTION_ID)
#undef INSTALL_SIMD_QUINARY_FUNCTION_ID
#define INSTALL_SIMD_SENARY_FUNCTION_ID(p1, p2, p3, p4, p5, p6, p7, p8, p9, \
p10) \
INSTALL_BUILTIN_ID(p1, p2, p3)
SIMD_SENARY_OPERATIONS(INSTALL_SIMD_SENARY_FUNCTION_ID)
#undef INSTALL_SIMD_SENARY_FUNCTION_ID
#undef INSTALL_BUILTIN_ID
}

void Genesis::InitializeNormalizedMapCaches() {
Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate());
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/linkage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ MachineType reptyp(Representation representation) {
case Representation::kNone:
case Representation::kNumRepresentations:
break;
case Representation::kFloat32x4:
case Representation::kInt32x4:
case Representation::kBool32x4:
// TODO(nhu): fix this in TF implementation.
break;
}
UNREACHABLE();
return MachineType::None();
Expand Down
40 changes: 40 additions & 0 deletions src/crankshaft/arm/lithium-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,46 @@ LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
return DefineAsRegister(result);
}

LInstruction* LChunkBuilder::DoNullarySIMDOperation(
HNullarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoUnarySIMDOperation(HUnarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoBinarySIMDOperation(
HBinarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoTernarySIMDOperation(
HTernarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoQuarternarySIMDOperation(
HQuarternarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoQuinarySIMDOperation(
HQuinarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoSenarySIMDOperation(
HSenarySIMDOperation* instr) {
UNIMPLEMENTED();
return NULL;
}

LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
LOperand* context = UseFixed(instr->context(), cp);
Expand Down
Loading