Version 3.24.24 (based on bleeding_edge revision r18840)
MIPS: Reduce the stack requirements of GetNoCodeAgeSequence (issue 3111).
Delete v8_shell target now that chrome uses d8 (Chromium issue 331585).
ARM: Reduce the stack requirements of GetNoCodeAgeSequence (issue 3111).
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@18841 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/ChangeLog b/ChangeLog
index 83c0783..004db69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-01-27: Version 3.24.24
+
+ MIPS: Reduce the stack requirements of GetNoCodeAgeSequence (issue
+ 3111).
+
+ Delete v8_shell target now that chrome uses d8 (Chromium issue 331585).
+
+ ARM: Reduce the stack requirements of GetNoCodeAgeSequence (issue 3111).
+
+ Performance and stability improvements on all platforms.
+
+
2014-01-24: Version 3.24.23
Performance and stability improvements on all platforms.
diff --git a/include/v8.h b/include/v8.h
index 96d8c6f..4bb3ad9 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2000,15 +2000,26 @@
};
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 3aa7af7..064a4b0 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2371,26 +2371,14 @@
}
-#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<i::Object> 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<i::Object> 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 @@
}
-#define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \
- void v8::ApiClass::CheckCast(Value* that) { \
- i::Handle<i::Object> 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<i::Object> 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 @@
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 @@
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 @@
"JSArray is not supported")) {
return;
}
- PrepareExternalArrayElements(self, data, kExternalPixelArray, length);
+ PrepareExternalArrayElements(self, data, kExternalUint8ClampedArray, length);
}
@@ -3743,7 +3711,7 @@
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
return false);
- return self->HasExternalPixelElements();
+ return self->HasExternalUint8ClampedElements();
}
@@ -3751,9 +3719,9 @@
i::Handle<i::JSObject> 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 @@
i::Handle<i::JSObject> 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 @@
"v8::GetIndexedPropertiesExternalArrayDataType()",
return static_cast<ExternalArrayType>(-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<ExternalArrayType>(-1);
}
@@ -6018,41 +5973,24 @@
}
-#define TYPED_ARRAY_NEW(TypedArray, element_type, array_type, elements_kind) \
- Local<TypedArray> TypedArray::New(Handle<ArrayBuffer> array_buffer, \
+#define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
+ Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
size_t byte_offset, size_t length) { \
i::Isolate* isolate = i::Isolate::Current(); \
EnsureInitializedForIsolate(isolate, \
- "v8::" #TypedArray "::New(Handle<ArrayBuffer>, size_t, size_t)"); \
+ "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
LOG_API(isolate, \
- "v8::" #TypedArray "::New(Handle<ArrayBuffer>, size_t, size_t)"); \
+ "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
ENTER_V8(isolate); \
i::Handle<i::JSTypedArray> obj = \
- NewTypedArray<element_type, array_type, elements_kind>( \
+ NewTypedArray<ctype, v8::kExternal##Type##Array, \
+ i::EXTERNAL_##TYPE##_ELEMENTS>( \
isolate, array_buffer, byte_offset, length); \
- return Utils::ToLocal##TypedArray(obj); \
+ return Utils::ToLocal##Type##Array(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)
-
+TYPED_ARRAYS(TYPED_ARRAY_NEW)
#undef TYPED_ARRAY_NEW
Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer,
@@ -7006,11 +6944,11 @@
case i::HeapGraphEdge::kInternal:
case i::HeapGraphEdge::kProperty:
case i::HeapGraphEdge::kShortcut:
+ case i::HeapGraphEdge::kWeak:
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(edge->name()));
case i::HeapGraphEdge::kElement:
case i::HeapGraphEdge::kHidden:
- case i::HeapGraphEdge::kWeak:
return ToApiHandle<Number>(
isolate->factory()->NewNumberFromInt(edge->index()));
default: UNREACHABLE();
diff --git a/src/api.h b/src/api.h
index 9d4dcf7..9fc99d9 100644
--- a/src/api.h
+++ b/src/api.h
@@ -344,11 +344,11 @@
}
-#define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \
- Local<v8::TypedArray> Utils::ToLocal##TypedArray( \
+#define MAKE_TO_LOCAL_TYPED_ARRAY(Type, typeName, TYPE, ctype, size) \
+ Local<v8::Type##Array> Utils::ToLocal##Type##Array( \
v8::internal::Handle<v8::internal::JSTypedArray> obj) { \
- ASSERT(obj->type() == typeConst); \
- return Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \
+ ASSERT(obj->type() == kExternal##Type##Array); \
+ return Convert<v8::internal::JSTypedArray, v8::Type##Array>(obj); \
}
@@ -365,15 +365,7 @@
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/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index 12742fb..8e9a394 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -427,6 +427,21 @@
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
}
+ {
+ CallInterfaceDescriptor* descriptor =
+ isolate->call_descriptor(Isolate::CallHandler);
+ static Register registers[] = { cp, // context
+ r0, // receiver
+ };
+ static Representation representations[] = {
+ Representation::Tagged(), // context
+ Representation::Tagged(), // receiver
+ };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->param_representations_ = representations;
+ descriptor->platform_specific_descriptor_ = &default_descriptor;
+ }
}
diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc
index 0b268e7..cfc9dfe 100644
--- a/src/arm/codegen-arm.cc
+++ b/src/arm/codegen-arm.cc
@@ -857,12 +857,15 @@
byte* byte_sequence = reinterpret_cast<byte*>(sequence);
*length = kNoCodeAgeSequenceLength * Assembler::kInstrSize;
if (!initialized) {
- CodePatcher patcher(byte_sequence, kNoCodeAgeSequenceLength);
- PredictableCodeSizeScope scope(patcher.masm(), *length);
- patcher.masm()->PushFixedFrame(r1);
- patcher.masm()->nop(ip.code());
- patcher.masm()->add(fp, sp,
- Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
+ // Since patcher is a large object, allocate it dynamically when needed,
+ // to avoid overloading the stack in stress conditions.
+ SmartPointer<CodePatcher>
+ patcher(new CodePatcher(byte_sequence, kNoCodeAgeSequenceLength));
+ PredictableCodeSizeScope scope(patcher->masm(), *length);
+ patcher->masm()->PushFixedFrame(r1);
+ patcher->masm()->nop(ip.code());
+ patcher->masm()->add(
+ fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
initialized = true;
}
return byte_sequence;
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index 8a91216..c12e9b8 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1250,7 +1250,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
LOperand* value = UseRegisterAtStart(instr->left());
LDivI* div = new(zone()) LDivI(value, UseConstant(instr->right()), NULL);
@@ -1296,43 +1296,25 @@
}
-HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
- if (CpuFeatures::IsSupported(SUDIV)) {
- // A value with an integer representation does not need to be transformed.
- if (divisor->representation().IsInteger32()) {
- return divisor;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (divisor->IsChange() &&
- HChange::cast(divisor)->from().IsInteger32()) {
- return HChange::cast(divisor)->value();
- }
- }
-
- if (divisor->IsConstant() && HConstant::cast(divisor)->HasInteger32Value()) {
- HConstant* constant_val = HConstant::cast(divisor);
- int32_t int32_val = constant_val->Integer32Value();
- if (LChunkBuilder::HasMagicNumberForDivisor(int32_val) ||
- CpuFeatures::IsSupported(SUDIV)) {
- return constant_val->CopyToRepresentation(Representation::Integer32(),
- divisor->block()->zone());
- }
- }
-
- return NULL;
-}
-
-
LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
+ // LMathFloorOfDiv can only handle a subset of divisors, so fall
+ // back to a flooring division in all other cases.
HValue* right = instr->right();
+ if (!right->IsInteger32Constant() ||
+ (!CpuFeatures::IsSupported(SUDIV) &&
+ !HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()))) {
+ LOperand* dividend = UseRegister(instr->left());
+ LOperand* divisor = UseRegister(right);
+ LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4);
+ LDivI* div = new(zone()) LDivI(dividend, divisor, temp);
+ return AssignEnvironment(DefineAsRegister(div));
+ }
+
LOperand* dividend = UseRegister(instr->left());
LOperand* divisor = CpuFeatures::IsSupported(SUDIV)
? UseRegister(right)
: UseOrConstant(right);
LOperand* remainder = TempRegister();
- ASSERT(CpuFeatures::IsSupported(SUDIV) ||
- (right->IsConstant() &&
- HConstant::cast(right)->HasInteger32Value() &&
- HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())));
return AssignEnvironment(DefineAsRegister(
new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
}
@@ -1344,7 +1326,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!right->CanBeZero());
LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
UseConstant(right));
@@ -2123,7 +2105,7 @@
// 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-arm.h b/src/arm/lithium-arm.h
index 91cbc71..cee6b85 100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -654,6 +654,8 @@
LOperand* right() { return inputs_[1]; }
LOperand* temp() { return temps_[0]; }
+ bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
+
DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
DECLARE_HYDROGEN_ACCESSOR(Div)
};
@@ -2695,7 +2697,6 @@
LInstruction* DoRSub(HSub* instr);
static bool HasMagicNumberForDivisor(int32_t divisor);
- static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
LInstruction* DoMathRound(HUnaryMathOperation* instr);
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index 47be6cd..062c7d1 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -1115,7 +1115,7 @@
HMod* hmod = instr->hydrogen();
HValue* left = hmod->left();
HValue* right = hmod->right();
- if (hmod->HasPowerOf2Divisor()) {
+ if (hmod->RightIsPowerOf2()) {
// TODO(svenpanne) We should really do the strength reduction on the
// Hydrogen level.
Register left_reg = ToRegister(instr->left());
@@ -1345,7 +1345,7 @@
void LCodeGen::DoDivI(LDivI* instr) {
- if (instr->hydrogen()->HasPowerOf2Divisor()) {
+ if (!instr->is_flooring() && instr->hydrogen()->RightIsPowerOf2()) {
const Register dividend = ToRegister(instr->left());
const Register result = ToRegister(instr->result());
int32_t divisor = instr->hydrogen()->right()->GetInteger32Constant();
@@ -1402,15 +1402,15 @@
const Register result = ToRegister(instr->result());
// Check for x / 0.
- if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
+ if (instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
__ cmp(right, Operand::Zero());
DeoptimizeIf(eq, instr->environment());
}
// Check for (0 / -x) that will produce negative zero.
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
+ if (instr->hydrogen_value()->CheckFlag(HValue::kBailoutOnMinusZero)) {
Label positive;
- if (!instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
+ if (!instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
// Do the test only if it hadn't be done above.
__ cmp(right, Operand::Zero());
}
@@ -1421,9 +1421,10 @@
}
// Check for (kMinInt / -1).
- if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow) &&
+ if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow) &&
(!CpuFeatures::IsSupported(SUDIV) ||
- !instr->hydrogen()->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
+ !instr->hydrogen_value()->CheckFlag(
+ HValue::kAllUsesTruncatingToInt32))) {
// We don't need to check for overflow when truncating with sdiv
// support because, on ARM, sdiv kMinInt, -1 -> kMinInt.
__ cmp(left, Operand(kMinInt));
@@ -1435,7 +1436,7 @@
CpuFeatureScope scope(masm(), SUDIV);
__ sdiv(result, left, right);
- if (!instr->hydrogen()->CheckFlag(
+ if (!instr->hydrogen_value()->CheckFlag(
HInstruction::kAllUsesTruncatingToInt32)) {
// Compute remainder and deopt if it's not zero.
const Register remainder = scratch0();
@@ -1454,7 +1455,7 @@
__ vcvt_s32_f64(double_scratch0().low(), vleft);
__ vmov(result, double_scratch0().low());
- if (!instr->hydrogen()->CheckFlag(
+ if (!instr->hydrogen_value()->CheckFlag(
HInstruction::kAllUsesTruncatingToInt32)) {
// Deopt if exact conversion to integer was not possible.
// Use vright as scratch register.
@@ -3213,9 +3214,9 @@
: 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;
@@ -3224,7 +3225,7 @@
? 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());
@@ -3238,29 +3239,29 @@
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)) {
@@ -3270,8 +3271,8 @@
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:
@@ -4275,9 +4276,9 @@
? 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;
@@ -4293,7 +4294,7 @@
} 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);
@@ -4307,30 +4308,30 @@
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/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index da3d4c9..987437b 100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -1601,79 +1601,6 @@
}
-Handle<Code> CallStubCompiler::CompileArrayPopCall(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Cell> cell,
- Handle<JSFunction> function,
- Handle<String> name,
- Code::StubType type) {
- // If object is not an array or is observed or sealed, bail out to regular
- // call.
- if (!object->IsJSArray() ||
- !cell.is_null() ||
- Handle<JSArray>::cast(object)->map()->is_observed() ||
- !Handle<JSArray>::cast(object)->map()->is_extensible()) {
- return Handle<Code>::null();
- }
-
- Label miss, return_undefined, call_builtin;
- Register receiver = r0;
- Register scratch = r1;
- Register elements = r3;
-
- HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
-
- // Get the elements array of the object.
- __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset));
-
- // Check that the elements are in fast mode and writable.
- __ CheckMap(elements,
- scratch,
- Heap::kFixedArrayMapRootIndex,
- &call_builtin,
- DONT_DO_SMI_CHECK);
-
- // Get the array's length into r4 and calculate new length.
- __ ldr(r4, FieldMemOperand(receiver, JSArray::kLengthOffset));
- __ sub(r4, r4, Operand(Smi::FromInt(1)), SetCC);
- __ b(lt, &return_undefined);
-
- // Get the last element.
- __ LoadRoot(r6, Heap::kTheHoleValueRootIndex);
- // We can't address the last element in one operation. Compute the more
- // expensive shift first, and use an offset later on.
- __ add(elements, elements, Operand::PointerOffsetFromSmiKey(r4));
- __ ldr(scratch, FieldMemOperand(elements, FixedArray::kHeaderSize));
- __ cmp(scratch, r6);
- __ b(eq, &call_builtin);
-
- // Set the array's length.
- __ str(r4, FieldMemOperand(receiver, JSArray::kLengthOffset));
-
- // Fill with the hole.
- __ str(r6, FieldMemOperand(elements, FixedArray::kHeaderSize));
- const int argc = arguments().immediate();
- __ Drop(argc + 1);
- __ mov(r0, scratch);
- __ Ret();
-
- __ bind(&return_undefined);
- __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
- __ Drop(argc + 1);
- __ Ret();
-
- __ bind(&call_builtin);
- __ TailCallExternalReference(
- ExternalReference(Builtins::c_ArrayPop, isolate()), argc + 1, 1);
-
- HandlerFrontendFooter(&miss);
-
- // Return the generated code.
- return GetCode(type, name);
-}
-
-
Handle<Code> CallStubCompiler::CompileFastApiCall(
const CallOptimization& optimization,
Handle<Object> object,
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 97364ca..6952a55 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1094,33 +1094,14 @@
}
{ // -- T y p e d A r r a y s
- Handle<JSFunction> int8_fun = InstallTypedArray("Int8Array",
- EXTERNAL_BYTE_ELEMENTS);
- native_context()->set_int8_array_fun(*int8_fun);
- Handle<JSFunction> uint8_fun = InstallTypedArray("Uint8Array",
- EXTERNAL_UNSIGNED_BYTE_ELEMENTS);
- native_context()->set_uint8_array_fun(*uint8_fun);
- Handle<JSFunction> int16_fun = InstallTypedArray("Int16Array",
- EXTERNAL_SHORT_ELEMENTS);
- native_context()->set_int16_array_fun(*int16_fun);
- Handle<JSFunction> uint16_fun = InstallTypedArray("Uint16Array",
- EXTERNAL_UNSIGNED_SHORT_ELEMENTS);
- native_context()->set_uint16_array_fun(*uint16_fun);
- Handle<JSFunction> int32_fun = InstallTypedArray("Int32Array",
- EXTERNAL_INT_ELEMENTS);
- native_context()->set_int32_array_fun(*int32_fun);
- Handle<JSFunction> uint32_fun = InstallTypedArray("Uint32Array",
- EXTERNAL_UNSIGNED_INT_ELEMENTS);
- native_context()->set_uint32_array_fun(*uint32_fun);
- Handle<JSFunction> float_fun = InstallTypedArray("Float32Array",
- EXTERNAL_FLOAT_ELEMENTS);
- native_context()->set_float_array_fun(*float_fun);
- Handle<JSFunction> double_fun = InstallTypedArray("Float64Array",
- EXTERNAL_DOUBLE_ELEMENTS);
- native_context()->set_double_array_fun(*double_fun);
- Handle<JSFunction> 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<JSFunction> fun = InstallTypedArray(#Type "Array", \
+ EXTERNAL_##TYPE##_ELEMENTS); \
+ native_context()->set_##type##_array_fun(*fun); \
+ }
+ TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
+#undef INSTALL_TYPED_ARRAY
Handle<JSFunction> data_view_fun =
InstallFunction(
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index a2da803..5a2d2f4 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -557,24 +557,12 @@
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 1b857c3..bd6c6a2 100644
--- a/src/contexts.h
+++ b/src/contexts.h
@@ -131,9 +131,9 @@
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 @@
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 ebb4616..d2abb04 100644
--- a/src/elements-kind.cc
+++ b/src/elements-kind.cc
@@ -37,26 +37,26 @@
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 3d55105..5a3f00d 100644
--- a/src/elements-kind.h
+++ b/src/elements-kind.h
@@ -53,15 +53,15 @@
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 @@
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 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 5bce3b9..2e4667d 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 @@
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 @@
}
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 @@
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 @@
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 @@
// Super class for all external element arrays.
-template<typename AccessorSubclass,
- ElementsKind Kind>
+template<ElementsKind Kind>
class TypedElementsAccessor
- : public ElementsAccessorBase<AccessorSubclass,
+ : public ElementsAccessorBase<TypedElementsAccessor<Kind>,
ElementsKindTraits<Kind> > {
public:
explicit TypedElementsAccessor(const char* name)
- : ElementsAccessorBase<AccessorSubclass,
+ : ElementsAccessorBase<AccessorClass,
ElementsKindTraits<Kind> >(name) {}
protected:
typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore;
+ typedef TypedElementsAccessor<Kind> AccessorClass;
- friend class ElementsAccessorBase<AccessorSubclass,
+ friend class ElementsAccessorBase<AccessorClass,
ElementsKindTraits<Kind> >;
MUST_USE_RESULT static MaybeObject* GetImpl(Object* receiver,
@@ -1398,7 +1348,7 @@
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 @@
uint32_t key,
FixedArrayBase* backing_store) {
return
- key < AccessorSubclass::GetCapacityImpl(backing_store)
+ key < AccessorClass::GetCapacityImpl(backing_store)
? NONE : ABSENT;
}
@@ -1419,7 +1369,7 @@
uint32_t key,
FixedArrayBase* backing_store) {
return
- key < AccessorSubclass::GetCapacityImpl(backing_store)
+ key < AccessorClass::GetCapacityImpl(backing_store)
? FIELD : NONEXISTENT;
}
@@ -1444,175 +1394,28 @@
uint32_t key,
FixedArrayBase* backing_store) {
uint32_t capacity =
- AccessorSubclass::GetCapacityImpl(backing_store);
+ AccessorClass::GetCapacityImpl(backing_store);
return key < capacity;
}
};
-class ExternalByteElementsAccessor
- : public TypedElementsAccessor<ExternalByteElementsAccessor,
- EXTERNAL_BYTE_ELEMENTS> {
- public:
- explicit ExternalByteElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalByteElementsAccessor,
- EXTERNAL_BYTE_ELEMENTS>(name) {}
-};
+
+#define EXTERNAL_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
+ typedef TypedElementsAccessor<EXTERNAL_##TYPE##_ELEMENTS> \
+ External##Type##ElementsAccessor;
+
+TYPED_ARRAYS(EXTERNAL_ELEMENTS_ACCESSOR)
+#undef EXTERNAL_ELEMENTS_ACCESSOR
+
+#define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \
+ typedef TypedElementsAccessor<TYPE##_ELEMENTS > \
+ Fixed##Type##ElementsAccessor;
+
+TYPED_ARRAYS(FIXED_ELEMENTS_ACCESSOR)
+#undef FIXED_ELEMENTS_ACCESSOR
-class ExternalUnsignedByteElementsAccessor
- : public TypedElementsAccessor<ExternalUnsignedByteElementsAccessor,
- EXTERNAL_UNSIGNED_BYTE_ELEMENTS> {
- public:
- explicit ExternalUnsignedByteElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalUnsignedByteElementsAccessor,
- EXTERNAL_UNSIGNED_BYTE_ELEMENTS>(name) {}
-};
-
-
-class ExternalShortElementsAccessor
- : public TypedElementsAccessor<ExternalShortElementsAccessor,
- EXTERNAL_SHORT_ELEMENTS> {
- public:
- explicit ExternalShortElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalShortElementsAccessor,
- EXTERNAL_SHORT_ELEMENTS>(name) {}
-};
-
-
-class ExternalUnsignedShortElementsAccessor
- : public TypedElementsAccessor<ExternalUnsignedShortElementsAccessor,
- EXTERNAL_UNSIGNED_SHORT_ELEMENTS> {
- public:
- explicit ExternalUnsignedShortElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalUnsignedShortElementsAccessor,
- EXTERNAL_UNSIGNED_SHORT_ELEMENTS>(name) {}
-};
-
-
-class ExternalIntElementsAccessor
- : public TypedElementsAccessor<ExternalIntElementsAccessor,
- EXTERNAL_INT_ELEMENTS> {
- public:
- explicit ExternalIntElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalIntElementsAccessor,
- EXTERNAL_INT_ELEMENTS>(name) {}
-};
-
-
-class ExternalUnsignedIntElementsAccessor
- : public TypedElementsAccessor<ExternalUnsignedIntElementsAccessor,
- EXTERNAL_UNSIGNED_INT_ELEMENTS> {
- public:
- explicit ExternalUnsignedIntElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalUnsignedIntElementsAccessor,
- EXTERNAL_UNSIGNED_INT_ELEMENTS>(name) {}
-};
-
-
-class ExternalFloatElementsAccessor
- : public TypedElementsAccessor<ExternalFloatElementsAccessor,
- EXTERNAL_FLOAT_ELEMENTS> {
- public:
- explicit ExternalFloatElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalFloatElementsAccessor,
- EXTERNAL_FLOAT_ELEMENTS>(name) {}
-};
-
-
-class ExternalDoubleElementsAccessor
- : public TypedElementsAccessor<ExternalDoubleElementsAccessor,
- EXTERNAL_DOUBLE_ELEMENTS> {
- public:
- explicit ExternalDoubleElementsAccessor(const char* name)
- : TypedElementsAccessor<ExternalDoubleElementsAccessor,
- EXTERNAL_DOUBLE_ELEMENTS>(name) {}
-};
-
-
-class PixelElementsAccessor
- : public TypedElementsAccessor<PixelElementsAccessor,
- EXTERNAL_PIXEL_ELEMENTS> {
- public:
- explicit PixelElementsAccessor(const char* name)
- : TypedElementsAccessor<PixelElementsAccessor,
- EXTERNAL_PIXEL_ELEMENTS>(name) {}
-};
-
-
-class FixedUint8ArrayAccessor
- : public TypedElementsAccessor<FixedUint8ArrayAccessor,
- UINT8_ELEMENTS> {
- public:
- explicit FixedUint8ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedUint8ArrayAccessor,
- UINT8_ELEMENTS>(name) {}
-};
-class FixedUint8ClampedArrayAccessor
- : public TypedElementsAccessor<FixedUint8ClampedArrayAccessor,
- UINT8_CLAMPED_ELEMENTS> {
- public:
- explicit FixedUint8ClampedArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedUint8ClampedArrayAccessor,
- UINT8_CLAMPED_ELEMENTS>(name) {}
-};
-class FixedInt8ArrayAccessor
- : public TypedElementsAccessor<FixedInt8ArrayAccessor,
- INT8_ELEMENTS> {
- public:
- explicit FixedInt8ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedInt8ArrayAccessor,
- INT8_ELEMENTS>(name) {}
-};
-class FixedUint16ArrayAccessor
- : public TypedElementsAccessor<FixedUint16ArrayAccessor,
- UINT16_ELEMENTS> {
- public:
- explicit FixedUint16ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedUint16ArrayAccessor,
- UINT16_ELEMENTS>(name) {}
-};
-class FixedInt16ArrayAccessor
- : public TypedElementsAccessor<FixedInt16ArrayAccessor,
- INT16_ELEMENTS> {
- public:
- explicit FixedInt16ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedInt16ArrayAccessor,
- INT16_ELEMENTS>(name) {}
-};
-class FixedUint32ArrayAccessor
- : public TypedElementsAccessor<FixedUint32ArrayAccessor,
- UINT32_ELEMENTS> {
- public:
- explicit FixedUint32ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedUint32ArrayAccessor,
- UINT32_ELEMENTS>(name) {}
-};
-class FixedInt32ArrayAccessor
- : public TypedElementsAccessor<FixedInt32ArrayAccessor,
- INT32_ELEMENTS> {
- public:
- explicit FixedInt32ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedInt32ArrayAccessor,
- INT32_ELEMENTS>(name) {}
-};
-
-class FixedFloat32ArrayAccessor
- : public TypedElementsAccessor<FixedFloat32ArrayAccessor,
- FLOAT32_ELEMENTS> {
- public:
- explicit FixedFloat32ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedFloat32ArrayAccessor,
- FLOAT32_ELEMENTS>(name) {}
-};
-class FixedFloat64ArrayAccessor
- : public TypedElementsAccessor<FixedFloat64ArrayAccessor,
- FLOAT64_ELEMENTS> {
- public:
- explicit FixedFloat64ArrayAccessor(const char* name)
- : TypedElementsAccessor<FixedFloat64ArrayAccessor,
- FLOAT64_ELEMENTS>(name) {}
-};
class DictionaryElementsAccessor
: public ElementsAccessorBase<DictionaryElementsAccessor,
diff --git a/src/factory.cc b/src/factory.cc
index 65888ac..0513297 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1486,32 +1486,12 @@
Isolate* isolate) {
Context* native_context = isolate->context()->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-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index 35cfcb4..887e9f5 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -47,7 +47,8 @@
ASSERT(type == kContextVariable
|| type == kProperty
|| type == kInternal
- || type == kShortcut);
+ || type == kShortcut
+ || type == kWeak);
}
@@ -56,7 +57,7 @@
from_index_(from),
to_index_(to),
index_(index) {
- ASSERT(type == kElement || type == kHidden || type == kWeak);
+ ASSERT(type == kElement || type == kHidden);
}
@@ -150,7 +151,7 @@
break;
case HeapGraphEdge::kWeak:
edge_prefix = "w";
- OS::SNPrintF(index, "%d", edge.index());
+ edge_name = edge.name();
break;
default:
OS::SNPrintF(index, "!!! unknown edge type: %d ", edge.type());
@@ -1114,11 +1115,13 @@
SetInternalReference(js_fun, entry,
"context", js_fun->context(),
JSFunction::kContextOffset);
- for (int i = JSFunction::kNonWeakFieldsEndOffset;
- i < JSFunction::kSize;
- i += kPointerSize) {
- SetWeakReference(js_fun, entry, i, *HeapObject::RawField(js_fun, i), i);
- }
+ SetWeakReference(js_fun, entry,
+ "next_function_link", js_fun->next_function_link(),
+ JSFunction::kNextFunctionLinkOffset);
+ STATIC_CHECK(JSFunction::kNextFunctionLinkOffset
+ == JSFunction::kNonWeakFieldsEndOffset);
+ STATIC_CHECK(JSFunction::kNextFunctionLinkOffset + kPointerSize
+ == JSFunction::kSize);
} else if (obj->IsGlobalObject()) {
GlobalObject* global_obj = GlobalObject::cast(obj);
SetInternalReference(global_obj, entry,
@@ -1130,6 +1133,19 @@
SetInternalReference(global_obj, entry,
"global_receiver", global_obj->global_receiver(),
GlobalObject::kGlobalReceiverOffset);
+ } else if (obj->IsJSArrayBufferView()) {
+ JSArrayBufferView* view = JSArrayBufferView::cast(obj);
+ SetInternalReference(view, entry, "buffer", view->buffer(),
+ JSArrayBufferView::kBufferOffset);
+ SetWeakReference(view, entry, "weak_next", view->weak_next(),
+ JSArrayBufferView::kWeakNextOffset);
+ } else if (obj->IsJSArrayBuffer()) {
+ JSArrayBuffer* buffer = JSArrayBuffer::cast(obj);
+ SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
+ JSArrayBuffer::kWeakNextOffset);
+ SetWeakReference(buffer, entry,
+ "weak_first_view", buffer->weak_first_view(),
+ JSArrayBuffer::kWeakFirstViewOffset);
}
TagObject(js_obj->properties(), "(object properties)");
SetInternalReference(obj, entry,
@@ -1180,8 +1196,13 @@
}
#define EXTRACT_CONTEXT_FIELD(index, type, name) \
- SetInternalReference(context, entry, #name, context->get(Context::index), \
- FixedArray::OffsetOfElementAt(Context::index));
+ if (Context::index < Context::FIRST_WEAK_SLOT) { \
+ SetInternalReference(context, entry, #name, context->get(Context::index), \
+ FixedArray::OffsetOfElementAt(Context::index)); \
+ } else { \
+ SetWeakReference(context, entry, #name, context->get(Context::index), \
+ FixedArray::OffsetOfElementAt(Context::index)); \
+ }
EXTRACT_CONTEXT_FIELD(CLOSURE_INDEX, JSFunction, closure);
EXTRACT_CONTEXT_FIELD(PREVIOUS_INDEX, Context, previous);
EXTRACT_CONTEXT_FIELD(EXTENSION_INDEX, Object, extension);
@@ -1193,13 +1214,15 @@
TagObject(context->runtime_context(), "(runtime context)");
TagObject(context->embedder_data(), "(context data)");
NATIVE_CONTEXT_FIELDS(EXTRACT_CONTEXT_FIELD);
+ EXTRACT_CONTEXT_FIELD(OPTIMIZED_FUNCTIONS_LIST, , optimized_functions_list);
+ EXTRACT_CONTEXT_FIELD(OPTIMIZED_CODE_LIST, , optimized_code_list);
+ EXTRACT_CONTEXT_FIELD(DEOPTIMIZED_CODE_LIST, , deoptimized_code_list);
+ EXTRACT_CONTEXT_FIELD(NEXT_CONTEXT_LINK, , next_context_link);
#undef EXTRACT_CONTEXT_FIELD
- for (int i = Context::FIRST_WEAK_SLOT;
- i < Context::NATIVE_CONTEXT_SLOTS;
- ++i) {
- SetWeakReference(context, entry, i, context->get(i),
- FixedArray::OffsetOfElementAt(i));
- }
+ STATIC_CHECK(Context::OPTIMIZED_FUNCTIONS_LIST == Context::FIRST_WEAK_SLOT);
+ STATIC_CHECK(Context::NEXT_CONTEXT_LINK + 1
+ == Context::NATIVE_CONTEXT_SLOTS);
+ STATIC_CHECK(Context::FIRST_WEAK_SLOT + 5 == Context::NATIVE_CONTEXT_SLOTS);
}
}
@@ -1293,7 +1316,7 @@
"optimized_code_map", shared->optimized_code_map(),
SharedFunctionInfo::kOptimizedCodeMapOffset);
SetWeakReference(obj, entry,
- 1, shared->initial_map(),
+ "initial_map", shared->initial_map(),
SharedFunctionInfo::kInitialMapOffset);
}
@@ -1823,17 +1846,17 @@
void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj,
int parent_entry,
- int index,
+ const char* reference_name,
Object* child_obj,
int field_offset) {
ASSERT(parent_entry == GetEntry(parent_obj)->index());
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry == NULL) return;
if (IsEssentialObject(child_obj)) {
- filler_->SetIndexedReference(HeapGraphEdge::kWeak,
- parent_entry,
- index,
- child_entry);
+ filler_->SetNamedReference(HeapGraphEdge::kWeak,
+ parent_entry,
+ reference_name,
+ child_entry);
}
IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
}
@@ -1905,10 +1928,17 @@
name,
child_entry);
} else {
- filler_->SetIndexedAutoIndexReference(
- is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement,
- snapshot_->gc_subroot(tag)->index(),
- child_entry);
+ if (is_weak) {
+ filler_->SetNamedAutoIndexReference(
+ HeapGraphEdge::kWeak,
+ snapshot_->gc_subroot(tag)->index(),
+ child_entry);
+ } else {
+ filler_->SetIndexedAutoIndexReference(
+ HeapGraphEdge::kElement,
+ snapshot_->gc_subroot(tag)->index(),
+ child_entry);
+ }
}
// Add a shortcut to JS global object reference at snapshot root.
@@ -2642,7 +2672,6 @@
EmbeddedVector<char, kBufferSize> buffer;
int edge_name_or_index = edge->type() == HeapGraphEdge::kElement
|| edge->type() == HeapGraphEdge::kHidden
- || edge->type() == HeapGraphEdge::kWeak
? edge->index() : GetStringId(edge->name());
int buffer_pos = 0;
if (!first_edge) {
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index d93362f..59d324e 100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -57,14 +57,15 @@
Type type() const { return static_cast<Type>(type_); }
int index() const {
- ASSERT(type_ == kElement || type_ == kHidden || type_ == kWeak);
+ ASSERT(type_ == kElement || type_ == kHidden);
return index_;
}
const char* name() const {
ASSERT(type_ == kContextVariable
|| type_ == kProperty
|| type_ == kInternal
- || type_ == kShortcut);
+ || type_ == kShortcut
+ || type_ == kWeak);
return name_;
}
INLINE(HeapEntry* from() const);
@@ -448,7 +449,7 @@
Object* child);
void SetWeakReference(HeapObject* parent_obj,
int parent,
- int index,
+ const char* reference_name,
Object* child_obj,
int field_offset);
void SetPropertyReference(HeapObject* parent_obj,
diff --git a/src/heap.cc b/src/heap.cc
index d9bd7d5..862e2ea 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2833,31 +2833,19 @@
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 @@
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 @@
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 @@
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::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 @@
int* element_size,
ElementsKind* element_kind) {
switch (array_type) {
- case kExternalUnsignedByteArray:
- *element_size = 1;
- *element_kind = UINT8_ELEMENTS;
+#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
+ case kExternal##Type##Array: \
+ *element_size = size; \
+ *element_kind = TYPE##_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;
- return;
+
+ TYPED_ARRAYS(TYPED_ARRAY_CASE)
+#undef TYPED_ARRAY_CASE
+
default:
*element_size = 0; // Bogus
*element_kind = UINT8_ELEMENTS; // Bogus
@@ -3986,7 +3906,7 @@
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* 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 22e252c..c9101be 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -133,29 +133,29 @@
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 2861751..89399db 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1408,81 +1408,51 @@
}
-static HValue* SimplifiedDividendForMathFloorOfDiv(HValue* dividend) {
- // A value with an integer representation does not need to be transformed.
- if (dividend->representation().IsInteger32()) {
- return dividend;
- }
- // A change from an integer32 can be replaced by the integer32 value.
- if (dividend->IsChange() &&
- HChange::cast(dividend)->from().IsInteger32()) {
- return HChange::cast(dividend)->value();
- }
- return NULL;
-}
-
-
HValue* HUnaryMathOperation::Canonicalize() {
if (op() == kMathRound || op() == kMathFloor) {
HValue* val = value();
if (val->IsChange()) val = HChange::cast(val)->value();
-
- // If the input is smi or integer32 then we replace the instruction with its
- // input.
if (val->representation().IsSmiOrInteger32()) {
- if (!val->representation().Equals(representation())) {
- HChange* result = new(block()->zone()) HChange(
- val, representation(), false, false);
- result->InsertBefore(this);
- return result;
- }
- return val;
+ if (val->representation().Equals(representation())) return val;
+ return Prepend(new(block()->zone()) HChange(
+ val, representation(), false, false));
}
}
+ if (op() == kMathFloor && value()->IsDiv() && value()->UseCount() == 1) {
+ HDiv* hdiv = HDiv::cast(value());
- if (op() == kMathFloor) {
- HValue* val = value();
- if (val->IsDiv() && (val->UseCount() == 1)) {
- HDiv* hdiv = HDiv::cast(val);
- HValue* left = hdiv->left();
- HValue* right = hdiv->right();
- // Try to simplify left and right values of the division.
- HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left);
- if (new_left == NULL &&
- hdiv->observed_input_representation(1).IsSmiOrInteger32()) {
- new_left = new(block()->zone()) HChange(
- left, Representation::Integer32(), false, false);
- HChange::cast(new_left)->InsertBefore(this);
- }
- HValue* new_right =
- LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(right);
- if (new_right == NULL &&
-#if V8_TARGET_ARCH_ARM
- CpuFeatures::IsSupported(SUDIV) &&
-#endif
- hdiv->observed_input_representation(2).IsSmiOrInteger32()) {
- new_right = new(block()->zone()) HChange(
- right, Representation::Integer32(), false, false);
- HChange::cast(new_right)->InsertBefore(this);
- }
-
- // Return if left or right are not optimizable.
- if ((new_left == NULL) || (new_right == NULL)) return this;
-
- // Insert the new values in the graph.
- if (new_left->IsInstruction() &&
- !HInstruction::cast(new_left)->IsLinked()) {
- HInstruction::cast(new_left)->InsertBefore(this);
- }
- if (new_right->IsInstruction() &&
- !HInstruction::cast(new_right)->IsLinked()) {
- HInstruction::cast(new_right)->InsertBefore(this);
- }
- HMathFloorOfDiv* instr =
- HMathFloorOfDiv::New(block()->zone(), context(), new_left, new_right);
- instr->InsertBefore(this);
- return instr;
+ HValue* left = hdiv->left();
+ if (left->representation().IsInteger32()) {
+ // A value with an integer representation does not need to be transformed.
+ } else if (left->IsChange() && HChange::cast(left)->from().IsInteger32()) {
+ // A change from an integer32 can be replaced by the integer32 value.
+ left = HChange::cast(left)->value();
+ } else if (hdiv->observed_input_representation(1).IsSmiOrInteger32()) {
+ left = Prepend(new(block()->zone()) HChange(
+ left, Representation::Integer32(), false, false));
+ } else {
+ return this;
}
+
+ HValue* right = hdiv->right();
+ if (right->IsInteger32Constant()) {
+ right = Prepend(HConstant::cast(right)->CopyToRepresentation(
+ Representation::Integer32(), right->block()->zone()));
+ } else if (right->representation().IsInteger32()) {
+ // A value with an integer representation does not need to be transformed.
+ } else if (right->IsChange() &&
+ HChange::cast(right)->from().IsInteger32()) {
+ // A change from an integer32 can be replaced by the integer32 value.
+ right = HChange::cast(right)->value();
+ } else if (hdiv->observed_input_representation(2).IsSmiOrInteger32()) {
+ right = Prepend(new(block()->zone()) HChange(
+ right, Representation::Integer32(), false, false));
+ } else {
+ return this;
+ }
+
+ return Prepend(HMathFloorOfDiv::New(
+ block()->zone(), context(), left, right));
}
return this;
}
@@ -2939,14 +2909,14 @@
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);
@@ -3226,10 +3196,8 @@
key_load->elements_kind());
map_check->InsertBefore(this);
index->InsertBefore(this);
- HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex(
- object(), index);
- load->InsertBefore(this);
- return load;
+ return Prepend(new(block()->zone()) HLoadFieldByIndex(
+ object(), index));
}
}
}
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index fe701ae..dbf6183 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -46,6 +46,7 @@
// Forward declarations.
class HBasicBlock;
+class HDiv;
class HEnvironment;
class HInferRepresentationPhase;
class HInstruction;
@@ -573,7 +574,7 @@
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.
@@ -1207,9 +1208,21 @@
bool IsLinked() const { return block() != NULL; }
void Unlink();
+
void InsertBefore(HInstruction* next);
+
+ template<class T> T* Prepend(T* instr) {
+ instr->InsertBefore(this);
+ return instr;
+ }
+
void InsertAfter(HInstruction* previous);
+ template<class T> T* Append(T* instr) {
+ instr->InsertAfter(this);
+ return instr;
+ }
+
// The position is a write-once variable.
virtual int position() const V8_OVERRIDE {
return position_.position();
@@ -2706,6 +2719,9 @@
virtual bool IsDeletable() const V8_OVERRIDE { return true; }
+ HValue* SimplifiedDividendForMathFloorOfDiv(HDiv* hdiv);
+ HValue* SimplifiedDivisorForMathFloorOfDiv(HDiv* hdiv);
+
BuiltinFunctionId op_;
};
@@ -3476,10 +3492,8 @@
int32_t value,
Representation representation,
HInstruction* instruction) {
- HConstant* new_constant =
- HConstant::New(zone, context, value, representation);
- new_constant->InsertAfter(instruction);
- return new_constant;
+ return instruction->Append(HConstant::New(
+ zone, context, value, representation));
}
static HConstant* CreateAndInsertBefore(Zone* zone,
@@ -3487,21 +3501,17 @@
int32_t value,
Representation representation,
HInstruction* instruction) {
- HConstant* new_constant =
- HConstant::New(zone, context, value, representation);
- new_constant->InsertBefore(instruction);
- return new_constant;
+ return instruction->Prepend(HConstant::New(
+ zone, context, value, representation));
}
static HConstant* CreateAndInsertBefore(Zone* zone,
Unique<Object> unique,
bool is_not_in_new_space,
HInstruction* instruction) {
- HConstant* new_constant = new(zone) HConstant(unique,
- Representation::Tagged(), HType::Tagged(), false, is_not_in_new_space,
- false, false);
- new_constant->InsertBefore(instruction);
- return new_constant;
+ return instruction->Prepend(new(zone) HConstant(
+ unique, Representation::Tagged(), HType::Tagged(), false,
+ is_not_in_new_space, false, false));
}
Handle<Object> handle(Isolate* isolate) {
@@ -4188,7 +4198,14 @@
}
}
+ bool RightIsPowerOf2() {
+ if (!right()->IsInteger32Constant()) return false;
+ int32_t value = right()->GetInteger32Constant();
+ return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
+ }
+
DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation)
+
private:
virtual bool IsDeletable() const V8_OVERRIDE { return true; }
};
@@ -4887,16 +4904,6 @@
HValue* left,
HValue* right);
- bool HasPowerOf2Divisor() {
- if (right()->IsConstant() &&
- HConstant::cast(right())->HasInteger32Value()) {
- int32_t value = HConstant::cast(right())->Integer32Value();
- return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
- }
-
- return false;
- }
-
virtual HValue* EnsureAndPropagateNotMinusZero(
BitVector* visited) V8_OVERRIDE;
@@ -4933,15 +4940,6 @@
HValue* left,
HValue* right);
- bool HasPowerOf2Divisor() {
- if (right()->IsInteger32Constant()) {
- int32_t value = right()->GetInteger32Constant();
- return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
- }
-
- return false;
- }
-
virtual HValue* EnsureAndPropagateNotMinusZero(
BitVector* visited) V8_OVERRIDE;
@@ -6428,8 +6426,8 @@
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());
@@ -6850,8 +6848,8 @@
}
// 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 8de887d..63b1de6 100644
--- a/src/hydrogen-uint32-analysis.cc
+++ b/src/hydrogen-uint32-analysis.cc
@@ -54,9 +54,9 @@
// 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 3180f4d..3698a32 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1208,7 +1208,7 @@
RemovableSimulate removable) {
ASSERT(current_block() != NULL);
ASSERT(!graph()->IsInsideNoSideEffectsScope());
- current_block()->AddNewSimulate(id, removable);
+ current_block()->AddNewSimulate(id, position_, removable);
}
@@ -2318,7 +2318,7 @@
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<HClampToUint8>(val);
}
@@ -2333,7 +2333,7 @@
HLoadKeyed* load = Add<HLoadKeyed>(
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);
}
@@ -7612,6 +7612,90 @@
return true;
}
break;
+ case kArrayPop: {
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
+ return false;
+ }
+ if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ ElementsKind elements_kind = receiver_map->elements_kind();
+ if (!IsFastElementsKind(elements_kind)) return false;
+ AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
+
+ Drop(expr->arguments()->length());
+ HValue* result;
+ HValue* checked_object;
+ HValue* reduced_length;
+ HValue* receiver = Pop();
+ { NoObservableSideEffectsScope scope(this);
+ checked_object = AddCheckMap(receiver, receiver_map);
+ HValue* elements = AddLoadElements(checked_object);
+ // Ensure that we aren't popping from a copy-on-write array.
+ if (IsFastSmiOrObjectElementsKind(elements_kind)) {
+ Add<HCheckMaps>(
+ elements, isolate()->factory()->fixed_array_map(), top_info());
+ }
+ HValue* length = Add<HLoadNamedField>(
+ checked_object, HObjectAccess::ForArrayLength(elements_kind));
+ reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1());
+ HValue* bounds_check = Add<HBoundsCheck>(
+ graph()->GetConstant0(), length);
+ result = AddElementAccess(elements, reduced_length, NULL,
+ bounds_check, elements_kind, false);
+ Factory* factory = isolate()->factory();
+ double nan_double = FixedDoubleArray::hole_nan_as_double();
+ HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind)
+ ? Add<HConstant>(factory->the_hole_value())
+ : Add<HConstant>(nan_double);
+ if (IsFastSmiOrObjectElementsKind(elements_kind)) {
+ elements_kind = FAST_HOLEY_ELEMENTS;
+ }
+ AddElementAccess(
+ elements, reduced_length, hole, bounds_check, elements_kind, true);
+ }
+ Add<HStoreNamedField>(
+ checked_object, HObjectAccess::ForArrayLength(elements_kind),
+ reduced_length);
+ if (!ast_context()->IsEffect()) Push(result);
+ Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
+ if (!ast_context()->IsEffect()) Drop(1);
+ ast_context()->ReturnValue(result);
+ return true;
+ }
+ case kArrayPush: {
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
+ return false;
+ }
+ if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ ElementsKind elements_kind = receiver_map->elements_kind();
+ if (!IsFastElementsKind(elements_kind)) return false;
+ AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
+
+ HValue* op_vals[] = {
+ context(),
+ // Receiver.
+ environment()->ExpressionStackAt(expr->arguments()->length())
+ };
+
+ const int argc = expr->arguments()->length();
+ // Includes receiver.
+ PushArgumentsFromEnvironment(argc + 1);
+
+ CallInterfaceDescriptor* descriptor =
+ isolate()->call_descriptor(Isolate::CallHandler);
+
+ ArrayPushStub stub(receiver_map->elements_kind(), argc);
+ Handle<Code> code = stub.GetCode(isolate());
+ HConstant* code_value = Add<HConstant>(code);
+
+ ASSERT((sizeof(op_vals) / kPointerSize) ==
+ descriptor->environment_length());
+
+ HInstruction* call = New<HCallWithDescriptor>(
+ code_value, argc + 1, descriptor,
+ Vector<HValue*>(op_vals, descriptor->environment_length()));
+ ast_context()->ReturnInstruction(call, expr->id());
+ return true;
+ }
default:
// Not yet supported for inlining.
break;
@@ -8308,7 +8392,7 @@
BuildArrayBufferViewInitialization<JSTypedArray>(
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/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index f21308f..48b5999 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -421,6 +421,20 @@
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
}
+ {
+ CallInterfaceDescriptor* descriptor =
+ isolate->call_descriptor(Isolate::CallHandler);
+ static Register registers[] = { esi, // context
+ edx, // receiver
+ };
+ static Representation representations[] = {
+ Representation::Tagged(), // context
+ Representation::Tagged(), // receiver
+ };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->param_representations_ = representations;
+ }
}
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index 05b6f3c..dd54653 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -1372,7 +1372,7 @@
HMod* hmod = instr->hydrogen();
HValue* left = hmod->left();
HValue* right = hmod->right();
- if (hmod->HasPowerOf2Divisor()) {
+ if (hmod->RightIsPowerOf2()) {
// TODO(svenpanne) We should really do the strength reduction on the
// Hydrogen level.
Register left_reg = ToRegister(instr->left());
@@ -1454,7 +1454,7 @@
void LCodeGen::DoDivI(LDivI* instr) {
- if (!instr->is_flooring() && instr->hydrogen()->HasPowerOf2Divisor()) {
+ if (!instr->is_flooring() && instr->hydrogen()->RightIsPowerOf2()) {
Register dividend = ToRegister(instr->left());
int32_t divisor = instr->hydrogen()->right()->GetInteger32Constant();
int32_t test_value = 0;
@@ -3409,7 +3409,7 @@
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 @@
} 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 @@
} 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 @@
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 @@
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 @@
__ 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 @@
} 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 b4b4452..95b810f 100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1332,7 +1332,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
LOperand* value = UseRegisterAtStart(instr->left());
LDivI* div =
@@ -1354,25 +1354,6 @@
}
-HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
- if (divisor->IsConstant() &&
- HConstant::cast(divisor)->HasInteger32Value()) {
- HConstant* constant_val = HConstant::cast(divisor);
- return constant_val->CopyToRepresentation(Representation::Integer32(),
- divisor->block()->zone());
- }
- // A value with an integer representation does not need to be transformed.
- if (divisor->representation().IsInteger32()) {
- return divisor;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (divisor->IsChange() &&
- HChange::cast(divisor)->from().IsInteger32()) {
- return HChange::cast(divisor)->value();
- }
- return NULL;
-}
-
-
LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
HValue* right = instr->right();
if (!right->IsConstant()) {
@@ -1418,7 +1399,7 @@
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!right->CanBeZero());
LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
UseOrConstant(right),
@@ -2158,7 +2139,7 @@
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;
@@ -2181,9 +2162,9 @@
// 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 b278c70..bea6381 100644
--- a/src/ia32/lithium-ia32.h
+++ b/src/ia32/lithium-ia32.h
@@ -1605,9 +1605,9 @@
// 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);
@@ -2703,8 +2703,6 @@
HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
- static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
-
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
LInstruction* DoMathRound(HUnaryMathOperation* instr);
LInstruction* DoMathAbs(HUnaryMathOperation* instr);
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index 92b2f93..e76bfb5 100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -1616,76 +1616,6 @@
}
-Handle<Code> CallStubCompiler::CompileArrayPopCall(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Cell> cell,
- Handle<JSFunction> function,
- Handle<String> name,
- Code::StubType type) {
- // If object is not an array or is observed or sealed, bail out to regular
- // call.
- if (!object->IsJSArray() ||
- !cell.is_null() ||
- Handle<JSArray>::cast(object)->map()->is_observed() ||
- !Handle<JSArray>::cast(object)->map()->is_extensible()) {
- return Handle<Code>::null();
- }
-
- Label miss, return_undefined, call_builtin;
-
- HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
-
- // Get the elements array of the object.
- __ mov(ebx, FieldOperand(edx, JSArray::kElementsOffset));
-
- // Check that the elements are in fast mode and writable.
- __ cmp(FieldOperand(ebx, HeapObject::kMapOffset),
- Immediate(factory()->fixed_array_map()));
- __ j(not_equal, &call_builtin);
-
- // Get the array's length into ecx and calculate new length.
- __ mov(ecx, FieldOperand(edx, JSArray::kLengthOffset));
- __ sub(ecx, Immediate(Smi::FromInt(1)));
- __ j(negative, &return_undefined);
-
- // Get the last element.
- STATIC_ASSERT(kSmiTagSize == 1);
- STATIC_ASSERT(kSmiTag == 0);
- __ mov(eax, FieldOperand(ebx,
- ecx, times_half_pointer_size,
- FixedArray::kHeaderSize));
- __ cmp(eax, Immediate(factory()->the_hole_value()));
- __ j(equal, &call_builtin);
-
- // Set the array's length.
- __ mov(FieldOperand(edx, JSArray::kLengthOffset), ecx);
-
- // Fill with the hole.
- __ mov(FieldOperand(ebx,
- ecx, times_half_pointer_size,
- FixedArray::kHeaderSize),
- Immediate(factory()->the_hole_value()));
- const int argc = arguments().immediate();
- __ ret((argc + 1) * kPointerSize);
-
- __ bind(&return_undefined);
- __ mov(eax, Immediate(factory()->undefined_value()));
- __ ret((argc + 1) * kPointerSize);
-
- __ bind(&call_builtin);
- __ TailCallExternalReference(
- ExternalReference(Builtins::c_ArrayPop, isolate()),
- argc + 1,
- 1);
-
- HandlerFrontendFooter(&miss);
-
- // Return the generated code.
- return GetCode(type, name);
-}
-
-
Handle<Code> CallStubCompiler::CompileFastApiCall(
const CallOptimization& optimization,
Handle<Object> object,
diff --git a/src/isolate.h b/src/isolate.h
index d6dff05..5956baa 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -1076,6 +1076,7 @@
enum CallDescriptorKey {
KeyedCall,
NamedCall,
+ CallHandler,
ArgumentAdaptorCall,
NUMBER_OF_CALL_DESCRIPTORS
};
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index 2fe6d69..8651b69 100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -419,6 +419,20 @@
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
}
+ {
+ CallInterfaceDescriptor* descriptor =
+ isolate->call_descriptor(Isolate::CallHandler);
+ static Register registers[] = { cp, // context
+ a0, // receiver
+ };
+ static Representation representations[] = {
+ Representation::Tagged(), // context
+ Representation::Tagged(), // receiver
+ };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->param_representations_ = representations;
+ }
}
diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc
index ff5658a..e5338db 100644
--- a/src/mips/codegen-mips.cc
+++ b/src/mips/codegen-mips.cc
@@ -1048,11 +1048,15 @@
byte* byte_sequence = reinterpret_cast<byte*>(sequence);
*length = kNoCodeAgeSequenceLength * Assembler::kInstrSize;
if (!initialized) {
- CodePatcher patcher(byte_sequence, kNoCodeAgeSequenceLength);
- patcher.masm()->Push(ra, fp, cp, a1);
- patcher.masm()->nop(Assembler::CODE_AGE_SEQUENCE_NOP);
- patcher.masm()->Addu(fp, sp,
- Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
+ // Since patcher is a large object, allocate it dynamically when needed,
+ // to avoid overloading the stack in stress conditions.
+ SmartPointer<CodePatcher>
+ patcher(new CodePatcher(byte_sequence, kNoCodeAgeSequenceLength));
+ PredictableCodeSizeScope scope(patcher->masm(), *length);
+ patcher->masm()->Push(ra, fp, cp, a1);
+ patcher->masm()->nop(Assembler::CODE_AGE_SEQUENCE_NOP);
+ patcher->masm()->Addu(
+ fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
initialized = true;
}
return byte_sequence;
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc
index dc1cd51..5479806 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -1066,7 +1066,7 @@
HMod* hmod = instr->hydrogen();
HValue* left = hmod->left();
HValue* right = hmod->right();
- if (hmod->HasPowerOf2Divisor()) {
+ if (hmod->RightIsPowerOf2()) {
const Register left_reg = ToRegister(instr->left());
const Register result_reg = ToRegister(instr->result());
@@ -3075,9 +3075,9 @@
? 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 @@
__ 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 @@
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 @@
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 @@
? 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 @@
__ 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 @@
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 1615d4a..d14b11f 100644
--- a/src/mips/lithium-mips.cc
+++ b/src/mips/lithium-mips.cc
@@ -1295,20 +1295,6 @@
}
-HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
- // Only optimize when we have magic numbers for the divisor.
- // The standard integer division routine is usually slower than transitionning
- // to FPU.
- if (divisor->IsConstant() &&
- HConstant::cast(divisor)->HasInteger32Value()) {
- HConstant* constant_val = HConstant::cast(divisor);
- return constant_val->CopyToRepresentation(Representation::Integer32(),
- divisor->block()->zone());
- }
- return NULL;
-}
-
-
LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
HValue* right = instr->right();
LOperand* dividend = UseRegister(instr->left());
@@ -1325,7 +1311,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!right->CanBeZero());
LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
UseConstant(right));
@@ -2048,7 +2034,7 @@
// 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/mips/lithium-mips.h b/src/mips/lithium-mips.h
index d682748..dc58b44 100644
--- a/src/mips/lithium-mips.h
+++ b/src/mips/lithium-mips.h
@@ -2669,7 +2669,6 @@
LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
static bool HasMagicNumberForDivisor(int32_t divisor);
- static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
LInstruction* DoMathRound(HUnaryMathOperation* instr);
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index b713be9..ef98db5 100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -1585,78 +1585,6 @@
}
-Handle<Code> CallStubCompiler::CompileArrayPopCall(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Cell> cell,
- Handle<JSFunction> function,
- Handle<String> name,
- Code::StubType type) {
- // If object is not an array or is observed or sealed, bail out to regular
- // call.
- if (!object->IsJSArray() ||
- !cell.is_null() ||
- Handle<JSArray>::cast(object)->map()->is_observed() ||
- !Handle<JSArray>::cast(object)->map()->is_extensible()) {
- return Handle<Code>::null();
- }
-
- Label miss, return_undefined, call_builtin;
- Register receiver = a0;
- Register scratch = a1;
- Register elements = a3;
- HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
-
- // Get the elements array of the object.
- __ lw(elements, FieldMemOperand(receiver, JSArray::kElementsOffset));
-
- // Check that the elements are in fast mode and writable.
- __ CheckMap(elements,
- scratch,
- Heap::kFixedArrayMapRootIndex,
- &call_builtin,
- DONT_DO_SMI_CHECK);
-
- // Get the array's length into t0 and calculate new length.
- __ lw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
- __ Subu(t0, t0, Operand(Smi::FromInt(1)));
- __ Branch(&return_undefined, lt, t0, Operand(zero_reg));
-
- // Get the last element.
- __ LoadRoot(t2, Heap::kTheHoleValueRootIndex);
- STATIC_ASSERT(kSmiTagSize == 1);
- STATIC_ASSERT(kSmiTag == 0);
- // We can't address the last element in one operation. Compute the more
- // expensive shift first, and use an offset later on.
- __ sll(t1, t0, kPointerSizeLog2 - kSmiTagSize);
- __ Addu(elements, elements, t1);
- __ lw(scratch, FieldMemOperand(elements, FixedArray::kHeaderSize));
- __ Branch(&call_builtin, eq, scratch, Operand(t2));
-
- // Set the array's length.
- __ sw(t0, FieldMemOperand(receiver, JSArray::kLengthOffset));
-
- // Fill with the hole.
- __ sw(t2, FieldMemOperand(elements, FixedArray::kHeaderSize));
- const int argc = arguments().immediate();
- __ mov(v0, scratch);
- __ DropAndRet(argc + 1);
-
- __ bind(&return_undefined);
- __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
- __ DropAndRet(argc + 1);
-
- __ bind(&call_builtin);
- __ TailCallExternalReference(
- ExternalReference(Builtins::c_ArrayPop, isolate()), argc + 1, 1);
-
- HandlerFrontendFooter(&miss);
-
- // Return the generated code.
- return GetCode(type, name);
-}
-
-
Handle<Code> CallStubCompiler::CompileFastApiCall(
const CallOptimization& optimization,
Handle<Object> object,
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 414f2bc..e33b46b 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -104,61 +104,18 @@
case FREE_SPACE_TYPE:
FreeSpace::cast(this)->FreeSpaceVerify();
break;
- case EXTERNAL_PIXEL_ARRAY_TYPE:
- ExternalPixelArray::cast(this)->ExternalPixelArrayVerify();
+
+#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;
- 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();
- break;
+
+ TYPED_ARRAYS(VERIFY_TYPED_ARRAY)
+#undef VERIFY_TYPED_ARRAY
+
case CODE_TYPE:
Code::cast(this)->CodeVerify();
break;
@@ -289,49 +246,13 @@
}
-void ExternalPixelArray::ExternalPixelArrayVerify() {
- CHECK(IsExternalPixelArray());
-}
+#define EXTERNAL_ARRAY_VERIFY(Type, type, TYPE, ctype, size) \
+ void External##Type##Array::External##Type##ArrayVerify() { \
+ CHECK(IsExternal##Type##Array()); \
+ }
-
-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());
-}
-
-
-void ExternalDoubleArray::ExternalDoubleArrayVerify() {
- CHECK(IsExternalDoubleArray());
-}
+TYPED_ARRAYS(EXTERNAL_ARRAY_VERIFY)
+#undef EXTERNAL_ARRAY_VERIFY
template <class Traits>
@@ -1114,25 +1035,14 @@
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 8802d2f..f86e847 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -602,9 +602,6 @@
}
-TYPE_CHECKER(ExternalPixelArray, EXTERNAL_PIXEL_ARRAY_TYPE)
-
-
bool Object::IsExternalArray() {
if (!Object::IsHeapObject())
return false;
@@ -615,14 +612,12 @@
}
-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 @@
}
-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(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 @@
}
-uint8_t* ExternalPixelArray::external_pixel_pointer() {
+uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() {
return reinterpret_cast<uint8_t*>(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<int>(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 @@
}
-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<int8_t*>(external_pointer());
return ptr[index];
}
-MaybeObject* ExternalByteArray::get(int index) {
+MaybeObject* ExternalInt8Array::get(int index) {
return Smi::FromInt(static_cast<int>(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<int8_t*>(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<uint8_t*>(external_pointer());
return ptr[index];
}
-MaybeObject* ExternalUnsignedByteArray::get(int index) {
+MaybeObject* ExternalUint8Array::get(int index) {
return Smi::FromInt(static_cast<int>(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<uint8_t*>(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<int16_t*>(external_pointer());
return ptr[index];
}
-MaybeObject* ExternalShortArray::get(int index) {
+MaybeObject* ExternalInt16Array::get(int index) {
return Smi::FromInt(static_cast<int>(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<int16_t*>(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<uint16_t*>(external_pointer());
return ptr[index];
}
-MaybeObject* ExternalUnsignedShortArray::get(int index) {
+MaybeObject* ExternalUint16Array::get(int index) {
return Smi::FromInt(static_cast<int>(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<uint16_t*>(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<int32_t*>(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<int32_t*>(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<uint32_t*>(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<uint32_t*>(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<float*>(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<float*>(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<double*>(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<double*>(external_pointer());
ptr[index] = value;
@@ -5990,29 +5974,18 @@
}
-#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 ef98d57..909d8f7 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -107,52 +107,22 @@
case FREE_SPACE_TYPE:
FreeSpace::cast(this)->FreeSpacePrint(out);
break;
- case EXTERNAL_PIXEL_ARRAY_TYPE:
- ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(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;
- 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);
- 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,50 +229,16 @@
}
-void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) {
- PrintF(out, "external pixel array");
-}
+#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
+ void External##Type##Array::External##Type##ArrayPrint(FILE* out) { \
+ PrintF(out, "external " #type " array"); \
+ }
+TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
-void ExternalByteArray::ExternalByteArrayPrint(FILE* out) {
- PrintF(out, "external byte array");
-}
+#undef EXTERNAL_ARRAY_PRINTER
-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");
-}
-
-
-void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) {
- PrintF(out, "external float array");
-}
-
-
-void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) {
- PrintF(out, "external double array");
-}
-
template <class Traits>
void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
PrintF(out, "fixed %s", Traits::Designator());
@@ -412,18 +348,18 @@
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 e268768..16c5167 100644
--- a/src/objects-visiting.cc
+++ b/src/objects-visiting.cc
@@ -171,18 +171,14 @@
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 261b385..731d602 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1641,46 +1641,19 @@
case FREE_SPACE_TYPE:
accumulator->Add("<FreeSpace[%u]>", FreeSpace::cast(this)->Size());
break;
- case EXTERNAL_PIXEL_ARRAY_TYPE:
- accumulator->Add("<ExternalPixelArray[%u]>",
- ExternalPixelArray::cast(this)->length());
+#define TYPED_ARRAY_SHORT_PRINT(Type, type, TYPE, ctype, size) \
+ case EXTERNAL_##TYPE##_ARRAY_TYPE: \
+ accumulator->Add("<External" #Type "Array[%u]>", \
+ External##Type##Array::cast(this)->length()); \
+ break; \
+ case FIXED_##TYPE##_ARRAY_TYPE: \
+ accumulator->Add("<Fixed" #Type "Array[%u]>", \
+ Fixed##Type##Array::cast(this)->length()); \
break;
- case EXTERNAL_BYTE_ARRAY_TYPE:
- accumulator->Add("<ExternalByteArray[%u]>",
- ExternalByteArray::cast(this)->length());
- break;
- case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
- accumulator->Add("<ExternalUnsignedByteArray[%u]>",
- ExternalUnsignedByteArray::cast(this)->length());
- break;
- case EXTERNAL_SHORT_ARRAY_TYPE:
- accumulator->Add("<ExternalShortArray[%u]>",
- ExternalShortArray::cast(this)->length());
- break;
- case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
- accumulator->Add("<ExternalUnsignedShortArray[%u]>",
- ExternalUnsignedShortArray::cast(this)->length());
- break;
- case EXTERNAL_INT_ARRAY_TYPE:
- accumulator->Add("<ExternalIntArray[%u]>",
- ExternalIntArray::cast(this)->length());
- break;
- case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
- accumulator->Add("<ExternalUnsignedIntArray[%u]>",
- ExternalUnsignedIntArray::cast(this)->length());
- break;
- case EXTERNAL_FLOAT_ARRAY_TYPE:
- accumulator->Add("<ExternalFloatArray[%u]>",
- ExternalFloatArray::cast(this)->length());
- break;
- case EXTERNAL_DOUBLE_ARRAY_TYPE:
- accumulator->Add("<ExternalDoubleArray[%u]>",
- ExternalDoubleArray::cast(this)->length());
- break;
- case FIXED_UINT8_ARRAY_TYPE:
- accumulator->Add("<FixedUint8Array[%u]>",
- FixedUint8Array::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<char> debug_name =
@@ -1857,29 +1830,21 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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);
+
+#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
+ case EXTERNAL_##TYPE##_ELEMENTS: { \
+ Handle<External##Type##Array> array( \
+ External##Type##Array::cast(object->elements())); \
+ return External##Type##Array::SetValue(array, index, value); \
+ } \
+ case TYPE##_ELEMENTS: { \
+ Handle<Fixed##Type##Array> array( \
+ Fixed##Type##Array::cast(object->elements())); \
+ return Fixed##Type##Array::SetValue(array, index, value); \
}
- case EXTERNAL_BYTE_ELEMENTS: {
- Handle<ExternalByteArray> array(
- ExternalByteArray::cast(object->elements()));
- return ExternalByteArray::SetValue(array, index, value);
- }
- case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
- Handle<ExternalUnsignedByteArray> array(
- ExternalUnsignedByteArray::cast(object->elements()));
- return ExternalUnsignedByteArray::SetValue(array, index, value);
- }
- case EXTERNAL_SHORT_ELEMENTS: {
- Handle<ExternalShortArray> array(ExternalShortArray::cast(
- object->elements()));
- return ExternalShortArray::SetValue(array, index, value);
- }
- case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
- Handle<ExternalUnsignedShortArray> array(
- ExternalUnsignedShortArray::cast(object->elements()));
- return ExternalUnsignedShortArray::SetValue(array, index, value);
- }
- case EXTERNAL_INT_ELEMENTS: {
- Handle<ExternalIntArray> array(
- ExternalIntArray::cast(object->elements()));
- return ExternalIntArray::SetValue(array, index, value);
- }
- case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
- Handle<ExternalUnsignedIntArray> array(
- ExternalUnsignedIntArray::cast(object->elements()));
- return ExternalUnsignedIntArray::SetValue(array, index, value);
- }
- case EXTERNAL_FLOAT_ELEMENTS: {
- Handle<ExternalFloatArray> array(
- ExternalFloatArray::cast(object->elements()));
- return ExternalFloatArray::SetValue(array, index, value);
- }
- case EXTERNAL_DOUBLE_ELEMENTS: {
- Handle<ExternalDoubleArray> array(
- ExternalDoubleArray::cast(object->elements()));
- return ExternalDoubleArray::SetValue(array, index, value);
- }
- case UINT8_ELEMENTS: {
- Handle<FixedUint8Array> array(
- FixedUint8Array::cast(object->elements()));
- return FixedUint8Array::SetValue(array, index, value);
- }
- case UINT8_CLAMPED_ELEMENTS: {
- Handle<FixedUint8ClampedArray> array(
- FixedUint8ClampedArray::cast(object->elements()));
- return FixedUint8ClampedArray::SetValue(array, index, value);
- }
- case INT8_ELEMENTS: {
- Handle<FixedInt8Array> array(
- FixedInt8Array::cast(object->elements()));
- return FixedInt8Array::SetValue(array, index, value);
- }
- case UINT16_ELEMENTS: {
- Handle<FixedUint16Array> array(
- FixedUint16Array::cast(object->elements()));
- return FixedUint16Array::SetValue(array, index, value);
- }
- case INT16_ELEMENTS: {
- Handle<FixedInt16Array> array(
- FixedInt16Array::cast(object->elements()));
- return FixedInt16Array::SetValue(array, index, value);
- }
- case UINT32_ELEMENTS: {
- Handle<FixedUint32Array> array(
- FixedUint32Array::cast(object->elements()));
- return FixedUint32Array::SetValue(array, index, value);
- }
- case INT32_ELEMENTS: {
- Handle<FixedInt32Array> array(
- FixedInt32Array::cast(object->elements()));
- return FixedInt32Array::SetValue(array, index, value);
- }
- case FLOAT32_ELEMENTS: {
- Handle<FixedFloat32Array> array(
- FixedFloat32Array::cast(object->elements()));
- return FixedFloat32Array::SetValue(array, index, value);
- }
- case FLOAT64_ELEMENTS: {
- Handle<FixedFloat64Array> array(
- FixedFloat64Array::cast(object->elements()));
- return FixedFloat64Array::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 @@
}
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 @@
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 @@
ASSERT(!storage || storage->length() >= counter);
break;
}
+
case DICTIONARY_ELEMENTS: {
if (storage != NULL) {
element_dictionary()->CopyKeysTo(storage,
@@ -14665,24 +14490,13 @@
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<ExternalArrayType>(-1);
}
@@ -14691,24 +14505,13 @@
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 @@
}
-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<uint32_t>(length())) {
if (value->IsSmi()) {
@@ -14751,6 +14554,14 @@
}
+Handle<Object> ExternalUint8ClampedArray::SetValue(
+ Handle<ExternalUint8ClampedArray> array,
+ uint32_t index,
+ Handle<Object> value) {
+ return Handle<Object>(array->SetValue(index, *value), array->GetIsolate());
+}
+
+
template<typename ExternalArrayClass, typename ValueType>
static MaybeObject* ExternalArrayIntSetter(Heap* heap,
ExternalArrayClass* receiver,
@@ -14775,7 +14586,7 @@
}
-Handle<Object> ExternalByteArray::SetValue(Handle<ExternalByteArray> array,
+Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14784,14 +14595,14 @@
}
-MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) {
- return ExternalArrayIntSetter<ExternalByteArray, int8_t>
+MaybeObject* ExternalInt8Array::SetValue(uint32_t index, Object* value) {
+ return ExternalArrayIntSetter<ExternalInt8Array, int8_t>
(GetHeap(), this, index, value);
}
-Handle<Object> ExternalUnsignedByteArray::SetValue(
- Handle<ExternalUnsignedByteArray> array,
+Handle<Object> ExternalUint8Array::SetValue(
+ Handle<ExternalUint8Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14800,15 +14611,15 @@
}
-MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index,
+MaybeObject* ExternalUint8Array::SetValue(uint32_t index,
Object* value) {
- return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t>
+ return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>
(GetHeap(), this, index, value);
}
-Handle<Object> ExternalShortArray::SetValue(
- Handle<ExternalShortArray> array,
+Handle<Object> ExternalInt16Array::SetValue(
+ Handle<ExternalInt16Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14817,15 +14628,15 @@
}
-MaybeObject* ExternalShortArray::SetValue(uint32_t index,
+MaybeObject* ExternalInt16Array::SetValue(uint32_t index,
Object* value) {
- return ExternalArrayIntSetter<ExternalShortArray, int16_t>
+ return ExternalArrayIntSetter<ExternalInt16Array, int16_t>
(GetHeap(), this, index, value);
}
-Handle<Object> ExternalUnsignedShortArray::SetValue(
- Handle<ExternalUnsignedShortArray> array,
+Handle<Object> ExternalUint16Array::SetValue(
+ Handle<ExternalUint16Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14834,14 +14645,14 @@
}
-MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index,
+MaybeObject* ExternalUint16Array::SetValue(uint32_t index,
Object* value) {
- return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t>
+ return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>
(GetHeap(), this, index, value);
}
-Handle<Object> ExternalIntArray::SetValue(Handle<ExternalIntArray> array,
+Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14850,14 +14661,14 @@
}
-MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) {
- return ExternalArrayIntSetter<ExternalIntArray, int32_t>
+MaybeObject* ExternalInt32Array::SetValue(uint32_t index, Object* value) {
+ return ExternalArrayIntSetter<ExternalInt32Array, int32_t>
(GetHeap(), this, index, value);
}
-Handle<Object> ExternalUnsignedIntArray::SetValue(
- Handle<ExternalUnsignedIntArray> array,
+Handle<Object> ExternalUint32Array::SetValue(
+ Handle<ExternalUint32Array> array,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(array->GetIsolate(),
@@ -14866,7 +14677,7 @@
}
-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<uint32_t>(length())) {
@@ -14887,16 +14698,17 @@
}
-Handle<Object> ExternalFloatArray::SetValue(Handle<ExternalFloatArray> array,
- uint32_t index,
- Handle<Object> value) {
+Handle<Object> ExternalFloat32Array::SetValue(
+ Handle<ExternalFloat32Array> array,
+ uint32_t index,
+ Handle<Object> 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<float>(OS::nan_value());
Heap* heap = GetHeap();
if (index < static_cast<uint32_t>(length())) {
@@ -14917,16 +14729,17 @@
}
-Handle<Object> ExternalDoubleArray::SetValue(Handle<ExternalDoubleArray> array,
- uint32_t index,
- Handle<Object> value) {
+Handle<Object> ExternalFloat64Array::SetValue(
+ Handle<ExternalFloat64Array> array,
+ uint32_t index,
+ Handle<Object> 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<uint32_t>(length())) {
diff --git a/src/objects.h b/src/objects.h
index 186c866..c6f36bf 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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
};
+// 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 @@
};
-// 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 @@
// 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 @@
// undefined and clamps the converted value between 0 and 255.
Object* SetValue(uint32_t index, Object* value);
+ static Handle<Object> SetValue(Handle<ExternalUint8ClampedArray> array,
+ uint32_t index,
+ Handle<Object> 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<Object> SetValue(Handle<ExternalByteArray> array,
+ static Handle<Object> SetValue(Handle<ExternalInt8Array> array,
uint32_t index,
Handle<Object> value);
@@ -4653,25 +4672,25 @@
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<Object> SetValue(Handle<ExternalUnsignedByteArray> array,
+ static Handle<Object> SetValue(Handle<ExternalUint8Array> array,
uint32_t index,
Handle<Object> value);
@@ -4680,25 +4699,25 @@
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<Object> SetValue(Handle<ExternalShortArray> array,
+ static Handle<Object> SetValue(Handle<ExternalInt16Array> array,
uint32_t index,
Handle<Object> value);
@@ -4707,25 +4726,25 @@
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<Object> SetValue(Handle<ExternalUnsignedShortArray> array,
+ static Handle<Object> SetValue(Handle<ExternalUint16Array> array,
uint32_t index,
Handle<Object> value);
@@ -4734,25 +4753,25 @@
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<Object> SetValue(Handle<ExternalIntArray> array,
+ static Handle<Object> SetValue(Handle<ExternalInt32Array> array,
uint32_t index,
Handle<Object> value);
@@ -4761,25 +4780,25 @@
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<Object> SetValue(Handle<ExternalUnsignedIntArray> array,
+ static Handle<Object> SetValue(Handle<ExternalUint32Array> array,
uint32_t index,
Handle<Object> value);
@@ -4788,25 +4807,25 @@
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<Object> SetValue(Handle<ExternalFloatArray> array,
+ static Handle<Object> SetValue(Handle<ExternalFloat32Array> array,
uint32_t index,
Handle<Object> value);
@@ -4815,25 +4834,25 @@
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<Object> SetValue(Handle<ExternalDoubleArray> array,
+ static Handle<Object> SetValue(Handle<ExternalFloat64Array> array,
uint32_t index,
Handle<Object> value);
@@ -4842,14 +4861,14 @@
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 @@
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 @@
\
typedef FixedTypedArray<Type##ArrayTraits> 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 3fb886c..a2bc186 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -870,42 +870,15 @@
void Runtime::ArrayIdToTypeAndSize(
int arrayId, ExternalArrayType* array_type, size_t* element_size) {
switch (arrayId) {
- case ARRAY_ID_UINT8:
- *array_type = kExternalUnsignedByteArray;
- *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;
- 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;
- break;
+
+ TYPED_ARRAYS(ARRAY_ID_CASE)
+#undef ARRAY_ID_CASE
+
default:
UNREACHABLE();
}
@@ -927,7 +900,7 @@
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 @@
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 @@
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 @@
default: {
int dense_elements_length;
switch (kind) {
- case EXTERNAL_PIXEL_ELEMENTS: {
- dense_elements_length =
- ExternalPixelArray::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; \
}
- 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;
- }
+
+ TYPED_ARRAYS(TYPED_ARRAY_CASE)
+#undef TYPED_ARRAY_CASE
+
default:
UNREACHABLE();
dense_elements_length = 0;
@@ -10289,8 +10215,8 @@
}
break;
}
- case EXTERNAL_PIXEL_ELEMENTS: {
- Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast(
+ case EXTERNAL_UINT8_CLAMPED_ELEMENTS: {
+ Handle<ExternalUint8ClampedArray> pixels(ExternalUint8ClampedArray::cast(
receiver->elements()));
for (uint32_t j = 0; j < length; j++) {
Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)), isolate);
@@ -10298,43 +10224,43 @@
}
break;
}
- case EXTERNAL_BYTE_ELEMENTS: {
- IterateExternalArrayElements<ExternalByteArray, int8_t>(
+ case EXTERNAL_INT8_ELEMENTS: {
+ IterateExternalArrayElements<ExternalInt8Array, int8_t>(
isolate, receiver, true, true, visitor);
break;
}
- case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
- IterateExternalArrayElements<ExternalUnsignedByteArray, uint8_t>(
+ case EXTERNAL_UINT8_ELEMENTS: {
+ IterateExternalArrayElements<ExternalUint8Array, uint8_t>(
isolate, receiver, true, true, visitor);
break;
}
- case EXTERNAL_SHORT_ELEMENTS: {
- IterateExternalArrayElements<ExternalShortArray, int16_t>(
+ case EXTERNAL_INT16_ELEMENTS: {
+ IterateExternalArrayElements<ExternalInt16Array, int16_t>(
isolate, receiver, true, true, visitor);
break;
}
- case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
- IterateExternalArrayElements<ExternalUnsignedShortArray, uint16_t>(
+ case EXTERNAL_UINT16_ELEMENTS: {
+ IterateExternalArrayElements<ExternalUint16Array, uint16_t>(
isolate, receiver, true, true, visitor);
break;
}
- case EXTERNAL_INT_ELEMENTS: {
- IterateExternalArrayElements<ExternalIntArray, int32_t>(
+ case EXTERNAL_INT32_ELEMENTS: {
+ IterateExternalArrayElements<ExternalInt32Array, int32_t>(
isolate, receiver, true, false, visitor);
break;
}
- case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
- IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>(
+ case EXTERNAL_UINT32_ELEMENTS: {
+ IterateExternalArrayElements<ExternalUint32Array, uint32_t>(
isolate, receiver, true, false, visitor);
break;
}
- case EXTERNAL_FLOAT_ELEMENTS: {
- IterateExternalArrayElements<ExternalFloatArray, float>(
+ case EXTERNAL_FLOAT32_ELEMENTS: {
+ IterateExternalArrayElements<ExternalFloat32Array, float>(
isolate, receiver, false, false, visitor);
break;
}
- case EXTERNAL_DOUBLE_ELEMENTS: {
- IterateExternalArrayElements<ExternalDoubleArray, double>(
+ case EXTERNAL_FLOAT64_ELEMENTS: {
+ IterateExternalArrayElements<ExternalFloat64Array, double>(
isolate, receiver, false, false, visitor);
break;
}
@@ -14552,22 +14478,24 @@
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 ec89702..532066f 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -461,16 +461,16 @@
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 @@
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/stub-cache.cc b/src/stub-cache.cc
index 89ed586..f715573 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -1282,41 +1282,6 @@
}
-Handle<Code> CallStubCompiler::CompileArrayPushCall(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Cell> cell,
- Handle<JSFunction> function,
- Handle<String> name,
- Code::StubType type) {
- // If object is not an array or is observed or sealed, bail out to regular
- // call.
- if (!object->IsJSArray() ||
- !cell.is_null() ||
- Handle<JSArray>::cast(object)->map()->is_observed() ||
- !Handle<JSArray>::cast(object)->map()->is_extensible()) {
- return Handle<Code>::null();
- }
-
- Label miss;
-
- HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
-
- Handle<Map> map(Handle<JSArray>::cast(object)->map());
- ElementsKind elements_kind = map->elements_kind();
- const int argc = arguments().immediate();
-
- ArrayPushStub stub(elements_kind, argc);
- Handle<Code> code = stub.GetCode(isolate());
- StubCompiler::GenerateTailCall(masm(), code);
-
- HandlerFrontendFooter(&miss);
-
- // Return the generated code.
- return GetCode(type, name);
-}
-
-
Handle<Code> CallStubCompiler::CompileCallConstant(
Handle<Object> object,
Handle<JSObject> holder,
@@ -1913,13 +1878,6 @@
bool CallStubCompiler::HasCustomCallGenerator(Handle<JSFunction> function) {
- if (function->shared()->HasBuiltinFunctionId()) {
- BuiltinFunctionId id = function->shared()->builtin_function_id();
-#define CALL_GENERATOR_CASE(name) if (id == k##name) return true;
- CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE)
-#undef CALL_GENERATOR_CASE
- }
-
CallOptimization optimization(function);
return optimization.is_simple_api_call();
}
@@ -1933,21 +1891,6 @@
Handle<String> fname,
Code::StubType type) {
ASSERT(HasCustomCallGenerator(function));
-
- if (function->shared()->HasBuiltinFunctionId()) {
- BuiltinFunctionId id = function->shared()->builtin_function_id();
-#define CALL_GENERATOR_CASE(name) \
- if (id == k##name) { \
- return CallStubCompiler::Compile##name##Call(object, \
- holder, \
- cell, \
- function, \
- fname, \
- type); \
- }
- CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE)
-#undef CALL_GENERATOR_CASE
- }
CallOptimization optimization(function);
ASSERT(optimization.is_simple_api_call());
return CompileFastApiCall(optimization,
diff --git a/src/stub-cache.h b/src/stub-cache.h
index a54d92d..9cdd77f 100644
--- a/src/stub-cache.h
+++ b/src/stub-cache.h
@@ -868,13 +868,6 @@
};
-// Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call
-// IC stubs.
-#define CUSTOM_CALL_IC_GENERATORS(V) \
- V(ArrayPush) \
- V(ArrayPop)
-
-
class CallStubCompiler: public StubCompiler {
public:
CallStubCompiler(Isolate* isolate,
@@ -941,16 +934,6 @@
Handle<String> name,
Code::StubType type);
-#define DECLARE_CALL_GENERATOR(name) \
- Handle<Code> Compile##name##Call(Handle<Object> object, \
- Handle<JSObject> holder, \
- Handle<Cell> cell, \
- Handle<JSFunction> function, \
- Handle<String> fname, \
- Code::StubType type);
- CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR)
-#undef DECLARE_CALL_GENERATOR
-
Handle<Code> CompileFastApiCall(const CallOptimization& optimization,
Handle<Object> object,
Handle<JSObject> holder,
diff --git a/src/types.cc b/src/types.cc
index bbaf7a9..7867899 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -540,6 +540,30 @@
}
+template<class Config>
+template<class OtherType>
+typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
+ typename OtherType::TypeHandle type, Region* region) {
+ if (type->IsBitset()) {
+ return Config::from_bitset(type->AsBitset(), region);
+ } else if (type->IsClass()) {
+ return Config::from_class(type->AsClass(), region);
+ } else if (type->IsConstant()) {
+ return Config::from_constant(type->AsConstant(), region);
+ } else {
+ ASSERT(type->IsUnion());
+ typename OtherType::UnionedHandle unioned = type->AsUnion();
+ int length = OtherType::UnionLength(unioned);
+ UnionedHandle new_unioned = Config::union_create(length, region);
+ for (int i = 0; i < length; ++i) {
+ Config::union_set(new_unioned, i,
+ Convert<OtherType>(OtherType::UnionGet(unioned, i), region));
+ }
+ return Config::from_union(new_unioned);
+ }
+}
+
+
// TODO(rossberg): this does not belong here.
Representation Representation::FromType(Type* type) {
if (type->Is(Type::None())) return Representation::None();
@@ -620,5 +644,12 @@
template class TypeImpl<HeapTypeConfig>::Iterator<i::Map>;
template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
+template TypeImpl<ZoneTypeConfig>::TypeHandle
+ TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
+ TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
+template TypeImpl<HeapTypeConfig>::TypeHandle
+ TypeImpl<HeapTypeConfig>::Convert<Type>(
+ TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
+
} } // namespace v8::internal
diff --git a/src/types.h b/src/types.h
index e7b306e..99a809d 100644
--- a/src/types.h
+++ b/src/types.h
@@ -243,6 +243,10 @@
return t;
}
+ template<class OtherTypeImpl>
+ static TypeHandle Convert(
+ typename OtherTypeImpl::TypeHandle type, Region* region);
+
#ifdef OBJECT_PRINT
void TypePrint();
void TypePrint(FILE* out);
@@ -250,6 +254,7 @@
private:
template<class> friend class Iterator;
+ template<class> friend class TypeImpl;
// A union is a fixed array containing types. Invariants:
// - its length is at least 2
@@ -272,6 +277,13 @@
int AsBitset() { return Config::as_bitset(this); }
UnionedHandle AsUnion() { return Config::as_union(this); }
+ static int UnionLength(UnionedHandle unioned) {
+ return Config::union_length(unioned);
+ }
+ static TypeHandle UnionGet(UnionedHandle unioned, int i) {
+ return Config::union_get(unioned, i);
+ }
+
bool SlowIs(TypeImpl* that);
int LubBitset(); // least upper bound that's a bitset
diff --git a/src/version.cc b/src/version.cc
index accd682..e55fcd8 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,8 +34,8 @@
// system so their names cannot be changed without changing the scripts.
#define MAJOR_VERSION 3
#define MINOR_VERSION 24
-#define BUILD_NUMBER 23
-#define PATCH_LEVEL 1
+#define BUILD_NUMBER 24
+#define PATCH_LEVEL 0
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index 4585fa7..e7c20bb 100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -110,7 +110,7 @@
#endif
// Patch the code.
- patcher.masm()->movp(kScratchRegister, target, RelocInfo::NONE64);
+ patcher.masm()->movp(kScratchRegister, target, Assembler::RelocInfoNone());
patcher.masm()->call(kScratchRegister);
// Check that the size of the code generated is as expected.
diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h
index 39a6863..9692ec0 100644
--- a/src/x64/assembler-x64.h
+++ b/src/x64/assembler-x64.h
@@ -590,6 +590,15 @@
set_target_address_at(instruction_payload, target);
}
+ static inline RelocInfo::Mode RelocInfoNone() {
+ if (kPointerSize == kInt64Size) {
+ return RelocInfo::NONE64;
+ } else {
+ ASSERT(kPointerSize == kInt32Size);
+ return RelocInfo::NONE32;
+ }
+ }
+
inline Handle<Object> code_target_object_handle_at(Address pc);
inline Address runtime_entry_at(Address pc);
// Number of bytes taken up by the branch target in the code.
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 6159d6f..b8ef7de 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -418,6 +418,20 @@
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
}
+ {
+ CallInterfaceDescriptor* descriptor =
+ isolate->call_descriptor(Isolate::CallHandler);
+ static Register registers[] = { rsi, // context
+ rdx, // receiver
+ };
+ static Representation representations[] = {
+ Representation::Tagged(), // context
+ Representation::Tagged(), // receiver
+ };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->param_representations_ = representations;
+ }
}
@@ -2705,7 +2719,7 @@
// Do full GC and retry runtime call one final time.
Failure* failure = Failure::InternalError();
- __ Move(rax, failure, RelocInfo::NONE64);
+ __ Move(rax, failure, Assembler::RelocInfoNone());
GenerateCore(masm,
&throw_normal_exception,
&throw_termination_exception,
@@ -2726,7 +2740,7 @@
isolate);
Label already_have_failure;
JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure);
- __ Move(rax, Failure::OutOfMemoryException(0x1), RelocInfo::NONE64);
+ __ Move(rax, Failure::OutOfMemoryException(0x1), Assembler::RelocInfoNone());
__ bind(&already_have_failure);
__ Store(pending_exception, rax);
// Fall through to the next label.
@@ -2756,7 +2770,7 @@
// Scratch register is neither callee-save, nor an argument register on any
// platform. It's free to use at this point.
// Cannot use smi-register for loading yet.
- __ Move(kScratchRegister, Smi::FromInt(marker), RelocInfo::NONE64);
+ __ Move(kScratchRegister, Smi::FromInt(marker), Assembler::RelocInfoNone());
__ push(kScratchRegister); // context slot
__ push(kScratchRegister); // function slot
// Save callee-saved registers (X64/Win64 calling conventions).
@@ -2824,7 +2838,7 @@
ExternalReference pending_exception(Isolate::kPendingExceptionAddress,
isolate);
__ Store(pending_exception, rax);
- __ Move(rax, Failure::Exception(), RelocInfo::NONE64);
+ __ Move(rax, Failure::Exception(), Assembler::RelocInfoNone());
__ jmp(&exit);
// Invoke: Link this frame into the handler chain. There's only one
@@ -4864,7 +4878,7 @@
// Call the entry hook function.
__ Move(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()),
- RelocInfo::NONE64);
+ Assembler::RelocInfoNone());
AllowExternalCallThatCantCauseGC scope(masm);
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc
index 7031837..6c696c4 100644
--- a/src/x64/codegen-x64.cc
+++ b/src/x64/codegen-x64.cc
@@ -131,10 +131,10 @@
// Compute x mod y.
// Load y and x (use argument backing store as temporary storage).
- __ movsd(Operand(rsp, kPointerSize * 2), xmm1);
- __ movsd(Operand(rsp, kPointerSize), xmm0);
- __ fld_d(Operand(rsp, kPointerSize * 2));
- __ fld_d(Operand(rsp, kPointerSize));
+ __ movsd(Operand(rsp, kRegisterSize * 2), xmm1);
+ __ movsd(Operand(rsp, kRegisterSize), xmm0);
+ __ fld_d(Operand(rsp, kRegisterSize * 2));
+ __ fld_d(Operand(rsp, kRegisterSize));
// Clear exception flags before operation.
{
@@ -170,14 +170,14 @@
__ fstp(0); // Drop result in st(0).
int64_t kNaNValue = V8_INT64_C(0x7ff8000000000000);
__ movq(rcx, kNaNValue);
- __ movp(Operand(rsp, kPointerSize), rcx);
- __ movsd(xmm0, Operand(rsp, kPointerSize));
+ __ movq(Operand(rsp, kRegisterSize), rcx);
+ __ movsd(xmm0, Operand(rsp, kRegisterSize));
__ jmp(&return_result);
// If result is valid, return that.
__ bind(&valid_result);
- __ fstp_d(Operand(rsp, kPointerSize));
- __ movsd(xmm0, Operand(rsp, kPointerSize));
+ __ fstp_d(Operand(rsp, kRegisterSize));
+ __ movsd(xmm0, Operand(rsp, kRegisterSize));
// Clean up FPU stack and exceptions and return xmm0
__ bind(&return_result);
diff --git a/src/x64/deoptimizer-x64.cc b/src/x64/deoptimizer-x64.cc
index 1094dab..fd26cf5 100644
--- a/src/x64/deoptimizer-x64.cc
+++ b/src/x64/deoptimizer-x64.cc
@@ -71,7 +71,7 @@
// LLazyBailout instructions with nops if necessary.
CodePatcher patcher(call_address, Assembler::kCallSequenceLength);
patcher.masm()->Call(GetDeoptimizationEntry(isolate, i, LAZY),
- RelocInfo::NONE64);
+ Assembler::RelocInfoNone());
ASSERT(prev_call_address == NULL ||
call_address >= prev_call_address + patch_size());
ASSERT(call_address + patch_size() <= code->instruction_end());
@@ -186,9 +186,9 @@
// On windows put the arguments on the stack (PrepareCallCFunction
// has created space for this). On linux pass the arguments in r8 and r9.
#ifdef _WIN64
- __ movp(Operand(rsp, 4 * kPointerSize), arg5);
+ __ movq(Operand(rsp, 4 * kRegisterSize), arg5);
__ LoadAddress(arg5, ExternalReference::isolate_address(isolate()));
- __ movp(Operand(rsp, 5 * kPointerSize), arg5);
+ __ movq(Operand(rsp, 5 * kRegisterSize), arg5);
#else
__ movp(r8, arg5);
__ LoadAddress(r9, ExternalReference::isolate_address(isolate()));
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 64df73f..c4aedd4 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -3364,7 +3364,7 @@
__ bind(&runtime);
__ PrepareCallCFunction(2);
__ movp(arg_reg_1, object);
- __ Move(arg_reg_2, index, RelocInfo::NONE64);
+ __ Move(arg_reg_2, index, Assembler::RelocInfoNone());
__ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
__ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
__ jmp(&done);
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index e99c9e3..17ded77 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -987,7 +987,7 @@
HMod* hmod = instr->hydrogen();
HValue* left = hmod->left();
HValue* right = hmod->right();
- if (hmod->HasPowerOf2Divisor()) {
+ if (hmod->RightIsPowerOf2()) {
// TODO(svenpanne) We should really do the strength reduction on the
// Hydrogen level.
Register left_reg = ToRegister(instr->left());
@@ -1153,7 +1153,7 @@
void LCodeGen::DoDivI(LDivI* instr) {
- if (!instr->is_flooring() && instr->hydrogen()->HasPowerOf2Divisor()) {
+ if (!instr->is_flooring() && instr->hydrogen()->RightIsPowerOf2()) {
Register dividend = ToRegister(instr->left());
int32_t divisor =
HConstant::cast(instr->hydrogen()->right())->Integer32Value();
@@ -1643,7 +1643,7 @@
__ bind(&runtime);
__ PrepareCallCFunction(2);
__ movp(arg_reg_1, object);
- __ Move(arg_reg_2, index, RelocInfo::NONE64);
+ __ Move(arg_reg_2, index, Assembler::RelocInfoNone());
__ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
__ bind(&done);
}
@@ -2903,8 +2903,9 @@
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 @@
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 @@
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 @@
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 49f7b64..4936503 100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1253,7 +1253,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(instr->left()->representation().Equals(instr->representation()));
ASSERT(instr->right()->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
LOperand* value = UseRegisterAtStart(instr->left());
LDivI* div =
@@ -1275,25 +1275,6 @@
}
-HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
- if (divisor->IsConstant() &&
- HConstant::cast(divisor)->HasInteger32Value()) {
- HConstant* constant_val = HConstant::cast(divisor);
- return constant_val->CopyToRepresentation(Representation::Integer32(),
- divisor->block()->zone());
- }
- // A value with an integer representation does not need to be transformed.
- if (divisor->representation().IsInteger32()) {
- return divisor;
- // A change from an integer32 can be replaced by the integer32 value.
- } else if (divisor->IsChange() &&
- HChange::cast(divisor)->from().IsInteger32()) {
- return HChange::cast(divisor)->value();
- }
- return NULL;
-}
-
-
LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
HValue* right = instr->right();
if (!right->IsConstant()) {
@@ -1336,7 +1317,7 @@
if (instr->representation().IsSmiOrInteger32()) {
ASSERT(left->representation().Equals(instr->representation()));
ASSERT(right->representation().Equals(instr->representation()));
- if (instr->HasPowerOf2Divisor()) {
+ if (instr->RightIsPowerOf2()) {
ASSERT(!right->CanBeZero());
LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
UseOrConstant(right),
@@ -2038,7 +2019,7 @@
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.
@@ -2099,8 +2080,8 @@
(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/src/x64/lithium-x64.h b/src/x64/lithium-x64.h
index 49208f1..da432d2 100644
--- a/src/x64/lithium-x64.h
+++ b/src/x64/lithium-x64.h
@@ -2618,8 +2618,6 @@
HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO
- static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
-
LInstruction* DoMathFloor(HUnaryMathOperation* instr);
LInstruction* DoMathRound(HUnaryMathOperation* instr);
LInstruction* DoMathAbs(HUnaryMathOperation* instr);
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index a1f3f81..1fa2c8d 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -163,7 +163,7 @@
int64_t address = reinterpret_cast<int64_t>(source.address());
if (is_int32(address) && !Serializer::enabled()) {
if (emit_debug_code()) {
- Move(kScratchRegister, kZapValue, RelocInfo::NONE64);
+ Move(kScratchRegister, kZapValue, Assembler::RelocInfoNone());
}
push(Immediate(static_cast<int32_t>(address)));
return;
@@ -289,7 +289,7 @@
intptr_t new_space_start =
reinterpret_cast<intptr_t>(isolate()->heap()->NewSpaceStart());
Move(kScratchRegister, reinterpret_cast<Address>(-new_space_start),
- RelocInfo::NONE64);
+ Assembler::RelocInfoNone());
if (scratch.is(object)) {
addq(scratch, kScratchRegister);
} else {
@@ -340,8 +340,8 @@
// Clobber clobbered input registers when running with the debug-code flag
// turned on to provoke errors.
if (emit_debug_code()) {
- Move(value, kZapValue, RelocInfo::NONE64);
- Move(dst, kZapValue, RelocInfo::NONE64);
+ Move(value, kZapValue, Assembler::RelocInfoNone());
+ Move(dst, kZapValue, Assembler::RelocInfoNone());
}
}
@@ -374,8 +374,8 @@
// Clobber clobbered input registers when running with the debug-code flag
// turned on to provoke errors.
if (emit_debug_code()) {
- Move(value, kZapValue, RelocInfo::NONE64);
- Move(index, kZapValue, RelocInfo::NONE64);
+ Move(value, kZapValue, Assembler::RelocInfoNone());
+ Move(index, kZapValue, Assembler::RelocInfoNone());
}
}
@@ -439,8 +439,8 @@
// Clobber clobbered registers when running with the debug-code flag
// turned on to provoke errors.
if (emit_debug_code()) {
- Move(address, kZapValue, RelocInfo::NONE64);
- Move(value, kZapValue, RelocInfo::NONE64);
+ Move(address, kZapValue, Assembler::RelocInfoNone());
+ Move(value, kZapValue, Assembler::RelocInfoNone());
}
}
@@ -528,10 +528,11 @@
#endif
push(rax);
- Move(kScratchRegister, reinterpret_cast<Smi*>(p0), RelocInfo::NONE64);
+ Move(kScratchRegister, reinterpret_cast<Smi*>(p0),
+ Assembler::RelocInfoNone());
push(kScratchRegister);
Move(kScratchRegister, Smi::FromInt(static_cast<int>(p1 - p0)),
- RelocInfo::NONE64);
+ Assembler::RelocInfoNone());
push(kScratchRegister);
if (!has_frame_) {
@@ -1043,7 +1044,8 @@
void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
if (emit_debug_code()) {
- Move(dst, Smi::FromInt(kSmiConstantRegisterValue), RelocInfo::NONE64);
+ Move(dst, Smi::FromInt(kSmiConstantRegisterValue),
+ Assembler::RelocInfoNone());
cmpq(dst, kSmiConstantRegister);
Assert(equal, kUninitializedKSmiConstantRegister);
}
@@ -1083,7 +1085,7 @@
UNREACHABLE();
return;
default:
- Move(dst, source, RelocInfo::NONE64);
+ Move(dst, source, Assembler::RelocInfoNone());
return;
}
if (negative) {
@@ -2623,7 +2625,7 @@
void MacroAssembler::Call(Address destination, RelocInfo::Mode rmode) {
#ifdef DEBUG
- int end_position = pc_offset() + CallSize(destination, rmode);
+ int end_position = pc_offset() + CallSize(destination);
#endif
Move(kScratchRegister, destination, rmode);
call(kScratchRegister);
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index 08db9b9..048eff1 100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -391,7 +391,7 @@
void InitializeSmiConstantRegister() {
Move(kSmiConstantRegister, Smi::FromInt(kSmiConstantRegisterValue),
- RelocInfo::NONE64);
+ Assembler::RelocInfoNone());
}
// Conversions between tagged smi values and non-tagged integer values.
@@ -877,7 +877,7 @@
TypeFeedbackId ast_id = TypeFeedbackId::None());
// The size of the code generated for different call instructions.
- int CallSize(Address destination, RelocInfo::Mode rmode) {
+ int CallSize(Address destination) {
return kCallSequenceLength;
}
int CallSize(ExternalReference ext);
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 53e9f88..dbfd419 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -1534,77 +1534,6 @@
}
-Handle<Code> CallStubCompiler::CompileArrayPopCall(
- Handle<Object> object,
- Handle<JSObject> holder,
- Handle<Cell> cell,
- Handle<JSFunction> function,
- Handle<String> name,
- Code::StubType type) {
- // If object is not an array or is observed or sealed, bail out to regular
- // call.
- if (!object->IsJSArray() ||
- !cell.is_null() ||
- Handle<JSArray>::cast(object)->map()->is_observed() ||
- !Handle<JSArray>::cast(object)->map()->is_extensible()) {
- return Handle<Code>::null();
- }
-
- Label miss, return_undefined, call_builtin;
-
- HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
-
- // Get the elements array of the object.
- __ movp(rbx, FieldOperand(rdx, JSArray::kElementsOffset));
-
- // Check that the elements are in fast mode and writable.
- __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset),
- Heap::kFixedArrayMapRootIndex);
- __ j(not_equal, &call_builtin);
-
- // Get the array's length into rcx and calculate new length.
- __ SmiToInteger32(rcx, FieldOperand(rdx, JSArray::kLengthOffset));
- __ subl(rcx, Immediate(1));
- __ j(negative, &return_undefined);
-
- // Get the last element.
- __ LoadRoot(r9, Heap::kTheHoleValueRootIndex);
- __ movp(rax, FieldOperand(rbx,
- rcx, times_pointer_size,
- FixedArray::kHeaderSize));
- // Check if element is already the hole.
- __ cmpq(rax, r9);
- // If so, call slow-case to also check prototypes for value.
- __ j(equal, &call_builtin);
-
- // Set the array's length.
- __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rcx);
-
- // Fill with the hole and return original value.
- __ movp(FieldOperand(rbx,
- rcx, times_pointer_size,
- FixedArray::kHeaderSize),
- r9);
- const int argc = arguments().immediate();
- __ ret((argc + 1) * kPointerSize);
-
- __ bind(&return_undefined);
- __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
- __ ret((argc + 1) * kPointerSize);
-
- __ bind(&call_builtin);
- __ TailCallExternalReference(
- ExternalReference(Builtins::c_ArrayPop, isolate()),
- argc + 1,
- 1);
-
- HandlerFrontendFooter(&miss);
-
- // Return the generated code.
- return GetCode(type, name);
-}
-
-
Handle<Code> CallStubCompiler::CompileFastApiCall(
const CallOptimization& optimization,
Handle<Object> object,
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 715c41a..c0ba7fd 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -15705,10 +15705,10 @@
v8::HandleScope scope(context->GetIsolate());
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
- i::Handle<i::ExternalPixelArray> pixels =
- i::Handle<i::ExternalPixelArray>::cast(
+ i::Handle<i::ExternalUint8ClampedArray> pixels =
+ i::Handle<i::ExternalUint8ClampedArray>::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 @@
v8::HandleScope scope(isolate);
const int kElementCount = 260;
uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
- i::Handle<i::ExternalPixelArray> pixels =
- i::Handle<i::ExternalPixelArray>::cast(
+ i::Handle<i::ExternalUint8ClampedArray> pixels =
+ i::Handle<i::ExternalUint8ClampedArray>::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 @@
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 @@
"}"
"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<int>(i::OS::nan_value()),
static_cast<int>(
jsobj->GetElement(isolate, 7)->ToObjectChecked()->Number()));
@@ -16344,8 +16344,8 @@
static_cast<int>(
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 @@
"}"
"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 @@
"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 @@
THREADED_TEST(FixedUint8Array) {
FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>(
- v8::kExternalUnsignedByteArray,
+ v8::kExternalUint8Array,
0x0, 0xFF);
}
@@ -16532,56 +16532,56 @@
THREADED_TEST(FixedUint8ClampedArray) {
FixedTypedArrayTestHelper<i::FixedUint8ClampedArray,
i::UINT8_CLAMPED_ELEMENTS, uint8_t>(
- v8::kExternalPixelArray,
+ v8::kExternalUint8ClampedArray,
0x0, 0xFF);
}
THREADED_TEST(FixedInt8Array) {
FixedTypedArrayTestHelper<i::FixedInt8Array, i::INT8_ELEMENTS, int8_t>(
- v8::kExternalByteArray,
+ v8::kExternalInt8Array,
-0x80, 0x7F);
}
THREADED_TEST(FixedUint16Array) {
FixedTypedArrayTestHelper<i::FixedUint16Array, i::UINT16_ELEMENTS, uint16_t>(
- v8::kExternalUnsignedShortArray,
+ v8::kExternalUint16Array,
0x0, 0xFFFF);
}
THREADED_TEST(FixedInt16Array) {
FixedTypedArrayTestHelper<i::FixedInt16Array, i::INT16_ELEMENTS, int16_t>(
- v8::kExternalShortArray,
+ v8::kExternalInt16Array,
-0x8000, 0x7FFF);
}
THREADED_TEST(FixedUint32Array) {
FixedTypedArrayTestHelper<i::FixedUint32Array, i::UINT32_ELEMENTS, uint32_t>(
- v8::kExternalUnsignedIntArray,
+ v8::kExternalUint32Array,
0x0, UINT_MAX);
}
THREADED_TEST(FixedInt32Array) {
FixedTypedArrayTestHelper<i::FixedInt32Array, i::INT32_ELEMENTS, int32_t>(
- v8::kExternalIntArray,
+ v8::kExternalInt32Array,
INT_MIN, INT_MAX);
}
THREADED_TEST(FixedFloat32Array) {
FixedTypedArrayTestHelper<i::FixedFloat32Array, i::FLOAT32_ELEMENTS, float>(
- v8::kExternalFloatArray,
+ v8::kExternalFloat32Array,
-500, 500);
}
THREADED_TEST(FixedFloat64Array) {
FixedTypedArrayTestHelper<i::FixedFloat64Array, i::FLOAT64_ELEMENTS, float>(
- v8::kExternalDoubleArray,
+ v8::kExternalFloat64Array,
-500, 500);
}
@@ -16803,86 +16803,86 @@
}
-THREADED_TEST(ExternalByteArray) {
- ExternalArrayTestHelper<i::ExternalByteArray, int8_t>(
- v8::kExternalByteArray,
+THREADED_TEST(ExternalInt8Array) {
+ ExternalArrayTestHelper<i::ExternalInt8Array, int8_t>(
+ v8::kExternalInt8Array,
-128,
127);
}
-THREADED_TEST(ExternalUnsignedByteArray) {
- ExternalArrayTestHelper<i::ExternalUnsignedByteArray, uint8_t>(
- v8::kExternalUnsignedByteArray,
+THREADED_TEST(ExternalUint8Array) {
+ ExternalArrayTestHelper<i::ExternalUint8Array, uint8_t>(
+ v8::kExternalUint8Array,
0,
255);
}
-THREADED_TEST(ExternalPixelArray) {
- ExternalArrayTestHelper<i::ExternalPixelArray, uint8_t>(
- v8::kExternalPixelArray,
+THREADED_TEST(ExternalUint8ClampedArray) {
+ ExternalArrayTestHelper<i::ExternalUint8ClampedArray, uint8_t>(
+ v8::kExternalUint8ClampedArray,
0,
255);
}
-THREADED_TEST(ExternalShortArray) {
- ExternalArrayTestHelper<i::ExternalShortArray, int16_t>(
- v8::kExternalShortArray,
+THREADED_TEST(ExternalInt16Array) {
+ ExternalArrayTestHelper<i::ExternalInt16Array, int16_t>(
+ v8::kExternalInt16Array,
-32768,
32767);
}
-THREADED_TEST(ExternalUnsignedShortArray) {
- ExternalArrayTestHelper<i::ExternalUnsignedShortArray, uint16_t>(
- v8::kExternalUnsignedShortArray,
+THREADED_TEST(ExternalUint16Array) {
+ ExternalArrayTestHelper<i::ExternalUint16Array, uint16_t>(
+ v8::kExternalUint16Array,
0,
65535);
}
-THREADED_TEST(ExternalIntArray) {
- ExternalArrayTestHelper<i::ExternalIntArray, int32_t>(
- v8::kExternalIntArray,
+THREADED_TEST(ExternalInt32Array) {
+ ExternalArrayTestHelper<i::ExternalInt32Array, int32_t>(
+ v8::kExternalInt32Array,
INT_MIN, // -2147483648
INT_MAX); // 2147483647
}
-THREADED_TEST(ExternalUnsignedIntArray) {
- ExternalArrayTestHelper<i::ExternalUnsignedIntArray, uint32_t>(
- v8::kExternalUnsignedIntArray,
+THREADED_TEST(ExternalUint32Array) {
+ ExternalArrayTestHelper<i::ExternalUint32Array, uint32_t>(
+ v8::kExternalUint32Array,
0,
UINT_MAX); // 4294967295
}
-THREADED_TEST(ExternalFloatArray) {
- ExternalArrayTestHelper<i::ExternalFloatArray, float>(
- v8::kExternalFloatArray,
+THREADED_TEST(ExternalFloat32Array) {
+ ExternalArrayTestHelper<i::ExternalFloat32Array, float>(
+ v8::kExternalFloat32Array,
-500,
500);
}
-THREADED_TEST(ExternalDoubleArray) {
- ExternalArrayTestHelper<i::ExternalDoubleArray, double>(
- v8::kExternalDoubleArray,
+THREADED_TEST(ExternalFloat64Array) {
+ ExternalArrayTestHelper<i::ExternalFloat64Array, double>(
+ 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 @@
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 @@
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 @@
THREADED_TEST(Uint8Array) {
- TypedArrayTestHelper<uint8_t, v8::Uint8Array, i::ExternalUnsignedByteArray>(
- v8::kExternalUnsignedByteArray, 0, 0xFF);
+ TypedArrayTestHelper<uint8_t, v8::Uint8Array, i::ExternalUint8Array>(
+ v8::kExternalUint8Array, 0, 0xFF);
}
THREADED_TEST(Int8Array) {
- TypedArrayTestHelper<int8_t, v8::Int8Array, i::ExternalByteArray>(
- v8::kExternalByteArray, -0x80, 0x7F);
+ TypedArrayTestHelper<int8_t, v8::Int8Array, i::ExternalInt8Array>(
+ v8::kExternalInt8Array, -0x80, 0x7F);
}
THREADED_TEST(Uint16Array) {
TypedArrayTestHelper<uint16_t,
v8::Uint16Array,
- i::ExternalUnsignedShortArray>(
- v8::kExternalUnsignedShortArray, 0, 0xFFFF);
+ i::ExternalUint16Array>(
+ v8::kExternalUint16Array, 0, 0xFFFF);
}
THREADED_TEST(Int16Array) {
- TypedArrayTestHelper<int16_t, v8::Int16Array, i::ExternalShortArray>(
- v8::kExternalShortArray, -0x8000, 0x7FFF);
+ TypedArrayTestHelper<int16_t, v8::Int16Array, i::ExternalInt16Array>(
+ v8::kExternalInt16Array, -0x8000, 0x7FFF);
}
THREADED_TEST(Uint32Array) {
- TypedArrayTestHelper<uint32_t, v8::Uint32Array, i::ExternalUnsignedIntArray>(
- v8::kExternalUnsignedIntArray, 0, UINT_MAX);
+ TypedArrayTestHelper<uint32_t, v8::Uint32Array, i::ExternalUint32Array>(
+ v8::kExternalUint32Array, 0, UINT_MAX);
}
THREADED_TEST(Int32Array) {
- TypedArrayTestHelper<int32_t, v8::Int32Array, i::ExternalIntArray>(
- v8::kExternalIntArray, INT_MIN, INT_MAX);
+ TypedArrayTestHelper<int32_t, v8::Int32Array, i::ExternalInt32Array>(
+ v8::kExternalInt32Array, INT_MIN, INT_MAX);
}
THREADED_TEST(Float32Array) {
- TypedArrayTestHelper<float, v8::Float32Array, i::ExternalFloatArray>(
- v8::kExternalFloatArray, -500, 500);
+ TypedArrayTestHelper<float, v8::Float32Array, i::ExternalFloat32Array>(
+ v8::kExternalFloat32Array, -500, 500);
}
THREADED_TEST(Float64Array) {
- TypedArrayTestHelper<double, v8::Float64Array, i::ExternalDoubleArray>(
- v8::kExternalDoubleArray, -500, 500);
+ TypedArrayTestHelper<double, v8::Float64Array, i::ExternalFloat64Array>(
+ v8::kExternalFloat64Array, -500, 500);
}
THREADED_TEST(Uint8ClampedArray) {
- TypedArrayTestHelper<uint8_t, v8::Uint8ClampedArray, i::ExternalPixelArray>(
- v8::kExternalPixelArray, 0, 0xFF);
+ TypedArrayTestHelper<uint8_t,
+ v8::Uint8ClampedArray, i::ExternalUint8ClampedArray>(
+ v8::kExternalUint8ClampedArray, 0, 0xFF);
}
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 754d9a5..fdaf9fa 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2319,3 +2319,24 @@
heap_profiler->StopTrackingHeapObjects();
}
}
+
+
+TEST(ArrayBufferAndArrayBufferView) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ CompileRun("arr1 = new Uint32Array(100);\n");
+ const v8::HeapSnapshot* snapshot =
+ heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
+ CHECK(ValidateSnapshot(snapshot));
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+ const v8::HeapGraphNode* arr1_obj =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "arr1");
+ CHECK_NE(NULL, arr1_obj);
+ const v8::HeapGraphNode* arr1_buffer =
+ GetProperty(arr1_obj, v8::HeapGraphEdge::kInternal, "buffer");
+ CHECK_NE(NULL, arr1_buffer);
+ const v8::HeapGraphNode* first_view =
+ GetProperty(arr1_buffer, v8::HeapGraphEdge::kWeak, "weak_first_view");
+ CHECK_NE(NULL, first_view);
+}
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 9c3cce9..957c3d9 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -119,6 +119,54 @@
return Type::Intersect(t1, t2, region_);
}
+ template<class Type2, class TypeHandle2>
+ TypeHandle Convert(TypeHandle2 t) {
+ return Type::template Convert<Type2>(t, region_);
+ }
+
+ TypeHandle Fuzz(int depth = 5) {
+ switch (rand() % (depth == 0 ? 3 : 20)) {
+ case 0: { // bitset
+ int n = 0
+ #define COUNT_BITSET_TYPES(type, value) + 1
+ BITSET_TYPE_LIST(COUNT_BITSET_TYPES)
+ #undef COUNT_BITSET_TYPES
+ ;
+ int i = rand() % n;
+ #define PICK_BITSET_TYPE(type, value) \
+ if (i-- == 0) return Type::type(region_);
+ BITSET_TYPE_LIST(PICK_BITSET_TYPE)
+ #undef PICK_BITSET_TYPE
+ UNREACHABLE();
+ }
+ case 1: // class
+ switch (rand() % 2) {
+ case 0: return ObjectClass;
+ case 1: return ArrayClass;
+ }
+ UNREACHABLE();
+ case 2: // constant
+ switch (rand() % 6) {
+ case 0: return SmiConstant;
+ case 1: return Signed32Constant;
+ case 2: return ObjectConstant1;
+ case 3: return ObjectConstant2;
+ case 4: return ArrayConstant1;
+ case 5: return ArrayConstant2;
+ }
+ UNREACHABLE();
+ default: { // union
+ int n = rand() % 10;
+ TypeHandle type = None;
+ for (int i = 0; i < n; ++i) {
+ type = Type::Union(type, Fuzz(depth - 1), region_);
+ }
+ return type;
+ }
+ }
+ UNREACHABLE();
+ }
+
private:
Region* region_;
};
@@ -756,6 +804,16 @@
T.Union(T.ObjectConstant1, T.ArrayConstant2)),
T.ArrayConstant1);
}
+
+ template<class Type2, class TypeHandle2, class Region2, class Rep2>
+ void Convert() {
+ Types<Type2, TypeHandle2, Region2> T2(
+ Rep2::ToRegion(&zone, isolate), isolate);
+ for (int i = 0; i < 100; ++i) {
+ TypeHandle type = T.Fuzz();
+ CheckEqual(type, T.Convert<Type2>(T2.Convert<Type>(type)));
+ }
+ }
};
typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests;
@@ -809,3 +867,10 @@
ZoneTests().Intersect();
HeapTests().Intersect();
}
+
+
+TEST(Convert) {
+ CcTest::InitializeVM();
+ ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
+ HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
+}
diff --git a/test/mjsunit/array-pop.js b/test/mjsunit/array-pop.js
index f193f09..1777183 100644
--- a/test/mjsunit/array-pop.js
+++ b/test/mjsunit/array-pop.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+//
// Check pops with various number of arguments.
(function() {
var a = [];
@@ -121,3 +123,18 @@
assertEquals(99 - i, x.pop(), i + 'th iteration');
}
})();
+
+(function () {
+ function f(a, deopt) {
+ var v = a.pop() ? 1 : 2;
+ if (deopt) %DeoptimizeFunction(f);
+ return v;
+ }
+
+ var a = [true, true, true, true]
+ assertEquals(1, f(a, false));
+ assertEquals(1, f(a, false));
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals(1, f(a, false));
+ assertEquals(1, f(a, true));
+})();
diff --git a/test/mjsunit/compiler/alloc-number-debug.js b/test/mjsunit/compiler/alloc-number-debug.js
new file mode 100644
index 0000000..ccfcc0c
--- /dev/null
+++ b/test/mjsunit/compiler/alloc-number-debug.js
@@ -0,0 +1,44 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+// Try to get a GC because of a heap number allocation while we
+// have live values (o) in a register.
+function f(o) {
+ var x = 1.5;
+ var y = 2.5;
+ for (var i = 1; i < 3; i += 1) {
+ %SetAllocationTimeout(1, 0, false);
+ o.val = x + y + i;
+ %SetAllocationTimeout(-1, -1, true);
+ }
+ return o;
+}
+
+var o = { val: 0 };
+f(o);
diff --git a/test/mjsunit/compiler/regress-arguments.js b/test/mjsunit/compiler/regress-arguments.js
index ebae5a0..d32b435 100644
--- a/test/mjsunit/compiler/regress-arguments.js
+++ b/test/mjsunit/compiler/regress-arguments.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+
// Test of arguments.
// Test passing null or undefined as receiver.
@@ -35,8 +37,15 @@
var foo = 42;
-for (var i=0; i<1000000; i++) assertEquals(42, g());
-for (var i=0; i<1000000; i++) assertEquals(42, h());
+for (var i = 0; i < 3; i++) assertEquals(42, g());
+%OptimizeFunctionOnNextCall(g);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(42, g());
+
+for (var i = 0; i < 3; i++) assertEquals(42, h());
+%OptimizeFunctionOnNextCall(h);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(42, h());
var G1 = 21;
var G2 = 22;
@@ -49,4 +58,7 @@
Number.prototype.foo = 42;
delete Number.prototype.foo;
-for (var i=0; i<100000; i++) assertEquals(void 0, u());
+for (var i = 0; i < 3; i++) assertEquals(void 0, u());
+%OptimizeFunctionOnNextCall(u);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(void 0, u());
diff --git a/test/mjsunit/compiler/regress-rep-change.js b/test/mjsunit/compiler/regress-rep-change.js
index 9370999..c8a0983 100644
--- a/test/mjsunit/compiler/regress-rep-change.js
+++ b/test/mjsunit/compiler/regress-rep-change.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+
// Regression test for the case where a phi has two input operands with
// the same value.
@@ -35,8 +37,11 @@
for (var i = start; i < 10; i++) { }
}
-var n = 5000000;
+var n = 3;
for (var i = 0; i < n; ++i) {
test(0);
}
+
+%OptimizeFunctionOnNextCall(test);
+test(0);
diff --git a/test/mjsunit/elements-kind.js b/test/mjsunit/elements-kind.js
index d16ddca..e2bbc31 100644
--- a/test/mjsunit/elements-kind.js
+++ b/test/mjsunit/elements-kind.js
@@ -65,31 +65,31 @@
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;
}
}
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index 2669d0f..572291a 100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -104,6 +104,13 @@
# Tests verifying CHECK and ASSERT.
'verify-check-false': [FAIL, NO_VARIANTS],
'verify-assert-false': [NO_VARIANTS, ['mode == release', PASS], ['mode == debug', FAIL]],
+
+ ##############################################################################
+ # Tests with different versions for release and debug.
+ 'compiler/alloc-number': [PASS, ['mode == debug', SKIP]],
+ 'compiler/alloc-number-debug': [PASS, ['mode == release', SKIP]],
+ 'regress/regress-634': [PASS, ['mode == debug', SKIP]],
+ 'regress/regress-634-debug': [PASS, ['mode == release', SKIP]],
}], # ALWAYS
##############################################################################
@@ -142,30 +149,12 @@
'string-indexof-2': [PASS, TIMEOUT],
'mirror-object': [PASS, TIMEOUT],
- # BUG(3251035): Timeouts in long looping crankshaft optimization
- # tests. Skipping because having them timeout takes too long on the
- # buildbot.
+ # Long running tests. Skipping because having them timeout takes too long on
+ # the buildbot.
'compiler/alloc-number': [SKIP],
- 'compiler/array-length': [SKIP],
- 'compiler/assignment-deopt': [SKIP],
- 'compiler/deopt-args': [SKIP],
- 'compiler/inline-compare': [SKIP],
- 'compiler/inline-global-access': [SKIP],
- 'compiler/optimized-function-calls': [SKIP],
- 'compiler/pic': [SKIP],
- 'compiler/property-calls': [SKIP],
- 'compiler/recursive-deopt': [SKIP],
- 'compiler/regress-4': [SKIP],
- 'compiler/regress-funcaller': [SKIP],
- 'compiler/regress-rep-change': [SKIP],
- 'compiler/regress-arguments': [SKIP],
- 'compiler/regress-funarguments': [SKIP],
- 'compiler/regress-3249650': [SKIP],
- 'compiler/simple-deopt': [SKIP],
'regress/regress-490': [SKIP],
'regress/regress-634': [SKIP],
'regress/regress-create-exception': [SKIP],
- 'regress/regress-3218915': [SKIP],
'regress/regress-3247124': [SKIP],
# Requires bigger stack size in the Genesis and if stack size is increased,
@@ -211,30 +200,12 @@
'mirror-object': [PASS, TIMEOUT],
'string-indexof-2': [PASS, TIMEOUT],
- # BUG(3251035): Timeouts in long looping crankshaft optimization
- # tests. Skipping because having them timeout takes too long on the
- # buildbot.
+ # Long running tests. Skipping because having them timeout takes too long on
+ # the buildbot.
'compiler/alloc-number': [SKIP],
- 'compiler/array-length': [SKIP],
- 'compiler/assignment-deopt': [SKIP],
- 'compiler/deopt-args': [SKIP],
- 'compiler/inline-compare': [SKIP],
- 'compiler/inline-global-access': [SKIP],
- 'compiler/optimized-function-calls': [SKIP],
- 'compiler/pic': [SKIP],
- 'compiler/property-calls': [SKIP],
- 'compiler/recursive-deopt': [SKIP],
- 'compiler/regress-4': [SKIP],
- 'compiler/regress-funcaller': [SKIP],
- 'compiler/regress-rep-change': [SKIP],
- 'compiler/regress-arguments': [SKIP],
- 'compiler/regress-funarguments': [SKIP],
- 'compiler/regress-3249650': [SKIP],
- 'compiler/simple-deopt': [SKIP],
'regress/regress-490': [SKIP],
'regress/regress-634': [SKIP],
'regress/regress-create-exception': [SKIP],
- 'regress/regress-3218915': [SKIP],
'regress/regress-3247124': [SKIP],
# Requires bigger stack size in the Genesis and if stack size is increased,
diff --git a/test/mjsunit/object-seal.js b/test/mjsunit/object-seal.js
index f31f0b7..3afddb9 100644
--- a/test/mjsunit/object-seal.js
+++ b/test/mjsunit/object-seal.js
@@ -251,8 +251,7 @@
Object.seal(obj);
assertThrows(function() { push_call(obj); }, TypeError);
assertThrows(function() { shift_call(obj); }, TypeError);
-assertOptimized(push_call);
-// shift() doesn't have a custom call generator, so deopt will occur.
+assertUnoptimized(push_call);
assertUnoptimized(shift_call);
assertDoesNotThrow(function() { push_call(objControl); });
assertDoesNotThrow(function() { shift_call(objControl); });
diff --git a/test/mjsunit/regress/regress-490.js b/test/mjsunit/regress/regress-490.js
index 8dd8959..6ce89db 100644
--- a/test/mjsunit/regress/regress-490.js
+++ b/test/mjsunit/regress/regress-490.js
@@ -42,6 +42,9 @@
var b = '';
for (var j = 0; j < 10; j++) {
b += '$1';
+
+ // TODO(machenbach): Do we need all these replacements? Wouldn't corner
+ // cases like smallest and biggest suffice?
a.replace(/^(.*)/, b);
}
a += a;
diff --git a/test/mjsunit/regress/regress-634-debug.js b/test/mjsunit/regress/regress-634-debug.js
new file mode 100644
index 0000000..17ca828
--- /dev/null
+++ b/test/mjsunit/regress/regress-634-debug.js
@@ -0,0 +1,41 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+function f() {
+ %SetAllocationTimeout(1, 0, false);
+ a = new Array(0);
+ assertEquals(0, a.length);
+ assertEquals(0, a.length);
+ %SetAllocationTimeout(-1, -1, true);
+}
+
+f();
+f();
+%OptimizeFunctionOnNextCall(f);
+f();
diff --git a/test/mjsunit/regress/regress-array-pop-deopt.js b/test/mjsunit/regress/regress-array-pop-deopt.js
new file mode 100644
index 0000000..9a0d35d
--- /dev/null
+++ b/test/mjsunit/regress/regress-array-pop-deopt.js
@@ -0,0 +1,41 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+var o = [6,7,8,9];
+
+function f(b) {
+ var v = o.pop() + b;
+ return v;
+}
+
+assertEquals(10, f(1));
+assertEquals(9, f(1));
+assertEquals(8, f(1));
+%OptimizeFunctionOnNextCall(f);
+assertEquals("61", f("1"));
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index 124bd1b..d788537 100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1124,31 +1124,5 @@
}],
],
},
- {
- 'target_name': 'v8_shell',
- 'type': 'executable',
- 'dependencies': [
- 'v8'
- ],
- 'sources': [
- '../../samples/shell.cc',
- ],
- 'conditions': [
- ['want_separate_host_toolset==1', {
- 'toolsets': ['host'],
- }, {
- 'toolsets': ['target'],
- }],
- ['OS=="win"', {
- # This could be gotten by not setting chromium_code, if that's OK.
- 'defines': ['_CRT_SECURE_NO_WARNINGS'],
- }],
- ['v8_compress_startup_data=="bz2"', {
- 'libraries': [
- '-lbz2',
- ]
- }],
- ],
- },
],
}