Commit 7f646094 authored by bbudge's avatar bbudge Committed by Commit bot

[simd.js] Macro-ize more SIMD code.

Use macros for factory functions, and in hydrogen code stubs.

LOG=N
BUG=v8:4124

Review URL: https://codereview.chromium.org/1293533003

Cr-Commit-Position: refs/heads/master@{#30206}
parent 225a2b6f
......@@ -380,78 +380,32 @@ HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() {
{ Push(Add<HConstant>(factory->function_string())); }
is_function.Else();
{
IfBuilder is_float32x4(this);
is_float32x4.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->float32x4_map()));
is_float32x4.Then();
{ Push(Add<HConstant>(factory->float32x4_string())); }
is_float32x4.Else();
#define SIMD128_BUILDER_OPEN(TYPE, Type, type, lane_count, lane_type) \
IfBuilder is_##type(this); \
is_##type.If<HCompareObjectEqAndBranch>( \
map, Add<HConstant>(factory->type##_map())); \
is_##type.Then(); \
{ Push(Add<HConstant>(factory->type##_string())); } \
is_##type.Else(); {
SIMD128_TYPES(SIMD128_BUILDER_OPEN)
#undef SIMD128_BUILDER_OPEN
// Is it an undetectable object?
IfBuilder is_undetectable(this);
is_undetectable.If<HIsUndetectableAndBranch>(object);
is_undetectable.Then();
{
IfBuilder is_int32x4(this);
is_int32x4.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->int32x4_map()));
is_int32x4.Then();
{ Push(Add<HConstant>(factory->int32x4_string())); }
is_int32x4.Else();
{
IfBuilder is_bool32x4(this);
is_bool32x4.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->bool32x4_map()));
is_bool32x4.Then();
{ Push(Add<HConstant>(factory->bool32x4_string())); }
is_bool32x4.Else();
{
IfBuilder is_int16x8(this);
is_int16x8.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->int16x8_map()));
is_int16x8.Then();
{ Push(Add<HConstant>(factory->int16x8_string())); }
is_int16x8.Else();
{
IfBuilder is_bool16x8(this);
is_bool16x8.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->bool16x8_map()));
is_bool16x8.Then();
{ Push(Add<HConstant>(factory->bool16x8_string())); }
is_bool16x8.Else();
{
IfBuilder is_int8x16(this);
is_int8x16.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->int8x16_map()));
is_int8x16.Then();
{ Push(Add<HConstant>(factory->int8x16_string())); }
is_int8x16.Else();
{
IfBuilder is_bool8x16(this);
is_bool8x16.If<HCompareObjectEqAndBranch>(
map, Add<HConstant>(factory->bool8x16_map()));
is_bool8x16.Then();
{ Push(Add<HConstant>(factory->bool8x16_string())); }
is_bool8x16.Else();
{
// Is it an undetectable object?
IfBuilder is_undetectable(this);
is_undetectable.If<HIsUndetectableAndBranch>(
object);
is_undetectable.Then();
{
// typeof an undetectable object is 'undefined'.
Push(Add<HConstant>(factory->undefined_string()));
}
is_undetectable.Else();
{
// For any kind of object not handled above, the
// spec rule for host objects gives that it is
// okay to return "object".
Push(object_string);
}
}
}
}
}
}
}
// typeof an undetectable object is 'undefined'.
Push(Add<HConstant>(factory->undefined_string()));
}
is_undetectable.Else();
{
// For any kind of object not handled above, the spec rule for
// host objects gives that it is okay to return "object".
Push(object_string);
}
#define SIMD128_BUILDER_CLOSE(TYPE, Type, type, lane_count, lane_type) }
SIMD128_TYPES(SIMD128_BUILDER_CLOSE)
#undef SIMD128_BUILDER_CLOSE
}
is_function.End();
}
......
......@@ -1056,51 +1056,14 @@ Handle<HeapNumber> Factory::NewHeapNumber(double value,
}
Handle<Float32x4> Factory::NewFloat32x4(float lanes[4],
PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateFloat32x4(lanes, pretenure),
Float32x4);
}
Handle<Int32x4> Factory::NewInt32x4(int32_t lanes[4], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(), isolate()->heap()->AllocateInt32x4(lanes, pretenure), Int32x4);
}
Handle<Bool32x4> Factory::NewBool32x4(bool lanes[4], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateBool32x4(lanes, pretenure),
Bool32x4);
}
Handle<Int16x8> Factory::NewInt16x8(int16_t lanes[8], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(), isolate()->heap()->AllocateInt16x8(lanes, pretenure), Int16x8);
}
Handle<Bool16x8> Factory::NewBool16x8(bool lanes[8], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateBool16x8(lanes, pretenure),
Bool16x8);
}
Handle<Int8x16> Factory::NewInt8x16(int8_t lanes[16], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(), isolate()->heap()->AllocateInt8x16(lanes, pretenure), Int8x16);
}
Handle<Bool8x16> Factory::NewBool8x16(bool lanes[16], PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateBool8x16(lanes, pretenure),
Bool8x16);
}
#define SIMD128_NEW_DEF(TYPE, Type, type, lane_count, lane_type) \
Handle<Type> Factory::New##Type(lane_type lanes[lane_count], \
PretenureFlag pretenure) { \
CALL_HEAP_FUNCTION( \
isolate(), isolate()->heap()->Allocate##Type(lanes, pretenure), Type); \
}
SIMD128_TYPES(SIMD128_NEW_DEF)
#undef SIMD128_NEW_DEF
Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
......
......@@ -354,20 +354,12 @@ class Factory final {
Handle<HeapNumber> NewHeapNumber(double value,
MutableMode mode = IMMUTABLE,
PretenureFlag pretenure = NOT_TENURED);
Handle<Float32x4> NewFloat32x4(float lanes[4],
PretenureFlag pretenure = NOT_TENURED);
Handle<Int32x4> NewInt32x4(int32_t lanes[4],
PretenureFlag pretenure = NOT_TENURED);
Handle<Bool32x4> NewBool32x4(bool lanes[4],
PretenureFlag pretenure = NOT_TENURED);
Handle<Int16x8> NewInt16x8(int16_t lanes[8],
PretenureFlag pretenure = NOT_TENURED);
Handle<Bool16x8> NewBool16x8(bool lanes[8],
PretenureFlag pretenure = NOT_TENURED);
Handle<Int8x16> NewInt8x16(int8_t lanes[16],
PretenureFlag pretenure = NOT_TENURED);
Handle<Bool8x16> NewBool8x16(bool lanes[16],
PretenureFlag pretenure = NOT_TENURED);
#define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \
Handle<Type> New##Type(lane_type lanes[lane_count], \
PretenureFlag pretenure = NOT_TENURED);
SIMD128_TYPES(SIMD128_NEW_DECL)
#undef SIMD128_NEW_DECL
// These objects are used by the api to create env-independent data
// structures in the heap.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment