From 1a67b7f86a5d262fa74eba8f6d8937b2d3c1f844 Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Fri, 24 Jan 2014 16:01:15 +0000 Subject: [PATCH] External Array renaming and boilerplate scrapping Replaced symbolic names with correct JS name (byte -> int8, unsigned int -> uint32 etc). Using macros to scrap the boilerplate BUG= R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/145133013 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18835 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 29 +- src/api.cc | 150 +++------- src/api.h | 18 +- src/arm/lithium-arm.cc | 2 +- src/arm/lithium-codegen-arm.cc | 48 ++-- src/bootstrapper.cc | 35 +-- src/code-stubs.cc | 24 +- src/contexts.h | 12 +- src/elements-kind.cc | 18 +- src/elements-kind.h | 26 +- src/elements.cc | 371 ++++++------------------ src/factory.cc | 30 +- src/heap.cc | 162 +++-------- src/heap.h | 46 +-- src/hydrogen-instructions.cc | 10 +- src/hydrogen-instructions.h | 10 +- src/hydrogen-uint32-analysis.cc | 6 +- src/hydrogen.cc | 6 +- src/ia32/lithium-codegen-ia32.cc | 44 +-- src/ia32/lithium-ia32.cc | 8 +- src/ia32/lithium-ia32.h | 6 +- src/mips/lithium-codegen-mips.cc | 48 ++-- src/mips/lithium-mips.cc | 2 +- src/objects-debug.cc | 140 ++------- src/objects-inl.h | 135 ++++----- src/objects-printer.cc | 122 ++------ src/objects-visiting.cc | 14 +- src/objects.cc | 475 ++++++++++--------------------- src/objects.h | 233 +++++++-------- src/runtime.cc | 180 ++++-------- src/runtime.h | 20 +- src/x64/lithium-codegen-x64.cc | 49 ++-- src/x64/lithium-x64.cc | 6 +- test/cctest/test-api.cc | 225 +++++++-------- test/mjsunit/elements-kind.js | 18 +- 35 files changed, 955 insertions(+), 1773 deletions(-) diff --git a/include/v8.h b/include/v8.h index 96d8c6fb6..4bb3ad97c 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2000,15 +2000,26 @@ enum PropertyAttribute { }; enum ExternalArrayType { - kExternalByteArray = 1, - kExternalUnsignedByteArray, - kExternalShortArray, - kExternalUnsignedShortArray, - kExternalIntArray, - kExternalUnsignedIntArray, - kExternalFloatArray, - kExternalDoubleArray, - kExternalPixelArray + kExternalInt8Array = 1, + kExternalUint8Array, + kExternalInt16Array, + kExternalUint16Array, + kExternalInt32Array, + kExternalUint32Array, + kExternalFloat32Array, + kExternalFloat64Array, + kExternalUint8ClampedArray, + + // Legacy constant names + kExternalByteArray = kExternalInt8Array, + kExternalUnsignedByteArray = kExternalUint8Array, + kExternalShortArray = kExternalInt16Array, + kExternalUnsignedShortArray = kExternalUint16Array, + kExternalIntArray = kExternalInt32Array, + kExternalUnsignedIntArray = kExternalUint32Array, + kExternalFloatArray = kExternalFloat32Array, + kExternalDoubleArray = kExternalFloat64Array, + kExternalPixelArray = kExternalUint8ClampedArray }; /** diff --git a/src/api.cc b/src/api.cc index 3aa7af736..a00e60801 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2371,26 +2371,14 @@ bool Value::IsTypedArray() const { } -#define TYPED_ARRAY_LIST(F) \ - F(Uint8Array, kExternalUnsignedByteArray) \ - F(Int8Array, kExternalByteArray) \ - F(Uint16Array, kExternalUnsignedShortArray) \ - F(Int16Array, kExternalShortArray) \ - F(Uint32Array, kExternalUnsignedIntArray) \ - F(Int32Array, kExternalIntArray) \ - F(Float32Array, kExternalFloatArray) \ - F(Float64Array, kExternalDoubleArray) \ - F(Uint8ClampedArray, kExternalPixelArray) - - -#define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ - bool Value::Is##TypedArray() const { \ - i::Handle obj = Utils::OpenHandle(this); \ - if (!obj->IsJSTypedArray()) return false; \ - return i::JSTypedArray::cast(*obj)->type() == type_const; \ +#define VALUE_IS_TYPED_ARRAY(Type, typeName, TYPE, ctype, size) \ + bool Value::Is##Type##Array() const { \ + i::Handle obj = Utils::OpenHandle(this); \ + return obj->IsJSTypedArray() && \ + i::JSTypedArray::cast(*obj)->type() == kExternal##Type##Array; \ } -TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) +TYPED_ARRAYS(VALUE_IS_TYPED_ARRAY) #undef VALUE_IS_TYPED_ARRAY @@ -2722,17 +2710,18 @@ void v8::TypedArray::CheckCast(Value* that) { } -#define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ - void v8::ApiClass::CheckCast(Value* that) { \ - i::Handle obj = Utils::OpenHandle(that); \ - Utils::ApiCheck(obj->IsJSTypedArray() && \ - i::JSTypedArray::cast(*obj)->type() == typeConst, \ - "v8::" #ApiClass "::Cast()", \ - "Could not convert to " #ApiClass); \ +#define CHECK_TYPED_ARRAY_CAST(Type, typeName, TYPE, ctype, size) \ + void v8::Type##Array::CheckCast(Value* that) { \ + i::Handle obj = Utils::OpenHandle(that); \ + Utils::ApiCheck(obj->IsJSTypedArray() && \ + i::JSTypedArray::cast(*obj)->type() == \ + kExternal##Type##Array, \ + "v8::" #Type "Array::Cast()", \ + "Could not convert to " #Type "Array"); \ } -TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) +TYPED_ARRAYS(CHECK_TYPED_ARRAY_CAST) #undef CHECK_TYPED_ARRAY_CAST @@ -3665,33 +3654,12 @@ namespace { static i::ElementsKind GetElementsKindFromExternalArrayType( ExternalArrayType array_type) { switch (array_type) { - case kExternalByteArray: - return i::EXTERNAL_BYTE_ELEMENTS; - break; - case kExternalUnsignedByteArray: - return i::EXTERNAL_UNSIGNED_BYTE_ELEMENTS; - break; - case kExternalShortArray: - return i::EXTERNAL_SHORT_ELEMENTS; - break; - case kExternalUnsignedShortArray: - return i::EXTERNAL_UNSIGNED_SHORT_ELEMENTS; - break; - case kExternalIntArray: - return i::EXTERNAL_INT_ELEMENTS; - break; - case kExternalUnsignedIntArray: - return i::EXTERNAL_UNSIGNED_INT_ELEMENTS; - break; - case kExternalFloatArray: - return i::EXTERNAL_FLOAT_ELEMENTS; - break; - case kExternalDoubleArray: - return i::EXTERNAL_DOUBLE_ELEMENTS; - break; - case kExternalPixelArray: - return i::EXTERNAL_PIXEL_ELEMENTS; - break; +#define ARRAY_TYPE_TO_ELEMENTS_KIND(Type, type, TYPE, ctype, size) \ + case kExternal##Type##Array: \ + return i::EXTERNAL_##TYPE##_ELEMENTS; + + TYPED_ARRAYS(ARRAY_TYPE_TO_ELEMENTS_KIND) +#undef ARRAY_TYPE_TO_ELEMENTS_KIND } UNREACHABLE(); return i::DICTIONARY_ELEMENTS; @@ -3724,7 +3692,7 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { ENTER_V8(isolate); i::HandleScope scope(isolate); if (!Utils::ApiCheck(length >= 0 && - length <= i::ExternalPixelArray::kMaxLength, + length <= i::ExternalUint8ClampedArray::kMaxLength, "v8::Object::SetIndexedPropertiesToPixelData()", "length exceeds max acceptable value")) { return; @@ -3735,7 +3703,7 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { "JSArray is not supported")) { return; } - PrepareExternalArrayElements(self, data, kExternalPixelArray, length); + PrepareExternalArrayElements(self, data, kExternalUint8ClampedArray, length); } @@ -3743,7 +3711,7 @@ bool v8::Object::HasIndexedPropertiesInPixelData() { i::Handle self = Utils::OpenHandle(this); ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()", return false); - return self->HasExternalPixelElements(); + return self->HasExternalUint8ClampedElements(); } @@ -3751,9 +3719,9 @@ uint8_t* v8::Object::GetIndexedPropertiesPixelData() { i::Handle self = Utils::OpenHandle(this); ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelData()", return NULL); - if (self->HasExternalPixelElements()) { - return i::ExternalPixelArray::cast(self->elements())-> - external_pixel_pointer(); + if (self->HasExternalUint8ClampedElements()) { + return i::ExternalUint8ClampedArray::cast(self->elements())-> + external_uint8_clamped_pointer(); } else { return NULL; } @@ -3764,8 +3732,8 @@ int v8::Object::GetIndexedPropertiesPixelDataLength() { i::Handle self = Utils::OpenHandle(this); ON_BAILOUT(self->GetIsolate(), "v8::GetIndexedPropertiesPixelDataLength()", return -1); - if (self->HasExternalPixelElements()) { - return i::ExternalPixelArray::cast(self->elements())->length(); + if (self->HasExternalUint8ClampedElements()) { + return i::ExternalUint8ClampedArray::cast(self->elements())->length(); } else { return -1; } @@ -3823,24 +3791,11 @@ ExternalArrayType v8::Object::GetIndexedPropertiesExternalArrayDataType() { "v8::GetIndexedPropertiesExternalArrayDataType()", return static_cast(-1)); switch (self->elements()->map()->instance_type()) { - case i::EXTERNAL_BYTE_ARRAY_TYPE: - return kExternalByteArray; - case i::EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - return kExternalUnsignedByteArray; - case i::EXTERNAL_SHORT_ARRAY_TYPE: - return kExternalShortArray; - case i::EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - return kExternalUnsignedShortArray; - case i::EXTERNAL_INT_ARRAY_TYPE: - return kExternalIntArray; - case i::EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - return kExternalUnsignedIntArray; - case i::EXTERNAL_FLOAT_ARRAY_TYPE: - return kExternalFloatArray; - case i::EXTERNAL_DOUBLE_ARRAY_TYPE: - return kExternalDoubleArray; - case i::EXTERNAL_PIXEL_ARRAY_TYPE: - return kExternalPixelArray; +#define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \ + case i::EXTERNAL_##TYPE##_ARRAY_TYPE: \ + return kExternal##Type##Array; + TYPED_ARRAYS(INSTANCE_TYPE_TO_ARRAY_TYPE) +#undef INSTANCE_TYPE_TO_ARRAY_TYPE default: return static_cast(-1); } @@ -6018,41 +5973,24 @@ i::Handle NewTypedArray( } -#define TYPED_ARRAY_NEW(TypedArray, element_type, array_type, elements_kind) \ - Local TypedArray::New(Handle array_buffer, \ +#define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ + Local Type##Array::New(Handle array_buffer, \ size_t byte_offset, size_t length) { \ i::Isolate* isolate = i::Isolate::Current(); \ EnsureInitializedForIsolate(isolate, \ - "v8::" #TypedArray "::New(Handle, size_t, size_t)"); \ + "v8::" #Type "Array::New(Handle, size_t, size_t)"); \ LOG_API(isolate, \ - "v8::" #TypedArray "::New(Handle, size_t, size_t)"); \ + "v8::" #Type "Array::New(Handle, size_t, size_t)"); \ ENTER_V8(isolate); \ i::Handle obj = \ - NewTypedArray( \ + NewTypedArray( \ isolate, array_buffer, byte_offset, length); \ - return Utils::ToLocal##TypedArray(obj); \ - } - - -TYPED_ARRAY_NEW(Uint8Array, uint8_t, kExternalUnsignedByteArray, - i::EXTERNAL_UNSIGNED_BYTE_ELEMENTS) -TYPED_ARRAY_NEW(Uint8ClampedArray, uint8_t, kExternalPixelArray, - i::EXTERNAL_PIXEL_ELEMENTS) -TYPED_ARRAY_NEW(Int8Array, int8_t, kExternalByteArray, - i::EXTERNAL_BYTE_ELEMENTS) -TYPED_ARRAY_NEW(Uint16Array, uint16_t, kExternalUnsignedShortArray, - i::EXTERNAL_UNSIGNED_SHORT_ELEMENTS) -TYPED_ARRAY_NEW(Int16Array, int16_t, kExternalShortArray, - i::EXTERNAL_SHORT_ELEMENTS) -TYPED_ARRAY_NEW(Uint32Array, uint32_t, kExternalUnsignedIntArray, - i::EXTERNAL_UNSIGNED_INT_ELEMENTS) -TYPED_ARRAY_NEW(Int32Array, int32_t, kExternalIntArray, - i::EXTERNAL_INT_ELEMENTS) -TYPED_ARRAY_NEW(Float32Array, float, kExternalFloatArray, - i::EXTERNAL_FLOAT_ELEMENTS) -TYPED_ARRAY_NEW(Float64Array, double, kExternalDoubleArray, - i::EXTERNAL_DOUBLE_ELEMENTS) + return Utils::ToLocal##Type##Array(obj); \ + } + +TYPED_ARRAYS(TYPED_ARRAY_NEW) #undef TYPED_ARRAY_NEW Local DataView::New(Handle array_buffer, diff --git a/src/api.h b/src/api.h index 9d4dcf738..9fc99d9d2 100644 --- a/src/api.h +++ b/src/api.h @@ -344,11 +344,11 @@ inline v8::Local ToApiHandle( } -#define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \ - Local Utils::ToLocal##TypedArray( \ +#define MAKE_TO_LOCAL_TYPED_ARRAY(Type, typeName, TYPE, ctype, size) \ + Local Utils::ToLocal##Type##Array( \ v8::internal::Handle obj) { \ - ASSERT(obj->type() == typeConst); \ - return Convert(obj); \ + ASSERT(obj->type() == kExternal##Type##Array); \ + return Convert(obj); \ } @@ -365,15 +365,7 @@ MAKE_TO_LOCAL(ToLocal, JSArrayBufferView, ArrayBufferView) MAKE_TO_LOCAL(ToLocal, JSDataView, DataView) MAKE_TO_LOCAL(ToLocal, JSTypedArray, TypedArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Uint8Array, kExternalUnsignedByteArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Uint8ClampedArray, kExternalPixelArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Int8Array, kExternalByteArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Uint16Array, kExternalUnsignedShortArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Int16Array, kExternalShortArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Uint32Array, kExternalUnsignedIntArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Int32Array, kExternalIntArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Float32Array, kExternalFloatArray) -MAKE_TO_LOCAL_TYPED_ARRAY(Float64Array, kExternalDoubleArray) +TYPED_ARRAYS(MAKE_TO_LOCAL_TYPED_ARRAY) MAKE_TO_LOCAL(ToLocal, FunctionTemplateInfo, FunctionTemplate) MAKE_TO_LOCAL(ToLocal, ObjectTemplateInfo, ObjectTemplate) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index f20beac97..c12e9b808 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -2105,7 +2105,7 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. bool can_deoptimize = instr->RequiresHoleCheck() || - elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS || + elements_kind == EXTERNAL_UINT32_ELEMENTS || elements_kind == UINT32_ELEMENTS; return can_deoptimize ? AssignEnvironment(result) : result; } diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 29cd02412..062c7d183 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3214,9 +3214,9 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { : 0; - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS || - elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { int base_offset = (instr->additional_index() << element_size_shift) + additional_offset; @@ -3225,7 +3225,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { ? Operand(constant_key << element_size_shift) : Operand(key, LSL, shift_size); __ add(scratch0(), external_pointer, operand); - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { __ vldr(double_scratch0().low(), scratch0(), base_offset); __ vcvt_f64_f32(result, double_scratch0().low()); @@ -3239,29 +3239,29 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { element_size_shift, shift_size, instr->additional_index(), additional_offset); switch (elements_kind) { - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: case INT8_ELEMENTS: __ ldrsb(result, mem_operand); break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ ldrb(result, mem_operand); break; - case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: case INT16_ELEMENTS: __ ldrsh(result, mem_operand); break; - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: __ ldrh(result, mem_operand); break; - case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: case INT32_ELEMENTS: __ ldr(result, mem_operand); break; - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: __ ldr(result, mem_operand); if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { @@ -3271,8 +3271,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { break; case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: case FAST_HOLEY_ELEMENTS: case FAST_HOLEY_SMI_ELEMENTS: @@ -4276,9 +4276,9 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag : 0; - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS || - elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { int base_offset = (instr->additional_index() << element_size_shift) + additional_offset; @@ -4294,7 +4294,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { } else { __ add(address, external_pointer, Operand(key, LSL, shift_size)); } - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { __ vcvt_f32_f64(double_scratch0().low(), value); __ vstr(double_scratch0().low(), address, base_offset); @@ -4308,30 +4308,30 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { element_size_shift, shift_size, instr->additional_index(), additional_offset); switch (elements_kind) { - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: case INT8_ELEMENTS: __ strb(value, mem_operand); break; - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case INT16_ELEMENTS: case UINT16_ELEMENTS: __ strh(value, mem_operand); break; - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case INT32_ELEMENTS: case UINT32_ELEMENTS: __ str(value, mem_operand); break; case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_ELEMENTS: case FAST_SMI_ELEMENTS: diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 97364ca69..6952a5534 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1094,33 +1094,14 @@ void Genesis::InitializeGlobal(Handle inner_global, } { // -- T y p e d A r r a y s - Handle int8_fun = InstallTypedArray("Int8Array", - EXTERNAL_BYTE_ELEMENTS); - native_context()->set_int8_array_fun(*int8_fun); - Handle uint8_fun = InstallTypedArray("Uint8Array", - EXTERNAL_UNSIGNED_BYTE_ELEMENTS); - native_context()->set_uint8_array_fun(*uint8_fun); - Handle int16_fun = InstallTypedArray("Int16Array", - EXTERNAL_SHORT_ELEMENTS); - native_context()->set_int16_array_fun(*int16_fun); - Handle uint16_fun = InstallTypedArray("Uint16Array", - EXTERNAL_UNSIGNED_SHORT_ELEMENTS); - native_context()->set_uint16_array_fun(*uint16_fun); - Handle int32_fun = InstallTypedArray("Int32Array", - EXTERNAL_INT_ELEMENTS); - native_context()->set_int32_array_fun(*int32_fun); - Handle uint32_fun = InstallTypedArray("Uint32Array", - EXTERNAL_UNSIGNED_INT_ELEMENTS); - native_context()->set_uint32_array_fun(*uint32_fun); - Handle float_fun = InstallTypedArray("Float32Array", - EXTERNAL_FLOAT_ELEMENTS); - native_context()->set_float_array_fun(*float_fun); - Handle double_fun = InstallTypedArray("Float64Array", - EXTERNAL_DOUBLE_ELEMENTS); - native_context()->set_double_array_fun(*double_fun); - Handle uint8c_fun = InstallTypedArray("Uint8ClampedArray", - EXTERNAL_PIXEL_ELEMENTS); - native_context()->set_uint8c_array_fun(*uint8c_fun); +#define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ + { \ + Handle fun = InstallTypedArray(#Type "Array", \ + EXTERNAL_##TYPE##_ELEMENTS); \ + native_context()->set_##type##_array_fun(*fun); \ + } + TYPED_ARRAYS(INSTALL_TYPED_ARRAY) +#undef INSTALL_TYPED_ARRAY Handle data_view_fun = InstallFunction( diff --git a/src/code-stubs.cc b/src/code-stubs.cc index a2da8031a..5a2d2f4a7 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -557,24 +557,12 @@ void KeyedStoreElementStub::Generate(MacroAssembler* masm) { case FAST_HOLEY_SMI_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE UNREACHABLE(); break; case DICTIONARY_ELEMENTS: diff --git a/src/contexts.h b/src/contexts.h index 1b857c302..bd6c6a2bb 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -131,9 +131,9 @@ enum BindingFlags { V(INT16_ARRAY_FUN_INDEX, JSFunction, int16_array_fun) \ V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ V(INT32_ARRAY_FUN_INDEX, JSFunction, int32_array_fun) \ - V(FLOAT_ARRAY_FUN_INDEX, JSFunction, float_array_fun) \ - V(DOUBLE_ARRAY_FUN_INDEX, JSFunction, double_array_fun) \ - V(UINT8C_ARRAY_FUN_INDEX, JSFunction, uint8c_array_fun) \ + V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun) \ + V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun) \ + V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ V(FUNCTION_MAP_INDEX, Map, function_map) \ V(STRICT_MODE_FUNCTION_MAP_INDEX, Map, strict_mode_function_map) \ @@ -296,9 +296,9 @@ class Context: public FixedArray { INT16_ARRAY_FUN_INDEX, UINT32_ARRAY_FUN_INDEX, INT32_ARRAY_FUN_INDEX, - FLOAT_ARRAY_FUN_INDEX, - DOUBLE_ARRAY_FUN_INDEX, - UINT8C_ARRAY_FUN_INDEX, + FLOAT32_ARRAY_FUN_INDEX, + FLOAT64_ARRAY_FUN_INDEX, + UINT8_CLAMPED_ARRAY_FUN_INDEX, DATA_VIEW_FUN_INDEX, MESSAGE_LISTENERS_INDEX, MAKE_MESSAGE_FUN_INDEX, diff --git a/src/elements-kind.cc b/src/elements-kind.cc index ebb4616e9..d2abb0442 100644 --- a/src/elements-kind.cc +++ b/src/elements-kind.cc @@ -37,26 +37,26 @@ namespace internal { int ElementsKindToShiftSize(ElementsKind elements_kind) { switch (elements_kind) { - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case INT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: return 0; - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: case INT16_ELEMENTS: return 1; - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: case UINT32_ELEMENTS: case INT32_ELEMENTS: case FLOAT32_ELEMENTS: return 2; - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: case FLOAT64_ELEMENTS: diff --git a/src/elements-kind.h b/src/elements-kind.h index 3d55105c3..5a3f00dcc 100644 --- a/src/elements-kind.h +++ b/src/elements-kind.h @@ -53,15 +53,15 @@ enum ElementsKind { DICTIONARY_ELEMENTS, NON_STRICT_ARGUMENTS_ELEMENTS, // The "fast" kind for external arrays - EXTERNAL_BYTE_ELEMENTS, - EXTERNAL_UNSIGNED_BYTE_ELEMENTS, - EXTERNAL_SHORT_ELEMENTS, - EXTERNAL_UNSIGNED_SHORT_ELEMENTS, - EXTERNAL_INT_ELEMENTS, - EXTERNAL_UNSIGNED_INT_ELEMENTS, - EXTERNAL_FLOAT_ELEMENTS, - EXTERNAL_DOUBLE_ELEMENTS, - EXTERNAL_PIXEL_ELEMENTS, + EXTERNAL_INT8_ELEMENTS, + EXTERNAL_UINT8_ELEMENTS, + EXTERNAL_INT16_ELEMENTS, + EXTERNAL_UINT16_ELEMENTS, + EXTERNAL_INT32_ELEMENTS, + EXTERNAL_UINT32_ELEMENTS, + EXTERNAL_FLOAT32_ELEMENTS, + EXTERNAL_FLOAT64_ELEMENTS, + EXTERNAL_UINT8_CLAMPED_ELEMENTS, // Fixed typed arrays UINT8_ELEMENTS, @@ -79,8 +79,8 @@ enum ElementsKind { LAST_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS, LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS, - FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, - LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, + FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_INT8_ELEMENTS, + LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_UINT8_CLAMPED_ELEMENTS, FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_ELEMENTS, LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND = UINT8_CLAMPED_ELEMENTS, TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS @@ -135,8 +135,8 @@ inline bool IsFastDoubleElementsKind(ElementsKind kind) { inline bool IsExternalFloatOrDoubleElementsKind(ElementsKind kind) { - return kind == EXTERNAL_DOUBLE_ELEMENTS || - kind == EXTERNAL_FLOAT_ELEMENTS; + return kind == EXTERNAL_FLOAT64_ELEMENTS || + kind == EXTERNAL_FLOAT32_ELEMENTS; } diff --git a/src/elements.cc b/src/elements.cc index 5bce3b99b..2e4667d4a 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -48,25 +48,25 @@ // - FastDoubleElementsAccessor // - FastPackedDoubleElementsAccessor // - FastHoleyDoubleElementsAccessor -// - TypedElementsAccessor (abstract) -// - ExternalByteElementsAccessor -// - ExternalUnsignedByteElementsAccessor -// - ExternalShortElementsAccessor -// - ExternalUnsignedShortElementsAccessor -// - ExternalIntElementsAccessor -// - ExternalUnsignedIntElementsAccessor -// - ExternalFloatElementsAccessor -// - ExternalDoubleElementsAccessor -// - PixelElementsAccessor -// - FixedUint8ArrayAccessor -// - FixedInt8ArrayAccessor -// - FixedUint16ArrayAccessor -// - FixedInt16ArrayAccessor -// - FixedUint32ArrayAccessor -// - FixedInt32ArrayAccessor -// - FixedFloat32ArrayAccessor -// - FixedFloat64ArrayAccessor -// - FixedUint8ClampedArrayAccessor +// - TypedElementsAccessor: template, with instantiations: +// - ExternalInt8ElementsAccessor +// - ExternalUint8ElementsAccessor +// - ExternalInt16ElementsAccessor +// - ExternalUint16ElementsAccessor +// - ExternalInt32ElementsAccessor +// - ExternalUint32ElementsAccessor +// - ExternalFloat32ElementsAccessor +// - ExternalFloat64ElementsAccessor +// - ExternalUint8ClampedElementsAccessor +// - FixedUint8ElementsAccessor +// - FixedInt8ElementsAccessor +// - FixedUint16ElementsAccessor +// - FixedInt16ElementsAccessor +// - FixedUint32ElementsAccessor +// - FixedInt32ElementsAccessor +// - FixedFloat32ElementsAccessor +// - FixedFloat64ElementsAccessor +// - FixedUint8ClampedElementsAccessor // - DictionaryElementsAccessor // - NonStrictArgumentsElementsAccessor @@ -97,32 +97,34 @@ static const int kPackedSizeNotKnown = -1; SeededNumberDictionary) \ V(NonStrictArgumentsElementsAccessor, NON_STRICT_ARGUMENTS_ELEMENTS, \ FixedArray) \ - V(ExternalByteElementsAccessor, EXTERNAL_BYTE_ELEMENTS, \ - ExternalByteArray) \ - V(ExternalUnsignedByteElementsAccessor, \ - EXTERNAL_UNSIGNED_BYTE_ELEMENTS, ExternalUnsignedByteArray) \ - V(ExternalShortElementsAccessor, EXTERNAL_SHORT_ELEMENTS, \ - ExternalShortArray) \ - V(ExternalUnsignedShortElementsAccessor, \ - EXTERNAL_UNSIGNED_SHORT_ELEMENTS, ExternalUnsignedShortArray) \ - V(ExternalIntElementsAccessor, EXTERNAL_INT_ELEMENTS, \ - ExternalIntArray) \ - V(ExternalUnsignedIntElementsAccessor, \ - EXTERNAL_UNSIGNED_INT_ELEMENTS, ExternalUnsignedIntArray) \ - V(ExternalFloatElementsAccessor, \ - EXTERNAL_FLOAT_ELEMENTS, ExternalFloatArray) \ - V(ExternalDoubleElementsAccessor, \ - EXTERNAL_DOUBLE_ELEMENTS, ExternalDoubleArray) \ - V(PixelElementsAccessor, EXTERNAL_PIXEL_ELEMENTS, ExternalPixelArray) \ - V(FixedUint8ArrayAccessor, UINT8_ELEMENTS, FixedUint8Array) \ - V(FixedInt8ArrayAccessor, INT8_ELEMENTS, FixedInt8Array) \ - V(FixedUint16ArrayAccessor, UINT16_ELEMENTS, FixedUint16Array) \ - V(FixedInt16ArrayAccessor, INT16_ELEMENTS, FixedInt16Array) \ - V(FixedUint32ArrayAccessor, UINT32_ELEMENTS, FixedUint32Array) \ - V(FixedInt32ArrayAccessor, INT32_ELEMENTS, FixedInt32Array) \ - V(FixedFloat32ArrayAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ - V(FixedFloat64ArrayAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ - V(FixedUint8ClampedArrayAccessor, UINT8_CLAMPED_ELEMENTS, \ + V(ExternalInt8ElementsAccessor, EXTERNAL_INT8_ELEMENTS, \ + ExternalInt8Array) \ + V(ExternalUint8ElementsAccessor, \ + EXTERNAL_UINT8_ELEMENTS, ExternalUint8Array) \ + V(ExternalInt16ElementsAccessor, EXTERNAL_INT16_ELEMENTS, \ + ExternalInt16Array) \ + V(ExternalUint16ElementsAccessor, \ + EXTERNAL_UINT16_ELEMENTS, ExternalUint16Array) \ + V(ExternalInt32ElementsAccessor, EXTERNAL_INT32_ELEMENTS, \ + ExternalInt32Array) \ + V(ExternalUint32ElementsAccessor, \ + EXTERNAL_UINT32_ELEMENTS, ExternalUint32Array) \ + V(ExternalFloat32ElementsAccessor, \ + EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array) \ + V(ExternalFloat64ElementsAccessor, \ + EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array) \ + V(ExternalUint8ClampedElementsAccessor, \ + EXTERNAL_UINT8_CLAMPED_ELEMENTS, \ + ExternalUint8ClampedArray) \ + V(FixedUint8ElementsAccessor, UINT8_ELEMENTS, FixedUint8Array) \ + V(FixedInt8ElementsAccessor, INT8_ELEMENTS, FixedInt8Array) \ + V(FixedUint16ElementsAccessor, UINT16_ELEMENTS, FixedUint16Array) \ + V(FixedInt16ElementsAccessor, INT16_ELEMENTS, FixedInt16Array) \ + V(FixedUint32ElementsAccessor, UINT32_ELEMENTS, FixedUint32Array) \ + V(FixedInt32ElementsAccessor, INT32_ELEMENTS, FixedInt32Array) \ + V(FixedFloat32ElementsAccessor, FLOAT32_ELEMENTS, FixedFloat32Array) \ + V(FixedFloat64ElementsAccessor, FLOAT64_ELEMENTS, FixedFloat64Array) \ + V(FixedUint8ClampedElementsAccessor, UINT8_CLAMPED_ELEMENTS, \ FixedUint8ClampedArray) @@ -1097,43 +1099,15 @@ static inline ElementsKind ElementsKindForArray(FixedArrayBase* array) { } case FIXED_DOUBLE_ARRAY_TYPE: return FAST_HOLEY_DOUBLE_ELEMENTS; - case EXTERNAL_BYTE_ARRAY_TYPE: - return EXTERNAL_BYTE_ELEMENTS; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - return EXTERNAL_UNSIGNED_BYTE_ELEMENTS; - case EXTERNAL_SHORT_ARRAY_TYPE: - return EXTERNAL_SHORT_ELEMENTS; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - return EXTERNAL_UNSIGNED_SHORT_ELEMENTS; - case EXTERNAL_INT_ARRAY_TYPE: - return EXTERNAL_INT_ELEMENTS; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - return EXTERNAL_UNSIGNED_INT_ELEMENTS; - case EXTERNAL_FLOAT_ARRAY_TYPE: - return EXTERNAL_FLOAT_ELEMENTS; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - return EXTERNAL_DOUBLE_ELEMENTS; - case EXTERNAL_PIXEL_ARRAY_TYPE: - return EXTERNAL_PIXEL_ELEMENTS; - - case FIXED_UINT8_ARRAY_TYPE: - return UINT8_ELEMENTS; - case FIXED_INT8_ARRAY_TYPE: - return INT8_ELEMENTS; - case FIXED_UINT16_ARRAY_TYPE: - return UINT16_ELEMENTS; - case FIXED_INT16_ARRAY_TYPE: - return INT16_ELEMENTS; - case FIXED_UINT32_ARRAY_TYPE: - return UINT32_ELEMENTS; - case FIXED_INT32_ARRAY_TYPE: - return INT32_ELEMENTS; - case FIXED_FLOAT32_ARRAY_TYPE: - return FLOAT32_ELEMENTS; - case FIXED_FLOAT64_ARRAY_TYPE: - return FLOAT64_ELEMENTS; - case FIXED_UINT8_CLAMPED_ARRAY_TYPE: - return UINT8_CLAMPED_ELEMENTS; + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + return EXTERNAL_##TYPE##_ELEMENTS; \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + return TYPE##_ELEMENTS; + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE default: UNREACHABLE(); @@ -1188,25 +1162,12 @@ class FastSmiOrObjectElementsAccessor return CopyElementsImpl(arguments, from_start, to, from_kind, to_start, packed_size, copy_size); } - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ UNREACHABLE(); + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE } return NULL; } @@ -1322,25 +1283,14 @@ class FastDoubleElementsAccessor from, from_start, to, to_start, copy_size); break; case NON_STRICT_ARGUMENTS_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: UNREACHABLE(); + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + UNREACHABLE(); + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE } return to->GetHeap()->undefined_value(); } @@ -1377,20 +1327,20 @@ class FastHoleyDoubleElementsAccessor // Super class for all external element arrays. -template +template class TypedElementsAccessor - : public ElementsAccessorBase, ElementsKindTraits > { public: explicit TypedElementsAccessor(const char* name) - : ElementsAccessorBase >(name) {} protected: typedef typename ElementsKindTraits::BackingStore BackingStore; + typedef TypedElementsAccessor AccessorClass; - friend class ElementsAccessorBase >; MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver, @@ -1398,7 +1348,7 @@ class TypedElementsAccessor uint32_t key, FixedArrayBase* backing_store) { return - key < AccessorSubclass::GetCapacityImpl(backing_store) + key < AccessorClass::GetCapacityImpl(backing_store) ? BackingStore::cast(backing_store)->get(key) : backing_store->GetHeap()->undefined_value(); } @@ -1409,7 +1359,7 @@ class TypedElementsAccessor uint32_t key, FixedArrayBase* backing_store) { return - key < AccessorSubclass::GetCapacityImpl(backing_store) + key < AccessorClass::GetCapacityImpl(backing_store) ? NONE : ABSENT; } @@ -1419,7 +1369,7 @@ class TypedElementsAccessor uint32_t key, FixedArrayBase* backing_store) { return - key < AccessorSubclass::GetCapacityImpl(backing_store) + key < AccessorClass::GetCapacityImpl(backing_store) ? FIELD : NONEXISTENT; } @@ -1444,175 +1394,28 @@ class TypedElementsAccessor uint32_t key, FixedArrayBase* backing_store) { uint32_t capacity = - AccessorSubclass::GetCapacityImpl(backing_store); + AccessorClass::GetCapacityImpl(backing_store); return key < capacity; } }; -class ExternalByteElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalByteElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class ExternalUnsignedByteElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalUnsignedByteElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; +#define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ + typedef TypedElementsAccessor \ + External##Type##ElementsAccessor; -class ExternalShortElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalShortElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; +TYPED_ARRAYS(EXTERNAL_ELEMENTS_ACCESSOR) +#undef EXTERNAL_ELEMENTS_ACCESSOR +#define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ + typedef TypedElementsAccessor \ + Fixed##Type##ElementsAccessor; -class ExternalUnsignedShortElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalUnsignedShortElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; +TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR) +#undef FIXED_ELEMENTS_ACCESSOR -class ExternalIntElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalIntElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class ExternalUnsignedIntElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalUnsignedIntElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class ExternalFloatElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalFloatElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class ExternalDoubleElementsAccessor - : public TypedElementsAccessor { - public: - explicit ExternalDoubleElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class PixelElementsAccessor - : public TypedElementsAccessor { - public: - explicit PixelElementsAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - - -class FixedUint8ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedUint8ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedUint8ClampedArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedUint8ClampedArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedInt8ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedInt8ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedUint16ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedUint16ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedInt16ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedInt16ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedUint32ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedUint32ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedInt32ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedInt32ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; - -class FixedFloat32ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedFloat32ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; -class FixedFloat64ArrayAccessor - : public TypedElementsAccessor { - public: - explicit FixedFloat64ArrayAccessor(const char* name) - : TypedElementsAccessor(name) {} -}; class DictionaryElementsAccessor : public ElementsAccessorBasecontext()->native_context(); switch (type) { - case kExternalUnsignedByteArray: - return native_context->uint8_array_fun(); +#define TYPED_ARRAY_FUN(Type, type, TYPE, ctype, size) \ + case kExternal##Type##Array: \ + return native_context->type##_array_fun(); - case kExternalByteArray: - return native_context->int8_array_fun(); - - case kExternalUnsignedShortArray: - return native_context->uint16_array_fun(); - - case kExternalShortArray: - return native_context->int16_array_fun(); - - case kExternalUnsignedIntArray: - return native_context->uint32_array_fun(); - - case kExternalIntArray: - return native_context->int32_array_fun(); - - case kExternalFloatArray: - return native_context->float_array_fun(); - - case kExternalDoubleArray: - return native_context->double_array_fun(); - - case kExternalPixelArray: - return native_context->uint8c_array_fun(); + TYPED_ARRAYS(TYPED_ARRAY_FUN) +#undef TYPED_ARRAY_FUN default: UNREACHABLE(); diff --git a/src/heap.cc b/src/heap.cc index d9bd7d5d6..862e2eaa2 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -2833,31 +2833,19 @@ bool Heap::CreateInitialMaps() { ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) -#define ALLOCATE_EXTERNAL_ARRAY_MAP(TYPE, type) \ +#define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \ external_##type##_array) - ALLOCATE_EXTERNAL_ARRAY_MAP(PIXEL, pixel) - ALLOCATE_EXTERNAL_ARRAY_MAP(BYTE, byte) - ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_BYTE, unsigned_byte) - ALLOCATE_EXTERNAL_ARRAY_MAP(SHORT, short) // NOLINT - ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_SHORT, unsigned_short) - ALLOCATE_EXTERNAL_ARRAY_MAP(INT, int) - ALLOCATE_EXTERNAL_ARRAY_MAP(UNSIGNED_INT, unsigned_int) - ALLOCATE_EXTERNAL_ARRAY_MAP(FLOAT, float) - ALLOCATE_EXTERNAL_ARRAY_MAP(DOUBLE, double) + TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) #undef ALLOCATE_EXTERNAL_ARRAY_MAP - ALLOCATE_VARSIZE_MAP(FIXED_UINT8_ARRAY_TYPE, fixed_uint8_array) - ALLOCATE_VARSIZE_MAP(FIXED_UINT8_CLAMPED_ARRAY_TYPE, - fixed_uint8_clamped_array) - ALLOCATE_VARSIZE_MAP(FIXED_INT8_ARRAY_TYPE, fixed_int8_array) - ALLOCATE_VARSIZE_MAP(FIXED_UINT16_ARRAY_TYPE, fixed_uint16_array) - ALLOCATE_VARSIZE_MAP(FIXED_INT16_ARRAY_TYPE, fixed_int16_array) - ALLOCATE_VARSIZE_MAP(FIXED_UINT32_ARRAY_TYPE, fixed_uint32_array) - ALLOCATE_VARSIZE_MAP(FIXED_INT32_ARRAY_TYPE, fixed_int32_array) - ALLOCATE_VARSIZE_MAP(FIXED_FLOAT32_ARRAY_TYPE, fixed_float32_array) - ALLOCATE_VARSIZE_MAP(FIXED_FLOAT64_ARRAY_TYPE, fixed_float64_array) +#define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ + ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, \ + fixed_##type##_array) + + TYPED_ARRAYS(ALLOCATE_FIXED_TYPED_ARRAY_MAP) +#undef ALLOCATE_FIXED_TYPED_ARRAY_MAP ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, non_strict_arguments_elements) @@ -2909,22 +2897,14 @@ bool Heap::CreateInitialMaps() { set_empty_byte_array(byte_array); } -#define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type) \ +#define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ { ExternalArray* obj; \ if (!AllocateEmptyExternalArray(kExternal##Type##Array)->To(&obj)) \ return false; \ set_empty_external_##type##_array(obj); \ } - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Byte, byte) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedByte, unsigned_byte) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Short, short) // NOLINT - ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedShort, unsigned_short) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Int, int) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(UnsignedInt, unsigned_int) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Float, float) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Double, double) - ALLOCATE_EMPTY_EXTERNAL_ARRAY(Pixel, pixel) + TYPED_ARRAYS(ALLOCATE_EMPTY_EXTERNAL_ARRAY) #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY } ASSERT(!InNewSpace(empty_fixed_array())); @@ -3613,24 +3593,13 @@ Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { Heap::RootListIndex Heap::RootIndexForExternalArrayType( ExternalArrayType array_type) { switch (array_type) { - case kExternalByteArray: - return kExternalByteArrayMapRootIndex; - case kExternalUnsignedByteArray: - return kExternalUnsignedByteArrayMapRootIndex; - case kExternalShortArray: - return kExternalShortArrayMapRootIndex; - case kExternalUnsignedShortArray: - return kExternalUnsignedShortArrayMapRootIndex; - case kExternalIntArray: - return kExternalIntArrayMapRootIndex; - case kExternalUnsignedIntArray: - return kExternalUnsignedIntArrayMapRootIndex; - case kExternalFloatArray: - return kExternalFloatArrayMapRootIndex; - case kExternalDoubleArray: - return kExternalDoubleArrayMapRootIndex; - case kExternalPixelArray: - return kExternalPixelArrayMapRootIndex; +#define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ + case kExternal##Type##Array: \ + return kExternal##Type##ArrayMapRootIndex; + + TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) +#undef ARRAY_TYPE_TO_ROOT_INDEX + default: UNREACHABLE(); return kUndefinedValueRootIndex; @@ -3646,24 +3615,13 @@ Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { Heap::RootListIndex Heap::RootIndexForFixedTypedArray( ExternalArrayType array_type) { switch (array_type) { - case kExternalByteArray: - return kFixedInt8ArrayMapRootIndex; - case kExternalUnsignedByteArray: - return kFixedUint8ArrayMapRootIndex; - case kExternalShortArray: - return kFixedInt16ArrayMapRootIndex; - case kExternalUnsignedShortArray: - return kFixedUint16ArrayMapRootIndex; - case kExternalIntArray: - return kFixedInt32ArrayMapRootIndex; - case kExternalUnsignedIntArray: - return kFixedUint32ArrayMapRootIndex; - case kExternalFloatArray: - return kFixedFloat32ArrayMapRootIndex; - case kExternalDoubleArray: - return kFixedFloat64ArrayMapRootIndex; - case kExternalPixelArray: - return kFixedUint8ClampedArrayMapRootIndex; +#define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ + case kExternal##Type##Array: \ + return kFixed##Type##ArrayMapRootIndex; + + TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) +#undef ARRAY_TYPE_TO_ROOT_INDEX + default: UNREACHABLE(); return kUndefinedValueRootIndex; @@ -3674,24 +3632,13 @@ Heap::RootListIndex Heap::RootIndexForFixedTypedArray( Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( ElementsKind elementsKind) { switch (elementsKind) { - case EXTERNAL_BYTE_ELEMENTS: - return kEmptyExternalByteArrayRootIndex; - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - return kEmptyExternalUnsignedByteArrayRootIndex; - case EXTERNAL_SHORT_ELEMENTS: - return kEmptyExternalShortArrayRootIndex; - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - return kEmptyExternalUnsignedShortArrayRootIndex; - case EXTERNAL_INT_ELEMENTS: - return kEmptyExternalIntArrayRootIndex; - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - return kEmptyExternalUnsignedIntArrayRootIndex; - case EXTERNAL_FLOAT_ELEMENTS: - return kEmptyExternalFloatArrayRootIndex; - case EXTERNAL_DOUBLE_ELEMENTS: - return kEmptyExternalDoubleArrayRootIndex; - case EXTERNAL_PIXEL_ELEMENTS: - return kEmptyExternalPixelArrayRootIndex; +#define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + return kEmptyExternal##Type##ArrayRootIndex; + + TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX) +#undef ELEMENT_KIND_TO_ROOT_INDEX + default: UNREACHABLE(); return kUndefinedValueRootIndex; @@ -3933,42 +3880,15 @@ static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, ElementsKind* element_kind) { switch (array_type) { - case kExternalUnsignedByteArray: - *element_size = 1; - *element_kind = UINT8_ELEMENTS; - return; - case kExternalByteArray: - *element_size = 1; - *element_kind = INT8_ELEMENTS; - return; - case kExternalUnsignedShortArray: - *element_size = 2; - *element_kind = UINT16_ELEMENTS; - return; - case kExternalShortArray: - *element_size = 2; - *element_kind = INT16_ELEMENTS; - return; - case kExternalUnsignedIntArray: - *element_size = 4; - *element_kind = UINT32_ELEMENTS; - return; - case kExternalIntArray: - *element_size = 4; - *element_kind = INT32_ELEMENTS; - return; - case kExternalFloatArray: - *element_size = 4; - *element_kind = FLOAT32_ELEMENTS; - return; - case kExternalDoubleArray: - *element_size = 8; - *element_kind = FLOAT64_ELEMENTS; - return; - case kExternalPixelArray: - *element_size = 1; - *element_kind = UINT8_CLAMPED_ELEMENTS; +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case kExternal##Type##Array: \ + *element_size = size; \ + *element_kind = TYPE##_ELEMENTS; \ return; + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + default: *element_size = 0; // Bogus *element_kind = UINT8_ELEMENTS; // Bogus @@ -3986,7 +3906,7 @@ MaybeObject* Heap::AllocateFixedTypedArray(int length, int size = OBJECT_POINTER_ALIGN( length * element_size + FixedTypedArrayBase::kDataOffset); #ifndef V8_HOST_ARCH_64_BIT - if (array_type == kExternalDoubleArray) { + if (array_type == kExternalFloat64Array) { size += kPointerSize; } #endif @@ -3996,7 +3916,7 @@ MaybeObject* Heap::AllocateFixedTypedArray(int length, MaybeObject* maybe_object = AllocateRaw(size, space, OLD_DATA_SPACE); if (!maybe_object->To(&object)) return maybe_object; - if (array_type == kExternalDoubleArray) { + if (array_type == kExternalFloat64Array) { object = EnsureDoubleAligned(this, object, size); } diff --git a/src/heap.h b/src/heap.h index 22e252ce2..c9101bea9 100644 --- a/src/heap.h +++ b/src/heap.h @@ -133,29 +133,29 @@ namespace internal { V(Map, short_external_ascii_string_map, ShortExternalAsciiStringMap) \ V(Map, undetectable_string_map, UndetectableStringMap) \ V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ - V(Map, external_byte_array_map, ExternalByteArrayMap) \ - V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ - V(Map, external_short_array_map, ExternalShortArrayMap) \ - V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ - V(Map, external_int_array_map, ExternalIntArrayMap) \ - V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ - V(Map, external_float_array_map, ExternalFloatArrayMap) \ - V(Map, external_double_array_map, ExternalDoubleArrayMap) \ - V(Map, external_pixel_array_map, ExternalPixelArrayMap) \ - V(ExternalArray, empty_external_byte_array, \ - EmptyExternalByteArray) \ - V(ExternalArray, empty_external_unsigned_byte_array, \ - EmptyExternalUnsignedByteArray) \ - V(ExternalArray, empty_external_short_array, EmptyExternalShortArray) \ - V(ExternalArray, empty_external_unsigned_short_array, \ - EmptyExternalUnsignedShortArray) \ - V(ExternalArray, empty_external_int_array, EmptyExternalIntArray) \ - V(ExternalArray, empty_external_unsigned_int_array, \ - EmptyExternalUnsignedIntArray) \ - V(ExternalArray, empty_external_float_array, EmptyExternalFloatArray) \ - V(ExternalArray, empty_external_double_array, EmptyExternalDoubleArray) \ - V(ExternalArray, empty_external_pixel_array, \ - EmptyExternalPixelArray) \ + V(Map, external_int8_array_map, ExternalInt8ArrayMap) \ + V(Map, external_uint8_array_map, ExternalUint8ArrayMap) \ + V(Map, external_int16_array_map, ExternalInt16ArrayMap) \ + V(Map, external_uint16_array_map, ExternalUint16ArrayMap) \ + V(Map, external_int32_array_map, ExternalInt32ArrayMap) \ + V(Map, external_uint32_array_map, ExternalUint32ArrayMap) \ + V(Map, external_float32_array_map, ExternalFloat32ArrayMap) \ + V(Map, external_float64_array_map, ExternalFloat64ArrayMap) \ + V(Map, external_uint8_clamped_array_map, ExternalUint8ClampedArrayMap) \ + V(ExternalArray, empty_external_int8_array, \ + EmptyExternalInt8Array) \ + V(ExternalArray, empty_external_uint8_array, \ + EmptyExternalUint8Array) \ + V(ExternalArray, empty_external_int16_array, EmptyExternalInt16Array) \ + V(ExternalArray, empty_external_uint16_array, \ + EmptyExternalUint16Array) \ + V(ExternalArray, empty_external_int32_array, EmptyExternalInt32Array) \ + V(ExternalArray, empty_external_uint32_array, \ + EmptyExternalUint32Array) \ + V(ExternalArray, empty_external_float32_array, EmptyExternalFloat32Array) \ + V(ExternalArray, empty_external_float64_array, EmptyExternalFloat64Array) \ + V(ExternalArray, empty_external_uint8_clamped_array, \ + EmptyExternalUint8ClampedArray) \ V(Map, fixed_uint8_array_map, FixedUint8ArrayMap) \ V(Map, fixed_int8_array_map, FixedInt8ArrayMap) \ V(Map, fixed_uint16_array_map, FixedUint16ArrayMap) \ diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 78ea1dee1..89399db8e 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2909,14 +2909,14 @@ Range* HLoadNamedField::InferRange(Zone* zone) { Range* HLoadKeyed::InferRange(Zone* zone) { switch (elements_kind()) { - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: return new(zone) Range(kMinInt8, kMaxInt8); - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: return new(zone) Range(kMinUInt8, kMaxUInt8); - case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: return new(zone) Range(kMinInt16, kMaxInt16); - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: return new(zone) Range(kMinUInt16, kMaxUInt16); default: return HValue::InferRange(zone); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 45ee69582..dbf61835f 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -574,7 +574,7 @@ class HValue : public ZoneObject { kIsDead, // Instructions that are allowed to produce full range unsigned integer // values are marked with kUint32 flag. If arithmetic shift or a load from - // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag + // EXTERNAL_UINT32_ELEMENTS array is not marked with this flag // it will deoptimize if result does not fit into signed integer range. // HGraph::ComputeSafeUint32Operations is responsible for setting this // flag. @@ -6426,8 +6426,8 @@ class HLoadKeyed V8_FINAL SetGVNFlag(kDependsOnDoubleArrayElements); } } else { - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || - elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || + elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT32_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { set_representation(Representation::Double()); @@ -6848,8 +6848,8 @@ class HStoreKeyed V8_FINAL } // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. - if ((elements_kind >= EXTERNAL_BYTE_ELEMENTS && - elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) || + if ((elements_kind >= EXTERNAL_INT8_ELEMENTS && + elements_kind <= EXTERNAL_UINT32_ELEMENTS) || (elements_kind >= UINT8_ELEMENTS && elements_kind <= INT32_ELEMENTS)) { SetFlag(kTruncatingToInt32); diff --git a/src/hydrogen-uint32-analysis.cc b/src/hydrogen-uint32-analysis.cc index 8de887d6f..63b1de697 100644 --- a/src/hydrogen-uint32-analysis.cc +++ b/src/hydrogen-uint32-analysis.cc @@ -54,9 +54,9 @@ bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) { // operation. if (store->value() == val) { // Clamping or a conversion to double should have beed inserted. - ASSERT(store->elements_kind() != EXTERNAL_PIXEL_ELEMENTS); - ASSERT(store->elements_kind() != EXTERNAL_FLOAT_ELEMENTS); - ASSERT(store->elements_kind() != EXTERNAL_DOUBLE_ELEMENTS); + ASSERT(store->elements_kind() != EXTERNAL_UINT8_CLAMPED_ELEMENTS); + ASSERT(store->elements_kind() != EXTERNAL_FLOAT32_ELEMENTS); + ASSERT(store->elements_kind() != EXTERNAL_FLOAT64_ELEMENTS); return true; } } diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 37826a7cb..3698a322c 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -2318,7 +2318,7 @@ HInstruction* HGraphBuilder::AddElementAccess( LoadKeyedHoleMode load_mode) { if (is_store) { ASSERT(val != NULL); - if (elements_kind == EXTERNAL_PIXEL_ELEMENTS || + if (elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS || elements_kind == UINT8_CLAMPED_ELEMENTS) { val = Add(val); } @@ -2333,7 +2333,7 @@ HInstruction* HGraphBuilder::AddElementAccess( HLoadKeyed* load = Add( elements, checked_key, dependency, elements_kind, load_mode); if (FLAG_opt_safe_uint32_operations && - (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS || + (elements_kind == EXTERNAL_UINT32_ELEMENTS || elements_kind == UINT32_ELEMENTS)) { graph()->RecordUint32Instruction(load); } @@ -8392,7 +8392,7 @@ void HOptimizedGraphBuilder::VisitTypedArrayInitialize( BuildArrayBufferViewInitialization( obj, buffer, byte_offset, byte_length); - ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. + ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 973afee65..dd5465398 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3409,7 +3409,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { elements_kind, 0, instr->additional_index())); - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { if (CpuFeatures::IsSupported(SSE2)) { CpuFeatureScope scope(masm(), SSE2); @@ -3419,7 +3419,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { } else { X87Mov(ToX87Register(instr->result()), operand, kX87FloatOperand); } - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { if (CpuFeatures::IsSupported(SSE2)) { CpuFeatureScope scope(masm(), SSE2); @@ -3430,29 +3430,29 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { } else { Register result(ToRegister(instr->result())); switch (elements_kind) { - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: case INT8_ELEMENTS: __ movsx_b(result, operand); break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ movzx_b(result, operand); break; - case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: case INT16_ELEMENTS: __ movsx_w(result, operand); break; - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: __ movzx_w(result, operand); break; - case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: case INT32_ELEMENTS: __ mov(result, operand); break; - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: __ mov(result, operand); if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { @@ -3460,8 +3460,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { DeoptimizeIf(negative, instr->environment()); } break; - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_SMI_ELEMENTS: @@ -4539,7 +4539,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { elements_kind, 0, instr->additional_index())); - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { if (CpuFeatures::IsSafeForSnapshot(SSE2)) { CpuFeatureScope scope(masm(), SSE2); @@ -4550,7 +4550,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { __ fld(0); __ fstp_s(operand); } - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { if (CpuFeatures::IsSafeForSnapshot(SSE2)) { CpuFeatureScope scope(masm(), SSE2); @@ -4561,28 +4561,28 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { } else { Register value = ToRegister(instr->value()); switch (elements_kind) { - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: case UINT8_ELEMENTS: case INT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ mov_b(operand, value); break; - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: case INT16_ELEMENTS: __ mov_w(operand, value); break; - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: case INT32_ELEMENTS: __ mov(operand, value); break; - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_SMI_ELEMENTS: diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 6452831f1..95b810f66 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -2139,7 +2139,7 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { DefineAsRegister(result); bool can_deoptimize = instr->RequiresHoleCheck() || - (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); + (elements_kind == EXTERNAL_UINT32_ELEMENTS); // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. return can_deoptimize ? AssignEnvironment(result) : result; @@ -2162,9 +2162,9 @@ LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { // Determine if we need a byte register in this case for the value. bool val_is_fixed_register = - elements_kind == EXTERNAL_BYTE_ELEMENTS || - elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || - elements_kind == EXTERNAL_PIXEL_ELEMENTS || + elements_kind == EXTERNAL_INT8_ELEMENTS || + elements_kind == EXTERNAL_UINT8_ELEMENTS || + elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS || elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS || elements_kind == UINT8_CLAMPED_ELEMENTS; diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 2b509a05c..bea6381d0 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -1605,9 +1605,9 @@ inline static bool ExternalArrayOpRequiresTemp( // an index cannot fold the scale operation into a load and need an extra // temp register to do the work. return key_representation.IsSmi() && - (elements_kind == EXTERNAL_BYTE_ELEMENTS || - elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || - elements_kind == EXTERNAL_PIXEL_ELEMENTS || + (elements_kind == EXTERNAL_INT8_ELEMENTS || + elements_kind == EXTERNAL_UINT8_ELEMENTS || + elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS || elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS || elements_kind == UINT8_CLAMPED_ELEMENTS); diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index f74f6c0a7..547980657 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3075,9 +3075,9 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag : 0; - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS || - elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { int base_offset = (instr->additional_index() << element_size_shift) + additional_offset; @@ -3088,7 +3088,7 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { __ sll(scratch0(), key, shift_size); __ Addu(scratch0(), scratch0(), external_pointer); } - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { __ lwc1(result, MemOperand(scratch0(), base_offset)); __ cvt_d_s(result, result); @@ -3102,29 +3102,29 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { element_size_shift, shift_size, instr->additional_index(), additional_offset); switch (elements_kind) { - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: case INT8_ELEMENTS: __ lb(result, mem_operand); break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ lbu(result, mem_operand); break; - case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: case INT16_ELEMENTS: __ lh(result, mem_operand); break; - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: __ lhu(result, mem_operand); break; - case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: case INT32_ELEMENTS: __ lw(result, mem_operand); break; - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: __ lw(result, mem_operand); if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { @@ -3134,8 +3134,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { break; case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_ELEMENTS: case FAST_SMI_ELEMENTS: @@ -4200,9 +4200,9 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag : 0; - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS || - elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { int base_offset = (instr->additional_index() << element_size_shift) + additional_offset; @@ -4220,7 +4220,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { __ Addu(address, external_pointer, address); } - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { __ cvt_s_d(double_scratch0(), value); __ swc1(double_scratch0(), MemOperand(address, base_offset)); @@ -4234,30 +4234,30 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { element_size_shift, shift_size, instr->additional_index(), additional_offset); switch (elements_kind) { - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: case INT8_ELEMENTS: __ sb(value, mem_operand); break; - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case INT16_ELEMENTS: case UINT16_ELEMENTS: __ sh(value, mem_operand); break; - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case INT32_ELEMENTS: case UINT32_ELEMENTS: __ sw(value, mem_operand); break; case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_ELEMENTS: case FAST_SMI_ELEMENTS: diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index e051cba88..d14b11f0e 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -2034,7 +2034,7 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. bool can_deoptimize = instr->RequiresHoleCheck() || - elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS || + elements_kind == EXTERNAL_UINT32_ELEMENTS || elements_kind == UINT32_ELEMENTS; return can_deoptimize ? AssignEnvironment(result) : result; } diff --git a/src/objects-debug.cc b/src/objects-debug.cc index 414f2bcf1..e33b46be7 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -104,61 +104,18 @@ void HeapObject::HeapObjectVerify() { case FREE_SPACE_TYPE: FreeSpace::cast(this)->FreeSpaceVerify(); break; - case EXTERNAL_PIXEL_ARRAY_TYPE: - ExternalPixelArray::cast(this)->ExternalPixelArrayVerify(); - break; - case EXTERNAL_BYTE_ARRAY_TYPE: - ExternalByteArray::cast(this)->ExternalByteArrayVerify(); - break; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayVerify(); - break; - case EXTERNAL_SHORT_ARRAY_TYPE: - ExternalShortArray::cast(this)->ExternalShortArrayVerify(); - break; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - ExternalUnsignedShortArray::cast(this)-> - ExternalUnsignedShortArrayVerify(); - break; - case EXTERNAL_INT_ARRAY_TYPE: - ExternalIntArray::cast(this)->ExternalIntArrayVerify(); - break; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayVerify(); - break; - case EXTERNAL_FLOAT_ARRAY_TYPE: - ExternalFloatArray::cast(this)->ExternalFloatArrayVerify(); - break; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - ExternalDoubleArray::cast(this)->ExternalDoubleArrayVerify(); - break; - case FIXED_UINT8_ARRAY_TYPE: - FixedUint8Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_INT8_ARRAY_TYPE: - FixedInt8Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_UINT16_ARRAY_TYPE: - FixedUint16Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_INT16_ARRAY_TYPE: - FixedInt16Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_UINT32_ARRAY_TYPE: - FixedUint32Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_INT32_ARRAY_TYPE: - FixedInt32Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_FLOAT32_ARRAY_TYPE: - FixedFloat32Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_FLOAT64_ARRAY_TYPE: - FixedFloat64Array::cast(this)->FixedTypedArrayVerify(); - break; - case FIXED_UINT8_CLAMPED_ARRAY_TYPE: - FixedUint8ClampedArray::cast(this)->FixedTypedArrayVerify(); + +#define VERIFY_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + External##Type##Array::cast(this)->External##Type##ArrayVerify(); \ + break; \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + Fixed##Type##Array::cast(this)->FixedTypedArrayVerify(); \ break; + + TYPED_ARRAYS(VERIFY_TYPED_ARRAY) +#undef VERIFY_TYPED_ARRAY + case CODE_TYPE: Code::cast(this)->CodeVerify(); break; @@ -289,49 +246,13 @@ void FreeSpace::FreeSpaceVerify() { } -void ExternalPixelArray::ExternalPixelArrayVerify() { - CHECK(IsExternalPixelArray()); -} - - -void ExternalByteArray::ExternalByteArrayVerify() { - CHECK(IsExternalByteArray()); -} - - -void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { - CHECK(IsExternalUnsignedByteArray()); -} - - -void ExternalShortArray::ExternalShortArrayVerify() { - CHECK(IsExternalShortArray()); -} - - -void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { - CHECK(IsExternalUnsignedShortArray()); -} - - -void ExternalIntArray::ExternalIntArrayVerify() { - CHECK(IsExternalIntArray()); -} - - -void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { - CHECK(IsExternalUnsignedIntArray()); -} - - -void ExternalFloatArray::ExternalFloatArrayVerify() { - CHECK(IsExternalFloatArray()); -} - +#define EXTERNAL_ARRAY_VERIFY(Type, type, TYPE, ctype, size) \ + void External##Type##Array::External##Type##ArrayVerify() { \ + CHECK(IsExternal##Type##Array()); \ + } -void ExternalDoubleArray::ExternalDoubleArrayVerify() { - CHECK(IsExternalDoubleArray()); -} +TYPED_ARRAYS(EXTERNAL_ARRAY_VERIFY) +#undef EXTERNAL_ARRAY_VERIFY template @@ -1114,25 +1035,14 @@ void JSObject::IncrementSpillStatistics(SpillInformation* info) { info->number_of_fast_unused_elements_ += holes; break; } - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: { - info->number_of_objects_with_fast_elements_++; + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + { info->number_of_objects_with_fast_elements_++; FixedArrayBase* e = FixedArrayBase::cast(elements()); info->number_of_fast_used_elements_ += e->length(); break; diff --git a/src/objects-inl.h b/src/objects-inl.h index 8802d2f61..f86e84780 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -602,9 +602,6 @@ bool Object::IsFiller() { } -TYPE_CHECKER(ExternalPixelArray, EXTERNAL_PIXEL_ARRAY_TYPE) - - bool Object::IsExternalArray() { if (!Object::IsHeapObject()) return false; @@ -615,14 +612,12 @@ bool Object::IsExternalArray() { } -TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) -TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) -TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) -TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) -TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) -TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) -TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) -TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) +#define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype, size) \ + TYPE_CHECKER(External##Type##Array, EXTERNAL_##TYPE##_ARRAY_TYPE) \ + TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE) + +TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER) +#undef TYPED_ARRAY_TYPE_CHECKER bool Object::IsFixedTypedArrayBase() { @@ -635,17 +630,6 @@ bool Object::IsFixedTypedArrayBase() { } -TYPE_CHECKER(FixedUint8Array, FIXED_UINT8_ARRAY_TYPE) -TYPE_CHECKER(FixedInt8Array, FIXED_INT8_ARRAY_TYPE) -TYPE_CHECKER(FixedUint16Array, FIXED_UINT16_ARRAY_TYPE) -TYPE_CHECKER(FixedInt16Array, FIXED_INT16_ARRAY_TYPE) -TYPE_CHECKER(FixedUint32Array, FIXED_UINT32_ARRAY_TYPE) -TYPE_CHECKER(FixedInt32Array, FIXED_INT32_ARRAY_TYPE) -TYPE_CHECKER(FixedFloat32Array, FIXED_FLOAT32_ARRAY_TYPE) -TYPE_CHECKER(FixedFloat64Array, FIXED_FLOAT64_ARRAY_TYPE) -TYPE_CHECKER(FixedUint8ClampedArray, FIXED_UINT8_CLAMPED_ARRAY_TYPE) - - bool MaybeObject::IsFailure() { return HAS_FAILURE_TAG(this); } @@ -2850,15 +2834,15 @@ CAST_ACCESSOR(Foreign) CAST_ACCESSOR(ByteArray) CAST_ACCESSOR(FreeSpace) CAST_ACCESSOR(ExternalArray) -CAST_ACCESSOR(ExternalByteArray) -CAST_ACCESSOR(ExternalUnsignedByteArray) -CAST_ACCESSOR(ExternalShortArray) -CAST_ACCESSOR(ExternalUnsignedShortArray) -CAST_ACCESSOR(ExternalIntArray) -CAST_ACCESSOR(ExternalUnsignedIntArray) -CAST_ACCESSOR(ExternalFloatArray) -CAST_ACCESSOR(ExternalDoubleArray) -CAST_ACCESSOR(ExternalPixelArray) +CAST_ACCESSOR(ExternalInt8Array) +CAST_ACCESSOR(ExternalUint8Array) +CAST_ACCESSOR(ExternalInt16Array) +CAST_ACCESSOR(ExternalUint16Array) +CAST_ACCESSOR(ExternalInt32Array) +CAST_ACCESSOR(ExternalUint32Array) +CAST_ACCESSOR(ExternalFloat32Array) +CAST_ACCESSOR(ExternalFloat64Array) +CAST_ACCESSOR(ExternalUint8ClampedArray) CAST_ACCESSOR(Struct) CAST_ACCESSOR(AccessorInfo) @@ -3457,26 +3441,26 @@ Address ByteArray::GetDataStartAddress() { } -uint8_t* ExternalPixelArray::external_pixel_pointer() { +uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { return reinterpret_cast(external_pointer()); } -uint8_t ExternalPixelArray::get_scalar(int index) { +uint8_t ExternalUint8ClampedArray::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); - uint8_t* ptr = external_pixel_pointer(); + uint8_t* ptr = external_uint8_clamped_pointer(); return ptr[index]; } -MaybeObject* ExternalPixelArray::get(int index) { +MaybeObject* ExternalUint8ClampedArray::get(int index) { return Smi::FromInt(static_cast(get_scalar(index))); } -void ExternalPixelArray::set(int index, uint8_t value) { +void ExternalUint8ClampedArray::set(int index, uint8_t value) { ASSERT((index >= 0) && (index < this->length())); - uint8_t* ptr = external_pixel_pointer(); + uint8_t* ptr = external_uint8_clamped_pointer(); ptr[index] = value; } @@ -3493,152 +3477,152 @@ void ExternalArray::set_external_pointer(void* value, WriteBarrierMode mode) { } -int8_t ExternalByteArray::get_scalar(int index) { +int8_t ExternalInt8Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); int8_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalByteArray::get(int index) { +MaybeObject* ExternalInt8Array::get(int index) { return Smi::FromInt(static_cast(get_scalar(index))); } -void ExternalByteArray::set(int index, int8_t value) { +void ExternalInt8Array::set(int index, int8_t value) { ASSERT((index >= 0) && (index < this->length())); int8_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -uint8_t ExternalUnsignedByteArray::get_scalar(int index) { +uint8_t ExternalUint8Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); uint8_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalUnsignedByteArray::get(int index) { +MaybeObject* ExternalUint8Array::get(int index) { return Smi::FromInt(static_cast(get_scalar(index))); } -void ExternalUnsignedByteArray::set(int index, uint8_t value) { +void ExternalUint8Array::set(int index, uint8_t value) { ASSERT((index >= 0) && (index < this->length())); uint8_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -int16_t ExternalShortArray::get_scalar(int index) { +int16_t ExternalInt16Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); int16_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalShortArray::get(int index) { +MaybeObject* ExternalInt16Array::get(int index) { return Smi::FromInt(static_cast(get_scalar(index))); } -void ExternalShortArray::set(int index, int16_t value) { +void ExternalInt16Array::set(int index, int16_t value) { ASSERT((index >= 0) && (index < this->length())); int16_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -uint16_t ExternalUnsignedShortArray::get_scalar(int index) { +uint16_t ExternalUint16Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); uint16_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalUnsignedShortArray::get(int index) { +MaybeObject* ExternalUint16Array::get(int index) { return Smi::FromInt(static_cast(get_scalar(index))); } -void ExternalUnsignedShortArray::set(int index, uint16_t value) { +void ExternalUint16Array::set(int index, uint16_t value) { ASSERT((index >= 0) && (index < this->length())); uint16_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -int32_t ExternalIntArray::get_scalar(int index) { +int32_t ExternalInt32Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); int32_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalIntArray::get(int index) { +MaybeObject* ExternalInt32Array::get(int index) { return GetHeap()->NumberFromInt32(get_scalar(index)); } -void ExternalIntArray::set(int index, int32_t value) { +void ExternalInt32Array::set(int index, int32_t value) { ASSERT((index >= 0) && (index < this->length())); int32_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -uint32_t ExternalUnsignedIntArray::get_scalar(int index) { +uint32_t ExternalUint32Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); uint32_t* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalUnsignedIntArray::get(int index) { +MaybeObject* ExternalUint32Array::get(int index) { return GetHeap()->NumberFromUint32(get_scalar(index)); } -void ExternalUnsignedIntArray::set(int index, uint32_t value) { +void ExternalUint32Array::set(int index, uint32_t value) { ASSERT((index >= 0) && (index < this->length())); uint32_t* ptr = static_cast(external_pointer()); ptr[index] = value; } -float ExternalFloatArray::get_scalar(int index) { +float ExternalFloat32Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); float* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalFloatArray::get(int index) { +MaybeObject* ExternalFloat32Array::get(int index) { return GetHeap()->NumberFromDouble(get_scalar(index)); } -void ExternalFloatArray::set(int index, float value) { +void ExternalFloat32Array::set(int index, float value) { ASSERT((index >= 0) && (index < this->length())); float* ptr = static_cast(external_pointer()); ptr[index] = value; } -double ExternalDoubleArray::get_scalar(int index) { +double ExternalFloat64Array::get_scalar(int index) { ASSERT((index >= 0) && (index < this->length())); double* ptr = static_cast(external_pointer()); return ptr[index]; } -MaybeObject* ExternalDoubleArray::get(int index) { +MaybeObject* ExternalFloat64Array::get(int index) { return GetHeap()->NumberFromDouble(get_scalar(index)); } -void ExternalDoubleArray::set(int index, double value) { +void ExternalFloat64Array::set(int index, double value) { ASSERT((index >= 0) && (index < this->length())); double* ptr = static_cast(external_pointer()); ptr[index] = value; @@ -5990,29 +5974,18 @@ bool JSObject::HasExternalArrayElements() { } -#define EXTERNAL_ELEMENTS_CHECK(name, type) \ -bool JSObject::HasExternal##name##Elements() { \ - HeapObject* array = elements(); \ - ASSERT(array != NULL); \ - if (!array->IsHeapObject()) \ - return false; \ - return array->map()->instance_type() == type; \ +#define EXTERNAL_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ +bool JSObject::HasExternal##Type##Elements() { \ + HeapObject* array = elements(); \ + ASSERT(array != NULL); \ + if (!array->IsHeapObject()) \ + return false; \ + return array->map()->instance_type() == EXTERNAL_##TYPE##_ARRAY_TYPE; \ } +TYPED_ARRAYS(EXTERNAL_ELEMENTS_CHECK) -EXTERNAL_ELEMENTS_CHECK(Byte, EXTERNAL_BYTE_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(UnsignedByte, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(Short, EXTERNAL_SHORT_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(UnsignedShort, - EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(UnsignedInt, - EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(Float, - EXTERNAL_FLOAT_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(Double, - EXTERNAL_DOUBLE_ARRAY_TYPE) -EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) +#undef EXTERNAL_ELEMENTS_CHECK bool JSObject::HasFixedTypedArrayElements() { diff --git a/src/objects-printer.cc b/src/objects-printer.cc index ef98d57d8..909d8f742 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -107,52 +107,22 @@ void HeapObject::HeapObjectPrint(FILE* out) { case FREE_SPACE_TYPE: FreeSpace::cast(this)->FreeSpacePrint(out); break; - case EXTERNAL_PIXEL_ARRAY_TYPE: - ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(out); - break; - case EXTERNAL_BYTE_ARRAY_TYPE: - ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); - break; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - ExternalUnsignedByteArray::cast(this) - ->ExternalUnsignedByteArrayPrint(out); - break; - case EXTERNAL_SHORT_ARRAY_TYPE: - ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); - break; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - ExternalUnsignedShortArray::cast(this) - ->ExternalUnsignedShortArrayPrint(out); - break; - case EXTERNAL_INT_ARRAY_TYPE: - ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); - break; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); - break; - case EXTERNAL_FLOAT_ARRAY_TYPE: - ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); - break; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - ExternalDoubleArray::cast(this)->ExternalDoubleArrayPrint(out); + +#define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + External##Type##Array::cast(this)->External##Type##ArrayPrint(out); \ break; -#define PRINT_FIXED_TYPED_ARRAY(Type) \ + + TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY) +#undef PRINT_EXTERNAL_ARRAY + +#define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ case Fixed##Type##Array::kInstanceType: \ Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out); \ break; - PRINT_FIXED_TYPED_ARRAY(Uint8) - PRINT_FIXED_TYPED_ARRAY(Int8) - PRINT_FIXED_TYPED_ARRAY(Uint16) - PRINT_FIXED_TYPED_ARRAY(Int16) - PRINT_FIXED_TYPED_ARRAY(Uint32) - PRINT_FIXED_TYPED_ARRAY(Int32) - PRINT_FIXED_TYPED_ARRAY(Float32) - PRINT_FIXED_TYPED_ARRAY(Float64) - PRINT_FIXED_TYPED_ARRAY(Uint8Clamped) - -#undef PPINT_FIXED_TYPED_ARRAY - + TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY) +#undef PRINT_FIXED_TYPED_ARRAY case FILLER_TYPE: PrintF(out, "filler"); @@ -259,49 +229,15 @@ void FreeSpace::FreeSpacePrint(FILE* out) { } -void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) { - PrintF(out, "external pixel array"); -} - - -void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { - PrintF(out, "external byte array"); -} - - -void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { - PrintF(out, "external unsigned byte array"); -} - - -void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { - PrintF(out, "external short array"); -} - - -void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { - PrintF(out, "external unsigned short array"); -} - - -void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { - PrintF(out, "external int array"); -} - - -void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { - PrintF(out, "external unsigned int array"); -} - +#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \ + void External##Type##Array::External##Type##ArrayPrint(FILE* out) { \ + PrintF(out, "external " #type " array"); \ + } -void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { - PrintF(out, "external float array"); -} +TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER) +#undef EXTERNAL_ARRAY_PRINTER -void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { - PrintF(out, "external double array"); -} template void FixedTypedArray::FixedTypedArrayPrint(FILE* out) { @@ -412,18 +348,18 @@ void JSObject::PrintElements(FILE* out) { break; \ } - PRINT_ELEMENTS(EXTERNAL_PIXEL_ELEMENTS, ExternalPixelArray) - PRINT_ELEMENTS(EXTERNAL_BYTE_ELEMENTS, ExternalByteArray) - PRINT_ELEMENTS(EXTERNAL_UNSIGNED_BYTE_ELEMENTS, - ExternalUnsignedByteArray) - PRINT_ELEMENTS(EXTERNAL_SHORT_ELEMENTS, ExternalShortArray) - PRINT_ELEMENTS(EXTERNAL_UNSIGNED_SHORT_ELEMENTS, - ExternalUnsignedShortArray) - PRINT_ELEMENTS(EXTERNAL_INT_ELEMENTS, ExternalIntArray) - PRINT_ELEMENTS(EXTERNAL_UNSIGNED_INT_ELEMENTS, - ExternalUnsignedIntArray) - PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT_ELEMENTS, ExternalFloatArray) - PRINT_DOUBLE_ELEMENTS(EXTERNAL_DOUBLE_ELEMENTS, ExternalDoubleArray) + PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray) + PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array) + PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS, + ExternalUint8Array) + PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array) + PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS, + ExternalUint16Array) + PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array) + PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS, + ExternalUint32Array) + PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array) + PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array) PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array) diff --git a/src/objects-visiting.cc b/src/objects-visiting.cc index e268768cc..16c51676b 100644 --- a/src/objects-visiting.cc +++ b/src/objects-visiting.cc @@ -171,18 +171,14 @@ StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( return kVisitJSFunction; case HEAP_NUMBER_TYPE: - case EXTERNAL_PIXEL_ARRAY_TYPE: - case EXTERNAL_BYTE_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - case EXTERNAL_SHORT_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - case EXTERNAL_INT_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - case EXTERNAL_FLOAT_ARRAY_TYPE: - case EXTERNAL_DOUBLE_ARRAY_TYPE: +#define EXTERNAL_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: + + TYPED_ARRAYS(EXTERNAL_ARRAY_CASE) return GetVisitorIdForSize(kVisitDataObject, kVisitDataObjectGeneric, instance_size); +#undef EXTERNAL_ARRAY_CASE case FIXED_UINT8_ARRAY_TYPE: case FIXED_INT8_ARRAY_TYPE: diff --git a/src/objects.cc b/src/objects.cc index 261b38535..731d602b4 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -1641,46 +1641,19 @@ void HeapObject::HeapObjectShortPrint(StringStream* accumulator) { case FREE_SPACE_TYPE: accumulator->Add("", FreeSpace::cast(this)->Size()); break; - case EXTERNAL_PIXEL_ARRAY_TYPE: - accumulator->Add("", - ExternalPixelArray::cast(this)->length()); - break; - case EXTERNAL_BYTE_ARRAY_TYPE: - accumulator->Add("", - ExternalByteArray::cast(this)->length()); - break; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - accumulator->Add("", - ExternalUnsignedByteArray::cast(this)->length()); - break; - case EXTERNAL_SHORT_ARRAY_TYPE: - accumulator->Add("", - ExternalShortArray::cast(this)->length()); - break; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - accumulator->Add("", - ExternalUnsignedShortArray::cast(this)->length()); - break; - case EXTERNAL_INT_ARRAY_TYPE: - accumulator->Add("", - ExternalIntArray::cast(this)->length()); - break; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - accumulator->Add("", - ExternalUnsignedIntArray::cast(this)->length()); - break; - case EXTERNAL_FLOAT_ARRAY_TYPE: - accumulator->Add("", - ExternalFloatArray::cast(this)->length()); - break; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - accumulator->Add("", - ExternalDoubleArray::cast(this)->length()); - break; - case FIXED_UINT8_ARRAY_TYPE: - accumulator->Add("", - FixedUint8Array::cast(this)->length()); +#define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + accumulator->Add("", \ + External##Type##Array::cast(this)->length()); \ + break; \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + accumulator->Add("", \ + Fixed##Type##Array::cast(this)->length()); \ break; + + TYPED_ARRAYS(TYPED_ARRAY_SHORT_PRINT) +#undef TYPED_ARRAY_SHORT_PRINT + case SHARED_FUNCTION_INFO_TYPE: { SharedFunctionInfo* shared = SharedFunctionInfo::cast(this); SmartArrayPointer debug_name = @@ -1857,29 +1830,21 @@ void HeapObject::IterateBody(InstanceType type, int object_size, case SYMBOL_TYPE: Symbol::BodyDescriptor::IterateBody(this, v); break; + case HEAP_NUMBER_TYPE: case FILLER_TYPE: case BYTE_ARRAY_TYPE: case FREE_SPACE_TYPE: - case EXTERNAL_PIXEL_ARRAY_TYPE: - case EXTERNAL_BYTE_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - case EXTERNAL_SHORT_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - case EXTERNAL_INT_ARRAY_TYPE: - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - case EXTERNAL_FLOAT_ARRAY_TYPE: - case EXTERNAL_DOUBLE_ARRAY_TYPE: - case FIXED_INT8_ARRAY_TYPE: - case FIXED_UINT8_ARRAY_TYPE: - case FIXED_INT16_ARRAY_TYPE: - case FIXED_UINT16_ARRAY_TYPE: - case FIXED_INT32_ARRAY_TYPE: - case FIXED_UINT32_ARRAY_TYPE: - case FIXED_FLOAT32_ARRAY_TYPE: - case FIXED_FLOAT64_ARRAY_TYPE: - case FIXED_UINT8_CLAMPED_ARRAY_TYPE: break; + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + break; + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + case SHARED_FUNCTION_INFO_TYPE: { SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); break; @@ -5382,28 +5347,18 @@ bool JSObject::ReferencesObject(Object* obj) { // Check if the object is among the indexed properties. ElementsKind kind = GetElementsKind(); switch (kind) { - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + // Raw pixels and external arrays do not reference other + // objects. +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + break; + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: - // Raw pixels and external arrays do not reference other - // objects. break; case FAST_SMI_ELEMENTS: case FAST_HOLEY_SMI_ELEMENTS: @@ -5883,26 +5838,17 @@ Handle JSObjectWalkVisitor::StructureWalk( case NON_STRICT_ARGUMENTS_ELEMENTS: UNIMPLEMENTED(); break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: // No contained objects, nothing to do. break; } @@ -6131,26 +6077,16 @@ void JSObject::DefineElementAccessor(Handle object, case FAST_HOLEY_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE // Ignore getters and setters on pixel and external array elements. return; + case DICTIONARY_ELEMENTS: if (UpdateGetterSetterInDictionary(object->element_dictionary(), index, @@ -6598,27 +6534,17 @@ Handle JSObject::SetAccessor(Handle object, case FAST_HOLEY_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: break; - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE // Ignore getters and setters on pixel and external array // elements. return factory->undefined_value(); + case DICTIONARY_ELEMENTS: break; case NON_STRICT_ARGUMENTS_ELEMENTS: @@ -12720,95 +12646,23 @@ Handle JSObject::SetElementWithoutInterceptor( case FAST_HOLEY_DOUBLE_ELEMENTS: return SetFastDoubleElement(object, index, value, strict_mode, check_prototype); - case EXTERNAL_PIXEL_ELEMENTS: { - ExternalPixelArray* pixels = ExternalPixelArray::cast(object->elements()); - return handle(pixels->SetValue(index, *value), isolate); - } - case EXTERNAL_BYTE_ELEMENTS: { - Handle array( - ExternalByteArray::cast(object->elements())); - return ExternalByteArray::SetValue(array, index, value); - } - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { - Handle array( - ExternalUnsignedByteArray::cast(object->elements())); - return ExternalUnsignedByteArray::SetValue(array, index, value); - } - case EXTERNAL_SHORT_ELEMENTS: { - Handle array(ExternalShortArray::cast( - object->elements())); - return ExternalShortArray::SetValue(array, index, value); - } - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { - Handle array( - ExternalUnsignedShortArray::cast(object->elements())); - return ExternalUnsignedShortArray::SetValue(array, index, value); - } - case EXTERNAL_INT_ELEMENTS: { - Handle array( - ExternalIntArray::cast(object->elements())); - return ExternalIntArray::SetValue(array, index, value); - } - case EXTERNAL_UNSIGNED_INT_ELEMENTS: { - Handle array( - ExternalUnsignedIntArray::cast(object->elements())); - return ExternalUnsignedIntArray::SetValue(array, index, value); - } - case EXTERNAL_FLOAT_ELEMENTS: { - Handle array( - ExternalFloatArray::cast(object->elements())); - return ExternalFloatArray::SetValue(array, index, value); - } - case EXTERNAL_DOUBLE_ELEMENTS: { - Handle array( - ExternalDoubleArray::cast(object->elements())); - return ExternalDoubleArray::SetValue(array, index, value); - } - case UINT8_ELEMENTS: { - Handle array( - FixedUint8Array::cast(object->elements())); - return FixedUint8Array::SetValue(array, index, value); - } - case UINT8_CLAMPED_ELEMENTS: { - Handle array( - FixedUint8ClampedArray::cast(object->elements())); - return FixedUint8ClampedArray::SetValue(array, index, value); - } - case INT8_ELEMENTS: { - Handle array( - FixedInt8Array::cast(object->elements())); - return FixedInt8Array::SetValue(array, index, value); - } - case UINT16_ELEMENTS: { - Handle array( - FixedUint16Array::cast(object->elements())); - return FixedUint16Array::SetValue(array, index, value); - } - case INT16_ELEMENTS: { - Handle array( - FixedInt16Array::cast(object->elements())); - return FixedInt16Array::SetValue(array, index, value); - } - case UINT32_ELEMENTS: { - Handle array( - FixedUint32Array::cast(object->elements())); - return FixedUint32Array::SetValue(array, index, value); - } - case INT32_ELEMENTS: { - Handle array( - FixedInt32Array::cast(object->elements())); - return FixedInt32Array::SetValue(array, index, value); - } - case FLOAT32_ELEMENTS: { - Handle array( - FixedFloat32Array::cast(object->elements())); - return FixedFloat32Array::SetValue(array, index, value); - } - case FLOAT64_ELEMENTS: { - Handle array( - FixedFloat64Array::cast(object->elements())); - return FixedFloat64Array::SetValue(array, index, value); + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: { \ + Handle array( \ + External##Type##Array::cast(object->elements())); \ + return External##Type##Array::SetValue(array, index, value); \ + } \ + case TYPE##_ELEMENTS: { \ + Handle array( \ + Fixed##Type##Array::cast(object->elements())); \ + return Fixed##Type##Array::SetValue(array, index, value); \ } + + TYPED_ARRAYS(TYPED_ARRAY_CASE) + +#undef TYPED_ARRAY_CASE + case DICTIONARY_ELEMENTS: return SetDictionaryElement(object, index, value, attributes, strict_mode, check_prototype, @@ -13211,24 +13065,14 @@ void JSObject::GetElementsCapacityAndUsage(int* capacity, int* used) { } break; } - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: { + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + { // External arrays are considered 100% used. FixedArrayBase* external_array = FixedArrayBase::cast(elements()); *capacity = external_array->length(); @@ -13724,34 +13568,14 @@ int JSObject::GetLocalElementKeys(FixedArray* storage, ASSERT(!storage || storage->length() >= counter); break; } - case EXTERNAL_PIXEL_ELEMENTS: { - int length = ExternalPixelArray::cast(elements())->length(); - while (counter < length) { - if (storage != NULL) { - storage->set(counter, Smi::FromInt(counter)); - } - counter++; - } - ASSERT(!storage || storage->length() >= counter); - break; - } - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: { + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + { int length = FixedArrayBase::cast(elements())->length(); while (counter < length) { if (storage != NULL) { @@ -13762,6 +13586,7 @@ int JSObject::GetLocalElementKeys(FixedArray* storage, ASSERT(!storage || storage->length() >= counter); break; } + case DICTIONARY_ELEMENTS: { if (storage != NULL) { element_dictionary()->CopyKeysTo(storage, @@ -14665,24 +14490,13 @@ Handle JSObject::PrepareElementsForSort(Handle object, ExternalArrayType JSTypedArray::type() { switch (elements()->map()->instance_type()) { - case EXTERNAL_BYTE_ARRAY_TYPE: - return kExternalByteArray; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - return kExternalUnsignedByteArray; - case EXTERNAL_SHORT_ARRAY_TYPE: - return kExternalShortArray; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - return kExternalUnsignedShortArray; - case EXTERNAL_INT_ARRAY_TYPE: - return kExternalIntArray; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - return kExternalUnsignedIntArray; - case EXTERNAL_FLOAT_ARRAY_TYPE: - return kExternalFloatArray; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - return kExternalDoubleArray; - case EXTERNAL_PIXEL_ARRAY_TYPE: - return kExternalPixelArray; +#define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + return kExternal##Type##Array; + + TYPED_ARRAYS(INSTANCE_TYPE_TO_ARRAY_TYPE) +#undef INSTANCE_TYPE_TO_ARRAY_TYPE + default: return static_cast(-1); } @@ -14691,24 +14505,13 @@ ExternalArrayType JSTypedArray::type() { size_t JSTypedArray::element_size() { switch (elements()->map()->instance_type()) { - case EXTERNAL_BYTE_ARRAY_TYPE: - return 1; - case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: - return 1; - case EXTERNAL_SHORT_ARRAY_TYPE: - return 2; - case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: - return 2; - case EXTERNAL_INT_ARRAY_TYPE: - return 4; - case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: - return 4; - case EXTERNAL_FLOAT_ARRAY_TYPE: - return 4; - case EXTERNAL_DOUBLE_ARRAY_TYPE: - return 8; - case EXTERNAL_PIXEL_ARRAY_TYPE: - return 1; +#define INSTANCE_TYPE_TO_ELEMENT_SIZE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ARRAY_TYPE: \ + return size; + + TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE) +#undef INSTANCE_TYPE_TO_ELEMENT_SIZE + default: UNREACHABLE(); return 0; @@ -14716,7 +14519,7 @@ size_t JSTypedArray::element_size() { } -Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { +Object* ExternalUint8ClampedArray::SetValue(uint32_t index, Object* value) { uint8_t clamped_value = 0; if (index < static_cast(length())) { if (value->IsSmi()) { @@ -14751,6 +14554,14 @@ Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { } +Handle ExternalUint8ClampedArray::SetValue( + Handle array, + uint32_t index, + Handle value) { + return Handle(array->SetValue(index, *value), array->GetIsolate()); +} + + template static MaybeObject* ExternalArrayIntSetter(Heap* heap, ExternalArrayClass* receiver, @@ -14775,7 +14586,7 @@ static MaybeObject* ExternalArrayIntSetter(Heap* heap, } -Handle ExternalByteArray::SetValue(Handle array, +Handle ExternalInt8Array::SetValue(Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14784,14 +14595,14 @@ Handle ExternalByteArray::SetValue(Handle array, } -MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) { - return ExternalArrayIntSetter +MaybeObject* ExternalInt8Array::SetValue(uint32_t index, Object* value) { + return ExternalArrayIntSetter (GetHeap(), this, index, value); } -Handle ExternalUnsignedByteArray::SetValue( - Handle array, +Handle ExternalUint8Array::SetValue( + Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14800,15 +14611,15 @@ Handle ExternalUnsignedByteArray::SetValue( } -MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index, +MaybeObject* ExternalUint8Array::SetValue(uint32_t index, Object* value) { - return ExternalArrayIntSetter + return ExternalArrayIntSetter (GetHeap(), this, index, value); } -Handle ExternalShortArray::SetValue( - Handle array, +Handle ExternalInt16Array::SetValue( + Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14817,15 +14628,15 @@ Handle ExternalShortArray::SetValue( } -MaybeObject* ExternalShortArray::SetValue(uint32_t index, +MaybeObject* ExternalInt16Array::SetValue(uint32_t index, Object* value) { - return ExternalArrayIntSetter + return ExternalArrayIntSetter (GetHeap(), this, index, value); } -Handle ExternalUnsignedShortArray::SetValue( - Handle array, +Handle ExternalUint16Array::SetValue( + Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14834,14 +14645,14 @@ Handle ExternalUnsignedShortArray::SetValue( } -MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index, +MaybeObject* ExternalUint16Array::SetValue(uint32_t index, Object* value) { - return ExternalArrayIntSetter + return ExternalArrayIntSetter (GetHeap(), this, index, value); } -Handle ExternalIntArray::SetValue(Handle array, +Handle ExternalInt32Array::SetValue(Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14850,14 +14661,14 @@ Handle ExternalIntArray::SetValue(Handle array, } -MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) { - return ExternalArrayIntSetter +MaybeObject* ExternalInt32Array::SetValue(uint32_t index, Object* value) { + return ExternalArrayIntSetter (GetHeap(), this, index, value); } -Handle ExternalUnsignedIntArray::SetValue( - Handle array, +Handle ExternalUint32Array::SetValue( + Handle array, uint32_t index, Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), @@ -14866,7 +14677,7 @@ Handle ExternalUnsignedIntArray::SetValue( } -MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) { +MaybeObject* ExternalUint32Array::SetValue(uint32_t index, Object* value) { uint32_t cast_value = 0; Heap* heap = GetHeap(); if (index < static_cast(length())) { @@ -14887,16 +14698,17 @@ MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) { } -Handle ExternalFloatArray::SetValue(Handle array, - uint32_t index, - Handle value) { +Handle ExternalFloat32Array::SetValue( + Handle array, + uint32_t index, + Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), array->SetValue(index, *value), Object); } -MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) { +MaybeObject* ExternalFloat32Array::SetValue(uint32_t index, Object* value) { float cast_value = static_cast(OS::nan_value()); Heap* heap = GetHeap(); if (index < static_cast(length())) { @@ -14917,16 +14729,17 @@ MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) { } -Handle ExternalDoubleArray::SetValue(Handle array, - uint32_t index, - Handle value) { +Handle ExternalFloat64Array::SetValue( + Handle array, + uint32_t index, + Handle value) { CALL_HEAP_FUNCTION(array->GetIsolate(), array->SetValue(index, *value), Object); } -MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) { +MaybeObject* ExternalFloat64Array::SetValue(uint32_t index, Object* value) { double double_value = OS::nan_value(); Heap* heap = GetHeap(); if (index < static_cast(length())) { diff --git a/src/objects.h b/src/objects.h index 186c8668b..c6f36bf63 100644 --- a/src/objects.h +++ b/src/objects.h @@ -96,14 +96,14 @@ // - TransitionArray // - FixedDoubleArray // - ExternalArray -// - ExternalPixelArray -// - ExternalByteArray -// - ExternalUnsignedByteArray -// - ExternalShortArray -// - ExternalUnsignedShortArray -// - ExternalIntArray -// - ExternalUnsignedIntArray -// - ExternalFloatArray +// - ExternalUint8ClampedArray +// - ExternalInt8Array +// - ExternalUint8Array +// - ExternalInt16Array +// - ExternalUint16Array +// - ExternalInt32Array +// - ExternalUint32Array +// - ExternalFloat32Array // - Name // - String // - SeqString @@ -377,15 +377,15 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; /* Note: the order of these external array */ \ /* types is relied upon in */ \ /* Object::IsExternalArray(). */ \ - V(EXTERNAL_BYTE_ARRAY_TYPE) \ - V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ - V(EXTERNAL_SHORT_ARRAY_TYPE) \ - V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ - V(EXTERNAL_INT_ARRAY_TYPE) \ - V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ - V(EXTERNAL_FLOAT_ARRAY_TYPE) \ - V(EXTERNAL_DOUBLE_ARRAY_TYPE) \ - V(EXTERNAL_PIXEL_ARRAY_TYPE) \ + V(EXTERNAL_INT8_ARRAY_TYPE) \ + V(EXTERNAL_UINT8_ARRAY_TYPE) \ + V(EXTERNAL_INT16_ARRAY_TYPE) \ + V(EXTERNAL_UINT16_ARRAY_TYPE) \ + V(EXTERNAL_INT32_ARRAY_TYPE) \ + V(EXTERNAL_UINT32_ARRAY_TYPE) \ + V(EXTERNAL_FLOAT32_ARRAY_TYPE) \ + V(EXTERNAL_FLOAT64_ARRAY_TYPE) \ + V(EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE) \ \ V(FIXED_INT8_ARRAY_TYPE) \ V(FIXED_UINT8_ARRAY_TYPE) \ @@ -722,15 +722,16 @@ enum InstanceType { FOREIGN_TYPE, BYTE_ARRAY_TYPE, FREE_SPACE_TYPE, - EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE - EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, - EXTERNAL_SHORT_ARRAY_TYPE, - EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, - EXTERNAL_INT_ARRAY_TYPE, - EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, - EXTERNAL_FLOAT_ARRAY_TYPE, - EXTERNAL_DOUBLE_ARRAY_TYPE, - EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE + + EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE + EXTERNAL_UINT8_ARRAY_TYPE, + EXTERNAL_INT16_ARRAY_TYPE, + EXTERNAL_UINT16_ARRAY_TYPE, + EXTERNAL_INT32_ARRAY_TYPE, + EXTERNAL_UINT32_ARRAY_TYPE, + EXTERNAL_FLOAT32_ARRAY_TYPE, + EXTERNAL_FLOAT64_ARRAY_TYPE, + EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE FIXED_UINT8_ARRAY_TYPE, @@ -817,8 +818,8 @@ enum InstanceType { LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, FIRST_NONSTRING_TYPE = SYMBOL_TYPE, // Boundaries for testing for an external array. - FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, - LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, + FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_INT8_ARRAY_TYPE, + LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // Boundaries for testing for a fixed typed array. FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, @@ -1005,15 +1006,15 @@ class MaybeObject BASE_EMBEDDED { V(Symbol) \ \ V(ExternalArray) \ - V(ExternalByteArray) \ - V(ExternalUnsignedByteArray) \ - V(ExternalShortArray) \ - V(ExternalUnsignedShortArray) \ - V(ExternalIntArray) \ - V(ExternalUnsignedIntArray) \ - V(ExternalFloatArray) \ - V(ExternalDoubleArray) \ - V(ExternalPixelArray) \ + V(ExternalInt8Array) \ + V(ExternalUint8Array) \ + V(ExternalInt16Array) \ + V(ExternalUint16Array) \ + V(ExternalInt32Array) \ + V(ExternalUint32Array) \ + V(ExternalFloat32Array) \ + V(ExternalFloat64Array) \ + V(ExternalUint8ClampedArray) \ V(FixedTypedArrayBase) \ V(FixedUint8Array) \ V(FixedInt8Array) \ @@ -2143,16 +2144,16 @@ class JSObject: public JSReceiver { inline bool HasNonStrictArgumentsElements(); inline bool HasDictionaryElements(); - inline bool HasExternalPixelElements(); + inline bool HasExternalUint8ClampedElements(); inline bool HasExternalArrayElements(); - inline bool HasExternalByteElements(); - inline bool HasExternalUnsignedByteElements(); - inline bool HasExternalShortElements(); - inline bool HasExternalUnsignedShortElements(); - inline bool HasExternalIntElements(); - inline bool HasExternalUnsignedIntElements(); - inline bool HasExternalFloatElements(); - inline bool HasExternalDoubleElements(); + inline bool HasExternalInt8Elements(); + inline bool HasExternalUint8Elements(); + inline bool HasExternalInt16Elements(); + inline bool HasExternalUint16Elements(); + inline bool HasExternalInt32Elements(); + inline bool HasExternalUint32Elements(); + inline bool HasExternalFloat32Elements(); + inline bool HasExternalFloat64Elements(); inline bool HasFixedTypedArrayElements(); @@ -4568,6 +4569,20 @@ class FreeSpace: public HeapObject { }; +// V has parameters (Type, type, TYPE, C type, element_size) +#define TYPED_ARRAYS(V) \ + V(Uint8, uint8, UINT8, uint8_t, 1) \ + V(Int8, int8, INT8, int8_t, 1) \ + V(Uint16, uint16, UINT16, uint16_t, 2) \ + V(Int16, int16, INT16, int16_t, 2) \ + V(Uint32, uint32, UINT32, uint32_t, 4) \ + V(Int32, int32, INT32, int32_t, 4) \ + V(Float32, float32, FLOAT32, float, 4) \ + V(Float64, float64, FLOAT64, double, 8) \ + V(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t, 1) + + + // An ExternalArray represents a fixed-size array of primitive values // which live outside the JavaScript heap. Its subclasses are used to // implement the CanvasArray types being defined in the WebGL @@ -4604,7 +4619,7 @@ class ExternalArray: public FixedArrayBase { }; -// A ExternalPixelArray represents a fixed-size byte array with special +// A ExternalUint8ClampedArray represents a fixed-size byte array with special // semantics used for implementing the CanvasPixelArray object. Please see the // specification at: @@ -4612,9 +4627,9 @@ class ExternalArray: public FixedArrayBase { // multipage/the-canvas-element.html#canvaspixelarray // In particular, write access clamps the value written to 0 or 255 if the // value written is outside this range. -class ExternalPixelArray: public ExternalArray { +class ExternalUint8ClampedArray: public ExternalArray { public: - inline uint8_t* external_pixel_pointer(); + inline uint8_t* external_uint8_clamped_pointer(); // Setter and getter. inline uint8_t get_scalar(int index); @@ -4625,26 +4640,30 @@ class ExternalPixelArray: public ExternalArray { // undefined and clamps the converted value between 0 and 255. Object* SetValue(uint32_t index, Object* value); + static Handle SetValue(Handle array, + uint32_t index, + Handle value); + // Casting. - static inline ExternalPixelArray* cast(Object* obj); + static inline ExternalUint8ClampedArray* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalPixelArray) - DECLARE_VERIFIER(ExternalPixelArray) + DECLARE_PRINTER(ExternalUint8ClampedArray) + DECLARE_VERIFIER(ExternalUint8ClampedArray) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalPixelArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8ClampedArray); }; -class ExternalByteArray: public ExternalArray { +class ExternalInt8Array: public ExternalArray { public: // Setter and getter. inline int8_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, int8_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4653,25 +4672,25 @@ class ExternalByteArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalByteArray* cast(Object* obj); + static inline ExternalInt8Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalByteArray) - DECLARE_VERIFIER(ExternalByteArray) + DECLARE_PRINTER(ExternalInt8Array) + DECLARE_VERIFIER(ExternalInt8Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalByteArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt8Array); }; -class ExternalUnsignedByteArray: public ExternalArray { +class ExternalUint8Array: public ExternalArray { public: // Setter and getter. inline uint8_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, uint8_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4680,25 +4699,25 @@ class ExternalUnsignedByteArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalUnsignedByteArray* cast(Object* obj); + static inline ExternalUint8Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalUnsignedByteArray) - DECLARE_VERIFIER(ExternalUnsignedByteArray) + DECLARE_PRINTER(ExternalUint8Array) + DECLARE_VERIFIER(ExternalUint8Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedByteArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8Array); }; -class ExternalShortArray: public ExternalArray { +class ExternalInt16Array: public ExternalArray { public: // Setter and getter. inline int16_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, int16_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4707,25 +4726,25 @@ class ExternalShortArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalShortArray* cast(Object* obj); + static inline ExternalInt16Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalShortArray) - DECLARE_VERIFIER(ExternalShortArray) + DECLARE_PRINTER(ExternalInt16Array) + DECLARE_VERIFIER(ExternalInt16Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalShortArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt16Array); }; -class ExternalUnsignedShortArray: public ExternalArray { +class ExternalUint16Array: public ExternalArray { public: // Setter and getter. inline uint16_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, uint16_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4734,25 +4753,25 @@ class ExternalUnsignedShortArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalUnsignedShortArray* cast(Object* obj); + static inline ExternalUint16Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalUnsignedShortArray) - DECLARE_VERIFIER(ExternalUnsignedShortArray) + DECLARE_PRINTER(ExternalUint16Array) + DECLARE_VERIFIER(ExternalUint16Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedShortArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint16Array); }; -class ExternalIntArray: public ExternalArray { +class ExternalInt32Array: public ExternalArray { public: // Setter and getter. inline int32_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, int32_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4761,25 +4780,25 @@ class ExternalIntArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalIntArray* cast(Object* obj); + static inline ExternalInt32Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalIntArray) - DECLARE_VERIFIER(ExternalIntArray) + DECLARE_PRINTER(ExternalInt32Array) + DECLARE_VERIFIER(ExternalInt32Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalIntArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt32Array); }; -class ExternalUnsignedIntArray: public ExternalArray { +class ExternalUint32Array: public ExternalArray { public: // Setter and getter. inline uint32_t get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, uint32_t value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4788,25 +4807,25 @@ class ExternalUnsignedIntArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalUnsignedIntArray* cast(Object* obj); + static inline ExternalUint32Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalUnsignedIntArray) - DECLARE_VERIFIER(ExternalUnsignedIntArray) + DECLARE_PRINTER(ExternalUint32Array) + DECLARE_VERIFIER(ExternalUint32Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedIntArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint32Array); }; -class ExternalFloatArray: public ExternalArray { +class ExternalFloat32Array: public ExternalArray { public: // Setter and getter. inline float get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, float value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4815,25 +4834,25 @@ class ExternalFloatArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalFloatArray* cast(Object* obj); + static inline ExternalFloat32Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalFloatArray) - DECLARE_VERIFIER(ExternalFloatArray) + DECLARE_PRINTER(ExternalFloat32Array) + DECLARE_VERIFIER(ExternalFloat32Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat32Array); }; -class ExternalDoubleArray: public ExternalArray { +class ExternalFloat64Array: public ExternalArray { public: // Setter and getter. inline double get_scalar(int index); MUST_USE_RESULT inline MaybeObject* get(int index); inline void set(int index, double value); - static Handle SetValue(Handle array, + static Handle SetValue(Handle array, uint32_t index, Handle value); @@ -4842,14 +4861,14 @@ class ExternalDoubleArray: public ExternalArray { MUST_USE_RESULT MaybeObject* SetValue(uint32_t index, Object* value); // Casting. - static inline ExternalDoubleArray* cast(Object* obj); + static inline ExternalFloat64Array* cast(Object* obj); // Dispatched behavior. - DECLARE_PRINTER(ExternalDoubleArray) - DECLARE_VERIFIER(ExternalDoubleArray) + DECLARE_PRINTER(ExternalFloat64Array) + DECLARE_VERIFIER(ExternalFloat64Array) private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalDoubleArray); + DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); }; @@ -4899,7 +4918,7 @@ class FixedTypedArray: public FixedTypedArrayBase { DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); }; -#define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType) \ +#define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ class Type##ArrayTraits { \ public: \ typedef elementType ElementType; \ @@ -4911,15 +4930,7 @@ class FixedTypedArray: public FixedTypedArrayBase { \ typedef FixedTypedArray Fixed##Type##Array; -FIXED_TYPED_ARRAY_TRAITS(Uint8, uint8, UINT8, uint8_t) -FIXED_TYPED_ARRAY_TRAITS(Int8, int8, INT8, int8_t) -FIXED_TYPED_ARRAY_TRAITS(Uint16, uint16, UINT16, uint16_t) -FIXED_TYPED_ARRAY_TRAITS(Int16, int16, INT16, int16_t) -FIXED_TYPED_ARRAY_TRAITS(Uint32, uint32, UINT32, uint32_t) -FIXED_TYPED_ARRAY_TRAITS(Int32, int32, INT32, int32_t) -FIXED_TYPED_ARRAY_TRAITS(Float32, float32, FLOAT32, float) -FIXED_TYPED_ARRAY_TRAITS(Float64, float64, FLOAT64, double) -FIXED_TYPED_ARRAY_TRAITS(Uint8Clamped, uint8_clamped, UINT8_CLAMPED, uint8_t) +TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) #undef FIXED_TYPED_ARRAY_TRAITS diff --git a/src/runtime.cc b/src/runtime.cc index 3fb886c14..a2bc186d6 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -870,42 +870,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { void Runtime::ArrayIdToTypeAndSize( int arrayId, ExternalArrayType* array_type, size_t* element_size) { switch (arrayId) { - case ARRAY_ID_UINT8: - *array_type = kExternalUnsignedByteArray; - *element_size = 1; - break; - case ARRAY_ID_INT8: - *array_type = kExternalByteArray; - *element_size = 1; - break; - case ARRAY_ID_UINT16: - *array_type = kExternalUnsignedShortArray; - *element_size = 2; - break; - case ARRAY_ID_INT16: - *array_type = kExternalShortArray; - *element_size = 2; - break; - case ARRAY_ID_UINT32: - *array_type = kExternalUnsignedIntArray; - *element_size = 4; - break; - case ARRAY_ID_INT32: - *array_type = kExternalIntArray; - *element_size = 4; - break; - case ARRAY_ID_FLOAT32: - *array_type = kExternalFloatArray; - *element_size = 4; - break; - case ARRAY_ID_FLOAT64: - *array_type = kExternalDoubleArray; - *element_size = 8; - break; - case ARRAY_ID_UINT8C: - *array_type = kExternalPixelArray; - *element_size = 1; +#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \ + case ARRAY_ID_##TYPE: \ + *array_type = kExternal##Type##Array; \ + *element_size = size; \ break; + + TYPED_ARRAYS(ARRAY_ID_CASE) +#undef ARRAY_ID_CASE + default: UNREACHABLE(); } @@ -927,7 +900,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { holder->SetInternalField(i, Smi::FromInt(0)); } - ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. + ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); @@ -979,7 +952,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { holder->SetInternalField(i, Smi::FromInt(0)); } - ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. + ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); @@ -10003,24 +9976,12 @@ static uint32_t EstimateElementCount(Handle array) { break; } case NON_STRICT_ARGUMENTS_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: - case UINT8_ELEMENTS: - case INT8_ELEMENTS: - case UINT16_ELEMENTS: - case INT16_ELEMENTS: - case UINT32_ELEMENTS: - case INT32_ELEMENTS: - case FLOAT32_ELEMENTS: - case FLOAT64_ELEMENTS: - case UINT8_CLAMPED_ELEMENTS: +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: \ + case TYPE##_ELEMENTS: \ + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE // External arrays are always dense. return length; } @@ -10128,51 +10089,16 @@ static void CollectElementIndices(Handle object, default: { int dense_elements_length; switch (kind) { - case EXTERNAL_PIXEL_ELEMENTS: { - dense_elements_length = - ExternalPixelArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_BYTE_ELEMENTS: { - dense_elements_length = - ExternalByteArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { - dense_elements_length = - ExternalUnsignedByteArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_SHORT_ELEMENTS: { - dense_elements_length = - ExternalShortArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { - dense_elements_length = - ExternalUnsignedShortArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_INT_ELEMENTS: { - dense_elements_length = - ExternalIntArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_UNSIGNED_INT_ELEMENTS: { - dense_elements_length = - ExternalUnsignedIntArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_FLOAT_ELEMENTS: { - dense_elements_length = - ExternalFloatArray::cast(object->elements())->length(); - break; - } - case EXTERNAL_DOUBLE_ELEMENTS: { - dense_elements_length = - ExternalDoubleArray::cast(object->elements())->length(); - break; +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case EXTERNAL_##TYPE##_ELEMENTS: { \ + dense_elements_length = \ + External##Type##Array::cast(object->elements())->length(); \ + break; \ } + + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + default: UNREACHABLE(); dense_elements_length = 0; @@ -10289,8 +10215,8 @@ static bool IterateElements(Isolate* isolate, } break; } - case EXTERNAL_PIXEL_ELEMENTS: { - Handle pixels(ExternalPixelArray::cast( + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: { + Handle pixels(ExternalUint8ClampedArray::cast( receiver->elements())); for (uint32_t j = 0; j < length; j++) { Handle e(Smi::FromInt(pixels->get_scalar(j)), isolate); @@ -10298,43 +10224,43 @@ static bool IterateElements(Isolate* isolate, } break; } - case EXTERNAL_BYTE_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_INT8_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, true, visitor); break; } - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_UINT8_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, true, visitor); break; } - case EXTERNAL_SHORT_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_INT16_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, true, visitor); break; } - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_UINT16_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, true, visitor); break; } - case EXTERNAL_INT_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_INT32_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, false, visitor); break; } - case EXTERNAL_UNSIGNED_INT_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_UINT32_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, true, false, visitor); break; } - case EXTERNAL_FLOAT_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_FLOAT32_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, false, false, visitor); break; } - case EXTERNAL_DOUBLE_ELEMENTS: { - IterateExternalArrayElements( + case EXTERNAL_FLOAT64_ELEMENTS: { + IterateExternalArrayElements( isolate, receiver, false, false, visitor); break; } @@ -14552,22 +14478,24 @@ ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(NonStrictArgumentsElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) -ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) // Properties test sitting with elements tests - not fooling anyone. ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION +#define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ + RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ + CONVERT_ARG_CHECKED(JSObject, obj, 0); \ + return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ + } + +TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) + +#undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION + + RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { SealHandleScope shs(isolate); ASSERT(args.length() == 2); diff --git a/src/runtime.h b/src/runtime.h index ec8970282..532066f63 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -461,16 +461,16 @@ namespace internal { F(HasFastHoleyElements, 1, 1) \ F(HasDictionaryElements, 1, 1) \ F(HasNonStrictArgumentsElements, 1, 1) \ - F(HasExternalPixelElements, 1, 1) \ + F(HasExternalUint8ClampedElements, 1, 1) \ F(HasExternalArrayElements, 1, 1) \ - F(HasExternalByteElements, 1, 1) \ - F(HasExternalUnsignedByteElements, 1, 1) \ - F(HasExternalShortElements, 1, 1) \ - F(HasExternalUnsignedShortElements, 1, 1) \ - F(HasExternalIntElements, 1, 1) \ - F(HasExternalUnsignedIntElements, 1, 1) \ - F(HasExternalFloatElements, 1, 1) \ - F(HasExternalDoubleElements, 1, 1) \ + F(HasExternalInt8Elements, 1, 1) \ + F(HasExternalUint8Elements, 1, 1) \ + F(HasExternalInt16Elements, 1, 1) \ + F(HasExternalUint16Elements, 1, 1) \ + F(HasExternalInt32Elements, 1, 1) \ + F(HasExternalUint32Elements, 1, 1) \ + F(HasExternalFloat32Elements, 1, 1) \ + F(HasExternalFloat64Elements, 1, 1) \ F(HasFastProperties, 1, 1) \ F(TransitionElementsKind, 2, 1) \ F(HaveSameMap, 2, 1) \ @@ -839,7 +839,7 @@ class Runtime : public AllStatic { ARRAY_ID_INT32 = 6, ARRAY_ID_FLOAT32 = 7, ARRAY_ID_FLOAT64 = 8, - ARRAY_ID_UINT8C = 9 + ARRAY_ID_UINT8_CLAMPED = 9 }; static void ArrayIdToTypeAndSize(int array_id, diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index fb6a7764d..17ded772b 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2903,8 +2903,9 @@ void LCodeGen::DoLoadExternalArrayPointer( LLoadExternalArrayPointer* instr) { Register result = ToRegister(instr->result()); Register input = ToRegister(instr->object()); - __ movp(result, FieldOperand(input, - ExternalPixelArray::kExternalPointerOffset)); + __ movp(result, + FieldOperand(input, + ExternalUint8ClampedArray::kExternalPointerOffset)); } @@ -2961,40 +2962,40 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { base_offset, instr->additional_index())); - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { XMMRegister result(ToDoubleRegister(instr->result())); __ movss(result, operand); __ cvtss2sd(result, result); - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { __ movsd(ToDoubleRegister(instr->result()), operand); } else { Register result(ToRegister(instr->result())); switch (elements_kind) { - case EXTERNAL_BYTE_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: case INT8_ELEMENTS: __ movsxbq(result, operand); break; - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: - case EXTERNAL_PIXEL_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ movzxbq(result, operand); break; - case EXTERNAL_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: case INT16_ELEMENTS: __ movsxwq(result, operand); break; - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case UINT16_ELEMENTS: __ movzxwq(result, operand); break; - case EXTERNAL_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: case INT32_ELEMENTS: __ movsxlq(result, operand); break; - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case UINT32_ELEMENTS: __ movl(result, operand); if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { @@ -3002,8 +3003,8 @@ void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { DeoptimizeIf(negative, instr->environment()); } break; - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_ELEMENTS: @@ -4153,39 +4154,39 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { base_offset, instr->additional_index())); - if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || + if (elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS) { XMMRegister value(ToDoubleRegister(instr->value())); __ cvtsd2ss(value, value); __ movss(operand, value); - } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS || + } else if (elements_kind == EXTERNAL_FLOAT64_ELEMENTS || elements_kind == FLOAT64_ELEMENTS) { __ movsd(operand, ToDoubleRegister(instr->value())); } else { Register value(ToRegister(instr->value())); switch (elements_kind) { - case EXTERNAL_PIXEL_ELEMENTS: - case EXTERNAL_BYTE_ELEMENTS: - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + case EXTERNAL_UINT8_CLAMPED_ELEMENTS: + case EXTERNAL_INT8_ELEMENTS: + case EXTERNAL_UINT8_ELEMENTS: case INT8_ELEMENTS: case UINT8_ELEMENTS: case UINT8_CLAMPED_ELEMENTS: __ movb(operand, value); break; - case EXTERNAL_SHORT_ELEMENTS: - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: + case EXTERNAL_INT16_ELEMENTS: + case EXTERNAL_UINT16_ELEMENTS: case INT16_ELEMENTS: case UINT16_ELEMENTS: __ movw(operand, value); break; - case EXTERNAL_INT_ELEMENTS: - case EXTERNAL_UNSIGNED_INT_ELEMENTS: + case EXTERNAL_INT32_ELEMENTS: + case EXTERNAL_UINT32_ELEMENTS: case INT32_ELEMENTS: case UINT32_ELEMENTS: __ movl(operand, value); break; - case EXTERNAL_FLOAT_ELEMENTS: - case EXTERNAL_DOUBLE_ELEMENTS: + case EXTERNAL_FLOAT32_ELEMENTS: + case EXTERNAL_FLOAT64_ELEMENTS: case FLOAT32_ELEMENTS: case FLOAT64_ELEMENTS: case FAST_ELEMENTS: diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 656a256f2..493650328 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -2019,7 +2019,7 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { DefineAsRegister(result); bool can_deoptimize = instr->RequiresHoleCheck() || - (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) || + (elements_kind == EXTERNAL_UINT32_ELEMENTS) || (elements_kind == UINT32_ELEMENTS); // An unsigned int array load might overflow and cause a deopt, make sure it // has an environment. @@ -2080,8 +2080,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { (instr->is_external() && instr->elements()->representation().IsExternal())); bool val_is_temp_register = - elements_kind == EXTERNAL_PIXEL_ELEMENTS || - elements_kind == EXTERNAL_FLOAT_ELEMENTS || + elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS || + elements_kind == EXTERNAL_FLOAT32_ELEMENTS || elements_kind == FLOAT32_ELEMENTS; LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) : UseRegister(instr->value()); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 715c41a18..c0ba7fd39 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -15705,10 +15705,10 @@ THREADED_TEST(PixelArray) { v8::HandleScope scope(context->GetIsolate()); const int kElementCount = 260; uint8_t* pixel_data = reinterpret_cast(malloc(kElementCount)); - i::Handle pixels = - i::Handle::cast( + i::Handle pixels = + i::Handle::cast( factory->NewExternalArray(kElementCount, - v8::kExternalPixelArray, + v8::kExternalUint8ClampedArray, pixel_data)); // Force GC to trigger verification. CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); @@ -16119,10 +16119,10 @@ THREADED_TEST(PixelArrayWithInterceptor) { v8::HandleScope scope(isolate); const int kElementCount = 260; uint8_t* pixel_data = reinterpret_cast(malloc(kElementCount)); - i::Handle pixels = - i::Handle::cast( + i::Handle pixels = + i::Handle::cast( factory->NewExternalArray(kElementCount, - v8::kExternalPixelArray, + v8::kExternalUint8ClampedArray, pixel_data)); for (int i = 0; i < kElementCount; i++) { pixels->set(i, i % 256); @@ -16150,21 +16150,21 @@ THREADED_TEST(PixelArrayWithInterceptor) { static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { switch (array_type) { - case v8::kExternalByteArray: - case v8::kExternalUnsignedByteArray: - case v8::kExternalPixelArray: + case v8::kExternalInt8Array: + case v8::kExternalUint8Array: + case v8::kExternalUint8ClampedArray: return 1; break; - case v8::kExternalShortArray: - case v8::kExternalUnsignedShortArray: + case v8::kExternalInt16Array: + case v8::kExternalUint16Array: return 2; break; - case v8::kExternalIntArray: - case v8::kExternalUnsignedIntArray: - case v8::kExternalFloatArray: + case v8::kExternalInt32Array: + case v8::kExternalUint32Array: + case v8::kExternalFloat32Array: return 4; break; - case v8::kExternalDoubleArray: + case v8::kExternalFloat64Array: return 8; break; default: @@ -16326,8 +16326,8 @@ static void ObjectWithExternalArrayTestHelper( "}" "ext_array[7];"); CHECK_EQ(0, result->Int32Value()); - if (array_type == v8::kExternalDoubleArray || - array_type == v8::kExternalFloatArray) { + if (array_type == v8::kExternalFloat64Array || + array_type == v8::kExternalFloat32Array) { CHECK_EQ(static_cast(i::OS::nan_value()), static_cast( jsobj->GetElement(isolate, 7)->ToObjectChecked()->Number())); @@ -16344,8 +16344,8 @@ static void ObjectWithExternalArrayTestHelper( static_cast( jsobj->GetElement(isolate, 6)->ToObjectChecked()->Number())); - if (array_type != v8::kExternalFloatArray && - array_type != v8::kExternalDoubleArray) { + if (array_type != v8::kExternalFloat32Array && + array_type != v8::kExternalFloat64Array) { // Though the specification doesn't state it, be explicit about // converting NaNs and +/-Infinity to zero. result = CompileRun("for (var i = 0; i < 8; i++) {" @@ -16366,7 +16366,7 @@ static void ObjectWithExternalArrayTestHelper( "}" "ext_array[5];"); int expected_value = - (array_type == v8::kExternalPixelArray) ? 255 : 0; + (array_type == v8::kExternalUint8ClampedArray) ? 255 : 0; CHECK_EQ(expected_value, result->Int32Value()); CheckElementValue(isolate, expected_value, jsobj, 5); @@ -16391,10 +16391,10 @@ static void ObjectWithExternalArrayTestHelper( "var source_data = [0.6, 10.6];" "var expected_results = [1, 11];"; bool is_unsigned = - (array_type == v8::kExternalUnsignedByteArray || - array_type == v8::kExternalUnsignedShortArray || - array_type == v8::kExternalUnsignedIntArray); - bool is_pixel_data = array_type == v8::kExternalPixelArray; + (array_type == v8::kExternalUint8Array || + array_type == v8::kExternalUint16Array || + array_type == v8::kExternalUint32Array); + bool is_pixel_data = array_type == v8::kExternalUint8ClampedArray; i::OS::SNPrintF(test_buf, "%s" @@ -16524,7 +16524,7 @@ static void FixedTypedArrayTestHelper( THREADED_TEST(FixedUint8Array) { FixedTypedArrayTestHelper( - v8::kExternalUnsignedByteArray, + v8::kExternalUint8Array, 0x0, 0xFF); } @@ -16532,56 +16532,56 @@ THREADED_TEST(FixedUint8Array) { THREADED_TEST(FixedUint8ClampedArray) { FixedTypedArrayTestHelper( - v8::kExternalPixelArray, + v8::kExternalUint8ClampedArray, 0x0, 0xFF); } THREADED_TEST(FixedInt8Array) { FixedTypedArrayTestHelper( - v8::kExternalByteArray, + v8::kExternalInt8Array, -0x80, 0x7F); } THREADED_TEST(FixedUint16Array) { FixedTypedArrayTestHelper( - v8::kExternalUnsignedShortArray, + v8::kExternalUint16Array, 0x0, 0xFFFF); } THREADED_TEST(FixedInt16Array) { FixedTypedArrayTestHelper( - v8::kExternalShortArray, + v8::kExternalInt16Array, -0x8000, 0x7FFF); } THREADED_TEST(FixedUint32Array) { FixedTypedArrayTestHelper( - v8::kExternalUnsignedIntArray, + v8::kExternalUint32Array, 0x0, UINT_MAX); } THREADED_TEST(FixedInt32Array) { FixedTypedArrayTestHelper( - v8::kExternalIntArray, + v8::kExternalInt32Array, INT_MIN, INT_MAX); } THREADED_TEST(FixedFloat32Array) { FixedTypedArrayTestHelper( - v8::kExternalFloatArray, + v8::kExternalFloat32Array, -500, 500); } THREADED_TEST(FixedFloat64Array) { FixedTypedArrayTestHelper( - v8::kExternalDoubleArray, + v8::kExternalFloat64Array, -500, 500); } @@ -16803,86 +16803,86 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, } -THREADED_TEST(ExternalByteArray) { - ExternalArrayTestHelper( - v8::kExternalByteArray, +THREADED_TEST(ExternalInt8Array) { + ExternalArrayTestHelper( + v8::kExternalInt8Array, -128, 127); } -THREADED_TEST(ExternalUnsignedByteArray) { - ExternalArrayTestHelper( - v8::kExternalUnsignedByteArray, +THREADED_TEST(ExternalUint8Array) { + ExternalArrayTestHelper( + v8::kExternalUint8Array, 0, 255); } -THREADED_TEST(ExternalPixelArray) { - ExternalArrayTestHelper( - v8::kExternalPixelArray, +THREADED_TEST(ExternalUint8ClampedArray) { + ExternalArrayTestHelper( + v8::kExternalUint8ClampedArray, 0, 255); } -THREADED_TEST(ExternalShortArray) { - ExternalArrayTestHelper( - v8::kExternalShortArray, +THREADED_TEST(ExternalInt16Array) { + ExternalArrayTestHelper( + v8::kExternalInt16Array, -32768, 32767); } -THREADED_TEST(ExternalUnsignedShortArray) { - ExternalArrayTestHelper( - v8::kExternalUnsignedShortArray, +THREADED_TEST(ExternalUint16Array) { + ExternalArrayTestHelper( + v8::kExternalUint16Array, 0, 65535); } -THREADED_TEST(ExternalIntArray) { - ExternalArrayTestHelper( - v8::kExternalIntArray, +THREADED_TEST(ExternalInt32Array) { + ExternalArrayTestHelper( + v8::kExternalInt32Array, INT_MIN, // -2147483648 INT_MAX); // 2147483647 } -THREADED_TEST(ExternalUnsignedIntArray) { - ExternalArrayTestHelper( - v8::kExternalUnsignedIntArray, +THREADED_TEST(ExternalUint32Array) { + ExternalArrayTestHelper( + v8::kExternalUint32Array, 0, UINT_MAX); // 4294967295 } -THREADED_TEST(ExternalFloatArray) { - ExternalArrayTestHelper( - v8::kExternalFloatArray, +THREADED_TEST(ExternalFloat32Array) { + ExternalArrayTestHelper( + v8::kExternalFloat32Array, -500, 500); } -THREADED_TEST(ExternalDoubleArray) { - ExternalArrayTestHelper( - v8::kExternalDoubleArray, +THREADED_TEST(ExternalFloat64Array) { + ExternalArrayTestHelper( + v8::kExternalFloat64Array, -500, 500); } THREADED_TEST(ExternalArrays) { - TestExternalByteArray(); - TestExternalUnsignedByteArray(); - TestExternalShortArray(); - TestExternalUnsignedShortArray(); - TestExternalIntArray(); - TestExternalUnsignedIntArray(); - TestExternalFloatArray(); + TestExternalInt8Array(); + TestExternalUint8Array(); + TestExternalInt16Array(); + TestExternalUint16Array(); + TestExternalInt32Array(); + TestExternalUint32Array(); + TestExternalFloat32Array(); } @@ -16905,15 +16905,15 @@ void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) { THREADED_TEST(ExternalArrayInfo) { - ExternalArrayInfoTestHelper(v8::kExternalByteArray); - ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); - ExternalArrayInfoTestHelper(v8::kExternalShortArray); - ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); - ExternalArrayInfoTestHelper(v8::kExternalIntArray); - ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); - ExternalArrayInfoTestHelper(v8::kExternalFloatArray); - ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); - ExternalArrayInfoTestHelper(v8::kExternalPixelArray); + ExternalArrayInfoTestHelper(v8::kExternalInt8Array); + ExternalArrayInfoTestHelper(v8::kExternalUint8Array); + ExternalArrayInfoTestHelper(v8::kExternalInt16Array); + ExternalArrayInfoTestHelper(v8::kExternalUint16Array); + ExternalArrayInfoTestHelper(v8::kExternalInt32Array); + ExternalArrayInfoTestHelper(v8::kExternalUint32Array); + ExternalArrayInfoTestHelper(v8::kExternalFloat32Array); + ExternalArrayInfoTestHelper(v8::kExternalFloat64Array); + ExternalArrayInfoTestHelper(v8::kExternalUint8ClampedArray); } @@ -16934,24 +16934,24 @@ TEST(ExternalArrayLimits) { LocalContext context; v8::Isolate* isolate = context->GetIsolate(); v8::HandleScope scope(isolate); - ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0xffffffff); - ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0x40000000); - ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalUint8Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalUint8Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalInt16Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalInt16Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalUint16Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalUint16Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalInt32Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalInt32Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalUint32Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalUint32Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalFloat32Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalFloat32Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalFloat64Array, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalFloat64Array, 0xffffffff); + ExtArrayLimitsHelper(isolate, v8::kExternalUint8ClampedArray, 0x40000000); + ExtArrayLimitsHelper(isolate, v8::kExternalUint8ClampedArray, 0xffffffff); } @@ -16990,58 +16990,59 @@ void TypedArrayTestHelper(v8::ExternalArrayType array_type, THREADED_TEST(Uint8Array) { - TypedArrayTestHelper( - v8::kExternalUnsignedByteArray, 0, 0xFF); + TypedArrayTestHelper( + v8::kExternalUint8Array, 0, 0xFF); } THREADED_TEST(Int8Array) { - TypedArrayTestHelper( - v8::kExternalByteArray, -0x80, 0x7F); + TypedArrayTestHelper( + v8::kExternalInt8Array, -0x80, 0x7F); } THREADED_TEST(Uint16Array) { TypedArrayTestHelper( - v8::kExternalUnsignedShortArray, 0, 0xFFFF); + i::ExternalUint16Array>( + v8::kExternalUint16Array, 0, 0xFFFF); } THREADED_TEST(Int16Array) { - TypedArrayTestHelper( - v8::kExternalShortArray, -0x8000, 0x7FFF); + TypedArrayTestHelper( + v8::kExternalInt16Array, -0x8000, 0x7FFF); } THREADED_TEST(Uint32Array) { - TypedArrayTestHelper( - v8::kExternalUnsignedIntArray, 0, UINT_MAX); + TypedArrayTestHelper( + v8::kExternalUint32Array, 0, UINT_MAX); } THREADED_TEST(Int32Array) { - TypedArrayTestHelper( - v8::kExternalIntArray, INT_MIN, INT_MAX); + TypedArrayTestHelper( + v8::kExternalInt32Array, INT_MIN, INT_MAX); } THREADED_TEST(Float32Array) { - TypedArrayTestHelper( - v8::kExternalFloatArray, -500, 500); + TypedArrayTestHelper( + v8::kExternalFloat32Array, -500, 500); } THREADED_TEST(Float64Array) { - TypedArrayTestHelper( - v8::kExternalDoubleArray, -500, 500); + TypedArrayTestHelper( + v8::kExternalFloat64Array, -500, 500); } THREADED_TEST(Uint8ClampedArray) { - TypedArrayTestHelper( - v8::kExternalPixelArray, 0, 0xFF); + TypedArrayTestHelper( + v8::kExternalUint8ClampedArray, 0, 0xFF); } diff --git a/test/mjsunit/elements-kind.js b/test/mjsunit/elements-kind.js index d16ddcaac..e2bbc31a4 100644 --- a/test/mjsunit/elements-kind.js +++ b/test/mjsunit/elements-kind.js @@ -65,31 +65,31 @@ function getKind(obj) { if (%HasDictionaryElements(obj)) return elements_kind.dictionary; // Every external kind is also an external array. assertTrue(%HasExternalArrayElements(obj)); - if (%HasExternalByteElements(obj)) { + if (%HasExternalInt8Elements(obj)) { return elements_kind.external_byte; } - if (%HasExternalUnsignedByteElements(obj)) { + if (%HasExternalUint8Elements(obj)) { return elements_kind.external_unsigned_byte; } - if (%HasExternalShortElements(obj)) { + if (%HasExternalInt16Elements(obj)) { return elements_kind.external_short; } - if (%HasExternalUnsignedShortElements(obj)) { + if (%HasExternalUint16Elements(obj)) { return elements_kind.external_unsigned_short; } - if (%HasExternalIntElements(obj)) { + if (%HasExternalInt32Elements(obj)) { return elements_kind.external_int; } - if (%HasExternalUnsignedIntElements(obj)) { + if (%HasExternalUint32Elements(obj)) { return elements_kind.external_unsigned_int; } - if (%HasExternalFloatElements(obj)) { + if (%HasExternalFloat32Elements(obj)) { return elements_kind.external_float; } - if (%HasExternalDoubleElements(obj)) { + if (%HasExternalFloat64Elements(obj)) { return elements_kind.external_double; } - if (%HasExternalPixelElements(obj)) { + if (%HasExternalUint8ClampedElements(obj)) { return elements_kind.external_pixel; } } -- 2.34.1