OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 *element_size = 4; | 887 *element_size = 4; |
888 break; | 888 break; |
889 case ARRAY_ID_INT32: | 889 case ARRAY_ID_INT32: |
890 *array_type = kExternalIntArray; | 890 *array_type = kExternalIntArray; |
891 *element_size = 4; | 891 *element_size = 4; |
892 break; | 892 break; |
893 case ARRAY_ID_FLOAT32: | 893 case ARRAY_ID_FLOAT32: |
894 *array_type = kExternalFloatArray; | 894 *array_type = kExternalFloatArray; |
895 *element_size = 4; | 895 *element_size = 4; |
896 break; | 896 break; |
| 897 case ARRAY_ID_FLOAT32x4: |
| 898 *array_type = kExternalFloat32x4Array; |
| 899 *element_size = 16; |
| 900 break; |
| 901 case ARRAY_ID_INT32x4: |
| 902 *array_type = kExternalInt32x4Array; |
| 903 *element_size = 16; |
| 904 break; |
897 case ARRAY_ID_FLOAT64: | 905 case ARRAY_ID_FLOAT64: |
898 *array_type = kExternalDoubleArray; | 906 *array_type = kExternalDoubleArray; |
899 *element_size = 8; | 907 *element_size = 8; |
900 break; | 908 break; |
901 case ARRAY_ID_UINT8C: | 909 case ARRAY_ID_UINT8C: |
902 *array_type = kExternalPixelArray; | 910 *array_type = kExternalPixelArray; |
903 *element_size = 1; | 911 *element_size = 1; |
904 break; | 912 break; |
905 default: | 913 default: |
906 UNREACHABLE(); | 914 UNREACHABLE(); |
(...skipping 4304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5211 // In the case of a String object we just need to redirect the assignment to | 5219 // In the case of a String object we just need to redirect the assignment to |
5212 // the underlying string if the index is in range. Since the underlying | 5220 // the underlying string if the index is in range. Since the underlying |
5213 // string does nothing with the assignment then we can ignore such | 5221 // string does nothing with the assignment then we can ignore such |
5214 // assignments. | 5222 // assignments. |
5215 if (js_object->IsStringObjectWithCharacterAt(index)) { | 5223 if (js_object->IsStringObjectWithCharacterAt(index)) { |
5216 return value; | 5224 return value; |
5217 } | 5225 } |
5218 | 5226 |
5219 js_object->ValidateElements(); | 5227 js_object->ValidateElements(); |
5220 if (js_object->HasExternalArrayElements()) { | 5228 if (js_object->HasExternalArrayElements()) { |
5221 if (!value->IsNumber() && !value->IsUndefined()) { | 5229 // TODO(ningxin): Throw an error if setting a Float32x4Array element |
| 5230 // while the value is not Float32x4Object. |
| 5231 if (!value->IsNumber() && !value->IsFloat32x4() && |
| 5232 !value->IsInt32x4() && !value->IsUndefined()) { |
5222 bool has_exception; | 5233 bool has_exception; |
5223 Handle<Object> number = | 5234 Handle<Object> number = |
5224 Execution::ToNumber(isolate, value, &has_exception); | 5235 Execution::ToNumber(isolate, value, &has_exception); |
5225 if (has_exception) return Handle<Object>(); // exception | 5236 if (has_exception) return Handle<Object>(); // exception |
5226 value = number; | 5237 value = number; |
5227 } | 5238 } |
5228 } | 5239 } |
5229 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, | 5240 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, |
5230 strict_mode, | 5241 strict_mode, |
5231 true, | 5242 true, |
5232 set_mode); | 5243 set_mode); |
5233 js_object->ValidateElements(); | 5244 js_object->ValidateElements(); |
5234 return result.is_null() ? result : value; | 5245 return result.is_null() ? result : value; |
5235 } | 5246 } |
5236 | 5247 |
5237 if (key->IsName()) { | 5248 if (key->IsName()) { |
5238 Handle<Name> name = Handle<Name>::cast(key); | 5249 Handle<Name> name = Handle<Name>::cast(key); |
5239 if (name->AsArrayIndex(&index)) { | 5250 if (name->AsArrayIndex(&index)) { |
5240 if (js_object->HasExternalArrayElements()) { | 5251 if (js_object->HasExternalArrayElements()) { |
5241 if (!value->IsNumber() && !value->IsUndefined()) { | 5252 // TODO(ningxin): Throw an error if setting a Float32x4Array element |
| 5253 // while the value is not Float32x4Object. |
| 5254 if (!value->IsNumber() && !value->IsFloat32x4() && |
| 5255 !value->IsInt32x4() && !value->IsUndefined()) { |
5242 bool has_exception; | 5256 bool has_exception; |
5243 Handle<Object> number = | 5257 Handle<Object> number = |
5244 Execution::ToNumber(isolate, value, &has_exception); | 5258 Execution::ToNumber(isolate, value, &has_exception); |
5245 if (has_exception) return Handle<Object>(); // exception | 5259 if (has_exception) return Handle<Object>(); // exception |
5246 value = number; | 5260 value = number; |
5247 } | 5261 } |
5248 } | 5262 } |
5249 return JSObject::SetElement(js_object, index, value, attr, strict_mode, | 5263 return JSObject::SetElement(js_object, index, value, attr, strict_mode, |
5250 true, | 5264 true, |
5251 set_mode); | 5265 set_mode); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6015 } | 6029 } |
6016 | 6030 |
6017 | 6031 |
6018 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 6032 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
6019 // Possible optimizations: put the type string into the oddballs. | 6033 // Possible optimizations: put the type string into the oddballs. |
6020 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 6034 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
6021 SealHandleScope shs(isolate); | 6035 SealHandleScope shs(isolate); |
6022 | 6036 |
6023 Object* obj = args[0]; | 6037 Object* obj = args[0]; |
6024 if (obj->IsNumber()) return isolate->heap()->number_string(); | 6038 if (obj->IsNumber()) return isolate->heap()->number_string(); |
| 6039 if (obj->IsFloat32x4()) return isolate->heap()->float32x4_string(); |
| 6040 if (obj->IsInt32x4()) return isolate->heap()->int32x4_string(); |
6025 HeapObject* heap_obj = HeapObject::cast(obj); | 6041 HeapObject* heap_obj = HeapObject::cast(obj); |
6026 | 6042 |
6027 // typeof an undetectable object is 'undefined' | 6043 // typeof an undetectable object is 'undefined' |
6028 if (heap_obj->map()->is_undetectable()) { | 6044 if (heap_obj->map()->is_undetectable()) { |
6029 return isolate->heap()->undefined_string(); | 6045 return isolate->heap()->undefined_string(); |
6030 } | 6046 } |
6031 | 6047 |
6032 InstanceType instance_type = heap_obj->map()->instance_type(); | 6048 InstanceType instance_type = heap_obj->map()->instance_type(); |
6033 if (instance_type < FIRST_NONSTRING_TYPE) { | 6049 if (instance_type < FIRST_NONSTRING_TYPE) { |
6034 return isolate->heap()->string_string(); | 6050 return isolate->heap()->string_string(); |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6882 } | 6898 } |
6883 | 6899 |
6884 | 6900 |
6885 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { | 6901 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { |
6886 SealHandleScope shs(isolate); | 6902 SealHandleScope shs(isolate); |
6887 ASSERT(args.length() == 0); | 6903 ASSERT(args.length() == 0); |
6888 return isolate->heap()->AllocateHeapNumber(0); | 6904 return isolate->heap()->AllocateHeapNumber(0); |
6889 } | 6905 } |
6890 | 6906 |
6891 | 6907 |
| 6908 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateFloat32x4) { |
| 6909 SealHandleScope shs(isolate); |
| 6910 ASSERT(args.length() == 0); |
| 6911 |
| 6912 float32x4_value_t zero; |
| 6913 zero.storage[0] = 0; |
| 6914 zero.storage[1] = 0; |
| 6915 zero.storage[2] = 0; |
| 6916 zero.storage[3] = 0; |
| 6917 return isolate->heap()->AllocateFloat32x4(zero); |
| 6918 } |
| 6919 |
| 6920 |
| 6921 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInt32x4) { |
| 6922 SealHandleScope shs(isolate); |
| 6923 ASSERT(args.length() == 0); |
| 6924 |
| 6925 int32x4_value_t zero; |
| 6926 zero.storage[0] = 0; |
| 6927 zero.storage[1] = 0; |
| 6928 zero.storage[2] = 0; |
| 6929 zero.storage[3] = 0; |
| 6930 return isolate->heap()->AllocateInt32x4(zero); |
| 6931 } |
| 6932 |
| 6933 |
6892 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6934 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
6893 SealHandleScope shs(isolate); | 6935 SealHandleScope shs(isolate); |
6894 ASSERT(args.length() == 2); | 6936 ASSERT(args.length() == 2); |
6895 | 6937 |
6896 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6938 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6897 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6939 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6898 return isolate->heap()->NumberFromDouble(x + y); | 6940 return isolate->heap()->NumberFromDouble(x + y); |
6899 } | 6941 } |
6900 | 6942 |
6901 | 6943 |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7846 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { | 7888 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { |
7847 SealHandleScope shs(isolate); | 7889 SealHandleScope shs(isolate); |
7848 ASSERT(args.length() == 1); | 7890 ASSERT(args.length() == 1); |
7849 isolate->counters()->math_tan()->Increment(); | 7891 isolate->counters()->math_tan()->Increment(); |
7850 | 7892 |
7851 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7893 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7852 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | 7894 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); |
7853 } | 7895 } |
7854 | 7896 |
7855 | 7897 |
| 7898 RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) { |
| 7899 HandleScope scope(isolate); |
| 7900 ASSERT(args.length() == 3); |
| 7901 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0); |
| 7902 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1); |
| 7903 CONVERT_SMI_ARG_CHECKED(samples, 2); |
| 7904 RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray); |
| 7905 RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray); |
| 7906 double* sin_buffer = reinterpret_cast<double*>( |
| 7907 JSArrayBuffer::cast(sin_table->buffer())->backing_store()); |
| 7908 double* cos_buffer = reinterpret_cast<double*>( |
| 7909 JSArrayBuffer::cast(cos_table->buffer())->backing_store()); |
| 7910 |
| 7911 static const double pi_half = 3.1415926535897932 / 2; |
| 7912 double interval = pi_half / samples; |
| 7913 for (int i = 0; i < samples + 1; i++) { |
| 7914 double sample = sin(i * interval); |
| 7915 sin_buffer[i] = sample; |
| 7916 cos_buffer[samples - i] = sample * interval; |
| 7917 } |
| 7918 |
| 7919 // Fill this to catch out of bound accesses when calculating Math.sin(pi/2). |
| 7920 sin_buffer[samples + 1] = sin(pi_half + interval); |
| 7921 cos_buffer[samples + 1] = cos(pi_half + interval) * interval; |
| 7922 |
| 7923 return isolate->heap()->undefined_value(); |
| 7924 } |
| 7925 |
| 7926 |
| 7927 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDAbs) { |
| 7928 SealHandleScope shs(isolate); |
| 7929 ASSERT(args.length() == 1); |
| 7930 |
| 7931 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 7932 |
| 7933 float32x4_value_t result; |
| 7934 result.storage[0] = fabsf(a->x()); |
| 7935 result.storage[1] = fabsf(a->y()); |
| 7936 result.storage[2] = fabsf(a->z()); |
| 7937 result.storage[3] = fabsf(a->w()); |
| 7938 |
| 7939 Float32x4* float32x4; |
| 7940 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 7941 if (!maybe->To(&float32x4)) return maybe; |
| 7942 return float32x4; |
| 7943 } |
| 7944 |
| 7945 |
| 7946 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDNeg) { |
| 7947 SealHandleScope shs(isolate); |
| 7948 ASSERT(args.length() == 1); |
| 7949 |
| 7950 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 7951 |
| 7952 float32x4_value_t result; |
| 7953 result.storage[0] = -a->x(); |
| 7954 result.storage[1] = -a->y(); |
| 7955 result.storage[2] = -a->z(); |
| 7956 result.storage[3] = -a->w(); |
| 7957 |
| 7958 Float32x4* float32x4; |
| 7959 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 7960 if (!maybe->To(&float32x4)) return maybe; |
| 7961 return float32x4; |
| 7962 } |
| 7963 |
| 7964 |
| 7965 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDAdd) { |
| 7966 SealHandleScope shs(isolate); |
| 7967 ASSERT(args.length() == 2); |
| 7968 |
| 7969 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 7970 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 7971 |
| 7972 float32x4_value_t result; |
| 7973 result.storage[0] = a->x() + b->x(); |
| 7974 result.storage[1] = a->y() + b->y(); |
| 7975 result.storage[2] = a->z() + b->z(); |
| 7976 result.storage[3] = a->w() + b->w(); |
| 7977 |
| 7978 Float32x4* float32x4; |
| 7979 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 7980 if (!maybe->To(&float32x4)) return maybe; |
| 7981 return float32x4; |
| 7982 } |
| 7983 |
| 7984 |
| 7985 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDSub) { |
| 7986 SealHandleScope shs(isolate); |
| 7987 ASSERT(args.length() == 2); |
| 7988 |
| 7989 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 7990 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 7991 |
| 7992 float32x4_value_t result; |
| 7993 result.storage[0] = a->x() - b->x(); |
| 7994 result.storage[1] = a->y() - b->y(); |
| 7995 result.storage[2] = a->z() - b->z(); |
| 7996 result.storage[3] = a->w() - b->w(); |
| 7997 |
| 7998 Float32x4* float32x4; |
| 7999 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8000 if (!maybe->To(&float32x4)) return maybe; |
| 8001 return float32x4; |
| 8002 } |
| 8003 |
| 8004 |
| 8005 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDMul) { |
| 8006 SealHandleScope shs(isolate); |
| 8007 ASSERT(args.length() == 2); |
| 8008 |
| 8009 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8010 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8011 |
| 8012 float32x4_value_t result; |
| 8013 result.storage[0] = a->x() * b->x(); |
| 8014 result.storage[1] = a->y() * b->y(); |
| 8015 result.storage[2] = a->z() * b->z(); |
| 8016 result.storage[3] = a->w() * b->w(); |
| 8017 |
| 8018 Float32x4* float32x4; |
| 8019 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8020 if (!maybe->To(&float32x4)) return maybe; |
| 8021 return float32x4; |
| 8022 } |
| 8023 |
| 8024 |
| 8025 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDDiv) { |
| 8026 SealHandleScope shs(isolate); |
| 8027 ASSERT(args.length() == 2); |
| 8028 |
| 8029 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8030 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8031 |
| 8032 float32x4_value_t result; |
| 8033 result.storage[0] = a->x() / b->x(); |
| 8034 result.storage[1] = a->y() / b->y(); |
| 8035 result.storage[2] = a->z() / b->z(); |
| 8036 result.storage[3] = a->w() / b->w(); |
| 8037 |
| 8038 Float32x4* float32x4; |
| 8039 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8040 if (!maybe->To(&float32x4)) return maybe; |
| 8041 return float32x4; |
| 8042 } |
| 8043 |
| 8044 |
| 8045 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDClamp) { |
| 8046 SealHandleScope shs(isolate); |
| 8047 ASSERT(args.length() == 3); |
| 8048 |
| 8049 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8050 CONVERT_ARG_CHECKED(Float32x4, lo, 1); |
| 8051 CONVERT_ARG_CHECKED(Float32x4, hi, 2); |
| 8052 |
| 8053 float32x4_value_t result; |
| 8054 float _x = self->x() > lo->x() ? self->x() : lo->x(); |
| 8055 float _y = self->y() > lo->y() ? self->y() : lo->y(); |
| 8056 float _z = self->z() > lo->z() ? self->z() : lo->z(); |
| 8057 float _w = self->w() > lo->w() ? self->w() : lo->w(); |
| 8058 result.storage[0] = _x > hi->x() ? hi->x() : _x; |
| 8059 result.storage[1] = _y > hi->y() ? hi->y() : _y; |
| 8060 result.storage[2] = _z > hi->z() ? hi->z() : _z; |
| 8061 result.storage[3] = _w > hi->w() ? hi->w() : _w; |
| 8062 Float32x4* float32x4; |
| 8063 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8064 if (!maybe->To(&float32x4)) return maybe; |
| 8065 return float32x4; |
| 8066 } |
| 8067 |
| 8068 |
| 8069 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDMin) { |
| 8070 SealHandleScope shs(isolate); |
| 8071 ASSERT(args.length() == 2); |
| 8072 |
| 8073 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8074 CONVERT_ARG_CHECKED(Float32x4, other, 1); |
| 8075 |
| 8076 float32x4_value_t result; |
| 8077 result.storage[0] = self->x() < other->x() ? self->x() : other->x(); |
| 8078 result.storage[1] = self->y() < other->y() ? self->y() : other->y(); |
| 8079 result.storage[2] = self->z() < other->z() ? self->z() : other->z(); |
| 8080 result.storage[3] = self->w() < other->w() ? self->w() : other->w(); |
| 8081 |
| 8082 Float32x4* float32x4; |
| 8083 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8084 if (!maybe->To(&float32x4)) return maybe; |
| 8085 return float32x4; |
| 8086 } |
| 8087 |
| 8088 |
| 8089 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDMax) { |
| 8090 SealHandleScope shs(isolate); |
| 8091 ASSERT(args.length() == 2); |
| 8092 |
| 8093 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8094 CONVERT_ARG_CHECKED(Float32x4, other, 1); |
| 8095 |
| 8096 float32x4_value_t result; |
| 8097 result.storage[0] = self->x() > other->x() ? self->x() : other->x(); |
| 8098 result.storage[1] = self->y() > other->y() ? self->y() : other->y(); |
| 8099 result.storage[2] = self->z() > other->z() ? self->z() : other->z(); |
| 8100 result.storage[3] = self->w() > other->w() ? self->w() : other->w(); |
| 8101 |
| 8102 Float32x4* float32x4; |
| 8103 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8104 if (!maybe->To(&float32x4)) return maybe; |
| 8105 return float32x4; |
| 8106 } |
| 8107 |
| 8108 |
| 8109 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDReciprocal) { |
| 8110 SealHandleScope shs(isolate); |
| 8111 ASSERT(args.length() == 1); |
| 8112 |
| 8113 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8114 |
| 8115 float32x4_value_t result; |
| 8116 result.storage[0] = 1.0f / self->x(); |
| 8117 result.storage[1] = 1.0f / self->y(); |
| 8118 result.storage[2] = 1.0f / self->z(); |
| 8119 result.storage[3] = 1.0f / self->w(); |
| 8120 |
| 8121 Float32x4* float32x4; |
| 8122 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8123 if (!maybe->To(&float32x4)) return maybe; |
| 8124 return float32x4; |
| 8125 } |
| 8126 |
| 8127 |
| 8128 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDReciprocalSqrt) { |
| 8129 SealHandleScope shs(isolate); |
| 8130 ASSERT(args.length() == 1); |
| 8131 |
| 8132 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8133 |
| 8134 float32x4_value_t result; |
| 8135 result.storage[0] = sqrtf(1.0f / self->x()); |
| 8136 result.storage[1] = sqrtf(1.0f / self->y()); |
| 8137 result.storage[2] = sqrtf(1.0f / self->z()); |
| 8138 result.storage[3] = sqrtf(1.0f / self->w()); |
| 8139 |
| 8140 Float32x4* float32x4; |
| 8141 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8142 if (!maybe->To(&float32x4)) return maybe; |
| 8143 return float32x4; |
| 8144 } |
| 8145 |
| 8146 |
| 8147 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDScale) { |
| 8148 SealHandleScope shs(isolate); |
| 8149 ASSERT(args.length() == 2); |
| 8150 |
| 8151 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8152 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8153 |
| 8154 float _s = static_cast<float>(args.number_at(1)); |
| 8155 float32x4_value_t result; |
| 8156 result.storage[0] = self->x() * _s; |
| 8157 result.storage[1] = self->y() * _s; |
| 8158 result.storage[2] = self->z() * _s; |
| 8159 result.storage[3] = self->w() * _s; |
| 8160 |
| 8161 Float32x4* float32x4; |
| 8162 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8163 if (!maybe->To(&float32x4)) return maybe; |
| 8164 return float32x4; |
| 8165 } |
| 8166 |
| 8167 |
| 8168 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDSqrt) { |
| 8169 SealHandleScope shs(isolate); |
| 8170 ASSERT(args.length() == 1); |
| 8171 |
| 8172 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8173 |
| 8174 float32x4_value_t result; |
| 8175 result.storage[0] = sqrtf(self->x()); |
| 8176 result.storage[1] = sqrtf(self->y()); |
| 8177 result.storage[2] = sqrtf(self->z()); |
| 8178 result.storage[3] = sqrtf(self->w()); |
| 8179 |
| 8180 Float32x4* float32x4; |
| 8181 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8182 if (!maybe->To(&float32x4)) return maybe; |
| 8183 return float32x4; |
| 8184 } |
| 8185 |
| 8186 |
| 8187 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDShuffle) { |
| 8188 SealHandleScope shs(isolate); |
| 8189 ASSERT(args.length() == 2); |
| 8190 |
| 8191 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8192 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8193 |
| 8194 uint32_t m = NumberToUint32(args[1]); |
| 8195 float32x4_value_t result; |
| 8196 float data[4] = { self->x(), self->y(), self->z(), self->w() }; |
| 8197 result.storage[0] = data[m & 0x3]; |
| 8198 result.storage[1] = data[(m >> 2) & 0x3]; |
| 8199 result.storage[2] = data[(m >> 4) & 0x3]; |
| 8200 result.storage[3] = data[(m >> 6) & 0x3]; |
| 8201 |
| 8202 Float32x4* float32x4; |
| 8203 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8204 if (!maybe->To(&float32x4)) return maybe; |
| 8205 return float32x4; |
| 8206 } |
| 8207 |
| 8208 |
| 8209 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDShuffleu32) { |
| 8210 SealHandleScope shs(isolate); |
| 8211 ASSERT(args.length() == 2); |
| 8212 |
| 8213 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8214 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8215 |
| 8216 uint32_t m = NumberToUint32(args[1]); |
| 8217 int32x4_value_t result; |
| 8218 int32_t data[4] = { self->x(), self->y(), self->z(), self->w() }; |
| 8219 result.storage[0] = data[m & 0x3]; |
| 8220 result.storage[1] = data[(m >> 2) & 0x3]; |
| 8221 result.storage[2] = data[(m >> 4) & 0x3]; |
| 8222 result.storage[3] = data[(m >> 6) & 0x3]; |
| 8223 |
| 8224 Int32x4* int32x4; |
| 8225 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8226 if (!maybe->To(&int32x4)) return maybe; |
| 8227 return int32x4; |
| 8228 } |
| 8229 |
| 8230 |
| 8231 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDShuffleMix) { |
| 8232 SealHandleScope shs(isolate); |
| 8233 ASSERT(args.length() == 3); |
| 8234 |
| 8235 CONVERT_ARG_CHECKED(Float32x4, first, 0); |
| 8236 CONVERT_ARG_CHECKED(Float32x4, second, 1); |
| 8237 RUNTIME_ASSERT(args[2]->IsNumber()); |
| 8238 |
| 8239 uint32_t m = NumberToUint32(args[2]); |
| 8240 float32x4_value_t result; |
| 8241 float data1[4] = { first->x(), first->y(), first->z(), first->w() }; |
| 8242 float data2[4] = { second->x(), second->y(), second->z(), second->w() }; |
| 8243 result.storage[0] = data1[m & 0x3]; |
| 8244 result.storage[1] = data1[(m >> 2) & 0x3]; |
| 8245 result.storage[2] = data2[(m >> 4) & 0x3]; |
| 8246 result.storage[3] = data2[(m >> 6) & 0x3]; |
| 8247 |
| 8248 Float32x4* float32x4; |
| 8249 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8250 if (!maybe->To(&float32x4)) return maybe; |
| 8251 return float32x4; |
| 8252 } |
| 8253 |
| 8254 |
| 8255 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithX) { |
| 8256 SealHandleScope shs(isolate); |
| 8257 ASSERT(args.length() == 2); |
| 8258 |
| 8259 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8260 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8261 |
| 8262 float32x4_value_t result; |
| 8263 result.storage[0] = static_cast<float>(args.number_at(1)); |
| 8264 result.storage[1] = self->y(); |
| 8265 result.storage[2] = self->z(); |
| 8266 result.storage[3] = self->w(); |
| 8267 |
| 8268 Float32x4* float32x4; |
| 8269 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8270 if (!maybe->To(&float32x4)) return maybe; |
| 8271 return float32x4; |
| 8272 } |
| 8273 |
| 8274 |
| 8275 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithY) { |
| 8276 SealHandleScope shs(isolate); |
| 8277 ASSERT(args.length() == 2); |
| 8278 |
| 8279 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8280 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8281 |
| 8282 float32x4_value_t result; |
| 8283 result.storage[0] = self->x(); |
| 8284 result.storage[1] = static_cast<float>(args.number_at(1)); |
| 8285 result.storage[2] = self->z(); |
| 8286 result.storage[3] = self->w(); |
| 8287 |
| 8288 Float32x4* float32x4; |
| 8289 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8290 if (!maybe->To(&float32x4)) return maybe; |
| 8291 return float32x4; |
| 8292 } |
| 8293 |
| 8294 |
| 8295 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithZ) { |
| 8296 SealHandleScope shs(isolate); |
| 8297 ASSERT(args.length() == 2); |
| 8298 |
| 8299 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8300 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8301 |
| 8302 float32x4_value_t result; |
| 8303 result.storage[0] = self->x(); |
| 8304 result.storage[1] = self->y(); |
| 8305 result.storage[2] = static_cast<float>(args.number_at(1)); |
| 8306 result.storage[3] = self->w(); |
| 8307 |
| 8308 Float32x4* float32x4; |
| 8309 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8310 if (!maybe->To(&float32x4)) return maybe; |
| 8311 return float32x4; |
| 8312 } |
| 8313 |
| 8314 |
| 8315 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithW) { |
| 8316 SealHandleScope shs(isolate); |
| 8317 ASSERT(args.length() == 2); |
| 8318 |
| 8319 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8320 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8321 |
| 8322 float32x4_value_t result; |
| 8323 result.storage[0] = self->x(); |
| 8324 result.storage[1] = self->y(); |
| 8325 result.storage[2] = self->z(); |
| 8326 result.storage[3] = static_cast<float>(args.number_at(1)); |
| 8327 |
| 8328 Float32x4* float32x4; |
| 8329 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8330 if (!maybe->To(&float32x4)) return maybe; |
| 8331 return float32x4; |
| 8332 } |
| 8333 |
| 8334 |
| 8335 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDToFloat32x4) { |
| 8336 SealHandleScope shs(isolate); |
| 8337 ASSERT(args.length() == 1); |
| 8338 |
| 8339 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8340 |
| 8341 float32x4_value_t result; |
| 8342 result.storage[0] = static_cast<float>(self->x()); |
| 8343 result.storage[1] = static_cast<float>(self->y()); |
| 8344 result.storage[2] = static_cast<float>(self->z()); |
| 8345 result.storage[3] = static_cast<float>(self->w()); |
| 8346 |
| 8347 Float32x4* float32x4; |
| 8348 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8349 if (!maybe->To(&float32x4)) return maybe; |
| 8350 return float32x4; |
| 8351 } |
| 8352 |
| 8353 |
| 8354 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDBitsToFloat32x4) { |
| 8355 SealHandleScope shs(isolate); |
| 8356 ASSERT(args.length() == 1); |
| 8357 |
| 8358 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8359 |
| 8360 float32x4_value_t result; |
| 8361 int32x4_value_t source = self->value(); |
| 8362 memcpy(&result.storage[0], &source.storage[0], kFloatSize); |
| 8363 memcpy(&result.storage[1], &source.storage[1], kFloatSize); |
| 8364 memcpy(&result.storage[2], &source.storage[2], kFloatSize); |
| 8365 memcpy(&result.storage[3], &source.storage[3], kFloatSize); |
| 8366 |
| 8367 Float32x4* float32x4; |
| 8368 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8369 if (!maybe->To(&float32x4)) return maybe; |
| 8370 return float32x4; |
| 8371 } |
| 8372 |
| 8373 |
| 8374 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDToInt32x4) { |
| 8375 SealHandleScope shs(isolate); |
| 8376 ASSERT(args.length() == 1); |
| 8377 |
| 8378 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8379 |
| 8380 int32x4_value_t result; |
| 8381 result.storage[0] = DoubleToInt32(static_cast<double>(self->x())); |
| 8382 result.storage[1] = DoubleToInt32(static_cast<double>(self->y())); |
| 8383 result.storage[2] = DoubleToInt32(static_cast<double>(self->z())); |
| 8384 result.storage[3] = DoubleToInt32(static_cast<double>(self->w())); |
| 8385 |
| 8386 Int32x4* int32x4; |
| 8387 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8388 if (!maybe->To(&int32x4)) return maybe; |
| 8389 return int32x4; |
| 8390 } |
| 8391 |
| 8392 |
| 8393 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDBitsToInt32x4) { |
| 8394 SealHandleScope shs(isolate); |
| 8395 ASSERT(args.length() == 1); |
| 8396 |
| 8397 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 8398 |
| 8399 int32x4_value_t result; |
| 8400 float32x4_value_t source = self->value(); |
| 8401 memcpy(&result.storage[0], &source.storage[0], kInt32Size); |
| 8402 memcpy(&result.storage[1], &source.storage[1], kInt32Size); |
| 8403 memcpy(&result.storage[2], &source.storage[2], kInt32Size); |
| 8404 memcpy(&result.storage[3], &source.storage[3], kInt32Size); |
| 8405 |
| 8406 Int32x4* int32x4; |
| 8407 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8408 if (!maybe->To(&int32x4)) return maybe; |
| 8409 return int32x4; |
| 8410 } |
| 8411 |
| 8412 |
| 8413 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDLessThan) { |
| 8414 SealHandleScope shs(isolate); |
| 8415 ASSERT(args.length() == 2); |
| 8416 |
| 8417 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8418 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8419 |
| 8420 int32x4_value_t result; |
| 8421 result.storage[0] = a->x() < b->x() ? 0xFFFFFFFF : 0x0; |
| 8422 result.storage[1] = a->y() < b->y() ? 0xFFFFFFFF : 0x0; |
| 8423 result.storage[2] = a->z() < b->z() ? 0xFFFFFFFF : 0x0; |
| 8424 result.storage[3] = a->w() < b->w() ? 0xFFFFFFFF : 0x0; |
| 8425 |
| 8426 Int32x4* int32x4; |
| 8427 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8428 if (!maybe->To(&int32x4)) return maybe; |
| 8429 return int32x4; |
| 8430 } |
| 8431 |
| 8432 |
| 8433 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDLessThanOrEqual) { |
| 8434 SealHandleScope shs(isolate); |
| 8435 ASSERT(args.length() == 2); |
| 8436 |
| 8437 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8438 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8439 |
| 8440 int32x4_value_t result; |
| 8441 result.storage[0] = a->x() <= b->x() ? 0xFFFFFFFF : 0x0; |
| 8442 result.storage[1] = a->y() <= b->y() ? 0xFFFFFFFF : 0x0; |
| 8443 result.storage[2] = a->z() <= b->z() ? 0xFFFFFFFF : 0x0; |
| 8444 result.storage[3] = a->w() <= b->w() ? 0xFFFFFFFF : 0x0; |
| 8445 |
| 8446 Int32x4* int32x4; |
| 8447 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8448 if (!maybe->To(&int32x4)) return maybe; |
| 8449 return int32x4; |
| 8450 } |
| 8451 |
| 8452 |
| 8453 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDEqual) { |
| 8454 SealHandleScope shs(isolate); |
| 8455 ASSERT(args.length() == 2); |
| 8456 |
| 8457 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8458 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8459 |
| 8460 int32x4_value_t result; |
| 8461 result.storage[0] = a->x() == b->x() ? 0xFFFFFFFF : 0x0; |
| 8462 result.storage[1] = a->y() == b->y() ? 0xFFFFFFFF : 0x0; |
| 8463 result.storage[2] = a->z() == b->z() ? 0xFFFFFFFF : 0x0; |
| 8464 result.storage[3] = a->w() == b->w() ? 0xFFFFFFFF : 0x0; |
| 8465 |
| 8466 Int32x4* int32x4; |
| 8467 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8468 if (!maybe->To(&int32x4)) return maybe; |
| 8469 return int32x4; |
| 8470 } |
| 8471 |
| 8472 |
| 8473 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDNotEqual) { |
| 8474 SealHandleScope shs(isolate); |
| 8475 ASSERT(args.length() == 2); |
| 8476 |
| 8477 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8478 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8479 |
| 8480 int32x4_value_t result; |
| 8481 result.storage[0] = a->x() != b->x() ? 0xFFFFFFFF : 0x0; |
| 8482 result.storage[1] = a->y() != b->y() ? 0xFFFFFFFF : 0x0; |
| 8483 result.storage[2] = a->z() != b->z() ? 0xFFFFFFFF : 0x0; |
| 8484 result.storage[3] = a->w() != b->w() ? 0xFFFFFFFF : 0x0; |
| 8485 |
| 8486 Int32x4* int32x4; |
| 8487 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8488 if (!maybe->To(&int32x4)) return maybe; |
| 8489 return int32x4; |
| 8490 } |
| 8491 |
| 8492 |
| 8493 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDGreaterThan) { |
| 8494 SealHandleScope shs(isolate); |
| 8495 ASSERT(args.length() == 2); |
| 8496 |
| 8497 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8498 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8499 |
| 8500 int32x4_value_t result; |
| 8501 result.storage[0] = a->x() > b->x() ? 0xFFFFFFFF : 0x0; |
| 8502 result.storage[1] = a->y() > b->y() ? 0xFFFFFFFF : 0x0; |
| 8503 result.storage[2] = a->z() > b->z() ? 0xFFFFFFFF : 0x0; |
| 8504 result.storage[3] = a->w() > b->w() ? 0xFFFFFFFF : 0x0; |
| 8505 |
| 8506 Int32x4* int32x4; |
| 8507 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8508 if (!maybe->To(&int32x4)) return maybe; |
| 8509 return int32x4; |
| 8510 } |
| 8511 |
| 8512 |
| 8513 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDGreaterThanOrEqual) { |
| 8514 SealHandleScope shs(isolate); |
| 8515 ASSERT(args.length() == 2); |
| 8516 |
| 8517 CONVERT_ARG_CHECKED(Float32x4, a, 0); |
| 8518 CONVERT_ARG_CHECKED(Float32x4, b, 1); |
| 8519 |
| 8520 int32x4_value_t result; |
| 8521 result.storage[0] = a->x() >= b->x() ? 0xFFFFFFFF : 0x0; |
| 8522 result.storage[1] = a->y() >= b->y() ? 0xFFFFFFFF : 0x0; |
| 8523 result.storage[2] = a->z() >= b->z() ? 0xFFFFFFFF : 0x0; |
| 8524 result.storage[3] = a->w() >= b->w() ? 0xFFFFFFFF : 0x0; |
| 8525 |
| 8526 Int32x4* int32x4; |
| 8527 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8528 if (!maybe->To(&int32x4)) return maybe; |
| 8529 return int32x4; |
| 8530 } |
| 8531 |
| 8532 |
| 8533 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDAnd) { |
| 8534 SealHandleScope shs(isolate); |
| 8535 ASSERT(args.length() == 2); |
| 8536 |
| 8537 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8538 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8539 |
| 8540 int32x4_value_t result; |
| 8541 result.storage[0] = a->x() & b->x(); |
| 8542 result.storage[1] = a->y() & b->y(); |
| 8543 result.storage[2] = a->z() & b->z(); |
| 8544 result.storage[3] = a->w() & b->w(); |
| 8545 |
| 8546 Int32x4* int32x4; |
| 8547 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8548 if (!maybe->To(&int32x4)) return maybe; |
| 8549 return int32x4; |
| 8550 } |
| 8551 |
| 8552 |
| 8553 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDOr) { |
| 8554 SealHandleScope shs(isolate); |
| 8555 ASSERT(args.length() == 2); |
| 8556 |
| 8557 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8558 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8559 |
| 8560 int32x4_value_t result; |
| 8561 result.storage[0] = a->x() | b->x(); |
| 8562 result.storage[1] = a->y() | b->y(); |
| 8563 result.storage[2] = a->z() | b->z(); |
| 8564 result.storage[3] = a->w() | b->w(); |
| 8565 |
| 8566 Int32x4* int32x4; |
| 8567 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8568 if (!maybe->To(&int32x4)) return maybe; |
| 8569 return int32x4; |
| 8570 } |
| 8571 |
| 8572 |
| 8573 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDXor) { |
| 8574 SealHandleScope shs(isolate); |
| 8575 ASSERT(args.length() == 2); |
| 8576 |
| 8577 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8578 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8579 |
| 8580 int32x4_value_t result; |
| 8581 result.storage[0] = a->x() ^ b->x(); |
| 8582 result.storage[1] = a->y() ^ b->y(); |
| 8583 result.storage[2] = a->z() ^ b->z(); |
| 8584 result.storage[3] = a->w() ^ b->w(); |
| 8585 |
| 8586 Int32x4* int32x4; |
| 8587 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8588 if (!maybe->To(&int32x4)) return maybe; |
| 8589 return int32x4; |
| 8590 } |
| 8591 |
| 8592 |
| 8593 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDNot) { |
| 8594 SealHandleScope shs(isolate); |
| 8595 ASSERT(args.length() == 1); |
| 8596 |
| 8597 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8598 |
| 8599 int32x4_value_t result; |
| 8600 result.storage[0] = ~self->x(); |
| 8601 result.storage[1] = ~self->y(); |
| 8602 result.storage[2] = ~self->z(); |
| 8603 result.storage[3] = ~self->w(); |
| 8604 |
| 8605 Int32x4* int32x4; |
| 8606 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8607 if (!maybe->To(&int32x4)) return maybe; |
| 8608 return int32x4; |
| 8609 } |
| 8610 |
| 8611 |
| 8612 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDNegu32) { |
| 8613 SealHandleScope shs(isolate); |
| 8614 ASSERT(args.length() == 1); |
| 8615 |
| 8616 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8617 |
| 8618 int32x4_value_t result; |
| 8619 result.storage[0] = -self->x(); |
| 8620 result.storage[1] = -self->y(); |
| 8621 result.storage[2] = -self->z(); |
| 8622 result.storage[3] = -self->w(); |
| 8623 |
| 8624 Int32x4* int32x4; |
| 8625 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8626 if (!maybe->To(&int32x4)) return maybe; |
| 8627 return int32x4; |
| 8628 } |
| 8629 |
| 8630 |
| 8631 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDAddu32) { |
| 8632 SealHandleScope shs(isolate); |
| 8633 ASSERT(args.length() == 2); |
| 8634 |
| 8635 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8636 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8637 |
| 8638 int32x4_value_t result; |
| 8639 result.storage[0] = a->x() + b->x(); |
| 8640 result.storage[1] = a->y() + b->y(); |
| 8641 result.storage[2] = a->z() + b->z(); |
| 8642 result.storage[3] = a->w() + b->w(); |
| 8643 |
| 8644 Int32x4* int32x4; |
| 8645 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8646 if (!maybe->To(&int32x4)) return maybe; |
| 8647 return int32x4; |
| 8648 } |
| 8649 |
| 8650 |
| 8651 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDSubu32) { |
| 8652 SealHandleScope shs(isolate); |
| 8653 ASSERT(args.length() == 2); |
| 8654 |
| 8655 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8656 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8657 |
| 8658 int32x4_value_t result; |
| 8659 result.storage[0] = a->x() - b->x(); |
| 8660 result.storage[1] = a->y() - b->y(); |
| 8661 result.storage[2] = a->z() - b->z(); |
| 8662 result.storage[3] = a->w() - b->w(); |
| 8663 |
| 8664 Int32x4* int32x4; |
| 8665 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8666 if (!maybe->To(&int32x4)) return maybe; |
| 8667 return int32x4; |
| 8668 } |
| 8669 |
| 8670 |
| 8671 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDMulu32) { |
| 8672 SealHandleScope shs(isolate); |
| 8673 ASSERT(args.length() == 2); |
| 8674 |
| 8675 CONVERT_ARG_CHECKED(Int32x4, a, 0); |
| 8676 CONVERT_ARG_CHECKED(Int32x4, b, 1); |
| 8677 |
| 8678 int32x4_value_t result; |
| 8679 result.storage[0] = a->x() * b->x(); |
| 8680 result.storage[1] = a->y() * b->y(); |
| 8681 result.storage[2] = a->z() * b->z(); |
| 8682 result.storage[3] = a->w() * b->w(); |
| 8683 |
| 8684 Int32x4* int32x4; |
| 8685 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8686 if (!maybe->To(&int32x4)) return maybe; |
| 8687 return int32x4; |
| 8688 } |
| 8689 |
| 8690 |
| 8691 // Used to convert between uint32_t and float32 without breaking strict |
| 8692 // aliasing rules. |
| 8693 union float32_uint32 { |
| 8694 float f; |
| 8695 uint32_t u; |
| 8696 float32_uint32(float v) { |
| 8697 f = v; |
| 8698 } |
| 8699 float32_uint32(uint32_t v) { |
| 8700 u = v; |
| 8701 } |
| 8702 }; |
| 8703 |
| 8704 |
| 8705 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDSelect) { |
| 8706 SealHandleScope shs(isolate); |
| 8707 ASSERT(args.length() == 3); |
| 8708 |
| 8709 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8710 CONVERT_ARG_CHECKED(Float32x4, tv, 1); |
| 8711 CONVERT_ARG_CHECKED(Float32x4, fv, 2); |
| 8712 |
| 8713 uint32_t _maskX = self->x(); |
| 8714 uint32_t _maskY = self->y(); |
| 8715 uint32_t _maskZ = self->z(); |
| 8716 uint32_t _maskW = self->w(); |
| 8717 // Extract floats and interpret them as masks. |
| 8718 float32_uint32 tvx(tv->x()); |
| 8719 float32_uint32 tvy(tv->y()); |
| 8720 float32_uint32 tvz(tv->z()); |
| 8721 float32_uint32 tvw(tv->w()); |
| 8722 float32_uint32 fvx(fv->x()); |
| 8723 float32_uint32 fvy(fv->y()); |
| 8724 float32_uint32 fvz(fv->z()); |
| 8725 float32_uint32 fvw(fv->w()); |
| 8726 // Perform select. |
| 8727 float32_uint32 tempX((_maskX & tvx.u) | (~_maskX & fvx.u)); |
| 8728 float32_uint32 tempY((_maskY & tvy.u) | (~_maskY & fvy.u)); |
| 8729 float32_uint32 tempZ((_maskZ & tvz.u) | (~_maskZ & fvz.u)); |
| 8730 float32_uint32 tempW((_maskW & tvw.u) | (~_maskW & fvw.u)); |
| 8731 |
| 8732 float32x4_value_t result; |
| 8733 result.storage[0] = tempX.f; |
| 8734 result.storage[1] = tempY.f; |
| 8735 result.storage[2] = tempZ.f; |
| 8736 result.storage[3] = tempW.f; |
| 8737 |
| 8738 Float32x4* float32x4; |
| 8739 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(result); |
| 8740 if (!maybe->To(&float32x4)) return maybe; |
| 8741 return float32x4; |
| 8742 } |
| 8743 |
| 8744 |
| 8745 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithXu32) { |
| 8746 SealHandleScope shs(isolate); |
| 8747 ASSERT(args.length() == 2); |
| 8748 |
| 8749 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8750 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8751 |
| 8752 int32x4_value_t result; |
| 8753 result.storage[0] = NumberToUint32(args[1]); |
| 8754 result.storage[1] = self->y(); |
| 8755 result.storage[2] = self->z(); |
| 8756 result.storage[3] = self->w(); |
| 8757 |
| 8758 Int32x4* int32x4; |
| 8759 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8760 if (!maybe->To(&int32x4)) return maybe; |
| 8761 return int32x4; |
| 8762 } |
| 8763 |
| 8764 |
| 8765 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithYu32) { |
| 8766 SealHandleScope shs(isolate); |
| 8767 ASSERT(args.length() == 2); |
| 8768 |
| 8769 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8770 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8771 |
| 8772 int32x4_value_t result; |
| 8773 result.storage[0] = self->x(); |
| 8774 result.storage[1] = NumberToUint32(args[1]); |
| 8775 result.storage[2] = self->z(); |
| 8776 result.storage[3] = self->w(); |
| 8777 |
| 8778 Int32x4* int32x4; |
| 8779 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8780 if (!maybe->To(&int32x4)) return maybe; |
| 8781 return int32x4; |
| 8782 } |
| 8783 |
| 8784 |
| 8785 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithZu32) { |
| 8786 SealHandleScope shs(isolate); |
| 8787 ASSERT(args.length() == 2); |
| 8788 |
| 8789 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8790 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8791 |
| 8792 int32x4_value_t result; |
| 8793 result.storage[0] = self->x(); |
| 8794 result.storage[1] = self->y(); |
| 8795 result.storage[2] = NumberToUint32(args[1]); |
| 8796 result.storage[3] = self->w(); |
| 8797 |
| 8798 Int32x4* int32x4; |
| 8799 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8800 if (!maybe->To(&int32x4)) return maybe; |
| 8801 return int32x4; |
| 8802 } |
| 8803 |
| 8804 |
| 8805 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithWu32) { |
| 8806 SealHandleScope shs(isolate); |
| 8807 ASSERT(args.length() == 2); |
| 8808 |
| 8809 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8810 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8811 |
| 8812 int32x4_value_t result; |
| 8813 result.storage[0] = self->x(); |
| 8814 result.storage[1] = self->y(); |
| 8815 result.storage[2] = self->z(); |
| 8816 result.storage[3] = NumberToUint32(args[1]); |
| 8817 |
| 8818 Int32x4* int32x4; |
| 8819 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8820 if (!maybe->To(&int32x4)) return maybe; |
| 8821 return int32x4; |
| 8822 } |
| 8823 |
| 8824 |
| 8825 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithFlagX) { |
| 8826 SealHandleScope shs(isolate); |
| 8827 ASSERT(args.length() == 2); |
| 8828 |
| 8829 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8830 CONVERT_BOOLEAN_ARG_CHECKED(flagX, 1); |
| 8831 |
| 8832 int32x4_value_t result; |
| 8833 result.storage[0] = flagX ? 0xFFFFFFFF : 0x0; |
| 8834 result.storage[1] = self->y(); |
| 8835 result.storage[2] = self->z(); |
| 8836 result.storage[3] = self->w(); |
| 8837 |
| 8838 Int32x4* int32x4; |
| 8839 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8840 if (!maybe->To(&int32x4)) return maybe; |
| 8841 return int32x4; |
| 8842 } |
| 8843 |
| 8844 |
| 8845 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithFlagY) { |
| 8846 SealHandleScope shs(isolate); |
| 8847 ASSERT(args.length() == 2); |
| 8848 |
| 8849 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8850 CONVERT_BOOLEAN_ARG_CHECKED(flagY, 1); |
| 8851 |
| 8852 int32x4_value_t result; |
| 8853 result.storage[0] = self->x(); |
| 8854 result.storage[1] = flagY ? 0xFFFFFFFF : 0x0; |
| 8855 result.storage[2] = self->z(); |
| 8856 result.storage[3] = self->w(); |
| 8857 |
| 8858 Int32x4* int32x4; |
| 8859 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8860 if (!maybe->To(&int32x4)) return maybe; |
| 8861 return int32x4; |
| 8862 } |
| 8863 |
| 8864 |
| 8865 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithFlagZ) { |
| 8866 SealHandleScope shs(isolate); |
| 8867 ASSERT(args.length() == 2); |
| 8868 |
| 8869 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8870 CONVERT_BOOLEAN_ARG_CHECKED(flagZ, 1); |
| 8871 |
| 8872 int32x4_value_t result; |
| 8873 result.storage[0] = self->x(); |
| 8874 result.storage[1] = self->y(); |
| 8875 result.storage[2] = flagZ ? 0xFFFFFFFF : 0x0; |
| 8876 result.storage[3] = self->w(); |
| 8877 |
| 8878 Int32x4* int32x4; |
| 8879 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8880 if (!maybe->To(&int32x4)) return maybe; |
| 8881 return int32x4; |
| 8882 } |
| 8883 |
| 8884 |
| 8885 RUNTIME_FUNCTION(MaybeObject*, Runtime_SIMDWithFlagW) { |
| 8886 SealHandleScope shs(isolate); |
| 8887 ASSERT(args.length() == 2); |
| 8888 |
| 8889 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 8890 CONVERT_BOOLEAN_ARG_CHECKED(flagW, 1); |
| 8891 |
| 8892 int32x4_value_t result; |
| 8893 result.storage[0] = self->x(); |
| 8894 result.storage[1] = self->y(); |
| 8895 result.storage[2] = self->z(); |
| 8896 result.storage[3] = flagW ? 0xFFFFFFFF : 0x0; |
| 8897 |
| 8898 Int32x4* int32x4; |
| 8899 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(result); |
| 8900 if (!maybe->To(&int32x4)) return maybe; |
| 8901 return int32x4; |
| 8902 } |
| 8903 |
| 8904 |
7856 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 8905 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
7857 SealHandleScope shs(isolate); | 8906 SealHandleScope shs(isolate); |
7858 ASSERT(args.length() == 2); | 8907 ASSERT(args.length() == 2); |
7859 | 8908 |
7860 CONVERT_SMI_ARG_CHECKED(year, 0); | 8909 CONVERT_SMI_ARG_CHECKED(year, 0); |
7861 CONVERT_SMI_ARG_CHECKED(month, 1); | 8910 CONVERT_SMI_ARG_CHECKED(month, 1); |
7862 | 8911 |
7863 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 8912 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
7864 } | 8913 } |
7865 | 8914 |
(...skipping 28 matching lines...) Expand all Loading... |
7894 MaybeObject* maybe_result = | 8943 MaybeObject* maybe_result = |
7895 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time)); | 8944 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time)); |
7896 if (!maybe_result->ToObject(&value)) return maybe_result; | 8945 if (!maybe_result->ToObject(&value)) return maybe_result; |
7897 } | 8946 } |
7898 } | 8947 } |
7899 date->SetValue(value, is_value_nan); | 8948 date->SetValue(value, is_value_nan); |
7900 return value; | 8949 return value; |
7901 } | 8950 } |
7902 | 8951 |
7903 | 8952 |
| 8953 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateFloat32x4) { |
| 8954 HandleScope scope(isolate); |
| 8955 ASSERT(args.length() == 4); |
| 8956 RUNTIME_ASSERT(args[0]->IsNumber()); |
| 8957 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 8958 RUNTIME_ASSERT(args[2]->IsNumber()); |
| 8959 RUNTIME_ASSERT(args[3]->IsNumber()); |
| 8960 |
| 8961 float32x4_value_t value; |
| 8962 value.storage[0] = static_cast<float>(args.number_at(0)); |
| 8963 value.storage[1] = static_cast<float>(args.number_at(1)); |
| 8964 value.storage[2] = static_cast<float>(args.number_at(2)); |
| 8965 value.storage[3] = static_cast<float>(args.number_at(3)); |
| 8966 |
| 8967 Float32x4* float32x4; |
| 8968 MaybeObject* maybe = isolate->heap()->AllocateFloat32x4(value); |
| 8969 if (!maybe->To(&float32x4)) return maybe; |
| 8970 return float32x4; |
| 8971 } |
| 8972 |
| 8973 |
| 8974 RUNTIME_FUNCTION(MaybeObject*, Runtime_Float32x4GetX) { |
| 8975 HandleScope scope(isolate); |
| 8976 ASSERT(args.length() == 1); |
| 8977 CONVERT_ARG_CHECKED(Float32x4, float32x4, 0); |
| 8978 return isolate->heap()->AllocateHeapNumber(float32x4->x()); |
| 8979 } |
| 8980 |
| 8981 |
| 8982 RUNTIME_FUNCTION(MaybeObject*, Runtime_Float32x4GetY) { |
| 8983 HandleScope scope(isolate); |
| 8984 ASSERT(args.length() == 1); |
| 8985 CONVERT_ARG_CHECKED(Float32x4, float32x4, 0); |
| 8986 return isolate->heap()->AllocateHeapNumber(float32x4->y()); |
| 8987 } |
| 8988 |
| 8989 |
| 8990 RUNTIME_FUNCTION(MaybeObject*, Runtime_Float32x4GetZ) { |
| 8991 HandleScope scope(isolate); |
| 8992 ASSERT(args.length() == 1); |
| 8993 CONVERT_ARG_CHECKED(Float32x4, float32x4, 0); |
| 8994 return isolate->heap()->AllocateHeapNumber(float32x4->z()); |
| 8995 } |
| 8996 |
| 8997 |
| 8998 RUNTIME_FUNCTION(MaybeObject*, Runtime_Float32x4GetW) { |
| 8999 HandleScope scope(isolate); |
| 9000 ASSERT(args.length() == 1); |
| 9001 CONVERT_ARG_CHECKED(Float32x4, float32x4, 0); |
| 9002 return isolate->heap()->AllocateHeapNumber(float32x4->w()); |
| 9003 } |
| 9004 |
| 9005 |
| 9006 RUNTIME_FUNCTION(MaybeObject*, Runtime_Float32x4GetSignMask) { |
| 9007 HandleScope scope(isolate); |
| 9008 ASSERT(args.length() == 1); |
| 9009 CONVERT_ARG_CHECKED(Float32x4, self, 0); |
| 9010 float32_uint32 x(self->x()); |
| 9011 float32_uint32 y(self->y()); |
| 9012 float32_uint32 z(self->z()); |
| 9013 float32_uint32 w(self->w()); |
| 9014 uint32_t mx = (x.u & 0x80000000) >> 31; |
| 9015 uint32_t my = (y.u & 0x80000000) >> 31; |
| 9016 uint32_t mz = (z.u & 0x80000000) >> 31; |
| 9017 uint32_t mw = (w.u & 0x80000000) >> 31; |
| 9018 uint32_t value = mx | (my << 1) | (mz << 2) | (mw << 3); |
| 9019 return isolate->heap()->NumberFromUint32(value); |
| 9020 } |
| 9021 |
| 9022 |
| 9023 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateInt32x4) { |
| 9024 HandleScope scope(isolate); |
| 9025 ASSERT(args.length() == 4); |
| 9026 RUNTIME_ASSERT(args[0]->IsNumber()); |
| 9027 RUNTIME_ASSERT(args[1]->IsNumber()); |
| 9028 RUNTIME_ASSERT(args[2]->IsNumber()); |
| 9029 RUNTIME_ASSERT(args[3]->IsNumber()); |
| 9030 |
| 9031 int32x4_value_t value; |
| 9032 value.storage[0] = NumberToInt32(args[0]); |
| 9033 value.storage[1] = NumberToInt32(args[1]); |
| 9034 value.storage[2] = NumberToInt32(args[2]); |
| 9035 value.storage[3] = NumberToInt32(args[3]); |
| 9036 |
| 9037 Int32x4* int32x4; |
| 9038 MaybeObject* maybe = isolate->heap()->AllocateInt32x4(value); |
| 9039 if (!maybe->To(&int32x4)) return maybe; |
| 9040 return int32x4; |
| 9041 } |
| 9042 |
| 9043 |
| 9044 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetX) { |
| 9045 HandleScope scope(isolate); |
| 9046 ASSERT(args.length() == 1); |
| 9047 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9048 return isolate->heap()->NumberFromInt32(int32x4->x()); |
| 9049 } |
| 9050 |
| 9051 |
| 9052 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetY) { |
| 9053 HandleScope scope(isolate); |
| 9054 ASSERT(args.length() == 1); |
| 9055 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9056 return isolate->heap()->NumberFromInt32(int32x4->y()); |
| 9057 } |
| 9058 |
| 9059 |
| 9060 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetZ) { |
| 9061 HandleScope scope(isolate); |
| 9062 ASSERT(args.length() == 1); |
| 9063 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9064 return isolate->heap()->NumberFromInt32(int32x4->z()); |
| 9065 } |
| 9066 |
| 9067 |
| 9068 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetW) { |
| 9069 HandleScope scope(isolate); |
| 9070 ASSERT(args.length() == 1); |
| 9071 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9072 return isolate->heap()->NumberFromInt32(int32x4->w()); |
| 9073 } |
| 9074 |
| 9075 |
| 9076 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetFlagX) { |
| 9077 HandleScope scope(isolate); |
| 9078 ASSERT(args.length() == 1); |
| 9079 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9080 return isolate->heap()->ToBoolean(int32x4->x() != 0); |
| 9081 } |
| 9082 |
| 9083 |
| 9084 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetFlagY) { |
| 9085 HandleScope scope(isolate); |
| 9086 ASSERT(args.length() == 1); |
| 9087 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9088 return isolate->heap()->ToBoolean(int32x4->y() != 0); |
| 9089 } |
| 9090 |
| 9091 |
| 9092 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetFlagZ) { |
| 9093 HandleScope scope(isolate); |
| 9094 ASSERT(args.length() == 1); |
| 9095 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9096 return isolate->heap()->ToBoolean(int32x4->z() != 0); |
| 9097 } |
| 9098 |
| 9099 |
| 9100 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetFlagW) { |
| 9101 HandleScope scope(isolate); |
| 9102 ASSERT(args.length() == 1); |
| 9103 CONVERT_ARG_CHECKED(Int32x4, int32x4, 0); |
| 9104 return isolate->heap()->ToBoolean(int32x4->w() != 0); |
| 9105 } |
| 9106 |
| 9107 |
| 9108 RUNTIME_FUNCTION(MaybeObject*, Runtime_Int32x4GetSignMask) { |
| 9109 HandleScope scope(isolate); |
| 9110 ASSERT(args.length() == 1); |
| 9111 CONVERT_ARG_CHECKED(Int32x4, self, 0); |
| 9112 uint32_t mx = (self->x() & 0x80000000) >> 31; |
| 9113 uint32_t my = (self->y() & 0x80000000) >> 31; |
| 9114 uint32_t mz = (self->z() & 0x80000000) >> 31; |
| 9115 uint32_t mw = (self->w() & 0x80000000) >> 31; |
| 9116 uint32_t value = mx | (my << 1) | (mz << 2) | (mw << 3); |
| 9117 return isolate->heap()->NumberFromUint32(value); |
| 9118 } |
| 9119 |
| 9120 |
7904 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) { | 9121 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) { |
7905 HandleScope scope(isolate); | 9122 HandleScope scope(isolate); |
7906 ASSERT(args.length() == 3); | 9123 ASSERT(args.length() == 3); |
7907 | 9124 |
7908 Handle<JSFunction> callee = args.at<JSFunction>(0); | 9125 Handle<JSFunction> callee = args.at<JSFunction>(0); |
7909 Object** parameters = reinterpret_cast<Object**>(args[1]); | 9126 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7910 const int argument_count = Smi::cast(args[2])->value(); | 9127 const int argument_count = Smi::cast(args[2])->value(); |
7911 | 9128 |
7912 Handle<JSObject> result = | 9129 Handle<JSObject> result = |
7913 isolate->factory()->NewArgumentsObject(callee, argument_count); | 9130 isolate->factory()->NewArgumentsObject(callee, argument_count); |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10020 break; | 11237 break; |
10021 } | 11238 } |
10022 case NON_STRICT_ARGUMENTS_ELEMENTS: | 11239 case NON_STRICT_ARGUMENTS_ELEMENTS: |
10023 case EXTERNAL_BYTE_ELEMENTS: | 11240 case EXTERNAL_BYTE_ELEMENTS: |
10024 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 11241 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
10025 case EXTERNAL_SHORT_ELEMENTS: | 11242 case EXTERNAL_SHORT_ELEMENTS: |
10026 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 11243 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
10027 case EXTERNAL_INT_ELEMENTS: | 11244 case EXTERNAL_INT_ELEMENTS: |
10028 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 11245 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
10029 case EXTERNAL_FLOAT_ELEMENTS: | 11246 case EXTERNAL_FLOAT_ELEMENTS: |
| 11247 case EXTERNAL_FLOAT32x4_ELEMENTS: |
| 11248 case EXTERNAL_INT32x4_ELEMENTS: |
10030 case EXTERNAL_DOUBLE_ELEMENTS: | 11249 case EXTERNAL_DOUBLE_ELEMENTS: |
10031 case EXTERNAL_PIXEL_ELEMENTS: | 11250 case EXTERNAL_PIXEL_ELEMENTS: |
10032 // External arrays are always dense. | 11251 // External arrays are always dense. |
10033 return length; | 11252 return length; |
10034 } | 11253 } |
10035 // As an estimate, we assume that the prototype doesn't contain any | 11254 // As an estimate, we assume that the prototype doesn't contain any |
10036 // inherited elements. | 11255 // inherited elements. |
10037 return element_count; | 11256 return element_count; |
10038 } | 11257 } |
10039 | 11258 |
10040 | 11259 |
10041 | |
10042 template<class ExternalArrayClass, class ElementType> | 11260 template<class ExternalArrayClass, class ElementType> |
10043 static void IterateExternalArrayElements(Isolate* isolate, | 11261 static void IterateExternalArrayElements(Isolate* isolate, |
10044 Handle<JSObject> receiver, | 11262 Handle<JSObject> receiver, |
10045 bool elements_are_ints, | 11263 bool elements_are_ints, |
10046 bool elements_are_guaranteed_smis, | 11264 bool elements_are_guaranteed_smis, |
10047 ArrayConcatVisitor* visitor) { | 11265 ArrayConcatVisitor* visitor) { |
10048 Handle<ExternalArrayClass> array( | 11266 Handle<ExternalArrayClass> array( |
10049 ExternalArrayClass::cast(receiver->elements())); | 11267 ExternalArrayClass::cast(receiver->elements())); |
10050 uint32_t len = static_cast<uint32_t>(array->length()); | 11268 uint32_t len = static_cast<uint32_t>(array->length()); |
10051 | 11269 |
(...skipping 23 matching lines...) Expand all Loading... |
10075 } else { | 11293 } else { |
10076 for (uint32_t j = 0; j < len; j++) { | 11294 for (uint32_t j = 0; j < len; j++) { |
10077 HandleScope loop_scope(isolate); | 11295 HandleScope loop_scope(isolate); |
10078 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); | 11296 Handle<Object> e = isolate->factory()->NewNumber(array->get_scalar(j)); |
10079 visitor->visit(j, e); | 11297 visitor->visit(j, e); |
10080 } | 11298 } |
10081 } | 11299 } |
10082 } | 11300 } |
10083 | 11301 |
10084 | 11302 |
| 11303 static void IterateExternalFloat32x4ArrayElements(Isolate* isolate, |
| 11304 Handle<JSObject> receiver, |
| 11305 ArrayConcatVisitor* visitor) { |
| 11306 Handle<ExternalFloat32x4Array> array( |
| 11307 ExternalFloat32x4Array::cast(receiver->elements())); |
| 11308 uint32_t len = static_cast<uint32_t>(array->length()); |
| 11309 |
| 11310 ASSERT(visitor != NULL); |
| 11311 for (uint32_t j = 0; j < len; j++) { |
| 11312 HandleScope loop_scope(isolate); |
| 11313 Handle<Object> e = isolate->factory()->NewFloat32x4(array->get_scalar(j)); |
| 11314 visitor->visit(j, e); |
| 11315 } |
| 11316 } |
| 11317 |
| 11318 |
| 11319 static void IterateExternalInt32x4ArrayElements(Isolate* isolate, |
| 11320 Handle<JSObject> receiver, |
| 11321 ArrayConcatVisitor* visitor) { |
| 11322 Handle<ExternalInt32x4Array> array( |
| 11323 ExternalInt32x4Array::cast(receiver->elements())); |
| 11324 uint32_t len = static_cast<uint32_t>(array->length()); |
| 11325 |
| 11326 ASSERT(visitor != NULL); |
| 11327 for (uint32_t j = 0; j < len; j++) { |
| 11328 HandleScope loop_scope(isolate); |
| 11329 Handle<Object> e = isolate->factory()->NewInt32x4(array->get_scalar(j)); |
| 11330 visitor->visit(j, e); |
| 11331 } |
| 11332 } |
| 11333 |
| 11334 |
10085 // Used for sorting indices in a List<uint32_t>. | 11335 // Used for sorting indices in a List<uint32_t>. |
10086 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { | 11336 static int compareUInt32(const uint32_t* ap, const uint32_t* bp) { |
10087 uint32_t a = *ap; | 11337 uint32_t a = *ap; |
10088 uint32_t b = *bp; | 11338 uint32_t b = *bp; |
10089 return (a == b) ? 0 : (a < b) ? -1 : 1; | 11339 return (a == b) ? 0 : (a < b) ? -1 : 1; |
10090 } | 11340 } |
10091 | 11341 |
10092 | 11342 |
10093 static void CollectElementIndices(Handle<JSObject> object, | 11343 static void CollectElementIndices(Handle<JSObject> object, |
10094 uint32_t range, | 11344 uint32_t range, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10169 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { | 11419 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
10170 dense_elements_length = | 11420 dense_elements_length = |
10171 ExternalUnsignedIntArray::cast(object->elements())->length(); | 11421 ExternalUnsignedIntArray::cast(object->elements())->length(); |
10172 break; | 11422 break; |
10173 } | 11423 } |
10174 case EXTERNAL_FLOAT_ELEMENTS: { | 11424 case EXTERNAL_FLOAT_ELEMENTS: { |
10175 dense_elements_length = | 11425 dense_elements_length = |
10176 ExternalFloatArray::cast(object->elements())->length(); | 11426 ExternalFloatArray::cast(object->elements())->length(); |
10177 break; | 11427 break; |
10178 } | 11428 } |
| 11429 case EXTERNAL_FLOAT32x4_ELEMENTS: { |
| 11430 dense_elements_length = |
| 11431 ExternalFloat32x4Array::cast(object->elements())->length(); |
| 11432 break; |
| 11433 } |
| 11434 case EXTERNAL_INT32x4_ELEMENTS: { |
| 11435 dense_elements_length = |
| 11436 ExternalInt32x4Array::cast(object->elements())->length(); |
| 11437 break; |
| 11438 } |
10179 case EXTERNAL_DOUBLE_ELEMENTS: { | 11439 case EXTERNAL_DOUBLE_ELEMENTS: { |
10180 dense_elements_length = | 11440 dense_elements_length = |
10181 ExternalDoubleArray::cast(object->elements())->length(); | 11441 ExternalDoubleArray::cast(object->elements())->length(); |
10182 break; | 11442 break; |
10183 } | 11443 } |
10184 default: | 11444 default: |
10185 UNREACHABLE(); | 11445 UNREACHABLE(); |
10186 dense_elements_length = 0; | 11446 dense_elements_length = 0; |
10187 break; | 11447 break; |
10188 } | 11448 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10334 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { | 11594 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
10335 IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>( | 11595 IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>( |
10336 isolate, receiver, true, false, visitor); | 11596 isolate, receiver, true, false, visitor); |
10337 break; | 11597 break; |
10338 } | 11598 } |
10339 case EXTERNAL_FLOAT_ELEMENTS: { | 11599 case EXTERNAL_FLOAT_ELEMENTS: { |
10340 IterateExternalArrayElements<ExternalFloatArray, float>( | 11600 IterateExternalArrayElements<ExternalFloatArray, float>( |
10341 isolate, receiver, false, false, visitor); | 11601 isolate, receiver, false, false, visitor); |
10342 break; | 11602 break; |
10343 } | 11603 } |
| 11604 case EXTERNAL_FLOAT32x4_ELEMENTS: { |
| 11605 IterateExternalFloat32x4ArrayElements(isolate, receiver, visitor); |
| 11606 break; |
| 11607 } |
| 11608 case EXTERNAL_INT32x4_ELEMENTS: { |
| 11609 IterateExternalInt32x4ArrayElements(isolate, receiver, visitor); |
| 11610 break; |
| 11611 } |
10344 case EXTERNAL_DOUBLE_ELEMENTS: { | 11612 case EXTERNAL_DOUBLE_ELEMENTS: { |
10345 IterateExternalArrayElements<ExternalDoubleArray, double>( | 11613 IterateExternalArrayElements<ExternalDoubleArray, double>( |
10346 isolate, receiver, false, false, visitor); | 11614 isolate, receiver, false, false, visitor); |
10347 break; | 11615 break; |
10348 } | 11616 } |
10349 default: | 11617 default: |
10350 UNREACHABLE(); | 11618 UNREACHABLE(); |
10351 break; | 11619 break; |
10352 } | 11620 } |
10353 visitor->increase_index_offset(length); | 11621 visitor->increase_index_offset(length); |
(...skipping 4193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14547 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(NonStrictArgumentsElements) | 15815 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(NonStrictArgumentsElements) |
14548 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) | 15816 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) |
14549 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) | 15817 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) |
14550 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) | 15818 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) |
14551 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) | 15819 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) |
14552 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) | 15820 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) |
14553 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) | 15821 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) |
14554 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) | 15822 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) |
14555 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) | 15823 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) |
14556 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) | 15824 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) |
| 15825 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloat32x4Elements) |
| 15826 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalInt32x4Elements) |
14557 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) | 15827 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) |
14558 // Properties test sitting with elements tests - not fooling anyone. | 15828 // Properties test sitting with elements tests - not fooling anyone. |
14559 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) | 15829 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) |
14560 | 15830 |
14561 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 15831 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
14562 | 15832 |
14563 | 15833 |
14564 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 15834 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { |
14565 SealHandleScope shs(isolate); | 15835 SealHandleScope shs(isolate); |
14566 ASSERT(args.length() == 2); | 15836 ASSERT(args.length() == 2); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14893 // Handle last resort GC and make sure to allow future allocations | 16163 // Handle last resort GC and make sure to allow future allocations |
14894 // to grow the heap without causing GCs (if possible). | 16164 // to grow the heap without causing GCs (if possible). |
14895 isolate->counters()->gc_last_resort_from_js()->Increment(); | 16165 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14896 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 16166 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14897 "Runtime::PerformGC"); | 16167 "Runtime::PerformGC"); |
14898 } | 16168 } |
14899 } | 16169 } |
14900 | 16170 |
14901 | 16171 |
14902 } } // namespace v8::internal | 16172 } } // namespace v8::internal |
OLD | NEW |