Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: src/runtime.cc

Issue 8409010: Optimize JS date implementation for smi-only arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove superfluous double-elements case Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/date.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « src/date.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698