Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 044a4491ab27129e42acc0695822b661a0ffc29e..712509882aacc7385420cb8d90982e8f115ae774 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -7875,19 +7875,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { |
FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements()); |
RUNTIME_ASSERT(elms_base->length() == 3); |
- RUNTIME_ASSERT(res_array->GetElementsKind() <= FAST_DOUBLE_ELEMENTS); |
- |
- if (res_array->HasFastDoubleElements()) { |
- FixedDoubleArray* elms = FixedDoubleArray::cast(res_array->elements()); |
- elms->set(0, year); |
- elms->set(1, month); |
- elms->set(2, day); |
- } else { |
- FixedArray* elms = FixedArray::cast(res_array->elements()); |
- elms->set(0, Smi::FromInt(year)); |
- elms->set(1, Smi::FromInt(month)); |
- elms->set(2, Smi::FromInt(day)); |
- } |
+ RUNTIME_ASSERT(res_array->HasFastTypeElements()); |
+ |
+ MaybeObject* maybe = res_array->EnsureWritableFastElements(); |
+ if (maybe->IsFailure()) return maybe; |
+ FixedArray* elms = FixedArray::cast(res_array->elements()); |
+ elms->set(0, Smi::FromInt(year)); |
+ elms->set(1, Smi::FromInt(month)); |
+ elms->set(2, Smi::FromInt(day)); |
return isolate->heap()->undefined_value(); |
} |